chore(editor): view, selection-bridge, and type fixes
This commit is contained in:
Vendored
+1
-3
@@ -5,7 +5,5 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
interface HTMLAttributes {
|
type HTMLAttributes = Record<`data-${string}`, unknown>;
|
||||||
[key: `data-${string}`]: unknown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-6
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user