@atlaskit/editor-plugin-block-menu 5.1.4 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/flattenStep.js +21 -0
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +38 -0
  4. package/dist/cjs/editor-commands/transform-node-utils/transform.js +50 -4
  5. package/dist/cjs/editor-commands/transform-node-utils/types.js +1 -1
  6. package/dist/cjs/editor-commands/transform-node-utils/unwrapExpandStep.js +43 -0
  7. package/dist/cjs/editor-commands/transform-node-utils/unwrapStep.js +20 -0
  8. package/dist/cjs/editor-commands/transform-node-utils/utils.js +7 -1
  9. package/dist/cjs/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +23 -0
  10. package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +15 -0
  11. package/dist/cjs/editor-commands/transformNode.js +4 -1
  12. package/dist/es2019/editor-commands/transform-node-utils/flattenStep.js +15 -0
  13. package/dist/es2019/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +30 -0
  14. package/dist/es2019/editor-commands/transform-node-utils/transform.js +50 -4
  15. package/dist/es2019/editor-commands/transform-node-utils/types.js +1 -1
  16. package/dist/es2019/editor-commands/transform-node-utils/unwrapExpandStep.js +39 -0
  17. package/dist/es2019/editor-commands/transform-node-utils/unwrapStep.js +12 -0
  18. package/dist/es2019/editor-commands/transform-node-utils/utils.js +6 -0
  19. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +20 -0
  20. package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +11 -0
  21. package/dist/es2019/editor-commands/transformNode.js +4 -1
  22. package/dist/esm/editor-commands/transform-node-utils/flattenStep.js +15 -0
  23. package/dist/esm/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +31 -0
  24. package/dist/esm/editor-commands/transform-node-utils/transform.js +50 -4
  25. package/dist/esm/editor-commands/transform-node-utils/types.js +1 -1
  26. package/dist/esm/editor-commands/transform-node-utils/unwrapExpandStep.js +37 -0
  27. package/dist/esm/editor-commands/transform-node-utils/unwrapStep.js +13 -0
  28. package/dist/esm/editor-commands/transform-node-utils/utils.js +6 -0
  29. package/dist/esm/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +17 -0
  30. package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +9 -0
  31. package/dist/esm/editor-commands/transformNode.js +4 -1
  32. package/dist/types/editor-commands/transform-node-utils/flattenStep.d.ts +2 -0
  33. package/dist/types/editor-commands/transform-node-utils/steps/unwrapLayoutStep.d.ts +14 -0
  34. package/dist/types/editor-commands/transform-node-utils/transform.d.ts +2 -1
  35. package/dist/types/editor-commands/transform-node-utils/types.d.ts +1 -1
  36. package/dist/types/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +8 -0
  37. package/dist/types/editor-commands/transform-node-utils/unwrapStep.d.ts +2 -0
  38. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +2 -0
  39. package/dist/types/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +2 -0
  40. package/dist/types/editor-commands/transform-node-utils/wrapStep.d.ts +2 -0
  41. package/dist/types-ts4.5/editor-commands/transform-node-utils/flattenStep.d.ts +2 -0
  42. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/unwrapLayoutStep.d.ts +14 -0
  43. package/dist/types-ts4.5/editor-commands/transform-node-utils/transform.d.ts +2 -1
  44. package/dist/types-ts4.5/editor-commands/transform-node-utils/types.d.ts +1 -1
  45. package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +8 -0
  46. package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapStep.d.ts +2 -0
  47. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +2 -0
  48. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +2 -0
  49. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapStep.d.ts +2 -0
  50. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a202e97c73f3a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a202e97c73f3a) -
8
+ Adds base transform cases for codeBlock, layout, blockquote.
9
+
10
+ ## 5.1.5
11
+
12
+ ### Patch Changes
13
+
14
+ - [`f6905b2543ef1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f6905b2543ef1) -
15
+ [ux] Implements base steps for from container to other node categories transfroms.
16
+ - Updated dependencies
17
+
3
18
  ## 5.1.4
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flattenStep = void 0;
7
+ var flattenStep = exports.flattenStep = function flattenStep(nodes, context) {
8
+ var schema = context.schema,
9
+ targetNodeTypeName = context.targetNodeTypeName;
10
+
11
+ // TODO: EDITOR-2920 - Implement flattening logic.
12
+ // This is a simplified preliminary approach. We might want to use prosemirror-markdown functions.
13
+ var codeBlockContent = nodes.map(function (node) {
14
+ return node.content.textBetween(0, node.content.size, '\n');
15
+ }).join('\n');
16
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, schema.text(codeBlockContent));
17
+ if (!outputNode) {
18
+ return nodes;
19
+ }
20
+ return [outputNode];
21
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.unwrapLayoutStep = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ /**
10
+ * Unwraps a layoutSection node, extracting content from all columns.
11
+ * Works with any number of columns (2, 3, etc.).
12
+ *
13
+ * Example:
14
+ * layoutSection(
15
+ * layoutColumn(p('a'), p('b')),
16
+ * layoutColumn(p('c')),
17
+ * layoutColumn(p('d'))
18
+ * )
19
+ * → [p('a'), p('b'), p('c'), p('d')]
20
+ */
21
+ var unwrapLayoutStep = exports.unwrapLayoutStep = function unwrapLayoutStep(nodes) {
22
+ var outputNodes = [];
23
+ nodes.forEach(function (node) {
24
+ var isLayoutSection = node.type.name === 'layoutSection';
25
+ if (isLayoutSection) {
26
+ node.children.forEach(function (column) {
27
+ var isLayoutColumn = column.type.name === 'layoutColumn';
28
+ if (isLayoutColumn) {
29
+ outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(column.children));
30
+ }
31
+ });
32
+ }
33
+ });
34
+ if (outputNodes.length === 0) {
35
+ return nodes;
36
+ }
37
+ return outputNodes;
38
+ };
@@ -4,10 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getOutputNodes = void 0;
7
+ var _utils = require("../transform-node-utils/utils");
7
8
  var _flattenListStep = require("./flattenListStep");
9
+ var _flattenStep = require("./flattenStep");
10
+ var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
8
11
  var _stubStep = require("./stubStep");
9
12
  var _types = require("./types");
13
+ var _unwrapExpandStep = require("./unwrapExpandStep");
10
14
  var _unwrapListStep = require("./unwrapListStep");
15
+ var _unwrapStep = require("./unwrapStep");
16
+ var _wrapIntoLayoutStep = require("./wrapIntoLayoutStep");
17
+ var _wrapStep = require("./wrapStep");
11
18
  // Exampled step for overrides:
12
19
  // - open Block menu on a paragraph, click 'Panel' in the Turn into'
13
20
  // - expected to put paragraph into a panel
@@ -26,9 +33,9 @@ var TRANSFORM_STEPS = {
26
33
  },
27
34
  container: {
28
35
  atomic: undefined,
29
- container: [_stubStep.stubStep],
36
+ container: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
30
37
  list: undefined,
31
- text: undefined
38
+ text: [_unwrapStep.unwrapStep]
32
39
  },
33
40
  list: {
34
41
  atomic: undefined,
@@ -49,6 +56,43 @@ var TRANSFORM_STEPS = {
49
56
  var TRANSFORM_STEPS_OVERRIDE = {
50
57
  paragraph: {
51
58
  panel: [wrapIntoPanelStep]
59
+ },
60
+ panel: {
61
+ layoutSection: [_unwrapStep.unwrapStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
62
+ codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
63
+ },
64
+ expand: {
65
+ panel: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
66
+ blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
67
+ layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
68
+ paragraph: [_unwrapExpandStep.unwrapExpandStep],
69
+ codeBlock: [_unwrapExpandStep.unwrapExpandStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
70
+ },
71
+ nestedExpand: {
72
+ panel: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
73
+ blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
74
+ paragraph: [_unwrapExpandStep.unwrapExpandStep],
75
+ codeBlock: [_unwrapExpandStep.unwrapExpandStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
76
+ },
77
+ blockquote: {
78
+ expand: [_wrapStep.wrapStep],
79
+ nestedExpand: [_wrapStep.wrapStep],
80
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
81
+ codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
82
+ },
83
+ layoutSection: {
84
+ blockquote: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
85
+ expand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
86
+ panel: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
87
+ codeBlock: [_unwrapLayoutStep.unwrapLayoutStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
88
+ paragraph: [_unwrapLayoutStep.unwrapLayoutStep]
89
+ },
90
+ codeBlock: {
91
+ blockquote: [_wrapStep.wrapStep],
92
+ expand: [_wrapStep.wrapStep],
93
+ nestedExpand: [_wrapStep.wrapStep],
94
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
95
+ panel: [_wrapStep.wrapStep]
52
96
  }
53
97
  };
54
98
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -62,10 +106,12 @@ var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selec
62
106
  var getOutputNodes = exports.getOutputNodes = function getOutputNodes(_ref) {
63
107
  var sourceNode = _ref.sourceNode,
64
108
  targetNodeType = _ref.targetNodeType,
65
- schema = _ref.schema;
109
+ schema = _ref.schema,
110
+ isNested = _ref.isNested;
66
111
  var nodesToReplace = [sourceNode];
67
112
  var selectedNodeTypeName = (0, _types.toNodeTypeValue)(sourceNode.type.name);
68
- var targetNodeTypeName = (0, _types.toNodeTypeValue)(targetNodeType.name);
113
+ var initialTargetNodeTypeName = (0, _types.toNodeTypeValue)(targetNodeType.name);
114
+ var targetNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(initialTargetNodeTypeName, isNested);
69
115
  if (!selectedNodeTypeName || !targetNodeTypeName) {
70
116
  // We may decide to return an empty array or undefined here
71
117
  return;
@@ -15,7 +15,7 @@ var NODE_CATEGORY_BY_TYPE = exports.NODE_CATEGORY_BY_TYPE = {
15
15
  expand: 'container',
16
16
  extension: 'atomic',
17
17
  heading: 'text',
18
- layout: 'container',
18
+ layoutSection: 'container',
19
19
  media: 'atomic',
20
20
  mediaGroup: 'atomic',
21
21
  mediaSingle: 'atomic',
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.unwrapExpandStep = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _unwrapStep = require("./unwrapStep");
10
+ /**
11
+ * Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
12
+ * and prepending it to the children.
13
+ *
14
+ * Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
15
+ */
16
+ var unwrapExpandStep = exports.unwrapExpandStep = function unwrapExpandStep(nodes, context) {
17
+ var schema = context.schema;
18
+ var outputNodes = [];
19
+ var _schema$nodes = schema.nodes,
20
+ expand = _schema$nodes.expand,
21
+ nestedExpand = _schema$nodes.nestedExpand;
22
+ nodes.forEach(function (node) {
23
+ var isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
24
+ if (isExpand) {
25
+ var _node$attrs;
26
+ var title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
27
+
28
+ // Create a paragraph from the title if it exists
29
+ if (title) {
30
+ var titleParagraph = schema.nodes.paragraph.createAndFill({}, schema.text(title));
31
+ if (titleParagraph) {
32
+ outputNodes.push(titleParagraph);
33
+ }
34
+ }
35
+
36
+ // Add the children
37
+ outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(node.children));
38
+ } else {
39
+ (0, _unwrapStep.unwrapStep)([node], context);
40
+ }
41
+ });
42
+ return outputNodes;
43
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.unwrapStep = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var unwrapStep = exports.unwrapStep = function unwrapStep(nodes) {
10
+ var outputNodes = [];
11
+ nodes.forEach(function (node) {
12
+ // we may want to just skip the original instead of using it
13
+ if (node.children.length === 0) {
14
+ outputNodes.push(node);
15
+ } else {
16
+ outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(node.children));
17
+ }
18
+ });
19
+ return outputNodes;
20
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSelectedNode = void 0;
6
+ exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var _utils = require("@atlaskit/editor-prosemirror/utils");
9
9
  var _editorTables = require("@atlaskit/editor-tables");
@@ -48,4 +48,10 @@ var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selecti
48
48
  }
49
49
  }
50
50
  return undefined;
51
+ };
52
+ var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested) {
53
+ if (nodeTypeName === 'expand' && isNested) {
54
+ return 'nestedExpand';
55
+ }
56
+ return nodeTypeName;
51
57
  };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapIntoLayoutStep = void 0;
7
+ var _model = require("@atlaskit/editor-prosemirror/model");
8
+ var wrapIntoLayoutStep = exports.wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
9
+ var schema = context.schema;
10
+ var _ref = schema.nodes || {},
11
+ layoutSection = _ref.layoutSection,
12
+ layoutColumn = _ref.layoutColumn;
13
+ var columnOne = layoutColumn.createAndFill({}, _model.Fragment.fromArray(nodes));
14
+ var columnTwo = layoutColumn.createAndFill();
15
+ if (!columnOne || !columnTwo) {
16
+ return nodes;
17
+ }
18
+ var layout = layoutSection.createAndFill({}, _model.Fragment.fromArray([columnOne, columnTwo]));
19
+ if (!layout) {
20
+ return nodes;
21
+ }
22
+ return [layout];
23
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapStep = void 0;
7
+ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
8
+ var schema = context.schema,
9
+ targetNodeTypeName = context.targetNodeTypeName;
10
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, nodes);
11
+ if (outputNode) {
12
+ return [outputNode];
13
+ }
14
+ return nodes;
15
+ };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.transformNode = void 0;
7
7
  var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _model = require("@atlaskit/editor-prosemirror/model");
9
+ var _isNestedNode = require("../ui/utils/isNestedNode");
9
10
  var _transform = require("./transform-node-utils/transform");
10
11
  var _utils = require("./transforms/utils");
11
12
  var transformNode = exports.transformNode = function transformNode(api) {
@@ -22,6 +23,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
22
23
  var _expandToBlockRange = (0, _selection.expandToBlockRange)(preservedSelection.$from, preservedSelection.$to),
23
24
  $from = _expandToBlockRange.$from,
24
25
  $to = _expandToBlockRange.$to;
26
+ var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
25
27
  var selectedParent = $from.parent;
26
28
  var fragment = _model.Fragment.empty;
27
29
  var isList = (0, _utils.isListNode)(selectedParent);
@@ -30,7 +32,8 @@ var transformNode = exports.transformNode = function transformNode(api) {
30
32
  var outputNode = (0, _transform.getOutputNodes)({
31
33
  sourceNode: node,
32
34
  targetNodeType: targetType,
33
- schema: tr.doc.type.schema
35
+ schema: tr.doc.type.schema,
36
+ isNested: isNested
34
37
  });
35
38
  if (outputNode) {
36
39
  fragment = fragment.append(_model.Fragment.fromArray(outputNode));
@@ -0,0 +1,15 @@
1
+ export const flattenStep = (nodes, context) => {
2
+ const {
3
+ schema,
4
+ targetNodeTypeName
5
+ } = context;
6
+
7
+ // TODO: EDITOR-2920 - Implement flattening logic.
8
+ // This is a simplified preliminary approach. We might want to use prosemirror-markdown functions.
9
+ const codeBlockContent = nodes.map(node => node.content.textBetween(0, node.content.size, '\n')).join('\n');
10
+ const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, schema.text(codeBlockContent));
11
+ if (!outputNode) {
12
+ return nodes;
13
+ }
14
+ return [outputNode];
15
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Unwraps a layoutSection node, extracting content from all columns.
3
+ * Works with any number of columns (2, 3, etc.).
4
+ *
5
+ * Example:
6
+ * layoutSection(
7
+ * layoutColumn(p('a'), p('b')),
8
+ * layoutColumn(p('c')),
9
+ * layoutColumn(p('d'))
10
+ * )
11
+ * → [p('a'), p('b'), p('c'), p('d')]
12
+ */
13
+ export const unwrapLayoutStep = nodes => {
14
+ const outputNodes = [];
15
+ nodes.forEach(node => {
16
+ const isLayoutSection = node.type.name === 'layoutSection';
17
+ if (isLayoutSection) {
18
+ node.children.forEach(column => {
19
+ const isLayoutColumn = column.type.name === 'layoutColumn';
20
+ if (isLayoutColumn) {
21
+ outputNodes.push(...column.children);
22
+ }
23
+ });
24
+ }
25
+ });
26
+ if (outputNodes.length === 0) {
27
+ return nodes;
28
+ }
29
+ return outputNodes;
30
+ };
@@ -1,7 +1,14 @@
1
+ import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
1
2
  import { flattenListStep } from './flattenListStep';
3
+ import { flattenStep } from './flattenStep';
4
+ import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
2
5
  import { stubStep } from './stubStep';
3
6
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
7
+ import { unwrapExpandStep } from './unwrapExpandStep';
4
8
  import { unwrapListStep } from './unwrapListStep';
9
+ import { unwrapStep } from './unwrapStep';
10
+ import { wrapIntoLayoutStep } from './wrapIntoLayoutStep';
11
+ import { wrapStep } from './wrapStep';
5
12
 
6
13
  // Exampled step for overrides:
7
14
  // - open Block menu on a paragraph, click 'Panel' in the Turn into'
@@ -21,9 +28,9 @@ const TRANSFORM_STEPS = {
21
28
  },
22
29
  container: {
23
30
  atomic: undefined,
24
- container: [stubStep],
31
+ container: [unwrapStep, wrapStep],
25
32
  list: undefined,
26
- text: undefined
33
+ text: [unwrapStep]
27
34
  },
28
35
  list: {
29
36
  atomic: undefined,
@@ -44,6 +51,43 @@ const TRANSFORM_STEPS = {
44
51
  const TRANSFORM_STEPS_OVERRIDE = {
45
52
  paragraph: {
46
53
  panel: [wrapIntoPanelStep]
54
+ },
55
+ panel: {
56
+ layoutSection: [unwrapStep, wrapIntoLayoutStep],
57
+ codeBlock: [unwrapStep, flattenStep, wrapStep]
58
+ },
59
+ expand: {
60
+ panel: [unwrapExpandStep, wrapStep],
61
+ blockquote: [unwrapExpandStep, wrapStep],
62
+ layoutSection: [unwrapExpandStep, wrapIntoLayoutStep],
63
+ paragraph: [unwrapExpandStep],
64
+ codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
65
+ },
66
+ nestedExpand: {
67
+ panel: [unwrapExpandStep, wrapStep],
68
+ blockquote: [unwrapExpandStep, wrapStep],
69
+ paragraph: [unwrapExpandStep],
70
+ codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
71
+ },
72
+ blockquote: {
73
+ expand: [wrapStep],
74
+ nestedExpand: [wrapStep],
75
+ layoutSection: [wrapIntoLayoutStep],
76
+ codeBlock: [unwrapStep, flattenStep, wrapStep]
77
+ },
78
+ layoutSection: {
79
+ blockquote: [unwrapLayoutStep, wrapStep],
80
+ expand: [unwrapLayoutStep, wrapStep],
81
+ panel: [unwrapLayoutStep, wrapStep],
82
+ codeBlock: [unwrapLayoutStep, flattenStep, wrapStep],
83
+ paragraph: [unwrapLayoutStep]
84
+ },
85
+ codeBlock: {
86
+ blockquote: [wrapStep],
87
+ expand: [wrapStep],
88
+ nestedExpand: [wrapStep],
89
+ layoutSection: [wrapIntoLayoutStep],
90
+ panel: [wrapStep]
47
91
  }
48
92
  };
49
93
  const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
@@ -57,11 +101,13 @@ const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName)
57
101
  export const getOutputNodes = ({
58
102
  sourceNode,
59
103
  targetNodeType,
60
- schema
104
+ schema,
105
+ isNested
61
106
  }) => {
62
107
  const nodesToReplace = [sourceNode];
63
108
  const selectedNodeTypeName = toNodeTypeValue(sourceNode.type.name);
64
- const targetNodeTypeName = toNodeTypeValue(targetNodeType.name);
109
+ const initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
110
+ const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
65
111
  if (!selectedNodeTypeName || !targetNodeTypeName) {
66
112
  // We may decide to return an empty array or undefined here
67
113
  return;
@@ -9,7 +9,7 @@ export const NODE_CATEGORY_BY_TYPE = {
9
9
  expand: 'container',
10
10
  extension: 'atomic',
11
11
  heading: 'text',
12
- layout: 'container',
12
+ layoutSection: 'container',
13
13
  media: 'atomic',
14
14
  mediaGroup: 'atomic',
15
15
  mediaSingle: 'atomic',
@@ -0,0 +1,39 @@
1
+ import { unwrapStep } from './unwrapStep';
2
+
3
+ /**
4
+ * Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
5
+ * and prepending it to the children.
6
+ *
7
+ * Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
8
+ */
9
+ export const unwrapExpandStep = (nodes, context) => {
10
+ const {
11
+ schema
12
+ } = context;
13
+ const outputNodes = [];
14
+ const {
15
+ expand,
16
+ nestedExpand
17
+ } = schema.nodes;
18
+ nodes.forEach(node => {
19
+ const isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
20
+ if (isExpand) {
21
+ var _node$attrs;
22
+ const title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
23
+
24
+ // Create a paragraph from the title if it exists
25
+ if (title) {
26
+ const titleParagraph = schema.nodes.paragraph.createAndFill({}, schema.text(title));
27
+ if (titleParagraph) {
28
+ outputNodes.push(titleParagraph);
29
+ }
30
+ }
31
+
32
+ // Add the children
33
+ outputNodes.push(...node.children);
34
+ } else {
35
+ unwrapStep([node], context);
36
+ }
37
+ });
38
+ return outputNodes;
39
+ };
@@ -0,0 +1,12 @@
1
+ export const unwrapStep = nodes => {
2
+ const outputNodes = [];
3
+ nodes.forEach(node => {
4
+ // we may want to just skip the original instead of using it
5
+ if (node.children.length === 0) {
6
+ outputNodes.push(node);
7
+ } else {
8
+ outputNodes.push(...node.children);
9
+ }
10
+ });
11
+ return outputNodes;
12
+ };
@@ -43,4 +43,10 @@ export const getSelectedNode = selection => {
43
43
  }
44
44
  }
45
45
  return undefined;
46
+ };
47
+ export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested) => {
48
+ if (nodeTypeName === 'expand' && isNested) {
49
+ return 'nestedExpand';
50
+ }
51
+ return nodeTypeName;
46
52
  };
@@ -0,0 +1,20 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ export const wrapIntoLayoutStep = (nodes, context) => {
3
+ const {
4
+ schema
5
+ } = context;
6
+ const {
7
+ layoutSection,
8
+ layoutColumn
9
+ } = schema.nodes || {};
10
+ const columnOne = layoutColumn.createAndFill({}, Fragment.fromArray(nodes));
11
+ const columnTwo = layoutColumn.createAndFill();
12
+ if (!columnOne || !columnTwo) {
13
+ return nodes;
14
+ }
15
+ const layout = layoutSection.createAndFill({}, Fragment.fromArray([columnOne, columnTwo]));
16
+ if (!layout) {
17
+ return nodes;
18
+ }
19
+ return [layout];
20
+ };
@@ -0,0 +1,11 @@
1
+ export const wrapStep = (nodes, context) => {
2
+ const {
3
+ schema,
4
+ targetNodeTypeName
5
+ } = context;
6
+ const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, nodes);
7
+ if (outputNode) {
8
+ return [outputNode];
9
+ }
10
+ return nodes;
11
+ };
@@ -1,5 +1,6 @@
1
1
  import { expandToBlockRange } from '@atlaskit/editor-common/selection';
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ import { isNestedNode } from '../ui/utils/isNestedNode';
3
4
  import { getOutputNodes } from './transform-node-utils/transform';
4
5
  import { isListNode } from './transforms/utils';
5
6
  export const transformNode = api =>
@@ -17,6 +18,7 @@ export const transformNode = api =>
17
18
  $from,
18
19
  $to
19
20
  } = expandToBlockRange(preservedSelection.$from, preservedSelection.$to);
21
+ const isNested = isNestedNode(preservedSelection, '');
20
22
  const selectedParent = $from.parent;
21
23
  let fragment = Fragment.empty;
22
24
  const isList = isListNode(selectedParent);
@@ -25,7 +27,8 @@ export const transformNode = api =>
25
27
  const outputNode = getOutputNodes({
26
28
  sourceNode: node,
27
29
  targetNodeType: targetType,
28
- schema: tr.doc.type.schema
30
+ schema: tr.doc.type.schema,
31
+ isNested
29
32
  });
30
33
  if (outputNode) {
31
34
  fragment = fragment.append(Fragment.fromArray(outputNode));
@@ -0,0 +1,15 @@
1
+ export var flattenStep = function flattenStep(nodes, context) {
2
+ var schema = context.schema,
3
+ targetNodeTypeName = context.targetNodeTypeName;
4
+
5
+ // TODO: EDITOR-2920 - Implement flattening logic.
6
+ // This is a simplified preliminary approach. We might want to use prosemirror-markdown functions.
7
+ var codeBlockContent = nodes.map(function (node) {
8
+ return node.content.textBetween(0, node.content.size, '\n');
9
+ }).join('\n');
10
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, schema.text(codeBlockContent));
11
+ if (!outputNode) {
12
+ return nodes;
13
+ }
14
+ return [outputNode];
15
+ };
@@ -0,0 +1,31 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ /**
3
+ * Unwraps a layoutSection node, extracting content from all columns.
4
+ * Works with any number of columns (2, 3, etc.).
5
+ *
6
+ * Example:
7
+ * layoutSection(
8
+ * layoutColumn(p('a'), p('b')),
9
+ * layoutColumn(p('c')),
10
+ * layoutColumn(p('d'))
11
+ * )
12
+ * → [p('a'), p('b'), p('c'), p('d')]
13
+ */
14
+ export var unwrapLayoutStep = function unwrapLayoutStep(nodes) {
15
+ var outputNodes = [];
16
+ nodes.forEach(function (node) {
17
+ var isLayoutSection = node.type.name === 'layoutSection';
18
+ if (isLayoutSection) {
19
+ node.children.forEach(function (column) {
20
+ var isLayoutColumn = column.type.name === 'layoutColumn';
21
+ if (isLayoutColumn) {
22
+ outputNodes.push.apply(outputNodes, _toConsumableArray(column.children));
23
+ }
24
+ });
25
+ }
26
+ });
27
+ if (outputNodes.length === 0) {
28
+ return nodes;
29
+ }
30
+ return outputNodes;
31
+ };
@@ -1,7 +1,14 @@
1
+ import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
1
2
  import { flattenListStep } from './flattenListStep';
3
+ import { flattenStep } from './flattenStep';
4
+ import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
2
5
  import { stubStep } from './stubStep';
3
6
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
7
+ import { unwrapExpandStep } from './unwrapExpandStep';
4
8
  import { unwrapListStep } from './unwrapListStep';
9
+ import { unwrapStep } from './unwrapStep';
10
+ import { wrapIntoLayoutStep } from './wrapIntoLayoutStep';
11
+ import { wrapStep } from './wrapStep';
5
12
 
6
13
  // Exampled step for overrides:
7
14
  // - open Block menu on a paragraph, click 'Panel' in the Turn into'
@@ -21,9 +28,9 @@ var TRANSFORM_STEPS = {
21
28
  },
22
29
  container: {
23
30
  atomic: undefined,
24
- container: [stubStep],
31
+ container: [unwrapStep, wrapStep],
25
32
  list: undefined,
26
- text: undefined
33
+ text: [unwrapStep]
27
34
  },
28
35
  list: {
29
36
  atomic: undefined,
@@ -44,6 +51,43 @@ var TRANSFORM_STEPS = {
44
51
  var TRANSFORM_STEPS_OVERRIDE = {
45
52
  paragraph: {
46
53
  panel: [wrapIntoPanelStep]
54
+ },
55
+ panel: {
56
+ layoutSection: [unwrapStep, wrapIntoLayoutStep],
57
+ codeBlock: [unwrapStep, flattenStep, wrapStep]
58
+ },
59
+ expand: {
60
+ panel: [unwrapExpandStep, wrapStep],
61
+ blockquote: [unwrapExpandStep, wrapStep],
62
+ layoutSection: [unwrapExpandStep, wrapIntoLayoutStep],
63
+ paragraph: [unwrapExpandStep],
64
+ codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
65
+ },
66
+ nestedExpand: {
67
+ panel: [unwrapExpandStep, wrapStep],
68
+ blockquote: [unwrapExpandStep, wrapStep],
69
+ paragraph: [unwrapExpandStep],
70
+ codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
71
+ },
72
+ blockquote: {
73
+ expand: [wrapStep],
74
+ nestedExpand: [wrapStep],
75
+ layoutSection: [wrapIntoLayoutStep],
76
+ codeBlock: [unwrapStep, flattenStep, wrapStep]
77
+ },
78
+ layoutSection: {
79
+ blockquote: [unwrapLayoutStep, wrapStep],
80
+ expand: [unwrapLayoutStep, wrapStep],
81
+ panel: [unwrapLayoutStep, wrapStep],
82
+ codeBlock: [unwrapLayoutStep, flattenStep, wrapStep],
83
+ paragraph: [unwrapLayoutStep]
84
+ },
85
+ codeBlock: {
86
+ blockquote: [wrapStep],
87
+ expand: [wrapStep],
88
+ nestedExpand: [wrapStep],
89
+ layoutSection: [wrapIntoLayoutStep],
90
+ panel: [wrapStep]
47
91
  }
48
92
  };
49
93
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -57,10 +101,12 @@ var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selec
57
101
  export var getOutputNodes = function getOutputNodes(_ref) {
58
102
  var sourceNode = _ref.sourceNode,
59
103
  targetNodeType = _ref.targetNodeType,
60
- schema = _ref.schema;
104
+ schema = _ref.schema,
105
+ isNested = _ref.isNested;
61
106
  var nodesToReplace = [sourceNode];
62
107
  var selectedNodeTypeName = toNodeTypeValue(sourceNode.type.name);
63
- var targetNodeTypeName = toNodeTypeValue(targetNodeType.name);
108
+ var initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
109
+ var targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
64
110
  if (!selectedNodeTypeName || !targetNodeTypeName) {
65
111
  // We may decide to return an empty array or undefined here
66
112
  return;
@@ -9,7 +9,7 @@ export var NODE_CATEGORY_BY_TYPE = {
9
9
  expand: 'container',
10
10
  extension: 'atomic',
11
11
  heading: 'text',
12
- layout: 'container',
12
+ layoutSection: 'container',
13
13
  media: 'atomic',
14
14
  mediaGroup: 'atomic',
15
15
  mediaSingle: 'atomic',
@@ -0,0 +1,37 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { unwrapStep } from './unwrapStep';
3
+
4
+ /**
5
+ * Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
6
+ * and prepending it to the children.
7
+ *
8
+ * Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
9
+ */
10
+ export var unwrapExpandStep = function unwrapExpandStep(nodes, context) {
11
+ var schema = context.schema;
12
+ var outputNodes = [];
13
+ var _schema$nodes = schema.nodes,
14
+ expand = _schema$nodes.expand,
15
+ nestedExpand = _schema$nodes.nestedExpand;
16
+ nodes.forEach(function (node) {
17
+ var isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
18
+ if (isExpand) {
19
+ var _node$attrs;
20
+ var title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
21
+
22
+ // Create a paragraph from the title if it exists
23
+ if (title) {
24
+ var titleParagraph = schema.nodes.paragraph.createAndFill({}, schema.text(title));
25
+ if (titleParagraph) {
26
+ outputNodes.push(titleParagraph);
27
+ }
28
+ }
29
+
30
+ // Add the children
31
+ outputNodes.push.apply(outputNodes, _toConsumableArray(node.children));
32
+ } else {
33
+ unwrapStep([node], context);
34
+ }
35
+ });
36
+ return outputNodes;
37
+ };
@@ -0,0 +1,13 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ export var unwrapStep = function unwrapStep(nodes) {
3
+ var outputNodes = [];
4
+ nodes.forEach(function (node) {
5
+ // we may want to just skip the original instead of using it
6
+ if (node.children.length === 0) {
7
+ outputNodes.push(node);
8
+ } else {
9
+ outputNodes.push.apply(outputNodes, _toConsumableArray(node.children));
10
+ }
11
+ });
12
+ return outputNodes;
13
+ };
@@ -42,4 +42,10 @@ export var getSelectedNode = function getSelectedNode(selection) {
42
42
  }
43
43
  }
44
44
  return undefined;
45
+ };
46
+ export var getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested) {
47
+ if (nodeTypeName === 'expand' && isNested) {
48
+ return 'nestedExpand';
49
+ }
50
+ return nodeTypeName;
45
51
  };
@@ -0,0 +1,17 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ export var wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
3
+ var schema = context.schema;
4
+ var _ref = schema.nodes || {},
5
+ layoutSection = _ref.layoutSection,
6
+ layoutColumn = _ref.layoutColumn;
7
+ var columnOne = layoutColumn.createAndFill({}, Fragment.fromArray(nodes));
8
+ var columnTwo = layoutColumn.createAndFill();
9
+ if (!columnOne || !columnTwo) {
10
+ return nodes;
11
+ }
12
+ var layout = layoutSection.createAndFill({}, Fragment.fromArray([columnOne, columnTwo]));
13
+ if (!layout) {
14
+ return nodes;
15
+ }
16
+ return [layout];
17
+ };
@@ -0,0 +1,9 @@
1
+ export var wrapStep = function wrapStep(nodes, context) {
2
+ var schema = context.schema,
3
+ targetNodeTypeName = context.targetNodeTypeName;
4
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, nodes);
5
+ if (outputNode) {
6
+ return [outputNode];
7
+ }
8
+ return nodes;
9
+ };
@@ -1,5 +1,6 @@
1
1
  import { expandToBlockRange } from '@atlaskit/editor-common/selection';
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ import { isNestedNode } from '../ui/utils/isNestedNode';
3
4
  import { getOutputNodes } from './transform-node-utils/transform';
4
5
  import { isListNode } from './transforms/utils';
5
6
  export var transformNode = function transformNode(api) {
@@ -16,6 +17,7 @@ export var transformNode = function transformNode(api) {
16
17
  var _expandToBlockRange = expandToBlockRange(preservedSelection.$from, preservedSelection.$to),
17
18
  $from = _expandToBlockRange.$from,
18
19
  $to = _expandToBlockRange.$to;
20
+ var isNested = isNestedNode(preservedSelection, '');
19
21
  var selectedParent = $from.parent;
20
22
  var fragment = Fragment.empty;
21
23
  var isList = isListNode(selectedParent);
@@ -24,7 +26,8 @@ export var transformNode = function transformNode(api) {
24
26
  var outputNode = getOutputNodes({
25
27
  sourceNode: node,
26
28
  targetNodeType: targetType,
27
- schema: tr.doc.type.schema
29
+ schema: tr.doc.type.schema,
30
+ isNested: isNested
28
31
  });
29
32
  if (outputNode) {
30
33
  fragment = fragment.append(Fragment.fromArray(outputNode));
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const flattenStep: TransformStep;
@@ -0,0 +1,14 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Unwraps a layoutSection node, extracting content from all columns.
4
+ * Works with any number of columns (2, 3, etc.).
5
+ *
6
+ * Example:
7
+ * layoutSection(
8
+ * layoutColumn(p('a'), p('b')),
9
+ * layoutColumn(p('c')),
10
+ * layoutColumn(p('d'))
11
+ * )
12
+ * → [p('a'), p('b'), p('c'), p('d')]
13
+ */
14
+ export declare const unwrapLayoutStep: TransformStep;
@@ -1,8 +1,9 @@
1
1
  import { type Node as PMNode, type NodeType, type Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  interface GetOutputNodesArgs {
3
+ isNested: boolean;
3
4
  schema: Schema;
4
5
  sourceNode: PMNode;
5
6
  targetNodeType: NodeType;
6
7
  }
7
- export declare const getOutputNodes: ({ sourceNode, targetNodeType, schema, }: GetOutputNodesArgs) => PMNode[] | undefined;
8
+ export declare const getOutputNodes: ({ sourceNode, targetNodeType, schema, isNested, }: GetOutputNodesArgs) => PMNode[] | undefined;
8
9
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
- export type NodeTypeName = 'blockquote' | 'blockCard' | 'bodiedExtension' | 'bulletList' | 'codeBlock' | 'decisionList' | 'embedCard' | 'expand' | 'extension' | 'heading' | 'layout' | 'media' | 'mediaGroup' | 'mediaSingle' | 'multiBodiedExtension' | 'orderedList' | 'panel' | 'paragraph' | 'nestedExpand' | 'taskList' | 'table';
2
+ export type NodeTypeName = 'blockquote' | 'blockCard' | 'bodiedExtension' | 'bulletList' | 'codeBlock' | 'decisionList' | 'embedCard' | 'expand' | 'extension' | 'heading' | 'layoutSection' | 'media' | 'mediaGroup' | 'mediaSingle' | 'multiBodiedExtension' | 'orderedList' | 'panel' | 'paragraph' | 'nestedExpand' | 'taskList' | 'table';
3
3
  export type NodeCategory = 'atomic' | 'container' | 'list' | 'text';
4
4
  export declare const NODE_CATEGORY_BY_TYPE: Record<NodeTypeName, NodeCategory>;
5
5
  export declare const isNodeTypeName: (value: string) => value is NodeTypeName;
@@ -0,0 +1,8 @@
1
+ import type { TransformStep } from './types';
2
+ /**
3
+ * Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
4
+ * and prepending it to the children.
5
+ *
6
+ * Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
7
+ */
8
+ export declare const unwrapExpandStep: TransformStep;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const unwrapStep: TransformStep;
@@ -1,3 +1,5 @@
1
1
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
3
+ import type { NodeTypeName } from './types';
3
4
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
5
+ export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const wrapIntoLayoutStep: TransformStep;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const wrapStep: TransformStep;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const flattenStep: TransformStep;
@@ -0,0 +1,14 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Unwraps a layoutSection node, extracting content from all columns.
4
+ * Works with any number of columns (2, 3, etc.).
5
+ *
6
+ * Example:
7
+ * layoutSection(
8
+ * layoutColumn(p('a'), p('b')),
9
+ * layoutColumn(p('c')),
10
+ * layoutColumn(p('d'))
11
+ * )
12
+ * → [p('a'), p('b'), p('c'), p('d')]
13
+ */
14
+ export declare const unwrapLayoutStep: TransformStep;
@@ -1,8 +1,9 @@
1
1
  import { type Node as PMNode, type NodeType, type Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  interface GetOutputNodesArgs {
3
+ isNested: boolean;
3
4
  schema: Schema;
4
5
  sourceNode: PMNode;
5
6
  targetNodeType: NodeType;
6
7
  }
7
- export declare const getOutputNodes: ({ sourceNode, targetNodeType, schema, }: GetOutputNodesArgs) => PMNode[] | undefined;
8
+ export declare const getOutputNodes: ({ sourceNode, targetNodeType, schema, isNested, }: GetOutputNodesArgs) => PMNode[] | undefined;
8
9
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
- export type NodeTypeName = 'blockquote' | 'blockCard' | 'bodiedExtension' | 'bulletList' | 'codeBlock' | 'decisionList' | 'embedCard' | 'expand' | 'extension' | 'heading' | 'layout' | 'media' | 'mediaGroup' | 'mediaSingle' | 'multiBodiedExtension' | 'orderedList' | 'panel' | 'paragraph' | 'nestedExpand' | 'taskList' | 'table';
2
+ export type NodeTypeName = 'blockquote' | 'blockCard' | 'bodiedExtension' | 'bulletList' | 'codeBlock' | 'decisionList' | 'embedCard' | 'expand' | 'extension' | 'heading' | 'layoutSection' | 'media' | 'mediaGroup' | 'mediaSingle' | 'multiBodiedExtension' | 'orderedList' | 'panel' | 'paragraph' | 'nestedExpand' | 'taskList' | 'table';
3
3
  export type NodeCategory = 'atomic' | 'container' | 'list' | 'text';
4
4
  export declare const NODE_CATEGORY_BY_TYPE: Record<NodeTypeName, NodeCategory>;
5
5
  export declare const isNodeTypeName: (value: string) => value is NodeTypeName;
@@ -0,0 +1,8 @@
1
+ import type { TransformStep } from './types';
2
+ /**
3
+ * Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
4
+ * and prepending it to the children.
5
+ *
6
+ * Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
7
+ */
8
+ export declare const unwrapExpandStep: TransformStep;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const unwrapStep: TransformStep;
@@ -1,3 +1,5 @@
1
1
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
3
+ import type { NodeTypeName } from './types';
3
4
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
5
+ export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const wrapIntoLayoutStep: TransformStep;
@@ -0,0 +1,2 @@
1
+ import type { TransformStep } from './types';
2
+ export declare const wrapStep: TransformStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/css": "^0.17.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
- "@atlaskit/editor-plugin-block-controls": "^7.11.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^7.12.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^14.5.0",
47
+ "@atlaskit/tmp-editor-statsig": "^14.7.0",
48
48
  "@atlaskit/tokens": "^8.4.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },