@atlaskit/editor-plugin-block-menu 5.2.14 → 5.2.16

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 (45) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/nodeChecks.js +33 -0
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/flattenListStep.js +7 -12
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +3 -3
  5. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +11 -11
  6. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +21 -0
  7. package/dist/cjs/editor-commands/transform-node-utils/transform.js +5 -11
  8. package/dist/cjs/editor-commands/transform-node-utils/utils.js +20 -7
  9. package/dist/cjs/editor-commands/transform-node-utils/wrapIntoListStep.js +29 -7
  10. package/dist/cjs/ui/block-menu-components.js +1 -3
  11. package/dist/cjs/ui/copy-link.js +2 -2
  12. package/dist/cjs/ui/delete-section.js +1 -8
  13. package/dist/es2019/editor-commands/transform-node-utils/nodeChecks.js +23 -0
  14. package/dist/es2019/editor-commands/transform-node-utils/steps/flattenListStep.js +7 -6
  15. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +3 -4
  16. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +11 -12
  17. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +18 -0
  18. package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -11
  19. package/dist/es2019/editor-commands/transform-node-utils/utils.js +19 -4
  20. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoListStep.js +29 -7
  21. package/dist/es2019/ui/block-menu-components.js +1 -3
  22. package/dist/es2019/ui/copy-link.js +2 -2
  23. package/dist/es2019/ui/delete-section.js +0 -7
  24. package/dist/esm/editor-commands/transform-node-utils/nodeChecks.js +27 -0
  25. package/dist/esm/editor-commands/transform-node-utils/steps/flattenListStep.js +7 -12
  26. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +3 -4
  27. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +11 -12
  28. package/dist/esm/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +16 -0
  29. package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -11
  30. package/dist/esm/editor-commands/transform-node-utils/utils.js +19 -6
  31. package/dist/esm/editor-commands/transform-node-utils/wrapIntoListStep.js +29 -7
  32. package/dist/esm/ui/block-menu-components.js +1 -3
  33. package/dist/esm/ui/copy-link.js +2 -2
  34. package/dist/esm/ui/delete-section.js +1 -8
  35. package/dist/types/editor-commands/transform-node-utils/nodeChecks.d.ts +17 -0
  36. package/dist/types/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +9 -0
  37. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +8 -1
  38. package/dist/types/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +7 -1
  39. package/dist/types/ui/delete-section.d.ts +1 -4
  40. package/dist/types-ts4.5/editor-commands/transform-node-utils/nodeChecks.d.ts +17 -0
  41. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +9 -0
  42. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +8 -1
  43. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +7 -1
  44. package/dist/types-ts4.5/ui/delete-section.d.ts +1 -4
  45. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`493a21ccda098`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/493a21ccda098) -
8
+ Add wrapTextToCodeblock step to handle text to codeblock step, add remaining steps for paragraph
9
+ to container steps
10
+ - [`38369379f9e12`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38369379f9e12) -
11
+ [ux] Editor-3976: Make copy link and delete available for empty line
12
+ - Updated dependencies
13
+
14
+ ## 5.2.15
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 5.2.14
4
21
 
5
22
  ### Patch Changes
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isListWithTextContentOnly = exports.isListWithIndentation = void 0;
7
+ /**
8
+ * Checks if a node is a list type that supports indentation (bulletList, orderedList, taskList).
9
+ *
10
+ * @param node - The node to check.
11
+ * @param schema - ProseMirror schema for check
12
+ * @returns True if the node is a list type, false otherwise.
13
+ */
14
+ var isListWithIndentation = exports.isListWithIndentation = function isListWithIndentation(nodeTypeName, schema) {
15
+ var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
16
+ return lists.some(function (list) {
17
+ return list.name === nodeTypeName;
18
+ });
19
+ };
20
+
21
+ /**
22
+ * Checks if a node is a list where its list items only support text content (taskList or decisionList).
23
+ *
24
+ * @param nodeTypeName - The node type name to check.
25
+ * @param schema - ProseMirror schema for check
26
+ * @returns True if the node is a list text type, false otherwise.
27
+ */
28
+ var isListWithTextContentOnly = exports.isListWithTextContentOnly = function isListWithTextContentOnly(nodeTypeName, schema) {
29
+ var lists = [schema.nodes.taskList, schema.nodes.decisionList];
30
+ return lists.some(function (list) {
31
+ return list.name === nodeTypeName;
32
+ });
33
+ };
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.flattenListStep = void 0;
7
7
  var _model = require("@atlaskit/editor-prosemirror/model");
8
- var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes, schema) {
8
+ var _nodeChecks = require("../nodeChecks");
9
+ var extractNestedLists = function extractNestedLists(node, schema) {
9
10
  var items = [];
10
11
  var paragraph = schema.nodes.paragraph;
12
+ var itemTypes = [schema.nodes.listItem, schema.nodes.taskItem];
11
13
  var _extract = function extract(currentNode) {
12
14
  currentNode.forEach(function (child) {
13
15
  if (itemTypes.some(function (type) {
@@ -16,9 +18,7 @@ var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes,
16
18
  var contentWithoutNestedLists = [];
17
19
  var nestedLists = [];
18
20
  child.forEach(function (grandChild) {
19
- if (listTypes.some(function (type) {
20
- return grandChild.type === type;
21
- })) {
21
+ if ((0, _nodeChecks.isListWithIndentation)(grandChild.type.name, schema)) {
22
22
  nestedLists.push(grandChild);
23
23
  } else if (grandChild.isText) {
24
24
  contentWithoutNestedLists.push(paragraph.createAndFill({}, grandChild));
@@ -30,9 +30,7 @@ var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes,
30
30
  nestedLists.forEach(function (nestedList) {
31
31
  _extract(nestedList);
32
32
  });
33
- } else if (listTypes.some(function (type) {
34
- return child.type === type;
35
- })) {
33
+ } else if ((0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
36
34
  _extract(child);
37
35
  }
38
36
  });
@@ -71,12 +69,9 @@ var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes,
71
69
  * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
72
70
  */
73
71
  var flattenListStep = exports.flattenListStep = function flattenListStep(nodes, context) {
74
- var listTypes = [context.schema.nodes.bulletList, context.schema.nodes.orderedList, context.schema.nodes.taskList];
75
72
  return nodes.map(function (node) {
76
- if (listTypes.some(function (type) {
77
- return node.type === type;
78
- })) {
79
- return node.copy(_model.Fragment.from(extractNestedLists(node, listTypes, [context.schema.nodes.listItem, context.schema.nodes.taskItem], context.schema)));
73
+ if ((0, _nodeChecks.isListWithIndentation)(node.type.name, context.schema)) {
74
+ return node.copy(_model.Fragment.from(extractNestedLists(node, context.schema)));
80
75
  }
81
76
  return node;
82
77
  });
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.listToDecisionListStep = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _utils = require("../utils");
9
+ var _nodeChecks = require("../nodeChecks");
10
10
  /**
11
11
  * Transforms a bulletList, orderedList, or taskList into a decisionList.
12
12
  *
@@ -35,7 +35,7 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
35
35
  var paragraphType = schema.nodes.paragraph;
36
36
  var unsupportedContent = [];
37
37
  var transformedNodes = nodes.map(function (node) {
38
- if (!(0, _utils.isListType)(node, schema)) {
38
+ if (!(0, _nodeChecks.isListWithIndentation)(node.type.name, schema)) {
39
39
  return node;
40
40
  }
41
41
  var decisionItems = [];
@@ -47,7 +47,7 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
47
47
  itemContent.push.apply(itemContent, (0, _toConsumableArray2.default)(child.children));
48
48
  } else if (child.isText) {
49
49
  itemContent.push(child);
50
- } else if (!(0, _utils.isListType)(child, schema)) {
50
+ } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
51
51
  unsupportedContent.push(child);
52
52
  }
53
53
  });
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.listToListStep = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _model = require("@atlaskit/editor-prosemirror/model");
10
- var _utils = require("../utils");
10
+ var _nodeChecks = require("../nodeChecks");
11
11
  /**
12
12
  * Recursively converts nested lists to the target list type.
13
13
  * This function handles the conversion of both the list container and its items,
@@ -21,13 +21,13 @@ var _transformList = function transformList(node, targetListType, targetItemType
21
21
  var schema = node.type.schema;
22
22
  var taskListType = schema.nodes.taskList;
23
23
  var isSourceTaskList = node.type === taskListType;
24
- var isTargetTaskList = targetListType === 'taskList';
24
+ var isTargetTaskList = targetListType === taskListType.name;
25
25
  var convertFromTaskListStructure = function convertFromTaskListStructure(node, targetListType, targetItemType) {
26
26
  var schema = node.type.schema;
27
27
  var targetListNodeType = schema.nodes[targetListType];
28
28
  var transformedContent = [];
29
29
  node.forEach(function (child) {
30
- if ((0, _utils.isListType)(child, schema)) {
30
+ if ((0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
31
31
  // This is a nested list - it should become a child of the previous item
32
32
  if (transformedContent.length > 0) {
33
33
  var previousItem = transformedContent[transformedContent.length - 1];
@@ -39,7 +39,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
39
39
  }
40
40
  // If there's no previous item, skip this nested list (orphaned)
41
41
  } else {
42
- var transformedItem = transformListItem(child, targetItemType, targetListType);
42
+ var transformedItem = transformListItem(child, targetListType, targetItemType);
43
43
  if (transformedItem) {
44
44
  transformedContent.push(transformedItem);
45
45
  }
@@ -52,19 +52,19 @@ var _transformList = function transformList(node, targetListType, targetItemType
52
52
  var targetListNodeType = schema.nodes[targetListType];
53
53
  var transformedContent = [];
54
54
  node.forEach(function (itemNode) {
55
- var transformedItem = transformListItem(itemNode, targetItemType, targetListType, true);
55
+ var transformedItem = transformListItem(itemNode, targetListType, targetItemType, true);
56
56
  if (transformedItem) {
57
57
  transformedContent.push(transformedItem);
58
58
  }
59
59
  itemNode.forEach(function (child) {
60
- if ((0, _utils.isListType)(child, schema)) {
60
+ if ((0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
61
61
  transformedContent.push(_transformList(child, targetListType, targetItemType, unsupportedContent));
62
62
  }
63
63
  });
64
64
  });
65
65
  return targetListNodeType.create(node.attrs, transformedContent);
66
66
  };
67
- var transformListItem = function transformListItem(itemNode, targetItemType, targetListType) {
67
+ var transformListItem = function transformListItem(itemNode, targetListType, targetItemType) {
68
68
  var excludeNestedLists = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
69
69
  var schema = itemNode.type.schema;
70
70
  var targetItemNodeType = schema.nodes[targetItemType];
@@ -79,7 +79,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
79
79
  } else if (child.isText) {
80
80
  inlineContent.push(child);
81
81
  // Nested lists will be extracted and placed as siblings in the taskList
82
- } else if (!(0, _utils.isListType)(child, schema)) {
82
+ } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
83
83
  unsupportedContent.push(child);
84
84
  }
85
85
  });
@@ -90,7 +90,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
90
90
  transformedContent.push(paragraphType.create(null, itemNode.content));
91
91
  } else {
92
92
  itemNode.forEach(function (child) {
93
- if ((0, _utils.isListType)(child, schema)) {
93
+ if ((0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
94
94
  if (excludeNestedLists) {
95
95
  // Skip nested lists - they will be handled separately as siblings
96
96
  return;
@@ -110,7 +110,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
110
110
  var targetListNodeType = schema.nodes[targetListType];
111
111
  var transformedContent = [];
112
112
  node.forEach(function (childNode) {
113
- var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetItemType, targetListType);
113
+ var transformedItem = (0, _nodeChecks.isListWithIndentation)(childNode.type.name, schema) ? _transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetListType, targetItemType);
114
114
  if (transformedItem) {
115
115
  transformedContent.push(transformedItem);
116
116
  }
@@ -193,7 +193,7 @@ var listToListStep = exports.listToListStep = function listToListStep(nodes, con
193
193
  targetNodeTypeName = context.targetNodeTypeName;
194
194
  var unsupportedContent = [];
195
195
  var transformedNodes = nodes.map(function (node) {
196
- if ((0, _utils.isListType)(node, schema)) {
196
+ if ((0, _nodeChecks.isListWithIndentation)(node.type.name, schema)) {
197
197
  var targetItemType = targetNodeTypeName === 'taskList' ? 'taskItem' : 'listItem';
198
198
  return _transformList(node, targetNodeTypeName, targetItemType, unsupportedContent);
199
199
  }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapTextToCodeblockStep = void 0;
7
+ var _utils = require("../utils");
8
+ /**
9
+ * Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
10
+ * This step handles the conversion of inline content (including marks) to plain text,
11
+ * which is required because codeBlocks can only contain plain text nodes.
12
+ *
13
+ * Example: paragraph with bold/italic/status → codeBlock with plain text
14
+ */
15
+ var wrapTextToCodeblockStep = exports.wrapTextToCodeblockStep = function wrapTextToCodeblockStep(nodes, context) {
16
+ var schema = context.schema;
17
+ return nodes.map(function (node) {
18
+ var codeBlockNode = schema.nodes.codeBlock.createAndFill({}, schema.text((0, _utils.createTextContent)(node)));
19
+ return codeBlockNode !== null && codeBlockNode !== void 0 ? codeBlockNode : node;
20
+ });
21
+ };
@@ -14,6 +14,7 @@ var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
14
14
  var _unwrapListStep = require("./steps/unwrapListStep");
15
15
  var _wrapBlockquoteToDecisionListStep = require("./steps/wrapBlockquoteToDecisionListStep");
16
16
  var _wrapMixedContentStep = require("./steps/wrapMixedContentStep");
17
+ var _wrapTextToCodeblock = require("./steps/wrapTextToCodeblock");
17
18
  var _stubStep = require("./stubStep");
18
19
  var _types = require("./types");
19
20
  var _unwrapExpandStep = require("./unwrapExpandStep");
@@ -21,14 +22,6 @@ var _unwrapStep = require("./unwrapStep");
21
22
  var _wrapIntoLayoutStep = require("./wrapIntoLayoutStep");
22
23
  var _wrapIntoListStep = require("./wrapIntoListStep");
23
24
  var _wrapStep = require("./wrapStep");
24
- // Exampled step for overrides:
25
- // - open Block menu on a paragraph, click 'Panel' in the Turn into'
26
- // - expected to put paragraph into a panel
27
- var wrapIntoPanelStep = function wrapIntoPanelStep(nodes, context) {
28
- var newNode = context.schema.nodes.panel.createAndFill({}, nodes);
29
- return newNode ? [newNode] : [];
30
- };
31
-
32
25
  // Transform steps for combinations of node categories (block/container/list/text)
33
26
  var TRANSFORM_STEPS = {
34
27
  atomic: {
@@ -51,8 +44,8 @@ var TRANSFORM_STEPS = {
51
44
  },
52
45
  text: {
53
46
  atomic: undefined,
54
- container: [_stubStep.stubStep],
55
- list: [_stubStep.stubStep],
47
+ container: [_wrapStep.wrapStep],
48
+ list: [_wrapIntoListStep.wrapIntoListStep],
56
49
  text: [_stubStep.stubStep]
57
50
  }
58
51
  };
@@ -61,7 +54,8 @@ var TRANSFORM_STEPS = {
61
54
  // using generic rules/steps from TRANSFORM_STEPS.
62
55
  var TRANSFORM_STEPS_OVERRIDE = {
63
56
  paragraph: {
64
- panel: [wrapIntoPanelStep]
57
+ codeBlock: [_wrapTextToCodeblock.wrapTextToCodeblockStep],
58
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
65
59
  },
66
60
  panel: {
67
61
  layoutSection: [_unwrapStep.unwrapStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
6
+ exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = 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");
@@ -55,12 +55,6 @@ var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = fu
55
55
  }
56
56
  return nodeTypeName;
57
57
  };
58
- var isListType = exports.isListType = function isListType(node, schema) {
59
- var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
60
- return lists.some(function (list) {
61
- return list === node.type;
62
- });
63
- };
64
58
 
65
59
  /**
66
60
  * Converts a nestedExpand to a regular expand node.
@@ -107,4 +101,23 @@ var getBlockNodesInRange = exports.getBlockNodesInRange = function getBlockNodes
107
101
  }
108
102
  }
109
103
  return blockNodes;
104
+ };
105
+
106
+ /**
107
+ * Iterates over a nodes children and extracting text content, removing all other inline content and converting
108
+ * hardbreaks to newlines.
109
+ *
110
+ * @param node - The node to create text content from (should be paragraph)
111
+ * @returns The text content string.
112
+ */
113
+ var createTextContent = exports.createTextContent = function createTextContent(node) {
114
+ var textContent = node.children.map(function (child) {
115
+ if (child.isText) {
116
+ return child.text;
117
+ } else if (child.type.name === 'hardBreak') {
118
+ return '\n';
119
+ }
120
+ return '';
121
+ });
122
+ return textContent.join('');
110
123
  };
@@ -4,14 +4,36 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.wrapIntoListStep = void 0;
7
- /** wrap nodes into bullet list or numbered list, does not work for task list */
7
+ var _nodeChecks = require("./nodeChecks");
8
+ var wrapIntoTaskOrDecisionList = function wrapIntoTaskOrDecisionList(nodes, targetNodeTypeName, schema) {
9
+ var itemNodeType = targetNodeTypeName === 'taskList' ? schema.nodes.taskItem : schema.nodes.decisionItem;
10
+ var inlineContent = nodes.flatMap(function (node) {
11
+ if (node.isTextblock) {
12
+ return node.children;
13
+ } else if (node.isText) {
14
+ return [node];
15
+ }
16
+ return [];
17
+ });
18
+ var itemNode = itemNodeType.create({}, inlineContent);
19
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, itemNode);
20
+ return outputNode ? [outputNode] : nodes;
21
+ };
22
+ var wrapIntoBulletOrOrderedList = function wrapIntoBulletOrOrderedList(nodes, targetNodeTypeName, schema) {
23
+ var listItemNode = schema.nodes.listItem.createAndFill({}, nodes);
24
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNode);
25
+ return outputNode ? [outputNode] : nodes;
26
+ };
27
+
28
+ /**
29
+ * Wraps nodes into bullet list, numbered list, task list, or decision list.
30
+ *
31
+ * @param nodes - The nodes to wrap.
32
+ * @param context - The transformation context containing schema and target node type.
33
+ * @returns The wrapped nodes.
34
+ */
8
35
  var wrapIntoListStep = exports.wrapIntoListStep = function wrapIntoListStep(nodes, context) {
9
36
  var schema = context.schema,
10
37
  targetNodeTypeName = context.targetNodeTypeName;
11
- var listItemNode = schema.nodes.listItem.createAndFill({}, nodes);
12
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNode);
13
- if (outputNode) {
14
- return [outputNode];
15
- }
16
- return nodes;
38
+ return (0, _nodeChecks.isListWithTextContentOnly)(targetNodeTypeName, schema) ? wrapIntoTaskOrDecisionList(nodes, targetNodeTypeName, schema) : wrapIntoBulletOrOrderedList(nodes, targetNodeTypeName, schema);
17
39
  };
@@ -203,9 +203,7 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
203
203
  rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.DELETE_MENU_SECTION.key],
204
204
  component: function component(_ref0) {
205
205
  var children = _ref0.children;
206
- return /*#__PURE__*/_react.default.createElement(_deleteSection.DeleteSection, {
207
- api: api
208
- }, children);
206
+ return /*#__PURE__*/_react.default.createElement(_deleteSection.DeleteSection, null, children);
209
207
  }
210
208
  }, {
211
209
  type: 'block-menu-item',
@@ -85,8 +85,8 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
85
85
  });
86
86
  }, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, selection]);
87
87
 
88
- // Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested or on empty line
89
- if (!(0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') || !!menuTriggerBy && (0, _isNestedNode.isNestedNode)(selection, menuTriggerBy) || selection !== null && selection !== void 0 && selection.empty) {
88
+ // Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested
89
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') || !!menuTriggerBy && (0, _isNestedNode.isNestedNode)(selection, menuTriggerBy)) {
90
90
  return null;
91
91
  }
92
92
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
@@ -8,14 +8,7 @@ exports.DeleteSection = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _editorToolbar = require("@atlaskit/editor-toolbar");
10
10
  var DeleteSection = exports.DeleteSection = function DeleteSection(_ref) {
11
- var _api$selection;
12
- var api = _ref.api,
13
- children = _ref.children;
14
- var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
15
- var isEmptyLineSelected = !!(selection !== null && selection !== void 0 && selection.empty);
16
- if (isEmptyLineSelected) {
17
- return null;
18
- }
11
+ var children = _ref.children;
19
12
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
20
13
  hasSeparator: true
21
14
  }, children);
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Checks if a node is a list type that supports indentation (bulletList, orderedList, taskList).
3
+ *
4
+ * @param node - The node to check.
5
+ * @param schema - ProseMirror schema for check
6
+ * @returns True if the node is a list type, false otherwise.
7
+ */
8
+ export const isListWithIndentation = (nodeTypeName, schema) => {
9
+ const lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
10
+ return lists.some(list => list.name === nodeTypeName);
11
+ };
12
+
13
+ /**
14
+ * Checks if a node is a list where its list items only support text content (taskList or decisionList).
15
+ *
16
+ * @param nodeTypeName - The node type name to check.
17
+ * @param schema - ProseMirror schema for check
18
+ * @returns True if the node is a list text type, false otherwise.
19
+ */
20
+ export const isListWithTextContentOnly = (nodeTypeName, schema) => {
21
+ const lists = [schema.nodes.taskList, schema.nodes.decisionList];
22
+ return lists.some(list => list.name === nodeTypeName);
23
+ };
@@ -1,14 +1,16 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- const extractNestedLists = (node, listTypes, itemTypes, schema) => {
2
+ import { isListWithIndentation } from '../nodeChecks';
3
+ const extractNestedLists = (node, schema) => {
3
4
  const items = [];
4
5
  const paragraph = schema.nodes.paragraph;
6
+ const itemTypes = [schema.nodes.listItem, schema.nodes.taskItem];
5
7
  const extract = currentNode => {
6
8
  currentNode.forEach(child => {
7
9
  if (itemTypes.some(type => child.type === type)) {
8
10
  const contentWithoutNestedLists = [];
9
11
  const nestedLists = [];
10
12
  child.forEach(grandChild => {
11
- if (listTypes.some(type => grandChild.type === type)) {
13
+ if (isListWithIndentation(grandChild.type.name, schema)) {
12
14
  nestedLists.push(grandChild);
13
15
  } else if (grandChild.isText) {
14
16
  contentWithoutNestedLists.push(paragraph.createAndFill({}, grandChild));
@@ -20,7 +22,7 @@ const extractNestedLists = (node, listTypes, itemTypes, schema) => {
20
22
  nestedLists.forEach(nestedList => {
21
23
  extract(nestedList);
22
24
  });
23
- } else if (listTypes.some(type => child.type === type)) {
25
+ } else if (isListWithIndentation(child.type.name, schema)) {
24
26
  extract(child);
25
27
  }
26
28
  });
@@ -59,10 +61,9 @@ const extractNestedLists = (node, listTypes, itemTypes, schema) => {
59
61
  * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
60
62
  */
61
63
  export const flattenListStep = (nodes, context) => {
62
- const listTypes = [context.schema.nodes.bulletList, context.schema.nodes.orderedList, context.schema.nodes.taskList];
63
64
  return nodes.map(node => {
64
- if (listTypes.some(type => node.type === type)) {
65
- return node.copy(Fragment.from(extractNestedLists(node, listTypes, [context.schema.nodes.listItem, context.schema.nodes.taskItem], context.schema)));
65
+ if (isListWithIndentation(node.type.name, context.schema)) {
66
+ return node.copy(Fragment.from(extractNestedLists(node, context.schema)));
66
67
  }
67
68
  return node;
68
69
  });
@@ -1,5 +1,4 @@
1
- import { isListType } from '../utils';
2
-
1
+ import { isListWithIndentation } from '../nodeChecks';
3
2
  /**
4
3
  * Transforms a bulletList, orderedList, or taskList into a decisionList.
5
4
  *
@@ -30,7 +29,7 @@ export const listToDecisionListStep = (nodes, context) => {
30
29
  const paragraphType = schema.nodes.paragraph;
31
30
  const unsupportedContent = [];
32
31
  const transformedNodes = nodes.map(node => {
33
- if (!isListType(node, schema)) {
32
+ if (!isListWithIndentation(node.type.name, schema)) {
34
33
  return node;
35
34
  }
36
35
  const decisionItems = [];
@@ -42,7 +41,7 @@ export const listToDecisionListStep = (nodes, context) => {
42
41
  itemContent.push(...child.children);
43
42
  } else if (child.isText) {
44
43
  itemContent.push(child);
45
- } else if (!isListType(child, schema)) {
44
+ } else if (!isListWithIndentation(child.type.name, schema)) {
46
45
  unsupportedContent.push(child);
47
46
  }
48
47
  });
@@ -1,6 +1,5 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import { isListType } from '../utils';
3
-
2
+ import { isListWithIndentation } from '../nodeChecks';
4
3
  /**
5
4
  * Recursively converts nested lists to the target list type.
6
5
  * This function handles the conversion of both the list container and its items,
@@ -14,13 +13,13 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
14
13
  const schema = node.type.schema;
15
14
  const taskListType = schema.nodes.taskList;
16
15
  const isSourceTaskList = node.type === taskListType;
17
- const isTargetTaskList = targetListType === 'taskList';
16
+ const isTargetTaskList = targetListType === taskListType.name;
18
17
  const convertFromTaskListStructure = (node, targetListType, targetItemType) => {
19
18
  const schema = node.type.schema;
20
19
  const targetListNodeType = schema.nodes[targetListType];
21
20
  const transformedContent = [];
22
21
  node.forEach(child => {
23
- if (isListType(child, schema)) {
22
+ if (isListWithIndentation(child.type.name, schema)) {
24
23
  // This is a nested list - it should become a child of the previous item
25
24
  if (transformedContent.length > 0) {
26
25
  const previousItem = transformedContent[transformedContent.length - 1];
@@ -32,7 +31,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
32
31
  }
33
32
  // If there's no previous item, skip this nested list (orphaned)
34
33
  } else {
35
- const transformedItem = transformListItem(child, targetItemType, targetListType);
34
+ const transformedItem = transformListItem(child, targetListType, targetItemType);
36
35
  if (transformedItem) {
37
36
  transformedContent.push(transformedItem);
38
37
  }
@@ -45,19 +44,19 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
45
44
  const targetListNodeType = schema.nodes[targetListType];
46
45
  const transformedContent = [];
47
46
  node.forEach(itemNode => {
48
- const transformedItem = transformListItem(itemNode, targetItemType, targetListType, true);
47
+ const transformedItem = transformListItem(itemNode, targetListType, targetItemType, true);
49
48
  if (transformedItem) {
50
49
  transformedContent.push(transformedItem);
51
50
  }
52
51
  itemNode.forEach(child => {
53
- if (isListType(child, schema)) {
52
+ if (isListWithIndentation(child.type.name, schema)) {
54
53
  transformedContent.push(transformList(child, targetListType, targetItemType, unsupportedContent));
55
54
  }
56
55
  });
57
56
  });
58
57
  return targetListNodeType.create(node.attrs, transformedContent);
59
58
  };
60
- const transformListItem = (itemNode, targetItemType, targetListType, excludeNestedLists = false) => {
59
+ const transformListItem = (itemNode, targetListType, targetItemType, excludeNestedLists = false) => {
61
60
  const schema = itemNode.type.schema;
62
61
  const targetItemNodeType = schema.nodes[targetItemType];
63
62
  const isTargetTaskItem = targetItemType === 'taskItem';
@@ -71,7 +70,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
71
70
  } else if (child.isText) {
72
71
  inlineContent.push(child);
73
72
  // Nested lists will be extracted and placed as siblings in the taskList
74
- } else if (!isListType(child, schema)) {
73
+ } else if (!isListWithIndentation(child.type.name, schema)) {
75
74
  unsupportedContent.push(child);
76
75
  }
77
76
  });
@@ -82,7 +81,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
82
81
  transformedContent.push(paragraphType.create(null, itemNode.content));
83
82
  } else {
84
83
  itemNode.forEach(child => {
85
- if (isListType(child, schema)) {
84
+ if (isListWithIndentation(child.type.name, schema)) {
86
85
  if (excludeNestedLists) {
87
86
  // Skip nested lists - they will be handled separately as siblings
88
87
  return;
@@ -102,7 +101,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
102
101
  const targetListNodeType = schema.nodes[targetListType];
103
102
  const transformedContent = [];
104
103
  node.forEach(childNode => {
105
- const transformedItem = isListType(childNode, schema) ? transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetItemType, targetListType);
104
+ const transformedItem = isListWithIndentation(childNode.type.name, schema) ? transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetListType, targetItemType);
106
105
  if (transformedItem) {
107
106
  transformedContent.push(transformedItem);
108
107
  }
@@ -187,7 +186,7 @@ export const listToListStep = (nodes, context) => {
187
186
  } = context;
188
187
  const unsupportedContent = [];
189
188
  const transformedNodes = nodes.map(node => {
190
- if (isListType(node, schema)) {
189
+ if (isListWithIndentation(node.type.name, schema)) {
191
190
  const targetItemType = targetNodeTypeName === 'taskList' ? 'taskItem' : 'listItem';
192
191
  return transformList(node, targetNodeTypeName, targetItemType, unsupportedContent);
193
192
  }
@@ -0,0 +1,18 @@
1
+ import { createTextContent } from '../utils';
2
+
3
+ /**
4
+ * Transforms a paragraph (or heading) into a codeBlock by extracting its text content.
5
+ * This step handles the conversion of inline content (including marks) to plain text,
6
+ * which is required because codeBlocks can only contain plain text nodes.
7
+ *
8
+ * Example: paragraph with bold/italic/status → codeBlock with plain text
9
+ */
10
+ export const wrapTextToCodeblockStep = (nodes, context) => {
11
+ const {
12
+ schema
13
+ } = context;
14
+ return nodes.map(node => {
15
+ const codeBlockNode = schema.nodes.codeBlock.createAndFill({}, schema.text(createTextContent(node)));
16
+ return codeBlockNode !== null && codeBlockNode !== void 0 ? codeBlockNode : node;
17
+ });
18
+ };