Selection bugfix (#970)

* Selection bugfix

* fix cross block selection

* close inline toolbar when blocks selected via shift
This commit is contained in:
Murod Khaydarov 2019-11-30 22:36:49 +03:00 committed by GitHub
parent 053e25ebdb
commit 2729f8fd24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 9 deletions

10
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -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();
}
}

View file

@ -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();
}
/**

View file

@ -182,9 +182,6 @@ export default class InlineToolbar extends Module {
/** Check Tools state for selected fragment */
this.checkToolsState();
/** Clear selection */
this.Editor.BlockSelection.clearSelection();
}
/**

View file

@ -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);
}
}
/**