update: toolbar-vue popup

This commit is contained in:
yanmao 2021-12-31 01:11:08 +08:00
parent acc7ae7e41
commit 7684402502
1 changed files with 23 additions and 0 deletions

View File

@ -41,12 +41,35 @@ export default class Popup {
!selection ||
!selection.focusNode ||
range.collapsed ||
this.#editor.card.getSingleSelectedCard(range) ||
(!range.commonAncestorNode.inEditor() &&
!range.commonAncestorNode.isRoot())
) {
this.hide();
return;
}
const next = range.startNode.next();
if (
next?.isElement() &&
Math.abs(range.endOffset - range.startOffset) === 1
) {
const component = this.#editor.card.closest(next);
if (component) {
this.hide();
return;
}
}
const prev = range.startNode.prev();
if (
prev?.isElement() &&
Math.abs(range.startOffset - range.endOffset) === 1
) {
const component = this.#editor.card.closest(prev);
if (component) {
this.hide();
return;
}
}
const subRanges = range.getSubRanges();
if (
subRanges.length === 0 ||