UNPKG

@atlaskit/editor-plugin-expand

Version:

Expand plugin for @atlaskit/editor-core

17 lines (15 loc) • 995 B
import { hasParentNode } from '@atlaskit/editor-prosemirror/utils'; export var isNestedInExpand = function isNestedInExpand(state) { return hasParentNode(function (node) { return 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 var getExpandWrapper = function getExpandWrapper(editorView, pos) { return editorView.domAtPos(pos).node.parentElement; }; /** The title input of the expand whose content contains `pos`. */ export var getExpandTitleInput = function 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; };