UNPKG

@atlaskit/editor-plugin-expand

Version:

Expand plugin for @atlaskit/editor-core

28 lines (26 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findSelectedParentExpandNode = exports.findReplaceExpandDecorations = void 0; var _expand = require("@atlaskit/editor-common/expand"); var _utils = require("@atlaskit/editor-prosemirror/utils"); // from platform/packages/editor/editor-plugin-find-replace/src/ui/styles.ts var darkModeSearchMatchClass = 'search-match-dark'; var searchMatchExpandTitleClass = 'search-match-expand-title'; var selectedSearchMatchClass = 'selected-search-match'; var findSelectedParentExpandNode = exports.findSelectedParentExpandNode = function findSelectedParentExpandNode(state) { var nestedOrParentExpand = (0, _utils.findParentNodeOfType)(state.schema.nodes.nestedExpand)(state.selection) || (0, _utils.findParentNodeOfType)(state.schema.nodes.expand)(state.selection); // If it's nested expand, we should check if its parent expand is collapsed. // If the parent expand is collapsed, the nested expand is not visible, // so it could not be selected. // In this case, we return the parent expand node instead of the nested expand node. if ((nestedOrParentExpand === null || nestedOrParentExpand === void 0 ? void 0 : nestedOrParentExpand.node.type) === state.schema.nodes.nestedExpand) { var parentExpand = (0, _utils.findParentNodeOfType)(state.schema.nodes.expand)(state.selection); if (parentExpand && (0, _expand.isExpandCollapsed)(parentExpand.node)) { return parentExpand; } } return nestedOrParentExpand; }; var findReplaceExpandDecorations = exports.findReplaceExpandDecorations = [darkModeSearchMatchClass, searchMatchExpandTitleClass, selectedSearchMatchClass];