UNPKG

@atlaskit/editor-plugin-expand

Version:

Expand plugin for @atlaskit/editor-core

28 lines (27 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toggleExpandRange = void 0; var _expand = require("@atlaskit/editor-common/expand"); var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals"); var toggleExpandRange = exports.toggleExpandRange = function toggleExpandRange(from, to) { var open = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; return function (_ref) { var tr = _ref.tr; var _tr$doc$type$schema$n = tr.doc.type.schema.nodes, expand = _tr$doc$type$schema$n.expand, nestedExpand = _tr$doc$type$schema$n.nestedExpand; var fromClamped = from && from >= 0 ? from : 0; var toClamped = to && to <= tr.doc.content.size ? to : tr.doc.content.size; tr.doc.nodesBetween(fromClamped, toClamped, function (node) { if ([expand, nestedExpand].includes(node.type)) { _expand.expandedState.set(node, open); } }); if ((0, _expValEquals.expValEquals)('platform_editor_aifc_expand_collapses_oncreate_fix', 'isEnabled', true)) { return tr; } return null; }; };