UNPKG

@atlaskit/editor-plugin-expand

Version:

Expand plugin for @atlaskit/editor-core

23 lines (20 loc) • 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNestedInExpand = exports.getExpandWrapper = exports.getExpandTitleInput = void 0; var _utils = require("@atlaskit/editor-prosemirror/utils"); var isNestedInExpand = exports.isNestedInExpand = function isNestedInExpand(state) { return (0, _utils.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. */ var getExpandWrapper = exports.getExpandWrapper = function getExpandWrapper(editorView, pos) { return editorView.domAtPos(pos).node.parentElement; }; /** The title input of the expand whose content contains `pos`. */ var getExpandTitleInput = exports.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; };