@atlaskit/editor-plugin-block-menu 6.0.5 → 6.0.7

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 (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  5. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  6. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +2 -12
  7. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +69 -52
  8. package/dist/cjs/editor-commands/transform-node-utils/transform.js +18 -21
  9. package/dist/cjs/editor-commands/transform-node-utils/utils.js +10 -1
  10. package/dist/es2019/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  11. package/dist/es2019/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  12. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  13. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  14. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +1 -11
  15. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +71 -53
  16. package/dist/es2019/editor-commands/transform-node-utils/transform.js +18 -21
  17. package/dist/es2019/editor-commands/transform-node-utils/utils.js +10 -0
  18. package/dist/esm/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  19. package/dist/esm/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  20. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  21. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  22. package/dist/esm/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +1 -11
  23. package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +70 -53
  24. package/dist/esm/editor-commands/transform-node-utils/transform.js +18 -21
  25. package/dist/esm/editor-commands/transform-node-utils/utils.js +10 -0
  26. package/dist/types/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
  27. package/dist/types/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +17 -2
  28. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +5 -0
  29. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
  30. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +17 -2
  31. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +5 -0
  32. package/package.json +3 -3
  33. package/dist/cjs/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -20
  34. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -17
  35. package/dist/esm/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -14
  36. package/dist/types/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +0 -2
  37. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`65223704a60e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65223704a60e0) -
8
+ Fix hard breaks being lost in nested task lists during transformation
9
+ - Updated dependencies
10
+
11
+ ## 6.0.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [`27a9a5b28e8a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/27a9a5b28e8a6) -
16
+ [ux] Add ability to transform multiselected content to layouts
17
+
3
18
  ## 6.0.5
4
19
 
5
20
  ### Patch Changes
@@ -73,11 +73,7 @@ var decisionListToListStep = exports.decisionListToListStep = function decisionL
73
73
  }
74
74
  var newItems = [];
75
75
  node.forEach(function (decisionItem) {
76
- var itemContent = [];
77
- decisionItem.forEach(function (child) {
78
- itemContent.push(child);
79
- });
80
- var newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
76
+ var newItem = targetItemType.inlineContent ? targetItemType.create({}, decisionItem.children) : targetItemType.create({}, paragraphType.create({}, decisionItem.children));
81
77
  if (newItem) {
82
78
  newItems.push(newItem);
83
79
  }
@@ -24,7 +24,7 @@ var extractNestedLists = function extractNestedLists(node, schema) {
24
24
  child.forEach(function (grandChild) {
25
25
  if ((0, _nodeChecks.isListWithIndentation)(grandChild.type.name, schema)) {
26
26
  nestedLists.push(grandChild);
27
- } else if (grandChild.isText) {
27
+ } else if (grandChild.isInline) {
28
28
  // For taskItem/decisionItem, keep text as-is (they support inline content)
29
29
  // For listItem, wrap text in paragraph (they require block content)
30
30
  if (isInlineItem) {
@@ -75,8 +75,6 @@ var extractNestedLists = function extractNestedLists(node, schema) {
75
75
  * @param nodes
76
76
  * @param context
77
77
  * @returns
78
- *
79
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
80
78
  */
81
79
  var flattenListStep = exports.flattenListStep = function flattenListStep(nodes, context) {
82
80
  return nodes.map(function (node) {
@@ -45,7 +45,7 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
45
45
  if (child.type === paragraphType) {
46
46
  // paragraph may contain hard breaks etc.
47
47
  itemContent.push.apply(itemContent, (0, _toConsumableArray2.default)(child.children));
48
- } else if (child.isText || child.isInline) {
48
+ } else if (child.isInline) {
49
49
  itemContent.push(child);
50
50
  } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
51
51
  unsupportedContent.push(child);
@@ -76,7 +76,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
76
76
  itemNode.forEach(function (child) {
77
77
  if (child.type === paragraphType) {
78
78
  inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(child.children));
79
- } else if (child.isText) {
79
+ } else if (child.isInline) {
80
80
  inlineContent.push(child);
81
81
  // Nested lists will be extracted and placed as siblings in the taskList
82
82
  } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
@@ -4,17 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.wrapBlockquoteToDecisionListStep = void 0;
7
- var _types = require("../types");
8
- /**
9
- * Determines if a node is a text node (heading or paragraph).
10
- * Only text nodes should have their inline content extracted for decisionItem.
11
- * All other nodes should break out.
12
- */
13
- var isTextNode = function isTextNode(node) {
14
- var category = _types.NODE_CATEGORY_BY_TYPE[node.type.name];
15
- return category === 'text';
16
- };
17
-
7
+ var _utils = require("../utils");
18
8
  /**
19
9
  * Creates a decisionItem with the given inline content.
20
10
  */
@@ -74,7 +64,7 @@ var wrapBlockquoteToDecisionListStep = exports.wrapBlockquoteToDecisionListStep
74
64
  }
75
65
  };
76
66
  nodes.forEach(function (node) {
77
- var decisionItem = isTextNode(node) ? createDecisionItem(node.content, schema) : null;
67
+ var decisionItem = (0, _utils.isTextNode)(node) ? createDecisionItem(node.content, schema) : null;
78
68
  if (decisionItem) {
79
69
  // Accumulate consecutive decisionItems
80
70
  currentDecisionItems.push(decisionItem);
@@ -10,33 +10,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
10
10
  var _marks = require("../marks");
11
11
  var _types = require("../types");
12
12
  var _utils = require("../utils");
13
- /**
14
- * Determines if a node is a text node (heading or paragraph).
15
- * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
16
- */
17
- var isTextNode = function isTextNode(node) {
18
- var category = _types.NODE_CATEGORY_BY_TYPE[node.type.name];
19
- return category === 'text';
20
- };
21
-
22
- /**
23
- * Determines if a node can be wrapped in the target container type, removes block marks from the node during check.
24
- * Uses the schema's validContent to check if the target container can hold this node.
25
- *
26
- * Note: What can be wrapped depends on the target container type - for example:
27
- * - Tables and media CAN go inside expand nodes
28
- * - Tables CANNOT go inside panels or blockquotes
29
- */
30
- var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeTypeName) {
31
- // Same-type containers should break out as separate containers
32
- if (node.type.name === targetNodeTypeName) {
33
- return false;
34
- }
35
-
36
- // Use the schema to determine if this node can be contained in the target
37
- return targetNodeType.validContent(_model.Fragment.from((0, _marks.removeDisallowedMarks)([node], targetNodeType)));
38
- };
39
-
40
13
  /**
41
14
  * Handles the edge case where transforming from a container to another container results in
42
15
  * all content breaking out (no valid children for the target). In this case, creates an empty
@@ -75,18 +48,33 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
75
48
  * - Same-type containers break out as separate containers (preserved as-is)
76
49
  * - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
77
50
  * - Container structures that can't be nested in target break out (not flattened)
78
- * - Text/list nodes that can't be wrapped are flattened and merged into the container
51
+ * - Text/list nodes that can't be wrapped are converted to paragraphs and merged into the container
79
52
  * - Atomic nodes (tables, media, macros) break out
80
53
  *
54
+ * Special handling for layouts:
55
+ * - Layout sections break out as separate layouts (preserved as-is, not wrapped)
56
+ * - Other nodes (including headings, paragraphs, lists) are wrapped into layout columns within a layout section
57
+ * - Layouts always require layoutColumns as children (never paragraphs directly)
58
+ * - Layout columns can contain most block content including headings, paragraphs, lists, etc.
59
+ *
60
+ * Edge case handling:
61
+ * - For regular containers: If all content breaks out (container → container transform with no
62
+ * valid children), an empty container with a paragraph is created to ensure the target type exists
63
+ * - For layouts: Edge case handling is skipped because layouts require columns, not direct paragraphs.
64
+ * If all content breaks out, only the broken-out nodes are returned (no empty layout created)
65
+ *
81
66
  * What can be wrapped depends on the target container's schema:
82
67
  * - expand → panel: tables break out, nestedExpands convert to expands and break out
83
- * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
68
+ * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out, headings converted to paragraphs
84
69
  * - expand → expand: tables/media stay inside (expands can contain them)
70
+ * - multi → layoutSection: layout sections break out, headings/paragraphs/lists wrapped into layout columns
85
71
  *
86
72
  * Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
87
73
  * Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
88
74
  * Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
89
75
  * Example: expand(nestedExpand()(p())) → panel: [panel(), expand()(p())] (empty panel when all content breaks out)
76
+ * Example: [p('a'), layoutSection(...), p('b')] → layoutSection: [layoutSection(layoutColumn(p('a'))), layoutSection(...), layoutSection(layoutColumn(p('b')))]
77
+ * Example: [h1('heading'), p('para')] → layoutSection: [layoutSection(layoutColumn(h1('heading'), p('para')))] (headings stay as headings in layouts)
90
78
  */
91
79
  var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedContentStep(nodes, context) {
92
80
  var schema = context.schema,
@@ -96,49 +84,78 @@ var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedCont
96
84
  if (!targetNodeType) {
97
85
  return nodes;
98
86
  }
87
+ var isLayout = targetNodeTypeName === 'layoutSection';
88
+ var _schema$nodes = schema.nodes,
89
+ layoutSection = _schema$nodes.layoutSection,
90
+ layoutColumn = _schema$nodes.layoutColumn;
99
91
  var result = [];
100
92
  var currentContainerContent = [];
101
93
  var hasCreatedContainer = false;
102
94
  var flushCurrentContainer = function flushCurrentContainer() {
103
- if (currentContainerContent.length > 0) {
104
- var containerNode = targetNodeType.createAndFill({}, _model.Fragment.fromArray(currentContainerContent));
105
- if (containerNode) {
106
- result.push(containerNode);
95
+ if (currentContainerContent.length === 0) {
96
+ return;
97
+ }
98
+ if (isLayout) {
99
+ // For layouts, create layoutSection with two layoutColumns
100
+ var columnOne = layoutColumn.createAndFill({}, (0, _marks.removeDisallowedMarks)(currentContainerContent, layoutColumn));
101
+ var columnTwo = layoutColumn.createAndFill();
102
+ if (!columnOne || !columnTwo) {
103
+ currentContainerContent = [];
104
+ return;
105
+ }
106
+ var layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
107
+ if (layout) {
108
+ result.push(layout);
107
109
  hasCreatedContainer = true;
108
110
  }
109
111
  currentContainerContent = [];
112
+ return;
110
113
  }
114
+
115
+ // For regular containers, create directly
116
+ var containerNode = targetNodeType.createAndFill({}, currentContainerContent);
117
+ if (containerNode) {
118
+ result.push(containerNode);
119
+ hasCreatedContainer = true;
120
+ }
121
+ currentContainerContent = [];
111
122
  };
112
- nodes.forEach(function (node) {
113
- if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
123
+ var processNode = function processNode(node) {
124
+ var validationType = isLayout ? layoutColumn : targetNodeType;
125
+ var canWrapNode = validationType.validContent(_model.Fragment.from((0, _marks.removeDisallowedMarks)([node], validationType)));
126
+
127
+ // Node can be wrapped - add to current container content
128
+ if (canWrapNode) {
114
129
  var _currentContainerCont;
115
- // Node can be wrapped - add to current container content
116
130
  // remove marks from node as nested nodes don't usually support block marks
117
- (_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, (0, _toConsumableArray2.default)((0, _marks.removeDisallowedMarks)([node], targetNodeType)));
118
- } else if (node.type.name === targetNodeTypeName) {
119
- // Same-type container - breaks out as a separate container (preserved as-is)
120
- // This handles: "If there's a panel in the expand, it breaks out into a separate panel"
121
- flushCurrentContainer();
122
- result.push(node);
123
- } else if (isTextNode(node)) {
124
- // Text node (heading, paragraph) that can't be wrapped - convert to paragraph
125
- // Example: heading can't go in blockquote, so convert to paragraph with same content
131
+ (_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, (0, _toConsumableArray2.default)((0, _marks.removeDisallowedMarks)([node], validationType)));
132
+ return;
133
+ }
134
+
135
+ // Text node (heading, paragraph) that can't be wrapped - convert to paragraph
136
+ // Example: heading can't go in blockquote, so convert to paragraph with same content
137
+ if ((0, _utils.isTextNode)(node)) {
126
138
  var paragraph = (0, _utils.convertTextNodeToParagraph)(node, schema);
127
139
  if (paragraph) {
128
140
  currentContainerContent.push(paragraph);
129
141
  }
130
- } else {
131
- // All other nodes that cannot be wrapped (lists, containers, tables, media, macros) - break out
132
- // This includes list nodes like taskList that can't be placed in certain containers
133
- flushCurrentContainer();
134
- result.push(node);
142
+ return;
135
143
  }
136
- });
144
+
145
+ // All other nodes that cannot be wrapped in the target node - break out
146
+ // Examples: same-type containers, tables in panels, layoutSections in layouts
147
+ flushCurrentContainer();
148
+ result.push(node);
149
+ };
150
+ nodes.forEach(processNode);
137
151
 
138
152
  // Flush any remaining content into a container
139
153
  flushCurrentContainer();
140
154
 
141
- // Handle edge case: create empty container if all content broke out
155
+ // Skip edge case handling for layouts since layouts always have columns
156
+ if (isLayout) {
157
+ return result.length > 0 ? result : nodes;
158
+ }
142
159
  var finalResult = handleEmptyContainerEdgeCase(result, hasCreatedContainer, fromNode, targetNodeType, targetNodeTypeName, schema);
143
160
  return finalResult.length > 0 ? finalResult : nodes;
144
161
  };
@@ -21,7 +21,6 @@ var _wrapTextToCodeblock = require("./steps/wrapTextToCodeblock");
21
21
  var _types = require("./types");
22
22
  var _unwrapExpandStep = require("./unwrapExpandStep");
23
23
  var _unwrapStep = require("./unwrapStep");
24
- var _wrapIntoLayoutStep = require("./wrapIntoLayoutStep");
25
24
  var _wrapIntoListStep = require("./wrapIntoListStep");
26
25
  var _wrapStep = require("./wrapStep");
27
26
  // Transform steps for combinations of node categories (block/container/list/text)
@@ -70,15 +69,15 @@ var TRANSFORM_STEPS_OVERRIDE = {
70
69
  paragraph: {
71
70
  paragraph: null,
72
71
  codeBlock: [_wrapTextToCodeblock.wrapTextToCodeblockStep],
73
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
72
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
74
73
  },
75
74
  heading: {
76
75
  codeBlock: [_wrapTextToCodeblock.wrapTextToCodeblockStep],
77
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
76
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
78
77
  },
79
78
  panel: {
80
79
  panel: null,
81
- layoutSection: [_unwrapStep.unwrapStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
80
+ layoutSection: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
82
81
  codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
83
82
  blockquote: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
84
83
  taskList: null,
@@ -90,7 +89,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
90
89
  expand: null,
91
90
  panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
92
91
  blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
93
- layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
92
+ layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
94
93
  paragraph: [_unwrapExpandStep.unwrapExpandStep],
95
94
  codeBlock: null,
96
95
  heading: null
@@ -108,7 +107,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
108
107
  blockquote: null,
109
108
  expand: [_wrapStep.wrapStep],
110
109
  nestedExpand: [_wrapStep.wrapStep],
111
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
110
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
112
111
  codeBlock: null,
113
112
  decisionList: [_unwrapStep.unwrapStep, _wrapBlockquoteToDecisionListStep.wrapBlockquoteToDecisionListStep]
114
113
  },
@@ -126,34 +125,34 @@ var TRANSFORM_STEPS_OVERRIDE = {
126
125
  blockquote: [_wrapStep.wrapStep],
127
126
  expand: [_wrapStep.wrapStep],
128
127
  nestedExpand: [_wrapStep.wrapStep],
129
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
128
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
130
129
  panel: [_wrapStep.wrapStep],
131
130
  heading: null
132
131
  },
133
132
  bulletList: {
134
133
  bulletList: null,
135
134
  codeBlock: null,
136
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
135
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
137
136
  decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
138
137
  heading: null
139
138
  },
140
139
  orderedList: {
141
140
  orderedList: null,
142
141
  codeBlock: null,
143
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
142
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
144
143
  decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
145
144
  heading: null
146
145
  },
147
146
  taskList: {
148
147
  blockquote: null,
149
148
  codeBlock: null,
150
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
149
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
151
150
  decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
152
151
  heading: null,
153
152
  taskList: null
154
153
  },
155
154
  table: {
156
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
155
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
157
156
  blockquote: null,
158
157
  panel: null,
159
158
  codeBlock: null,
@@ -163,13 +162,13 @@ var TRANSFORM_STEPS_OVERRIDE = {
163
162
  decisionList: null
164
163
  },
165
164
  mediaSingle: {
166
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
165
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
167
166
  codeBlock: null,
168
167
  decisionList: null,
169
168
  taskList: null
170
169
  },
171
170
  mediaGroup: {
172
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
171
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
173
172
  codeBlock: null,
174
173
  decisionList: null,
175
174
  bulletList: null,
@@ -181,10 +180,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
181
180
  bulletList: [_decisionListToListStep.decisionListToListStep],
182
181
  orderedList: [_decisionListToListStep.decisionListToListStep],
183
182
  taskList: [_decisionListToListStep.decisionListToListStep],
184
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
183
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
185
184
  },
186
185
  blockCard: {
187
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
186
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
188
187
  blockquote: null,
189
188
  codeBlock: null,
190
189
  orderedList: null,
@@ -193,7 +192,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
193
192
  decisionList: null
194
193
  },
195
194
  embedCard: {
196
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
195
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
197
196
  blockquote: null,
198
197
  panel: null,
199
198
  codeBlock: null,
@@ -203,7 +202,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
203
202
  decisionList: null
204
203
  },
205
204
  extension: {
206
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
205
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
207
206
  codeBlock: null,
208
207
  decisionList: null,
209
208
  taskList: null,
@@ -211,7 +210,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
211
210
  bulletList: null
212
211
  },
213
212
  bodiedExtension: {
214
- layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
213
+ layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
215
214
  blockquote: null,
216
215
  expand: null,
217
216
  panel: null,
@@ -225,9 +224,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
225
224
  // TODO: EDITOR-4140 - Implement multiple paragraphs/headings/codeblocks to heading transform
226
225
  heading: null,
227
226
  // TODO: EDITOR-4141 - Implement multiple codeblocks/headings to paragraph transform
228
- paragraph: null,
229
- // TODO: EDITOR-4138 - Implement multi content to layout transform
230
- layoutSection: undefined
227
+ paragraph: null
231
228
  }
232
229
  };
233
230
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -3,10 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
6
+ exports.isTextNode = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = 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");
10
+ var _types = require("./types");
11
+ /**
12
+ * Determines if a node is a text node (heading or paragraph).
13
+ * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
14
+ */
15
+ var isTextNode = exports.isTextNode = function isTextNode(node) {
16
+ var category = _types.NODE_CATEGORY_BY_TYPE[node.type.name];
17
+ return category === 'text';
18
+ };
10
19
  var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selection) {
11
20
  if (selection instanceof _state.NodeSelection) {
12
21
  return {
@@ -70,11 +70,7 @@ export const decisionListToListStep = (nodes, context) => {
70
70
  }
71
71
  const newItems = [];
72
72
  node.forEach(decisionItem => {
73
- const itemContent = [];
74
- decisionItem.forEach(child => {
75
- itemContent.push(child);
76
- });
77
- const newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
73
+ const newItem = targetItemType.inlineContent ? targetItemType.create({}, decisionItem.children) : targetItemType.create({}, paragraphType.create({}, decisionItem.children));
78
74
  if (newItem) {
79
75
  newItems.push(newItem);
80
76
  }
@@ -16,7 +16,7 @@ const extractNestedLists = (node, schema) => {
16
16
  child.forEach(grandChild => {
17
17
  if (isListWithIndentation(grandChild.type.name, schema)) {
18
18
  nestedLists.push(grandChild);
19
- } else if (grandChild.isText) {
19
+ } else if (grandChild.isInline) {
20
20
  // For taskItem/decisionItem, keep text as-is (they support inline content)
21
21
  // For listItem, wrap text in paragraph (they require block content)
22
22
  if (isInlineItem) {
@@ -67,8 +67,6 @@ const extractNestedLists = (node, schema) => {
67
67
  * @param nodes
68
68
  * @param context
69
69
  * @returns
70
- *
71
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
72
70
  */
73
71
  export const flattenListStep = (nodes, context) => {
74
72
  return nodes.map(node => {
@@ -39,7 +39,7 @@ export const listToDecisionListStep = (nodes, context) => {
39
39
  if (child.type === paragraphType) {
40
40
  // paragraph may contain hard breaks etc.
41
41
  itemContent.push(...child.children);
42
- } else if (child.isText || child.isInline) {
42
+ } else if (child.isInline) {
43
43
  itemContent.push(child);
44
44
  } else if (!isListWithIndentation(child.type.name, schema)) {
45
45
  unsupportedContent.push(child);
@@ -67,7 +67,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
67
67
  itemNode.forEach(child => {
68
68
  if (child.type === paragraphType) {
69
69
  inlineContent.push(...child.children);
70
- } else if (child.isText) {
70
+ } else if (child.isInline) {
71
71
  inlineContent.push(child);
72
72
  // Nested lists will be extracted and placed as siblings in the taskList
73
73
  } else if (!isListWithIndentation(child.type.name, schema)) {
@@ -1,14 +1,4 @@
1
- import { NODE_CATEGORY_BY_TYPE } from '../types';
2
-
3
- /**
4
- * Determines if a node is a text node (heading or paragraph).
5
- * Only text nodes should have their inline content extracted for decisionItem.
6
- * All other nodes should break out.
7
- */
8
- const isTextNode = node => {
9
- const category = NODE_CATEGORY_BY_TYPE[node.type.name];
10
- return category === 'text';
11
- };
1
+ import { isTextNode } from '../utils';
12
2
 
13
3
  /**
14
4
  * Creates a decisionItem with the given inline content.