chore(editor): view, selection-bridge, and type fixes

This commit is contained in:
2026-06-08 15:51:30 +07:00
parent e83f10fe32
commit 9ef8125965
6 changed files with 8 additions and 14 deletions
+1 -3
View File
@@ -5,7 +5,5 @@ declare global {
} }
declare module 'vue' { declare module 'vue' {
interface HTMLAttributes { type HTMLAttributes = Record<`data-${string}`, unknown>;
[key: `data-${string}`]: unknown;
}
} }
+2 -6
View File
@@ -5,13 +5,9 @@ declare global {
} }
declare module 'vue' { declare module 'vue' {
interface ComponentCustomProps { type ComponentCustomProps = Record<`data${string}`, unknown>;
[key: `data${string}`]: unknown;
}
} }
declare module 'vue' { declare module 'vue' {
interface HTMLAttributes { type HTMLAttributes = Record<`data-${string}`, unknown>;
[key: `data-${string}`]: unknown;
}
} }
+1 -1
View File
@@ -35,7 +35,7 @@ function marksForElement(el: HTMLElement, registry: Registry): Mark[] {
function walk(node: Node, marks: readonly Mark[], out: InlineNode[], registry: Registry): void { function walk(node: Node, marks: readonly Mark[], out: InlineNode[], registry: Registry): void {
for (const child of Array.from(node.childNodes)) { for (const child of Array.from(node.childNodes)) {
if (child.nodeType === Node.TEXT_NODE) { if (child.nodeType === Node.TEXT_NODE) {
const text = (child.nodeValue ?? '').replace(ZWSP, ''); const text = (child.nodeValue ?? '').replaceAll(ZWSP, '');
if (text) if (text)
out.push({ text, marks }); out.push({ text, marks });
continue; continue;
@@ -48,7 +48,7 @@ function indexInParent(el: Node): number {
} }
function getWindow(): Window | null { function getWindow(): Window | null {
return typeof globalThis.window === 'undefined' ? null : globalThis.window; return globalThis.window === undefined ? null : globalThis.window;
} }
export function createSelectionBridge( export function createSelectionBridge(
+1 -1
View File
@@ -26,7 +26,7 @@ const { floatingStyles, update } = useFloating(reference, floatingEl, {
}); });
function selectionRect(): DOMRect | null { function selectionRect(): DOMRect | null {
const selection = typeof globalThis.window === 'undefined' ? null : globalThis.getSelection(); const selection = globalThis.window === undefined ? null : globalThis.getSelection();
if (!selection || selection.rangeCount === 0) if (!selection || selection.rangeCount === 0)
return null; return null;
+2 -2
View File
@@ -33,11 +33,11 @@ const { floatingStyles, update } = useFloating(reference, floatingEl, {
}); });
function escapeRegExp(value: string): string { function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); return value.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&');
} }
function caretRect(): DOMRect | null { function caretRect(): DOMRect | null {
const selection = typeof globalThis.window === 'undefined' ? null : globalThis.getSelection(); const selection = globalThis.window === undefined ? null : globalThis.getSelection();
if (!selection || selection.rangeCount === 0) if (!selection || selection.rangeCount === 0)
return null; return null;