mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { VElement, VLine } from '../components/index.js';
|
||||
|
||||
export function isNativeTextInVText(text: unknown): text is Text {
|
||||
return text instanceof Text && text.parentElement?.dataset.vText === 'true';
|
||||
}
|
||||
|
||||
export function isVElement(element: unknown): element is HTMLElement {
|
||||
return (
|
||||
element instanceof HTMLElement &&
|
||||
(element.dataset.vElement === 'true' || element instanceof VElement)
|
||||
);
|
||||
}
|
||||
|
||||
export function isVLine(element: unknown): element is HTMLElement {
|
||||
return (
|
||||
element instanceof HTMLElement &&
|
||||
(element instanceof VLine || element.parentElement instanceof VLine)
|
||||
);
|
||||
}
|
||||
|
||||
export function isInEmptyLine(element: Node) {
|
||||
const el = element instanceof Element ? element : element.parentElement;
|
||||
const vLine = el?.closest<VLine>('v-line');
|
||||
return !!vLine && vLine.vTextLength === 0;
|
||||
}
|
||||
|
||||
export function isInlineRoot(element: unknown): element is HTMLElement {
|
||||
return element instanceof HTMLElement && element.dataset.vRoot === 'true';
|
||||
}
|
||||
Reference in New Issue
Block a user