@atlaskit/editor-plugin-block-menu
Version:
BlockMenu plugin for @atlaskit/editor-core
286 lines • 11.2 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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) { _defineProperty(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; }
import { applyTargetTextTypeStep } from './steps/applyTargetTextTypeStep';
import { convertEachNodeStep } from './steps/convertEachNodeStep';
import { decisionListToListStep } from './steps/decisionListToListStep';
import { flattenListStep } from './steps/flattenListStep';
import { flattenStep } from './steps/flattenStep';
import { listToDecisionListStep } from './steps/listToDecisionListStep';
import { listToListStep } from './steps/listToListStep';
import { mergeNeighbourListsStep } from './steps/mergeNeighbourListsStep';
import { unwrapExpandStep } from './steps/unwrapExpandStep';
import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
import { unwrapListStep } from './steps/unwrapListStep';
import { unwrapStep } from './steps/unwrapStep';
import { wrapBlockquoteToDecisionListStep } from './steps/wrapBlockquoteToDecisionListStep';
import { wrapIntoListStep } from './steps/wrapIntoListStep';
import { wrapMixedContentStep } from './steps/wrapMixedContentStep';
import { wrapStep } from './steps/wrapStep';
/**
* 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, applyTargetTextTypeStep],
blockquote: [wrapMixedContentStep],
codeBlock: [wrapMixedContentStep],
expand: [wrapMixedContentStep],
nestedExpand: [wrapMixedContentStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [wrapMixedContentStep]
} : {}), {}, {
bulletList: [wrapIntoListStep],
orderedList: [wrapIntoListStep],
taskList: [wrapIntoListStep],
decisionList: [wrapIntoListStep]
}),
heading: _objectSpread(_objectSpread({
heading: [flattenStep, applyTargetTextTypeStep],
paragraph: [flattenStep, applyTargetTextTypeStep],
blockquote: [wrapMixedContentStep],
codeBlock: [wrapMixedContentStep],
expand: [wrapMixedContentStep],
nestedExpand: [wrapMixedContentStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [wrapMixedContentStep]
} : {}), {}, {
bulletList: [wrapIntoListStep],
orderedList: [wrapIntoListStep],
taskList: [wrapIntoListStep],
decisionList: [wrapIntoListStep]
}),
panel: {
blockquote: [unwrapStep, wrapMixedContentStep],
codeBlock: [unwrapStep, wrapMixedContentStep],
expand: [unwrapStep, wrapStep],
nestedExpand: [unwrapStep, wrapStep],
layoutSection: [unwrapStep, wrapMixedContentStep],
paragraph: [unwrapStep]
},
panel_c1: includePanelC1 ? {
blockquote: [unwrapStep, wrapMixedContentStep],
codeBlock: [unwrapStep, wrapMixedContentStep],
expand: [unwrapStep, wrapStep],
nestedExpand: [unwrapStep, wrapStep],
layoutSection: [unwrapStep, wrapMixedContentStep],
paragraph: [unwrapStep]
} : {},
expand: _objectSpread(_objectSpread({
panel: [unwrapExpandStep, wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [unwrapExpandStep, wrapMixedContentStep]
} : {}), {}, {
blockquote: [unwrapExpandStep, wrapMixedContentStep],
layoutSection: [unwrapExpandStep, wrapMixedContentStep],
nestedExpand: [unwrapExpandStep, wrapStep],
paragraph: [unwrapExpandStep]
}),
nestedExpand: _objectSpread(_objectSpread({
panel: [unwrapExpandStep, wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [unwrapExpandStep, wrapMixedContentStep]
} : {}), {}, {
blockquote: [unwrapExpandStep, wrapMixedContentStep],
layoutSection: [unwrapExpandStep, wrapMixedContentStep],
paragraph: [unwrapExpandStep]
}),
blockquote: _objectSpread(_objectSpread({
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [unwrapStep, wrapStep]
}, includePanelC1 ? {
panel_c1: [unwrapStep, wrapStep]
} : {}), {}, {
paragraph: [unwrapStep],
decisionList: [unwrapStep, wrapBlockquoteToDecisionListStep]
}),
layoutSection: _objectSpread(_objectSpread({
blockquote: [unwrapLayoutStep, wrapMixedContentStep],
expand: [unwrapLayoutStep, wrapStep],
nestedExpand: [unwrapLayoutStep, wrapStep],
panel: [unwrapLayoutStep, wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [unwrapLayoutStep, wrapMixedContentStep]
} : {}), {}, {
paragraph: [unwrapLayoutStep]
}),
codeBlock: _objectSpread(_objectSpread({
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
paragraph: [applyTargetTextTypeStep]
}),
bulletList: _objectSpread(_objectSpread({
orderedList: [listToListStep],
taskList: [listToListStep],
decisionList: [flattenListStep, listToDecisionListStep],
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
}),
orderedList: _objectSpread(_objectSpread({
bulletList: [listToListStep],
taskList: [listToListStep],
decisionList: [flattenListStep, listToDecisionListStep],
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
}),
taskList: _objectSpread(_objectSpread({
bulletList: [listToListStep],
orderedList: [listToListStep],
decisionList: [flattenListStep, listToDecisionListStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
}),
table: {
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep]
},
mediaSingle: _objectSpread(_objectSpread({
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
bulletList: [wrapIntoListStep],
orderedList: [wrapIntoListStep]
}),
mediaGroup: _objectSpread({
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}),
media: _objectSpread(_objectSpread({
blockquote: [wrapStep],
codeBlock: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
bulletList: [wrapIntoListStep],
orderedList: [wrapIntoListStep],
taskList: [wrapIntoListStep],
decisionList: [wrapIntoListStep]
}),
decisionList: _objectSpread(_objectSpread({
bulletList: [decisionListToListStep],
orderedList: [decisionListToListStep],
taskList: [decisionListToListStep],
blockquote: [unwrapListStep, wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep],
heading: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
}),
blockCard: _objectSpread({
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}),
embedCard: {
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep]
},
extension: _objectSpread({
blockquote: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}),
bodiedExtension: {
nestedExpand: [wrapStep],
layoutSection: [wrapMixedContentStep]
},
multiBodiedExtension: _objectSpread(_objectSpread({
blockquote: [wrapStep],
codeBlock: [wrapStep],
expand: [wrapStep],
nestedExpand: [wrapStep],
layoutSection: [wrapStep],
panel: [wrapStep]
}, includePanelC1 ? {
panel_c1: [wrapStep]
} : {}), {}, {
bulletList: [wrapIntoListStep],
orderedList: [wrapIntoListStep],
taskList: [wrapIntoListStep],
decisionList: [wrapIntoListStep]
}),
multi: _objectSpread(_objectSpread({
blockquote: [wrapMixedContentStep],
codeBlock: [wrapMixedContentStep],
expand: [wrapMixedContentStep],
nestedExpand: [wrapMixedContentStep],
layoutSection: [wrapMixedContentStep],
panel: [wrapMixedContentStep]
}, includePanelC1 ? {
panel_c1: [wrapMixedContentStep]
} : {}), {}, {
bulletList: [convertEachNodeStep, mergeNeighbourListsStep],
orderedList: [convertEachNodeStep, mergeNeighbourListsStep],
taskList: [convertEachNodeStep, mergeNeighbourListsStep],
decisionList: [convertEachNodeStep, mergeNeighbourListsStep],
paragraph: [convertEachNodeStep],
heading: [applyTargetTextTypeStep]
})
};
};
export var TRANSFORMATION_MATRIX = createTransformationMatrix(false);
export var TRANSFORMATION_MATRIX_PANEL_C1 = createTransformationMatrix(true);