mirror of
https://github.com/outline/outline.git
synced 2026-12-06 19:22:29 +03:00
17 lines
504 B
TypeScript
17 lines
504 B
TypeScript
import type { EditorView } from "prosemirror-view";
|
|
|
|
/**
|
|
* Focus the editor if focus is elsewhere, for controls such as the table grips
|
|
* that stay visible while focus is elsewhere. Focus in an open menu stays
|
|
* there, as moving it would close the menu.
|
|
*
|
|
* @param view The editor view.
|
|
*/
|
|
export function focusEditor(view: EditorView): void {
|
|
const { activeElement } = view.dom.ownerDocument;
|
|
if (view.hasFocus() || activeElement?.closest("[role='menu']")) {
|
|
return;
|
|
}
|
|
view.focus();
|
|
}
|