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
+2 -6
View File
@@ -5,13 +5,9 @@ declare global {
}
declare module 'vue' {
interface ComponentCustomProps {
[key: `data${string}`]: unknown;
}
type ComponentCustomProps = Record<`data${string}`, unknown>;
}
declare module 'vue' {
interface HTMLAttributes {
[key: `data-${string}`]: unknown;
}
type HTMLAttributes = Record<`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 {
for (const child of Array.from(node.childNodes)) {
if (child.nodeType === Node.TEXT_NODE) {
const text = (child.nodeValue ?? '').replace(ZWSP, '');
const text = (child.nodeValue ?? '').replaceAll(ZWSP, '');
if (text)
out.push({ text, marks });
continue;
@@ -48,7 +48,7 @@ function indexInParent(el: Node): number {
}
function getWindow(): Window | null {
return typeof globalThis.window === 'undefined' ? null : globalThis.window;
return globalThis.window === undefined ? null : globalThis.window;
}
export function createSelectionBridge(
+1 -1
View File
@@ -26,7 +26,7 @@ const { floatingStyles, update } = useFloating(reference, floatingEl, {
});
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)
return null;
+2 -2
View File
@@ -33,11 +33,11 @@ const { floatingStyles, update } = useFloating(reference, floatingEl, {
});
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
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)
return null;