UNPKG

@atlaskit/editor-plugin-block-menu

Version:

BlockMenu plugin for @atlaskit/editor-core

293 lines (292 loc) 15.2 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.TRANSFORMATION_MATRIX_PANEL_C1 = exports.TRANSFORMATION_MATRIX = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _applyTargetTextTypeStep = require("./steps/applyTargetTextTypeStep"); var _convertEachNodeStep = require("./steps/convertEachNodeStep"); var _decisionListToListStep = require("./steps/decisionListToListStep"); var _flattenListStep = require("./steps/flattenListStep"); var _flattenStep = require("./steps/flattenStep"); var _listToDecisionListStep = require("./steps/listToDecisionListStep"); var _listToListStep = require("./steps/listToListStep"); var _mergeNeighbourListsStep = require("./steps/mergeNeighbourListsStep"); var _unwrapExpandStep = require("./steps/unwrapExpandStep"); var _unwrapLayoutStep = require("./steps/unwrapLayoutStep"); var _unwrapListStep = require("./steps/unwrapListStep"); var _unwrapStep = require("./steps/unwrapStep"); var _wrapBlockquoteToDecisionListStep = require("./steps/wrapBlockquoteToDecisionListStep"); var _wrapIntoListStep = require("./steps/wrapIntoListStep"); var _wrapMixedContentStep = require("./steps/wrapMixedContentStep"); var _wrapStep = require("./steps/wrapStep"); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** * Creates the transformation matrix for all node type pairs. * When includePanelC1 is true (platform_editor_nest_table_in_panel experiment on), * panel_c1 entries are included as both source and target types. * If a transformation is not defined (undefined), it is not available. */ var createTransformationMatrix = function createTransformationMatrix(includePanelC1) { return { paragraph: _objectSpread(_objectSpread({ heading: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep], blockquote: [_wrapMixedContentStep.wrapMixedContentStep], codeBlock: [_wrapMixedContentStep.wrapMixedContentStep], expand: [_wrapMixedContentStep.wrapMixedContentStep], nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { bulletList: [_wrapIntoListStep.wrapIntoListStep], orderedList: [_wrapIntoListStep.wrapIntoListStep], taskList: [_wrapIntoListStep.wrapIntoListStep], decisionList: [_wrapIntoListStep.wrapIntoListStep] }), heading: _objectSpread(_objectSpread({ heading: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep], paragraph: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep], blockquote: [_wrapMixedContentStep.wrapMixedContentStep], codeBlock: [_wrapMixedContentStep.wrapMixedContentStep], expand: [_wrapMixedContentStep.wrapMixedContentStep], nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { bulletList: [_wrapIntoListStep.wrapIntoListStep], orderedList: [_wrapIntoListStep.wrapIntoListStep], taskList: [_wrapIntoListStep.wrapIntoListStep], decisionList: [_wrapIntoListStep.wrapIntoListStep] }), panel: { blockquote: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], codeBlock: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], expand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep], nestedExpand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep], layoutSection: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], paragraph: [_unwrapStep.unwrapStep] }, panel_c1: includePanelC1 ? { blockquote: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], codeBlock: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], expand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep], nestedExpand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep], layoutSection: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep], paragraph: [_unwrapStep.unwrapStep] } : {}, expand: _objectSpread(_objectSpread({ panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep], layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep], nestedExpand: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep], paragraph: [_unwrapExpandStep.unwrapExpandStep] }), nestedExpand: _objectSpread(_objectSpread({ panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep], layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep], paragraph: [_unwrapExpandStep.unwrapExpandStep] }), blockquote: _objectSpread(_objectSpread({ expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_unwrapStep.unwrapStep, _wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_unwrapStep.unwrapStep, _wrapStep.wrapStep] } : {}), {}, { paragraph: [_unwrapStep.unwrapStep], decisionList: [_unwrapStep.unwrapStep, _wrapBlockquoteToDecisionListStep.wrapBlockquoteToDecisionListStep] }), layoutSection: _objectSpread(_objectSpread({ blockquote: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep], expand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep], nestedExpand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep], panel: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { paragraph: [_unwrapLayoutStep.unwrapLayoutStep] }), codeBlock: _objectSpread(_objectSpread({ blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { paragraph: [_applyTargetTextTypeStep.applyTargetTextTypeStep] }), bulletList: _objectSpread(_objectSpread({ orderedList: [_listToListStep.listToListStep], taskList: [_listToListStep.listToListStep], decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep], blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep] }), orderedList: _objectSpread(_objectSpread({ bulletList: [_listToListStep.listToListStep], taskList: [_listToListStep.listToListStep], decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep], blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep] }), taskList: _objectSpread(_objectSpread({ bulletList: [_listToListStep.listToListStep], orderedList: [_listToListStep.listToListStep], decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep] }), table: { expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep] }, mediaSingle: _objectSpread(_objectSpread({ blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { bulletList: [_wrapIntoListStep.wrapIntoListStep], orderedList: [_wrapIntoListStep.wrapIntoListStep] }), mediaGroup: _objectSpread({ blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), media: _objectSpread(_objectSpread({ blockquote: [_wrapStep.wrapStep], codeBlock: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapStep.wrapStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { bulletList: [_wrapIntoListStep.wrapIntoListStep], orderedList: [_wrapIntoListStep.wrapIntoListStep], taskList: [_wrapIntoListStep.wrapIntoListStep], decisionList: [_wrapIntoListStep.wrapIntoListStep] }), decisionList: _objectSpread(_objectSpread({ bulletList: [_decisionListToListStep.decisionListToListStep], orderedList: [_decisionListToListStep.decisionListToListStep], taskList: [_decisionListToListStep.decisionListToListStep], blockquote: [_unwrapListStep.unwrapListStep, _wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep], heading: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep] }), blockCard: _objectSpread({ expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), embedCard: { expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep] }, extension: _objectSpread({ blockquote: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), bodiedExtension: { nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep] }, multiBodiedExtension: _objectSpread(_objectSpread({ blockquote: [_wrapStep.wrapStep], codeBlock: [_wrapStep.wrapStep], expand: [_wrapStep.wrapStep], nestedExpand: [_wrapStep.wrapStep], layoutSection: [_wrapStep.wrapStep], panel: [_wrapStep.wrapStep] }, includePanelC1 ? { panel_c1: [_wrapStep.wrapStep] } : {}), {}, { bulletList: [_wrapIntoListStep.wrapIntoListStep], orderedList: [_wrapIntoListStep.wrapIntoListStep], taskList: [_wrapIntoListStep.wrapIntoListStep], decisionList: [_wrapIntoListStep.wrapIntoListStep] }), multi: _objectSpread(_objectSpread({ blockquote: [_wrapMixedContentStep.wrapMixedContentStep], codeBlock: [_wrapMixedContentStep.wrapMixedContentStep], expand: [_wrapMixedContentStep.wrapMixedContentStep], nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep], layoutSection: [_wrapMixedContentStep.wrapMixedContentStep], panel: [_wrapMixedContentStep.wrapMixedContentStep] }, includePanelC1 ? { panel_c1: [_wrapMixedContentStep.wrapMixedContentStep] } : {}), {}, { bulletList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep], orderedList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep], taskList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep], decisionList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep], paragraph: [_convertEachNodeStep.convertEachNodeStep], heading: [_applyTargetTextTypeStep.applyTargetTextTypeStep] }) }; }; var TRANSFORMATION_MATRIX = exports.TRANSFORMATION_MATRIX = createTransformationMatrix(false); var TRANSFORMATION_MATRIX_PANEL_C1 = exports.TRANSFORMATION_MATRIX_PANEL_C1 = createTransformationMatrix(true);