mirror of
https://github.com/codex-team/editor.js
synced 2026-03-17 16:10:07 +01:00
remove repetitive code
This commit is contained in:
parent
6c770ba0cc
commit
d29dfbd4cf
2 changed files with 5 additions and 12 deletions
|
|
@ -148,23 +148,20 @@ export default class CrossBlockSelection extends Module {
|
|||
*/
|
||||
private enableCrossBlockSelection(event: MouseEvent): void {
|
||||
const { UI } = this.Editor;
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
const clickedOnSettingsToggler = this.Editor.Toolbar.nodes.settingsToggler.contains(target);
|
||||
|
||||
/**
|
||||
* Each mouse down on must disable selectAll state
|
||||
*/
|
||||
if (!SelectionUtils.isCollapsed && !clickedOnSettingsToggler) {
|
||||
if (!SelectionUtils.isCollapsed) {
|
||||
this.Editor.BlockSelection.clearSelection(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* If mouse down is performed inside the editor, we should watch CBS
|
||||
*/
|
||||
if (UI.nodes.redactor.contains(target)) {
|
||||
if (UI.nodes.redactor.contains(event.target as Node)) {
|
||||
this.watchSelection(event);
|
||||
} else if (!clickedOnSettingsToggler) {
|
||||
} else {
|
||||
/**
|
||||
* Otherwise, clear selection
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -651,13 +651,9 @@ export default class UI extends Module<UINodes> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Clear Selection if user clicked somewhere only
|
||||
* when it's not click inside block setting toggler to prevent multiple
|
||||
* selection drag.
|
||||
* Clear Selection if user clicked somewhere
|
||||
*/
|
||||
if (!isClickedInsideBlockSettingsToggler) {
|
||||
this.Editor.BlockSelection.clearSelection(event);
|
||||
}
|
||||
this.Editor.BlockSelection.clearSelection(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue