diff --git a/shared/editor/lib/focusEditor.ts b/shared/editor/lib/focusEditor.ts new file mode 100644 index 0000000000..7783a1469c --- /dev/null +++ b/shared/editor/lib/focusEditor.ts @@ -0,0 +1,13 @@ +import type { EditorView } from "prosemirror-view"; + +/** + * Focus the editor if it does not have focus, for controls such as the table + * grips that stay visible while focus is elsewhere. + * + * @param view The editor view. + */ +export function focusEditor(view: EditorView): void { + if (!view.hasFocus()) { + view.focus(); + } +} diff --git a/shared/editor/lib/table.ts b/shared/editor/lib/table.ts index 0c2a238793..690775bab8 100644 --- a/shared/editor/lib/table.ts +++ b/shared/editor/lib/table.ts @@ -388,18 +388,6 @@ export function cellWidget( return Decoration.widget(cellPos + 1, toDOM, { ...spec, side: -1 }); } -/** - * Focus the editor if it does not have focus, for controls such as the table - * grips that stay visible while focus is elsewhere. - * - * @param view The editor view. - */ -export function focusEditor(view: EditorView): void { - if (!view.hasFocus()) { - view.focus(); - } -} - const spanTrackers = new WeakMap void>(); /** diff --git a/shared/editor/nodes/TableHeader.ts b/shared/editor/nodes/TableHeader.ts index 7f81549154..55609a0375 100644 --- a/shared/editor/nodes/TableHeader.ts +++ b/shared/editor/nodes/TableHeader.ts @@ -9,7 +9,6 @@ import { addColumnBefore, moveColumn, selectColumn } from "../commands/table"; import { isMobile } from "../../utils/browser"; import { isRemoteTransaction } from "../lib/multiplayer"; import { - focusEditor, cellWidget, getCellAttrs, getCellSpan, @@ -21,6 +20,7 @@ import { trackSpanPosition, untrackSpanPosition, } from "../lib/table"; +import { focusEditor } from "../lib/focusEditor"; import { isInlineTransaction } from "../queries/isInlineTransaction"; import { getCellsInColumn, diff --git a/shared/editor/nodes/TableRow.ts b/shared/editor/nodes/TableRow.ts index 4ea03ebfb9..c3b09d271f 100644 --- a/shared/editor/nodes/TableRow.ts +++ b/shared/editor/nodes/TableRow.ts @@ -4,13 +4,13 @@ import { isInTable, moveTableRow, selectedRect } from "prosemirror-tables"; import Node from "./Node"; import { cn } from "../styles/utils"; import { - focusEditor, cellWidget, getCellSpan, setSpanPosition, trackSpanPosition, untrackSpanPosition, } from "../lib/table"; +import { focusEditor } from "../lib/focusEditor"; import { EditorStyleHelper } from "../styles/EditorStyleHelper"; import { type Decoration, DecorationSet } from "prosemirror-view"; import type { EditorView } from "prosemirror-view";