mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
@@ -209,14 +209,23 @@ export class RangeBinding {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const el =
|
const el = getElement(range.commonAncestorContainer);
|
||||||
range.commonAncestorContainer instanceof Element
|
|
||||||
? range.commonAncestorContainer
|
|
||||||
: range.commonAncestorContainer.parentElement;
|
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);
|
const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);
|
||||||
if (block?.getAttribute(RANGE_SYNC_EXCLUDE_ATTR) === 'true') return;
|
if (block?.getAttribute(RANGE_SYNC_EXCLUDE_ATTR) === 'true') return;
|
||||||
|
|
||||||
|
const startElement = getElement(range.startContainer);
|
||||||
|
const endElement = getElement(range.endContainer);
|
||||||
|
|
||||||
|
// if neither start nor end is in a v-text, the range is invalid
|
||||||
|
if (!startElement?.closest('v-text') && !endElement?.closest('v-text')) {
|
||||||
|
this._prevTextSelection = null;
|
||||||
|
this.selectionManager.clear(['text']);
|
||||||
|
|
||||||
|
selection.removeRange(range);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const inlineEditor = this.rangeManager?.getClosestInlineEditor(
|
const inlineEditor = this.rangeManager?.getClosestInlineEditor(
|
||||||
range.commonAncestorContainer
|
range.commonAncestorContainer
|
||||||
);
|
);
|
||||||
@@ -351,3 +360,10 @@ export class RangeBinding {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getElement(node: Node): Element | null {
|
||||||
|
if (node instanceof Element) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
return node.parentElement;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user