Merge branch 'next' into feature/onpastehtml

This commit is contained in:
George Kovats 2023-02-20 19:04:36 -05:00 committed by GitHub
commit 33cd3ff600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 269 additions and 264 deletions

View file

@ -7,6 +7,9 @@ jobs:
image: cypress/browsers:node14.17.0-chrome88-ff89
options: --user 1001
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v2
- run: yarn ci:pull_paragraph
- uses: cypress-io/github-action@v2
@ -17,6 +20,9 @@ jobs:
chrome:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v2
- run: yarn ci:pull_paragraph
- uses: cypress-io/github-action@v2
@ -27,6 +33,9 @@ jobs:
edge:
runs-on: windows-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v2
- run: yarn ci:pull_paragraph
- uses: cypress-io/github-action@v2

425
README.md
View file

@ -1,277 +1,234 @@
<a href="https://editorjs.io/"><p align="center"><img src="https://capella.pics/79ce946a-d636-41cd-aa96-d3bc5ecfde03.jpg"></p></a>
<p align="center">
<a href="https://editorjs.io/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./assets/logo_night.png">
<source media="(prefers-color-scheme: light)" srcset="./assets/logo_day.png">
<img alt="Editor.js Logo" src="./assets/logo_day.png">
</picture>
</a>
</p>
[![](https://flat.badgen.net/npm/v/@editorjs/editorjs?icon=npm)](https://www.npmjs.com/package/@editorjs/editorjs)
[![](https://flat.badgen.net/bundlephobia/min/@editorjs/editorjs?color=cyan)](https://www.npmjs.com/package/@editorjs/editorjs)
[![](https://flat.badgen.net/bundlephobia/minzip/@editorjs/editorjs?color=green)](https://www.npmjs.com/package/@editorjs/editorjs)
[![Backers on Open Collective](https://opencollective.com/editorjs/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/editorjs/sponsors/badge.svg)](#sponsors)
[![](https://img.shields.io/npm/l/@editorjs/editorjs?style=flat-square)](https://www.npmjs.com/package/@editorjs/editorjs)
[![Join the chat at https://gitter.im/codex-team/editor.js](https://badges.gitter.im/codex-team/editor.js.svg)](https://gitter.im/codex-team/editor.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<p align="center">
<a href="https://editorjs.io/">editorjs.io</a> |
<a href="https://editorjs.io/base-concepts/">documentation</a> |
<a href="https://github.com/codex-team/editor.js/blob/next/docs/CHANGELOG.md">changelog</a>
</p>
| | | | | | |
| --------- | --------- | --------- | --------- | --------- | --------- |
| <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="16px" height="16px" /> Edge 12+ | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="16px" height="16px" /> Firefox 18+ | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="16px" height="16px" /> Chrome 49+ | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="16px" height="16px" /> Safari 10+ | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari-ios/safari-ios_48x48.png" alt="iOS Safari" width="16px" height="16px" /> iOS Safari 10+ | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="16px" height="16px" /> Opera 36+
<p align="center">
<a href="https://www.npmjs.com/package/@editorjs/editorjs">
<img src="https://flat.badgen.net/npm/v/@editorjs/editorjs?icon=npm" alt="npm"/>
</a>
<a href="https://www.npmjs.com/package/@editorjs/editorjs">
<img src="https://flat.badgen.net/bundlephobia/minzip/@editorjs/editorjs?color=green" alt="Minzipped size"/>
</a>
<a href="https://github.com/codex-team/editor.js#backers">
<img src="https://opencollective.com/editorjs/backers/badge.svg" alt="Backers on Open Collective"/>
</a>
<a href="https://github.com/codex-team/editor.js#sponsors">
<img src="https://opencollective.com/editorjs/sponsors/badge.svg" alt="Sponsors on Open Collective"/>
</a>
</p>
## About
Editor.js is an open-source text editor offering a variety of features to help users create and format content efficiently. It has a modern, block-style interface that allows users to easily add and arrange different types of content, such as text, images, lists, quotes, etc. Each Block is provided via a separate plugin making Editor.js extremely flexible.
## Roadmap
Editor.js outputs a clean JSON data instead of heavy HTML markup. Use it in Web, iOS, Android, AMP, Instant Articles, speech readers, AI chatbots — everywhere. Easy to sanitize, extend and integrate with your logic.
<img align="right" width="342" src="https://user-images.githubusercontent.com/3684889/152149321-3f9c585d-7d87-4dad-ab14-def0d526e71c.png" hspace="50">
- 😍  Modern UI out of the box
- 💎  Clean JSON output
- ⚙  Well-designed API
- 🛍  Various Tools available
- 💌  Free and open source
- Collaborative editing
- [ ] Implement Inline Tools JSON format `In progress` [#1801](https://github.com/codex-team/editor.js/pull/1801)
- [ ] Implement Operations creation and transformations
- [ ] Implement Tools API changes
- [ ] Implement Server and communication
- [ ] Update basic tools to fit the new API
<picture>
<img alt="Editor.js Overview" src="./assets/overview.png">
</picture>
- Unified Toolbox
- [x] Block Tunes moved left [#1815](https://github.com/codex-team/editor.js/pull/1815)
- [x] Toolbox become vertical [#2014](https://github.com/codex-team/editor.js/pull/2014)
- [x] Ability to display several Toolbox buttons by the single Tool [#2050](https://github.com/codex-team/editor.js/pull/2050)
- [x] Block Tunes become vertical
- [ ] Conversion Toolbar uses Unified Toolbox
- [ ] Conversion Toolbar added to the Block Tunes
- Ecosystem improvements
## Installation
<a href="https://opencollective.com/editorjs/donate" target="_blank">
<img width="432" alt="image" src="https://user-images.githubusercontent.com/3684889/166146666-e6f5fcc3-bccf-43b0-b48c-e8f1b25b2896.png">
</a>
It's quite simple:
##
1. Install Editor.js
2. Install tools you need
3. Initialize Editor's instance
Install using NPM, Yarn, or [CDN](https://www.jsdelivr.com/package/npm/@editorjs/editorjs):
## If you like a project 💗💗💗
If you like Editor.js you can support project improvements and development of new features with a donation to our collective.
👉 [https://opencollective.com/editorjs](https://opencollective.com/editorjs)
### Sponsors
Support us by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/editorjs/contribute/sir-8679/checkout)]
<a href="https://humm.earth/" target="_blank"><img src="https://images.opencollective.com/hummearth/2a8406a/logo/256.png" width="64"></a>
<a href="https://tesen.com/" target="_blank"><img src="https://images.opencollective.com/tesen-media-inc/b90cf6a/logo/256.png" width="64"></a>
<a href="https://slid.cc/" target="_blank"><img src="https://images.opencollective.com/slid_team/ff564d7/logo/256.png" width="64"></a>
### Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/editorjs/contribute/backer-8632/checkout)]
<a href="https://opencollective.com/editorjs#backers" target="_blank"><img src="https://opencollective.com/editorjs/backers.svg?width=890"></a>
### Contributors
This project exists thanks to all the people who contribute. <img src="https://opencollective.com/editorjs/contributors.svg?width=890&button=false" />
We really welcome new contributors. If you want to make some code with us, please take a look at the [Good First Tasks](https://github.com/codex-team/editor.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+task%22). You can write to us on `team@codex.so` or via special [Telegram chat](https://t.me/editorjsdev), or any other way.
## Documentation
Please visit [https://editorjs.io/](https://editorjs.io) to view all documentation articles.
- [Base concepts](https://editorjs.io/base-concepts)
- [Getting started](https://editorjs.io/getting-started)
- [Configuration](https://editorjs.io/configuration)
- [How to create a Block Tool Plugin](https://editorjs.io/creating-a-block-tool)
- [How to create an Inline Tool Plugin](https://editorjs.io/creating-an-inline-tool)
- [API for Tools](https://editorjs.io/tools-api)
You can join a [Gitter-channel](https://gitter.im/codex-team/editor.js) or [Telegram-chat](//t.me/codex_editor) and ask a question.
## Changelog
See the whole [Changelog](/docs/CHANGELOG.md)
If you want to follow Editor.js updates, [subscribe to our Newsletter](http://digest.editorjs.io/).
## How to use Editor.js
### Basics
Editor.js is a Block-Styled editor. Blocks are structural units, of which the Entry is composed.
For example, `Paragraph`, `Heading`, `Image`, `Video`, `List` are Blocks. Each Block is represented by Plugin.
We have [many](http://github.com/editor-js/) ready-to-use Plugins and a [simple API](https://editorjs.io/tools-api) for creating new ones.
How to use the Editor after [Installation](https://editorjs.io/getting-started).
- Create new Blocks by pressing Enter or clicking the Plus Button
- Press `TAB` or click on the Plus Button to view the Toolbox
- Press `TAB` again to leaf Toolbox and select a Block you need. Then press Enter.
![](https://github.com/editor-js/list/raw/master/assets/example.gif)
- Select a text fragment and apply a style or insert a link from the Inline Toolbar
![](https://capella.pics/7ccbcfcd-1c49-4674-bea7-71021468a1bd.jpg)
- Use the «three-dots» button on the right to open Block Settings. From here, you can move and delete a Block
or apply a Tool's settings, if it provided. For example, you can set a Heading level or List style.
![](https://capella.pics/01a55381-46cd-47c7-b92e-34765434f2ca.jpg)
### Shortcuts
A few shortcuts are preset as available.
Shortcut | Action | Restrictions
-- | -- | --
`TAB` | Show/leaf a Toolbox. | On empty block
`SHIFT+TAB` | Leaf back a Toolbox. | While Toolbox is opened
`ENTER` | Create a Block | While Toolbox is opened and some Tool is selected
`CMD+B` | Bold style | On selection
`CMD+I` | Italic style | On selection
`CMD+K` | Insert a link | On selection
Each Tool can also have its own shortcuts. These are specified in the configuration of the Tool, for example:
```js
var editor = new EditorJS({
//...
tools: {
header: {
class: Header,
shortcut: 'CMD+SHIFT+H'
},
list: {
class: List,
shortcut: 'CMD+SHIFT+L'
}
}
//...
});
```
## Installation Guide
There are few steps to run Editor.js on your site.
1. [Load Editor's core](#load-editors-core)
2. [Load Tools](#load-tools)
3. [Initialize Editor's instance](#create-editor-instance)
### Step 1. Load Editor's core
Get Editor.js itself. It is a [minified script](dist/editor.js) with Editor's core and some default must-have tools.
Choose the most usable method of getting Editor for you.
- Node package
- Source from CDN
##### Option A. NPM install
Install the package via NPM or Yarn
```shell
```bash
npm i @editorjs/editorjs
```
Include module in your application
Choose and install tools:
```javascript
import EditorJS from '@editorjs/editorjs';
```
- [Heading](https://github.com/editor-js/header)
- [Quote](https://github.com/editor-js/quote)
- [Image](https://github.com/editor-js/image)
- [Simple Image](https://github.com/editor-js/simple-image) (without backend requirement)
- [Nested List](https://github.com/editor-js/nested-list)
- [Checklist](https://github.com/editor-js/checklist)
- [Link embed](https://github.com/editor-js/link)
- [Embeds](https://github.com/editor-js/embed) (YouTube, Twitch, Vimeo, Gfycat, Instagram, Twitter, etc)
- [Table](https://github.com/editor-js/table)
- [Delimiter](https://github.com/editor-js/delimiter)
- [Warning](https://github.com/editor-js/warning)
- [Code](https://github.com/editor-js/code)
- [Raw HTML](https://github.com/editor-js/raw)
- [Attaches](https://github.com/editor-js/attaches)
- [Marker](https://github.com/editor-js/marker)
- [Inline Code](https://github.com/editor-js/inline-code)
##### Option B. Use a CDN
See the [😎 Awesome Editor.js](https://github.com/editor-js/awesome-editorjs) list for more tools.
You can load EditorJS directly from from [jsDelivr CDN](https://www.jsdelivr.com/package/npm/@editorjs/editorjs).
`https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest`
For example, place this in your HTML:
```html
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
```
Or download the bundle file and use it from your server.
```html
<script src="editor.js"></script>
```
### Step 2. Load the Tools that you want to make available
Each Block is represented by a [Tool](docs/tools.md). Tools are simple external scripts with their own logic. For example, there is a [Header](https://github.com/editor-js/header) Tool into which you type your heading text. If you want to be able to use this, install the Header Tool the same way as the Editor (Node.js, CDN, local file).
**Example:** use Header from CDN
```html
<script src="https://cdn.jsdelivr.net/npm/codex.editor.header@2.0.4/dist/bundle.js"></script>
```
Check [Editor.js's community](https://github.com/editor-js/) to see more ready-to-use Tools.
### Step 3. Create Editor instance
Create an instance of Editor.js and pass [Configuration Object](types/configs/editor-config.d.ts) with `holderId` and tools list.
Initialize the Editor:
```html
<div id="editorjs"></div>
```
You can create a simple Editor with only default Paragraph Tool by passing a string with element's Id (wrapper for Editor) as a configuration param. Or use the default `editorjs` id for wrapper.
```javascript
var editor = new EditorJS(); /** Zero-configuration */
import EditorJS from '@editorjs/editorjs'
// equals
var editor = new EditorJS('editorjs');
const editor = new EditorJS({
tools: {
// ... your tools
}
})
````
Or pass a whole settings object.
```javascript
var editor = new EditorJS({
/**
* Create a holder for the Editor and pass its ID
*/
holder : 'editorjs',
/**
* Available Tools list.
* Pass Tool's class or Settings object for each Tool you want to use
*/
tools: {
header: {
class: Header,
inlineToolbar : true
},
// ...
},
/**
* Previously saved data that should be rendered
*/
data: {}
});
```
See details about [Installation](https://editorjs.io/getting-started/) and [Configuration](https://editorjs.io/configuration/) at the documentation.
### Saving Data
Call `editor.save()` and handle returned Promise with saved data.
```javascript
editor.save()
.then((savedData) => {
console.log(savedData);
});
const data = await editor.save()
```
### Example
Take a look at the [example.html](example/example.html) to view more detailed examples.
## Credits and references
- We use [HTMLJanitor](https://github.com/guardian/html-janitor) module in our Sanitizer module.
## Roadmap
<img align="right" width="342" src="./assets/roadmap.png" style="margin-left: 30px">
- Unified Toolbox
- [x] Block Tunes moved left
- [x] Toolbox becomes vertical
- [x] Ability to display several Toolbox buttons by the single Tool
- [x] Block Tunes become vertical
- [ ] Block Tunes support nested menus
- [ ] Conversion Toolbar uses Unified Toolbox
- [ ] Conversion Toolbar added to the Block Tunes
- Collaborative editing
- [ ] Implement Inline Tools JSON format
- [ ] Operations Observer, Executor, Manager, Transformer
- [ ] Implement Undo/Redo Manager
- [ ] Implement Tools API changes
- [ ] Implement Server and communication
- [ ] Update basic tools to fit the new API
- Other features
- [ ] Blocks drag'n'drop
- [ ] New cross-block selection
- [ ] New cross-block caret moving
- Ecosystem improvements
- [x] CodeX Icons — the way to unify all tools and core icons
- [x] New Homepage and Docs
- [x] @editorjs/create-tool for Tools bootstrapping
- [ ] Editor.js DevTools — stand for core and tools development
- [ ] Editor.js Design System
- [ ] Editor.js Preset Env
- [ ] Editor.js ToolKit
- [ ] New core bundle system
- [ ] New documentation and guides
<a href="https://opencollective.com/editorjs/donate" target="_blank">
<picture>
<source width="162px" media="(prefers-color-scheme: dark)" srcset="./assets/support_night.png">
<source width="162px" media="(prefers-color-scheme: light)" srcset="./assets/support_day.png">
<img width="162px" alt="Support Editor.js" src="./assets/support_day.png">
</picture>
</a>
<br>
## Like Editor.js?
You can support project improvement and development of new features with a donation to our team.
[Donate via OpenCollective](https://opencollective.com/editorjs)
\
[Donate via Crypto](https://codex.so/donate)
\
[Donate via Patreon](https://www.patreon.com/editorjs)
### Why donate
Donations to open-source products have several advantages for your business:
- If your business relies on Editor.js, you'll probably want it to be maintained
- It helps Editor.js to evolve and get the new features
- We can support contributors and the community around the project. You'll receive well organized docs, guides, etc.
- We need to pay for our infrastructure and maintain public resources (domain names, homepages, docs, etc). Supporting it guarantees you to access any resources at the time you need them.
- You can advertise by adding your brand assets and mentions on our public resources
### Sponsors
Support us by becoming a sponsor. Your logo will show up here with a link to your website.
<p>
<a href="https://www.mister-auto.com/" target="_blank">
<img src="https://opencollective-production.s3.us-west-1.amazonaws.com/5131a030-5672-11ec-be79-1d003d12ec5f.png" width="50" alt="Mister Auto">
</a>
<a href="https://www.uplucid.com/" target="_blank">
<img src="https://logo.clearbit.com/uplucid.com" width="50" alt="UPLUCID, K.K.">
</a>
<a href="https://www.contentharmony.com/" target="_blank">
<img src="https://opencollective-production.s3.us-west-1.amazonaws.com/89edb1b0-7d82-11ed-b99e-ab6e6f9cb69f.png" width="50" alt="Kane Jamison">
</a>
<a href="https://www.contentharmony.com/product/" target="_blank">
<img src="https://logo.clearbit.com/contentharmony.com" width="50" alt="Content Harmony">
</a>
</p>
[Become a Sponsor](https://opencollective.com/editorjs/contribute/sir-8679/checkout)
### Backers
Thank you to all our backers
<a href="https://opencollective.com/editorjs#backers" target="_blank"><img src="https://opencollective.com/editorjs/backers.svg?width=890&avatarHeight=34"></a>
[Become a Backer](https://opencollective.com/editorjs/contribute/backer-8632/checkout)
### Contributors
This project exists thanks to all the people who contribute.
<p><img src="https://opencollective.com/editorjs/contributors.svg?width=890&button=false&avatarHeight=34" /></p>
### Need something special?
Hire CodeX experts to resolve technical challenges and match your product requirements.
- Resolve a problem that has high value for you
- Implement a new feature required by your business
- Help with integration or tool development
- Provide any consultation
Contact us via team@codex.so and share your details
## Community
- [Official Tools](https://github.com/editor-js)
- [Awesome Editor.js](https://github.com/editor-js/awesome-editorjs)
- [Good First Tasks](https://github.com/codex-team/editor.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+task%22)
- [Contributing](https://editorjs.io/contributing/)
- [Telegram Chat](https://t.me/codex_editor)
# About CodeX

BIN
assets/logo_day.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
assets/logo_night.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
assets/overview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
assets/roadmap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
assets/support_day.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/support_night.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -4,6 +4,8 @@
- `Refactoring` — Popover class refactored.
- `Improvement`*Toolbox* — Number of `close()` method calls optimized.
- `Improvement` — The `onChange` callback won't be triggered only if all mutations contain nodes with the `data-mutation-free` attributes.
- `Fix` — Resolve compiler error from importing the BlockToolData type
### 2.26.5

@ -1 +1 @@
Subproject commit 4d96a39d38011f4e0134934673ba4b2eb334f279
Subproject commit b1367277e070bbbf80b7b14b1963845ba9a71d8c

@ -1 +1 @@
Subproject commit 5ee4e1ef338493b82a11fd76a3568844afe1c78b
Subproject commit 927ec04edae75fb2e9a83add24be38d439dc3a19

@ -1 +1 @@
Subproject commit 53a12f3d816630e071ef8230c4a5870a7c0d0551
Subproject commit c5c47395516cae0e456881a67a84fd69fec06c47

@ -1 +1 @@
Subproject commit e1275bdabbae5d933215bf3cbaeddc0c0fffd9a4
Subproject commit 2d411a650afa04f0468f7648ee0b5a765362161c

@ -1 +1 @@
Subproject commit ff9bf7d3627b463d88aed99313e87b495a4211fc
Subproject commit 4a94a1592a500ebb6cc570fa1d6216a149b541a0

@ -1 +1 @@
Subproject commit e2726a7b301c960d318aa1ec73bac97f474e3d68
Subproject commit 7e706b1cb67655db75d3a154038e4f11e2d00128

View file

@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.27.0-rc.0",
"version": "2.27.0-rc.1",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
@ -52,7 +52,7 @@
"@cypress/webpack-preprocessor": "^5.6.0",
"@editorjs/code": "^2.7.0",
"@editorjs/delimiter": "^1.2.0",
"@editorjs/header": "^2.6.1",
"@editorjs/header": "^2.7.0",
"@editorjs/simple-image": "^1.4.1",
"@types/node": "^14.14.35",
"@types/webpack": "^4.41.12",

View file

@ -202,17 +202,53 @@ export default class Block extends EventsDispatcher<BlockEvents> {
/**
* Is fired when DOM mutation has been happened
*
* mutationsOrInputEvent actual changes
* - MutationRecord[] - any DOM change
* - InputEvent <input> change
* - undefined manual triggering of block.dispatchChange()
*/
private didMutated = _.debounce((mutationsOrInputEvent: MutationRecord[] | InputEvent = []): void => {
const shouldFireUpdate = mutationsOrInputEvent instanceof InputEvent ||
!mutationsOrInputEvent.some(({
addedNodes = [],
removedNodes,
}) => {
return [...Array.from(addedNodes), ...Array.from(removedNodes)]
.some(node => $.isElement(node) && (node as HTMLElement).dataset.mutationFree === 'true');
private didMutated = _.debounce((mutationsOrInputEvent: MutationRecord[] | InputEvent = undefined): void => {
/**
* We won't fire a Block mutation event if mutation contain only nodes marked with 'data-mutation-free' attributes
*/
let shouldFireUpdate;
if (mutationsOrInputEvent === undefined) {
shouldFireUpdate = true;
} else if (mutationsOrInputEvent instanceof InputEvent) {
shouldFireUpdate = true;
} else {
/**
* Update from 2023, Feb 17:
* Changed mutationsOrInputEvent.some() to mutationsOrInputEvent.every()
* since there could be a real mutations same-time with mutation-free changes,
* for example when Block Tune change: block is changing along with FakeCursor (mutation-free) removing
* we should fire 'didMutated' event in that case
*/
const everyRecordIsMutationFree = mutationsOrInputEvent.length > 0 && mutationsOrInputEvent.every((record) => {
const { addedNodes, removedNodes } = record;
const changedNodes = [
...Array.from(addedNodes),
...Array.from(removedNodes),
];
return changedNodes.some((node) => {
if ($.isElement(node) === false) {
return false;
}
return (node as HTMLElement).dataset.mutationFree === 'true';
});
});
if (everyRecordIsMutationFree) {
shouldFireUpdate = false;
} else {
shouldFireUpdate = true;
}
}
/**
* In case some mutation free elements are added or removed, do not trigger didMutated event
*/

View file

@ -512,7 +512,7 @@ describe('Editor Tools Api', () => {
/** config specified handled tag */
public static get pasteConfig(): PasteConfig {
return {
tags: ['img'], // only tag name specified. Attributes should be sanitized
tags: [ 'img' ], // only tag name specified. Attributes should be sanitized
};
}
@ -564,7 +564,7 @@ describe('Editor Tools Api', () => {
/** config specified handled tag */
public static get pasteConfig(): PasteConfig {
return {
tags: ['img'], // only tag name specified. Attributes should be sanitized
tags: [ 'img' ], // only tag name specified. Attributes should be sanitized
};
}

View file

@ -221,14 +221,7 @@ describe('onChange callback', () => {
.click();
cy.get('[data-cy=editorjs]')
.get('span.cdx-settings-button[data-level=4]')
.click()
/**
* For some reason, the first click fires the mutation of removeFakeCursor only, so we need to click again.
* Reproduced only in Cypress.
*
* @todo debug it later
*/
.get('.ce-settings .ce-popover-item:nth-child(4)')
.click();
cy.get('@onChange').should('be.calledWithMatch', EditorJSApiMock, Cypress.sinon.match({

View file

@ -1,4 +1,4 @@
import {BlockToolData} from '../tools';
import type { BlockToolData } from '../tools';
/**
* Config allows Tool to specify how it can be converted into/from another Tool

View file

@ -857,6 +857,11 @@
resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.1.0.tgz#a02885fe8699f69902d05b077b5f1cd48a2ca6b9"
integrity sha512-jW1fWnwtWzcP4FBGsaodbJY3s1ZaRU+IJy1pvJ7ygNQxkQinybJcwXoyt0a5mWwu/4w30A42EWhCrZn8lp4fdw==
"@codexteam/icons@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@codexteam/icons/-/icons-0.0.5.tgz#d17f39b6a0497c6439f57dd42711817a3dd3679c"
integrity sha512-s6H2KXhLz2rgbMZSkRm8dsMJvyUNZsEjxobBEg9ztdrb1B2H3pEzY6iTwI4XUPJWJ3c3qRKwV4TrO3J5jUdoQA==
"@codexteam/shortcuts@^1.1.1":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@codexteam/shortcuts/-/shortcuts-1.2.0.tgz#b8dd7396962b0bd845a5c8f8f19bc6119b520e19"
@ -944,9 +949,12 @@
version "1.2.0"
resolved "https://registry.yarnpkg.com/@editorjs/delimiter/-/delimiter-1.2.0.tgz#5075f1a3e68765cfb6aec8694b316d81e2b41607"
"@editorjs/header@^2.6.1":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@editorjs/header/-/header-2.6.2.tgz#523b6dda72ff882e53f64325840ee7bfc68ee6b7"
"@editorjs/header@^2.7.0":
version "2.7.0"
resolved "https://registry.yarnpkg.com/@editorjs/header/-/header-2.7.0.tgz#755d104a9210a8e2d9ccf22b175b2a93bdbb2330"
integrity sha512-4fGKGe2ZYblVqR/P/iw5ieG00uXInFgNMftBMqJRYcB2hUPD30kuu7Sn6eJDcLXoKUMOeqi8Z2AlUxYAmvw7zQ==
dependencies:
"@codexteam/icons" "^0.0.5"
"@editorjs/simple-image@^1.4.1":
version "1.4.1"