mirror of
https://github.com/codex-team/editor.js
synced 2024-06-01 13:32:43 +02:00
fix(caret): right-arrow on last non-default block (#1416)
* fix(caret): last non-default block navigation won't craete a new block untill reaching the end * reuse variable
This commit is contained in:
parent
bfd0ea10ea
commit
e319e04350
2
dist/editor.js
vendored
2
dist/editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@
|
||||||
- `Fix` - add getter keyword to `block.mergeable` method [#1415](https://github.com/codex-team/editor.js/issues/1415).
|
- `Fix` - add getter keyword to `block.mergeable` method [#1415](https://github.com/codex-team/editor.js/issues/1415).
|
||||||
- `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393)
|
- `Fix` — Fix problem with entering to Editor.js by Tab key [#1393](https://github.com/codex-team/editor.js/issues/1393)
|
||||||
- `Fix` - Sanitize pasted block data [#1396](https://github.com/codex-team/editor.js/issues/1396).
|
- `Fix` - Sanitize pasted block data [#1396](https://github.com/codex-team/editor.js/issues/1396).
|
||||||
|
- `Fix` - Unnecessary block creation after arrow navigation at last non-default block[#1414](https://github.com/codex-team/editor.js/issues/1414)
|
||||||
|
|
||||||
### 2.19
|
### 2.19
|
||||||
|
|
||||||
|
|
|
@ -396,14 +396,22 @@ export default class Caret extends Module {
|
||||||
const { BlockManager, Tools } = this.Editor;
|
const { BlockManager, Tools } = this.Editor;
|
||||||
const { currentBlock, nextContentfulBlock } = BlockManager;
|
const { currentBlock, nextContentfulBlock } = BlockManager;
|
||||||
const { nextInput } = currentBlock;
|
const { nextInput } = currentBlock;
|
||||||
|
const isAtEnd = this.isAtEnd;
|
||||||
|
|
||||||
let nextBlock = nextContentfulBlock;
|
let nextBlock = nextContentfulBlock;
|
||||||
|
|
||||||
if (!nextBlock && !nextInput) {
|
if (!nextBlock && !nextInput) {
|
||||||
/**
|
/**
|
||||||
* If there is no nextBlock and currentBlock is default, do not navigate
|
* This code allows to exit from the last non-initial tool:
|
||||||
|
* https://github.com/codex-team/editor.js/issues/1103
|
||||||
*/
|
*/
|
||||||
if (Tools.isDefault(currentBlock.tool)) {
|
|
||||||
|
/**
|
||||||
|
* 1. If there is a last block and it is default, do nothing
|
||||||
|
* 2. If there is a last block and it is non-default --> and caret not at the end <--, do nothing
|
||||||
|
* (https://github.com/codex-team/editor.js/issues/1414)
|
||||||
|
*/
|
||||||
|
if (Tools.isDefault(currentBlock.tool) || !isAtEnd) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +422,7 @@ export default class Caret extends Module {
|
||||||
nextBlock = BlockManager.insertAtEnd();
|
nextBlock = BlockManager.insertAtEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force || this.isAtEnd) {
|
if (force || isAtEnd) {
|
||||||
/** If next Tool`s input exists, focus on it. Otherwise set caret to the next Block */
|
/** If next Tool`s input exists, focus on it. Otherwise set caret to the next Block */
|
||||||
if (!nextInput) {
|
if (!nextInput) {
|
||||||
this.setToBlock(nextBlock, this.positions.START);
|
this.setToBlock(nextBlock, this.positions.START);
|
||||||
|
|
Loading…
Reference in a new issue