mirror of
https://github.com/outline/outline.git
synced 2026-12-06 19:22:29 +03:00
Move focusEditor to its own module
This commit is contained in:
4 files changed
+15
-14
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<globalThis.Node, () => void>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user