@atlaskit/editor-plugin-expand
Version:
Expand plugin for @atlaskit/editor-core
11 lines (9 loc) • 876 B
JavaScript
import { hasParentNode } from '@atlaskit/editor-prosemirror/utils';
export const isNestedInExpand = state => hasParentNode(node => node.type === state.schema.nodes.expand || node.type === state.schema.nodes.nestedExpand)(state.selection);
/** The element wrapping an expand's title and content, found from a position inside its content. */
export const getExpandWrapper = (editorView, pos) => editorView.domAtPos(pos).node.parentElement;
/** The title input of the expand whose content contains `pos`. */
export const getExpandTitleInput = (editorView, pos) => {
var _getExpandWrapper$que, _getExpandWrapper;
return (_getExpandWrapper$que = (_getExpandWrapper = getExpandWrapper(editorView, pos)) === null || _getExpandWrapper === void 0 ? void 0 : _getExpandWrapper.querySelector('input')) !== null && _getExpandWrapper$que !== void 0 ? _getExpandWrapper$que : null;
};