mirror of
https://github.com/codex-team/editor.js
synced 2024-06-26 09:20:07 +02:00
Selection bugfix (#970)
* Selection bugfix * fix cross block selection * close inline toolbar when blocks selected via shift
This commit is contained in:
parent
053e25ebdb
commit
2729f8fd24
10
dist/editor.js
vendored
10
dist/editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -251,6 +251,9 @@ export default class BlockSelection extends Module {
|
|||
.removeAllRanges();
|
||||
|
||||
block.selected = true;
|
||||
|
||||
/** close InlineToolbar when we selected any Block */
|
||||
this.Editor.InlineToolbar.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,6 +307,14 @@ export default class BlockSelection extends Module {
|
|||
*/
|
||||
this.Editor.ConversionToolbar.close();
|
||||
} else if (this.readyToBlockSelection) {
|
||||
/**
|
||||
* prevent default selection when we use custom selection
|
||||
*/
|
||||
event.preventDefault();
|
||||
|
||||
/**
|
||||
* select working Block
|
||||
*/
|
||||
this.selectBlockByIndex();
|
||||
|
||||
/**
|
||||
|
@ -331,5 +342,8 @@ export default class BlockSelection extends Module {
|
|||
.removeAllRanges();
|
||||
|
||||
this.allBlocksSelected = true;
|
||||
|
||||
/** close InlineToolbar if we selected all Blocks */
|
||||
this.Editor.InlineToolbar.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,14 @@ export default class CrossBlockSelection extends Module {
|
|||
Listeners.on(document, 'mouseup', this.onMouseUp);
|
||||
}
|
||||
|
||||
/**
|
||||
* return boolean is cross block selection started
|
||||
*/
|
||||
public get isCrossBlockSelectionStarted(): boolean {
|
||||
return !!this.firstSelectedBlock
|
||||
&& !!this.lastSelectedBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change selection state of the next Block
|
||||
* Used for CBS via Shift + arrow keys
|
||||
|
@ -65,6 +73,9 @@ export default class CrossBlockSelection extends Module {
|
|||
}
|
||||
|
||||
this.lastSelectedBlock = nextBlock;
|
||||
|
||||
/** close InlineToolbar when Blocks selected */
|
||||
this.Editor.InlineToolbar.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,6 +126,9 @@ export default class CrossBlockSelection extends Module {
|
|||
|
||||
Listeners.off(document, 'mouseover', this.onMouseOver);
|
||||
Listeners.off(document, 'mouseup', this.onMouseUp);
|
||||
|
||||
/** close InlineToolbar when Blocks selected */
|
||||
this.Editor.InlineToolbar.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -182,9 +182,6 @@ export default class InlineToolbar extends Module {
|
|||
|
||||
/** Check Tools state for selected fragment */
|
||||
this.checkToolsState();
|
||||
|
||||
/** Clear selection */
|
||||
this.Editor.BlockSelection.clearSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -493,7 +493,6 @@ export default class UI extends Module {
|
|||
this.Editor.BlockManager.dropPointer();
|
||||
this.Editor.InlineToolbar.close();
|
||||
this.Editor.Toolbar.close();
|
||||
this.Editor.BlockSelection.clearSelection(event);
|
||||
this.Editor.ConversionToolbar.close();
|
||||
}
|
||||
|
||||
|
@ -508,6 +507,13 @@ export default class UI extends Module {
|
|||
this.Editor.BlockManager.setCurrentBlockByChildNode(Selection.anchorNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Selection if user clicked somewhere
|
||||
*/
|
||||
if (!this.Editor.CrossBlockSelection.isCrossBlockSelectionStarted) {
|
||||
this.Editor.BlockSelection.clearSelection(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue