[Fix] Selection issues (#988)

This commit is contained in:
George Berezhnoy 2019-12-07 13:50:27 +03:00 committed by GitHub
parent 22b6f8073c
commit 952c1480ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 16 deletions

4
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -163,7 +163,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
core-js
MIT
Copyright (c) 2014-2018 Denis Pushkarev
Copyright (c) 2014-2019 Denis Pushkarev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -4,7 +4,8 @@
- `Fix` — Fix Firefox bug with incorrect height and cursor position of empty content editable elements [#947](https://github.com/codex-team/editor.js/issues/947) [#876](https://github.com/codex-team/editor.js/issues/876) [#608](https://github.com/codex-team/editor.js/issues/608) [#876](https://github.com/codex-team/editor.js/issues/876)
- `Fix` — Set initial hidden Inline Toolbar position [#979](https://github.com/codex-team/editor.js/issues/979)
- `Fix` — Fix issue with CodeX.Toolips TypeScript definitions [#978](https://github.com/codex-team/editor.js/issues/978)
- `Fix` — Fix issue with CodeX.Toolips TypeScript definitions [#978](https://github.com/codex-team/editor.js/issues/978)
- `Fix` — Fix some issues with Inline and Tunes toolbars.
- `Fix` - Fix `minHeight` option with zero-value issue [#724](https://github.com/codex-team/editor.js/issues/724)
### 2.16

View file

@ -289,6 +289,15 @@ export default class InlineToolbar extends Module {
this.flipper.activate(visibleTools as HTMLElement[]);
}
/**
* Check if node is contained by Inline Toolbar
*
* @param {Node} node node to chcek
*/
public containsNode(node: Node): boolean {
return this.nodes.wrapper.contains(node);
}
/**
* Need to show Inline Toolbar or not
*/

View file

@ -496,18 +496,6 @@ export default class UI extends Module {
this.Editor.ConversionToolbar.close();
}
if (Selection.isAtEditor) {
/**
* Focus clicked Block.
* Workaround case when user clicks on the bottom of editor
*/
if (Selection.anchorNode === this.nodes.redactor) {
this.Editor.Caret.setToTheLastBlock();
} else {
this.Editor.BlockManager.setCurrentBlockByChildNode(Selection.anchorNode);
}
}
/**
* Clear Selection if user clicked somewhere
*/
@ -625,6 +613,14 @@ export default class UI extends Module {
* We need to skip such firings
*/
if (!focusedElement || !focusedElement.closest(`.${Block.CSS.content}`)) {
/**
* If new selection is not on Inline Toolbar, we need to close it
*/
if (!this.Editor.InlineToolbar.containsNode(focusedElement)) {
this.Editor.InlineToolbar.close();
}
return;
}