@atlaskit/editor-plugin-block-menu 5.2.15 → 5.2.17

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 (51) hide show
  1. package/CHANGELOG.md +21 -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 +11 -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/editor-commands/transformNode.js +3 -2
  11. package/dist/cjs/ui/block-menu-components.js +1 -3
  12. package/dist/cjs/ui/block-menu.js +38 -33
  13. package/dist/cjs/ui/copy-link.js +2 -2
  14. package/dist/cjs/ui/delete-section.js +1 -8
  15. package/dist/es2019/editor-commands/transform-node-utils/nodeChecks.js +23 -0
  16. package/dist/es2019/editor-commands/transform-node-utils/steps/flattenListStep.js +7 -6
  17. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +3 -4
  18. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +11 -12
  19. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +18 -0
  20. package/dist/es2019/editor-commands/transform-node-utils/transform.js +11 -11
  21. package/dist/es2019/editor-commands/transform-node-utils/utils.js +19 -4
  22. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoListStep.js +29 -7
  23. package/dist/es2019/editor-commands/transformNode.js +3 -2
  24. package/dist/es2019/ui/block-menu-components.js +1 -3
  25. package/dist/es2019/ui/block-menu.js +38 -33
  26. package/dist/es2019/ui/copy-link.js +2 -2
  27. package/dist/es2019/ui/delete-section.js +0 -7
  28. package/dist/esm/editor-commands/transform-node-utils/nodeChecks.js +27 -0
  29. package/dist/esm/editor-commands/transform-node-utils/steps/flattenListStep.js +7 -12
  30. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +3 -4
  31. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +11 -12
  32. package/dist/esm/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.js +16 -0
  33. package/dist/esm/editor-commands/transform-node-utils/transform.js +11 -11
  34. package/dist/esm/editor-commands/transform-node-utils/utils.js +19 -6
  35. package/dist/esm/editor-commands/transform-node-utils/wrapIntoListStep.js +29 -7
  36. package/dist/esm/editor-commands/transformNode.js +3 -2
  37. package/dist/esm/ui/block-menu-components.js +1 -3
  38. package/dist/esm/ui/block-menu.js +38 -33
  39. package/dist/esm/ui/copy-link.js +2 -2
  40. package/dist/esm/ui/delete-section.js +1 -8
  41. package/dist/types/editor-commands/transform-node-utils/nodeChecks.d.ts +17 -0
  42. package/dist/types/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +9 -0
  43. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +8 -1
  44. package/dist/types/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +7 -1
  45. package/dist/types/ui/delete-section.d.ts +1 -4
  46. package/dist/types-ts4.5/editor-commands/transform-node-utils/nodeChecks.d.ts +17 -0
  47. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapTextToCodeblock.d.ts +9 -0
  48. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +8 -1
  49. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +7 -1
  50. package/dist/types-ts4.5/ui/delete-section.d.ts +1 -4
  51. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1da3868c8f709`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1da3868c8f709) -
8
+ EDITOR-3916 Fix block menu alternating on drag handle click
9
+ - [`722f272e8b78f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/722f272e8b78f) -
10
+ Editor-2778: Smartlink card and embed transform
11
+ - Updated dependencies
12
+
13
+ ## 5.2.16
14
+
15
+ ### Patch Changes
16
+
17
+ - [`493a21ccda098`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/493a21ccda098) -
18
+ Add wrapTextToCodeblock step to handle text to codeblock step, add remaining steps for paragraph
19
+ to container steps
20
+ - [`38369379f9e12`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38369379f9e12) -
21
+ [ux] Editor-3976: Make copy link and delete available for empty line
22
+ - Updated dependencies
23
+
3
24
  ## 5.2.15
4
25
 
5
26
  ### 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],
@@ -135,6 +129,12 @@ var TRANSFORM_STEPS_OVERRIDE = {
135
129
  orderedList: [_decisionListToListStep.decisionListToListStep],
136
130
  taskList: [_decisionListToListStep.decisionListToListStep],
137
131
  layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
132
+ },
133
+ blockCard: {
134
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
135
+ },
136
+ embedCard: {
137
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
138
138
  }
139
139
  };
140
140
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -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
  };
@@ -26,8 +26,9 @@ var transformNode = exports.transformNode = function transformNode(api) {
26
26
  var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(preservedSelection),
27
27
  $from = _expandSelectionToBlo.$from,
28
28
  $to = _expandSelectionToBlo.$to;
29
- var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
30
29
  var selectedParent = $from.parent;
30
+ var isParentLayout = selectedParent.type === nodes.layoutColumn;
31
+ var isNestedExceptLayout = (0, _isNestedNode.isNestedNode)(preservedSelection, '') && !isParentLayout;
31
32
  var fragment = _model.Fragment.empty;
32
33
  var isList = (0, _utils.isListNode)(selectedParent);
33
34
  var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
@@ -36,7 +37,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
36
37
  sourceNode: node,
37
38
  targetNodeType: targetType,
38
39
  schema: tr.doc.type.schema,
39
- isNested: isNested
40
+ isNested: isNestedExceptLayout
40
41
  });
41
42
  if (outputNode) {
42
43
  fragment = fragment.append(_model.Fragment.fromArray(outputNode));
@@ -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',
@@ -127,7 +127,7 @@ var BlockMenuContent = function BlockMenuContent(_ref3) {
127
127
  })));
128
128
  };
129
129
  var BlockMenu = function BlockMenu(_ref4) {
130
- var _editorView$dom, _ref5;
130
+ var _editorView$dom, _ref5, _api$analytics3;
131
131
  var editorView = _ref4.editorView,
132
132
  api = _ref4.api,
133
133
  mountTo = _ref4.mountTo,
@@ -202,6 +202,13 @@ var BlockMenu = function BlockMenu(_ref4) {
202
202
  return tr;
203
203
  });
204
204
  };
205
+ var handleClickOutside = function handleClickOutside(e) {
206
+ // check if the clicked element was another drag handle, if so don't close the menu
207
+ if (e.target instanceof HTMLElement && e.target.closest(_styles.DRAG_HANDLE_SELECTOR)) {
208
+ return;
209
+ }
210
+ closeMenu();
211
+ };
205
212
  var closeMenu = function closeMenu() {
206
213
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
207
214
  var _api$blockControls3, _api$userIntent3;
@@ -227,39 +234,37 @@ var BlockMenu = function BlockMenu(_ref4) {
227
234
  popupRef.current = el;
228
235
  }
229
236
  };
230
- if (targetHandleRef instanceof HTMLElement) {
231
- var _api$analytics3;
232
- return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
233
- component: _analytics.ACTION_SUBJECT.BLOCK_MENU,
234
- dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
235
- fallbackComponent: null
236
- }, /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
237
- alignX: 'right',
238
- alignY: 'start',
239
- handleClickOutside: closeMenu,
240
- handleEscapeKeydown: closeMenu,
241
- handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
242
- mountTo: mountTo,
243
- boundariesElement: boundariesElement,
244
- scrollableElement: scrollableElement,
245
- target: targetHandleRef,
246
- zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
247
- fitWidth: DEFAULT_MENU_WIDTH,
248
- fitHeight: menuHeight,
249
- preventOverflow: true,
250
- stick: true,
251
- offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
252
- focusTrap: openedViaKeyboard ?
253
- // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
254
- {
255
- initialFocus: undefined
256
- } : undefined
257
- }, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
258
- api: api,
259
- setRef: setRef
260
- })));
261
- } else {
237
+ if (!(targetHandleRef instanceof HTMLElement)) {
262
238
  return null;
263
239
  }
240
+ return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
241
+ component: _analytics.ACTION_SUBJECT.BLOCK_MENU,
242
+ dispatchAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent,
243
+ fallbackComponent: null
244
+ }, /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
245
+ alignX: 'right',
246
+ alignY: 'start',
247
+ handleClickOutside: handleClickOutside,
248
+ handleEscapeKeydown: closeMenu,
249
+ handleBackspaceDeleteKeydown: handleBackspaceDeleteKeydown,
250
+ mountTo: mountTo,
251
+ boundariesElement: boundariesElement,
252
+ scrollableElement: scrollableElement,
253
+ target: targetHandleRef,
254
+ zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
255
+ fitWidth: DEFAULT_MENU_WIDTH,
256
+ fitHeight: menuHeight,
257
+ preventOverflow: true,
258
+ stick: true,
259
+ offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, targetHandleHeightOffset],
260
+ focusTrap: openedViaKeyboard ?
261
+ // Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
262
+ {
263
+ initialFocus: undefined
264
+ } : undefined
265
+ }, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
266
+ api: api,
267
+ setRef: setRef
268
+ })));
264
269
  };
265
270
  var _default = exports.default = (0, _reactIntlNext.injectIntl)(BlockMenu);
@@ -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
  });