Skip to content

Commit 85fc182

Browse files
Merge branch 'codex-team:next' into next
2 parents 292d9f8 + 1320b04 commit 85fc182

30 files changed

+1263
-362
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"ArrayLike": true,
3333
"InputEvent": true,
3434
"unknown": true,
35-
"requestAnimationFrame": true
35+
"requestAnimationFrame": true,
36+
"navigator": true
3637
}
3738
}

.github/workflows/bump-version-on-merge-next.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: Bump version on merge
22

3+
# Caution:
4+
# the use of "pull_request_target" trigger allows to successfully
5+
# run workflow even when triggered from a fork. The trigger grants
6+
# access to repo's secrets and gives write permission to the runner.
7+
# This can be used to run malicious code on untrusted PR, so, please
8+
# DO NOT checkout any PR's ongoing commits (aka github.event.pull_request.head.sha)
9+
# while using this trigger.
310
on:
4-
pull_request:
11+
pull_request_target:
512
branches:
613
- next
714
types: [closed]

.github/workflows/create-a-release-draft.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: Create a release draft
22

3+
# Caution:
4+
# the use of "pull_request_target" trigger allows to successfully
5+
# run workflow even when triggered from a fork. The trigger grants
6+
# access to repo's secrets and gives write permission to the runner.
7+
# This can be used to run malicious code on untrusted PR, so, please
8+
# DO NOT checkout any PR's ongoing commits (aka github.event.pull_request.head.sha)
9+
# while using this trigger.
310
on:
4-
pull_request:
11+
pull_request_target:
512
branches:
613
- next
714
types: [closed]

.github/workflows/cypress.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
steps:
1313
- uses: actions/setup-node@v3
1414
with:
15-
node-version: 16
16-
- uses: actions/checkout@v3
17-
- uses: cypress-io/github-action@v5
15+
node-version: 18
16+
- uses: actions/checkout@v4
17+
- uses: cypress-io/github-action@v6
1818
with:
1919
config: video=false
2020
browser: ${{ matrix.browser }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ dist/
1717

1818
coverage/
1919
.nyc_output/
20+
.vscode/launch.json

docs/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
### 2.30.0
4+
5+
- `Improvement` — The ability to merge blocks of different types (if both tools provide the conversionConfig)
6+
- `Fix``onChange` will be called when removing the entire text within a descendant element of a block.
7+
- `Fix` - Unexpected new line on Enter press with selected block without caret
8+
- `Fix` - Search input autofocus loosing after Block Tunes opening
9+
- `Fix` - Block removing while Enter press on Block Tunes
10+
11+
### 2.29.1
12+
13+
- `Fix` — Toolbox wont be shown when Slash pressed with along with Shift or Alt
14+
- `Fix` — Toolbox will be opened when Slash pressed in non-US keyboard layout where there is no physical '/' key.
15+
316
### 2.29.0
417

518
- `New` — Editor Config now has the `style.nonce` attribute that could be used to allowlist editor style tag for Content Security Policy "style-src"
@@ -17,6 +30,8 @@
1730
- `Fix` — Caret losing on Mobile Devices when adding a block via Toolbox or via Backspace at the beginning of a Block
1831
- `Improvement` — Now you can set focus via arrows/Tab to "contentless" (decorative) blocks like Delimiter which have no inputs.
1932
- `Improvement` — Inline Toolbar sometimes opened in an incorrect position. Now it will be aligned by the left side of the selected text. And won't overflow the right side of the text column.
33+
- `Improvement` - Now the `data-mutation-free` supports deep nesting, so you can mark some element with it to prevent the onChange call caused by child element mutating
34+
- `Improvement` - Now the `data-mutation-free` also allows to skip "characterData" mutations (eg. text content change)
2035
- `Refactoring``ce-block--focused` class toggling removed as unused.
2136

2237
### 2.28.2

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@editorjs/editorjs",
3-
"version": "2.29.0-rc.8",
3+
"version": "2.30.0-rc.2",
44
"description": "Editor.js — Native JS, based on API and Open Source",
55
"main": "dist/editorjs.umd.js",
66
"module": "dist/editorjs.mjs",
@@ -45,14 +45,14 @@
4545
"@editorjs/code": "^2.7.0",
4646
"@editorjs/delimiter": "^1.2.0",
4747
"@editorjs/header": "^2.7.0",
48-
"@editorjs/paragraph": "^2.11.3",
48+
"@editorjs/paragraph": "^2.11.4",
4949
"@editorjs/simple-image": "^1.4.1",
5050
"@types/node": "^18.15.11",
5151
"chai-subset": "^1.6.0",
5252
"codex-notifier": "^1.1.2",
5353
"codex-tooltip": "^1.0.5",
5454
"core-js": "3.30.0",
55-
"cypress": "^12.9.0",
55+
"cypress": "^13.7.1",
5656
"cypress-intellij-reporter": "^0.0.7",
5757
"cypress-plugin-tab": "^1.0.5",
5858
"cypress-terminal-report": "^5.3.2",

src/components/block/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export default class Block extends EventsDispatcher<BlockEvents> {
550550
*
551551
* @returns {object}
552552
*/
553-
public async save(): Promise<void | SavedData> {
553+
public async save(): Promise<undefined | SavedData> {
554554
const extractedBlock = await this.toolInstance.save(this.pluginsContent as HTMLElement);
555555
const tunesData: { [name: string]: BlockTuneData } = this.unavailableTunesData;
556556

@@ -738,6 +738,10 @@ export default class Block extends EventsDispatcher<BlockEvents> {
738738
contentNode = $.make('div', Block.CSS.content),
739739
pluginsContent = this.toolInstance.render();
740740

741+
if (import.meta.env.MODE === 'test') {
742+
wrapper.setAttribute('data-cy', 'block-wrapper');
743+
}
744+
741745
/**
742746
* Export id to the DOM three
743747
* Useful for standalone modules development. For example, allows to identify Block by some child node. Or scroll to a particular Block by id.
@@ -898,10 +902,13 @@ export default class Block extends EventsDispatcher<BlockEvents> {
898902

899903
return changedNodes.some((node) => {
900904
if (!$.isElement(node)) {
901-
return false;
905+
/**
906+
* "characterData" mutation record has Text node as a target, so we need to get parent element to check it for mutation-free attribute
907+
*/
908+
node = node.parentElement;
902909
}
903910

904-
return (node as HTMLElement).dataset.mutationFree === 'true';
911+
return node && (node as HTMLElement).closest('[data-mutation-free="true"]') !== null;
905912
});
906913
});
907914

src/components/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Debounce timeout for selection change event
3+
* {@link modules/ui.ts}
4+
*/
5+
export const selectionChangeDebounceTimeout = 180;

src/components/modules/blockEvents.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,24 @@ export default class BlockEvents extends Module {
5252
case _.keyCodes.TAB:
5353
this.tabPressed(event);
5454
break;
55-
case _.keyCodes.SLASH:
56-
if (event.ctrlKey || event.metaKey) {
57-
this.commandSlashPressed();
58-
} else {
59-
this.slashPressed();
60-
}
61-
break;
55+
}
56+
57+
/**
58+
* We check for "key" here since on different keyboard layouts "/" can be typed as "Shift + 7" etc
59+
*
60+
* @todo probably using "beforeInput" event would be better here
61+
*/
62+
if (event.key === '/' && !event.ctrlKey && !event.metaKey) {
63+
this.slashPressed();
64+
}
65+
66+
/**
67+
* If user pressed "Ctrl + /" or "Cmd + /" — open Block Settings
68+
* We check for "code" here since on different keyboard layouts there can be different keys in place of Slash.
69+
*/
70+
if (event.code === 'Slash' && (event.ctrlKey || event.metaKey)) {
71+
event.preventDefault();
72+
this.commandSlashPressed();
6273
}
6374
}
6475

@@ -482,12 +493,9 @@ export default class BlockEvents extends Module {
482493
BlockManager
483494
.mergeBlocks(targetBlock, blockToMerge)
484495
.then(() => {
485-
window.requestAnimationFrame(() => {
486-
/** Restore caret position after merge */
487-
Caret.restoreCaret(targetBlock.pluginsContent as HTMLElement);
488-
targetBlock.pluginsContent.normalize();
489-
Toolbar.close();
490-
});
496+
/** Restore caret position after merge */
497+
Caret.restoreCaret(targetBlock.pluginsContent as HTMLElement);
498+
Toolbar.close();
491499
});
492500
}
493501

0 commit comments

Comments
 (0)