@atlaskit/editor-plugin-block-menu 5.2.7 → 5.2.9

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 (25) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/editor-actions/index.js +3 -13
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +12 -12
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +96 -119
  5. package/dist/cjs/editor-commands/transform-node-utils/transform.js +8 -2
  6. package/dist/cjs/editor-commands/transform-node-utils/utils.js +17 -1
  7. package/dist/cjs/editor-commands/transform-node-utils/wrapIntoListStep.js +17 -0
  8. package/dist/cjs/editor-commands/transformNode.js +13 -4
  9. package/dist/es2019/editor-actions/index.js +1 -11
  10. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +10 -12
  11. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +93 -118
  12. package/dist/es2019/editor-commands/transform-node-utils/transform.js +8 -2
  13. package/dist/es2019/editor-commands/transform-node-utils/utils.js +17 -1
  14. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoListStep.js +13 -0
  15. package/dist/es2019/editor-commands/transformNode.js +15 -4
  16. package/dist/esm/editor-actions/index.js +2 -13
  17. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +11 -12
  18. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +95 -119
  19. package/dist/esm/editor-commands/transform-node-utils/transform.js +8 -2
  20. package/dist/esm/editor-commands/transform-node-utils/utils.js +17 -1
  21. package/dist/esm/editor-commands/transform-node-utils/wrapIntoListStep.js +11 -0
  22. package/dist/esm/editor-commands/transformNode.js +13 -4
  23. package/dist/types/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +3 -0
  24. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoListStep.d.ts +3 -0
  25. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3d03e8b001dab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d03e8b001dab) -
8
+ Add logic to handle unsupported content for list to task/decision list
9
+ - [`b831109342cdf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b831109342cdf) -
10
+ EDITOR-3880 Register block menu selection extensions statically
11
+
12
+ ## 5.2.8
13
+
14
+ ### Patch Changes
15
+
16
+ - [`0006edf16b3a3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0006edf16b3a3) -
17
+ Editor-2778: Media wrap in container
18
+
3
19
  ## 5.2.7
4
20
 
5
21
  ### Patch Changes
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createBlockMenuRegistry = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
9
  /**
8
10
  * Create a simple registry for block menu components.
9
11
  *
@@ -54,19 +56,7 @@ exports.createBlockMenuRegistry = void 0;
54
56
  var createBlockMenuRegistry = exports.createBlockMenuRegistry = function createBlockMenuRegistry() {
55
57
  var components = [];
56
58
  var register = function register(blockMenuComponents) {
57
- blockMenuComponents.forEach(function (newComponent) {
58
- // Find if a component with the same key already exists
59
- var existingIndex = components.findIndex(function (comp) {
60
- return comp.key === newComponent.key;
61
- });
62
- if (existingIndex !== -1) {
63
- // Replace the existing component
64
- components[existingIndex] = newComponent;
65
- } else {
66
- // Add new component
67
- components.push(newComponent);
68
- }
69
- });
59
+ components.push.apply(components, (0, _toConsumableArray2.default)(blockMenuComponents));
70
60
  };
71
61
  return {
72
62
  register: register,
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.listToDecisionListStep = void 0;
7
- var _model = require("@atlaskit/editor-prosemirror/model");
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
8
9
  var _utils = require("../utils");
9
10
  /**
10
11
  * Transforms a bulletList, orderedList, or taskList into a decisionList.
@@ -32,7 +33,8 @@ var _utils = require("../utils");
32
33
  var listToDecisionListStep = exports.listToDecisionListStep = function listToDecisionListStep(nodes, context) {
33
34
  var schema = context.schema;
34
35
  var paragraphType = schema.nodes.paragraph;
35
- return nodes.map(function (node) {
36
+ var unsupportedContent = [];
37
+ var transformedNodes = nodes.map(function (node) {
36
38
  if (!(0, _utils.isListType)(node, schema)) {
37
39
  return node;
38
40
  }
@@ -42,20 +44,18 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
42
44
  item.forEach(function (child) {
43
45
  if (child.type === paragraphType) {
44
46
  // paragraph may contain hard breaks etc.
45
- child.content.forEach(function (inline) {
46
- itemContent.push(inline);
47
- });
48
- } else {
47
+ itemContent.push.apply(itemContent, (0, _toConsumableArray2.default)(child.children));
48
+ } else if (child.isText) {
49
49
  itemContent.push(child);
50
+ } else if (!(0, _utils.isListType)(child, schema)) {
51
+ unsupportedContent.push(child);
50
52
  }
51
- // TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
52
53
  });
53
- var decisionItem = schema.nodes.decisionItem.create({}, _model.Fragment.from(itemContent));
54
- if (decisionItem) {
55
- decisionItems.push(decisionItem);
56
- }
54
+ var decisionItem = schema.nodes.decisionItem.create({}, itemContent);
55
+ decisionItems.push(decisionItem);
57
56
  });
58
- var decisionList = schema.nodes.decisionList.create({}, _model.Fragment.from(decisionItems));
57
+ var decisionList = schema.nodes.decisionList.create({}, decisionItems);
59
58
  return decisionList || node;
60
59
  });
60
+ return [].concat((0, _toConsumableArray2.default)(transformedNodes), unsupportedContent);
61
61
  };
@@ -1,153 +1,128 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.listToListStep = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
9
  var _model = require("@atlaskit/editor-prosemirror/model");
8
10
  var _utils = require("../utils");
9
11
  /**
10
- * Converts FROM taskList structure TO bulletList/orderedList structure.
11
- */
12
- var convertFromTaskListStructure = function convertFromTaskListStructure(node, targetListType, targetItemType) {
13
- var schema = node.type.schema;
14
- var targetListNodeType = schema.nodes[targetListType];
15
- var convertedItems = [];
16
- node.content.forEach(function (child) {
17
- if ((0, _utils.isListType)(child, schema)) {
18
- // This is a nested list - it should become a child of the previous item
19
- if (convertedItems.length > 0) {
20
- var previousItem = convertedItems[convertedItems.length - 1];
21
- // Convert the nested list and add it to the previous item's content
22
- var convertedNestedList = _transformList(child, targetListType, targetItemType);
23
- var newContent = previousItem.content.append(_model.Fragment.from([convertedNestedList]));
24
- var updatedItem = previousItem.type.create(previousItem.attrs, newContent);
25
- convertedItems[convertedItems.length - 1] = updatedItem;
26
- }
27
- // If there's no previous item, skip this nested list (orphaned)
28
- } else {
29
- var convertedItem = transformListItem(child, targetItemType, targetListType);
30
- if (convertedItem) {
31
- convertedItems.push(convertedItem);
32
- }
33
- }
34
- });
35
- return targetListNodeType.create(node.attrs, _model.Fragment.from(convertedItems));
36
- };
37
-
38
- /**
39
- * Converts FROM bulletList/orderedList structure TO taskList structure.
12
+ * Recursively converts nested lists to the target list type.
13
+ * This function handles the conversion of both the list container and its items,
14
+ * including any nested lists within those items.
15
+ *
16
+ * Important: taskList has a different nesting structure than bulletList/orderedList:
17
+ * - taskList: nested taskLists are SIBLINGS of taskItems in the parent taskList
18
+ * - bulletList/orderedList: nested lists are CHILDREN of listItems
40
19
  */
41
- var convertToTaskListStructure = function convertToTaskListStructure(node, targetListType, targetItemType) {
20
+ var _transformList = function transformList(node, targetListType, targetItemType, unsupportedContent) {
42
21
  var schema = node.type.schema;
43
- var targetListNodeType = schema.nodes[targetListType];
44
- var transformedContent = [];
45
- node.content.forEach(function (itemNode) {
46
- var transformedItem = transformListItem(itemNode, targetItemType, targetListType, true);
47
- if (transformedItem) {
48
- transformedContent.push(transformedItem);
49
- }
50
- itemNode.content.forEach(function (child) {
22
+ var taskListType = schema.nodes.taskList;
23
+ var isSourceTaskList = node.type === taskListType;
24
+ var isTargetTaskList = targetListType === 'taskList';
25
+ var convertFromTaskListStructure = function convertFromTaskListStructure(node, targetListType, targetItemType) {
26
+ var schema = node.type.schema;
27
+ var targetListNodeType = schema.nodes[targetListType];
28
+ var transformedContent = [];
29
+ node.forEach(function (child) {
51
30
  if ((0, _utils.isListType)(child, schema)) {
52
- var transformedNestedList = _transformList(child, targetListType, targetItemType);
53
- transformedContent.push(transformedNestedList);
31
+ // This is a nested list - it should become a child of the previous item
32
+ if (transformedContent.length > 0) {
33
+ var previousItem = transformedContent[transformedContent.length - 1];
34
+ // Convert the nested list and add it to the previous item's content
35
+ var transformedNestedList = _transformList(child, targetListType, targetItemType, unsupportedContent);
36
+ var newContent = previousItem.content.append(_model.Fragment.from([transformedNestedList]));
37
+ var updatedItem = previousItem.type.create(previousItem.attrs, newContent);
38
+ transformedContent[transformedContent.length - 1] = updatedItem;
39
+ }
40
+ // If there's no previous item, skip this nested list (orphaned)
41
+ } else {
42
+ var transformedItem = transformListItem(child, targetItemType, targetListType);
43
+ if (transformedItem) {
44
+ transformedContent.push(transformedItem);
45
+ }
54
46
  }
55
47
  });
56
- });
57
- return targetListNodeType.create(node.attrs, _model.Fragment.from(transformedContent));
58
- };
59
-
60
- /**
61
- * Converts a single list item (listItem or taskItem) to the target item type.
62
- * Handles content transformation based on the target type's requirements.
63
- * @param itemNode - The list item node to convert
64
- * @param targetItemType - The target item type (listItem or taskItem)
65
- * @param targetListType - The target list type (bulletList, orderedList, or taskList)
66
- * @param excludeNestedLists - When true, nested lists are excluded from the item's content
67
- * (used when converting to taskList where nested lists become siblings)
68
- */
69
- var transformListItem = function transformListItem(itemNode, targetItemType, targetListType) {
70
- var excludeNestedLists = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
71
- var schema = itemNode.type.schema;
72
- var targetItemNodeType = schema.nodes[targetItemType];
73
- var isTargetTaskItem = targetItemType === 'taskItem';
74
- var isSourceTaskItem = itemNode.type.name === 'taskItem';
75
- var paragraphType = schema.nodes.paragraph;
76
- if (!targetItemNodeType) {
77
- return null;
78
- }
79
- if (isTargetTaskItem) {
80
- var inlineContent = [];
81
- itemNode.content.forEach(function (child) {
82
- if (child.type === paragraphType) {
83
- child.content.forEach(function (inline) {
84
- inlineContent.push(inline);
85
- });
86
- }
87
- if (child.isText) {
88
- inlineContent.push(child);
48
+ return targetListNodeType.create(node.attrs, transformedContent);
49
+ };
50
+ var convertToTaskListStructure = function convertToTaskListStructure(node, targetListType, targetItemType) {
51
+ var schema = node.type.schema;
52
+ var targetListNodeType = schema.nodes[targetListType];
53
+ var transformedContent = [];
54
+ node.forEach(function (itemNode) {
55
+ var transformedItem = transformListItem(itemNode, targetItemType, targetListType, true);
56
+ if (transformedItem) {
57
+ transformedContent.push(transformedItem);
89
58
  }
90
- // TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
91
- // Nested lists will be extracted and placed as siblings in the taskList
59
+ itemNode.forEach(function (child) {
60
+ if ((0, _utils.isListType)(child, schema)) {
61
+ transformedContent.push(_transformList(child, targetListType, targetItemType, unsupportedContent));
62
+ }
63
+ });
92
64
  });
93
- return targetItemNodeType.create({}, _model.Fragment.from(inlineContent));
94
- } else {
95
- var newContent = [];
65
+ return targetListNodeType.create(node.attrs, transformedContent);
66
+ };
67
+ var transformListItem = function transformListItem(itemNode, targetItemType, targetListType) {
68
+ var excludeNestedLists = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
69
+ var schema = itemNode.type.schema;
70
+ var targetItemNodeType = schema.nodes[targetItemType];
71
+ var isTargetTaskItem = targetItemType === 'taskItem';
72
+ var isSourceTaskItem = itemNode.type.name === 'taskItem';
73
+ var paragraphType = schema.nodes.paragraph;
74
+ if (isTargetTaskItem) {
75
+ var inlineContent = [];
76
+ itemNode.forEach(function (child) {
77
+ if (child.type === paragraphType) {
78
+ inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(child.children));
79
+ } else if (child.isText) {
80
+ inlineContent.push(child);
81
+ // Nested lists will be extracted and placed as siblings in the taskList
82
+ } else if (!(0, _utils.isListType)(child, schema)) {
83
+ unsupportedContent.push(child);
84
+ }
85
+ });
86
+ return targetItemNodeType.create({}, inlineContent);
87
+ }
88
+ var transformedContent = [];
96
89
  if (isSourceTaskItem) {
97
- newContent.push(paragraphType.create(null, itemNode.content));
90
+ transformedContent.push(paragraphType.create(null, itemNode.content));
98
91
  } else {
99
- itemNode.content.forEach(function (child) {
92
+ itemNode.forEach(function (child) {
100
93
  if ((0, _utils.isListType)(child, schema)) {
101
94
  if (excludeNestedLists) {
102
95
  // Skip nested lists - they will be handled separately as siblings
103
96
  return;
104
97
  }
105
- newContent.push(_transformList(child, targetListType, targetItemType));
98
+ transformedContent.push(_transformList(child, targetListType, targetItemType, unsupportedContent));
106
99
  } else {
107
- newContent.push(child);
100
+ transformedContent.push(child);
108
101
  }
109
102
  });
110
103
  }
111
- if (newContent.length === 0) {
112
- newContent.push(paragraphType.create());
104
+ if (transformedContent.length === 0) {
105
+ transformedContent.push(paragraphType.create());
113
106
  }
114
- return targetItemNodeType.create({}, _model.Fragment.from(newContent));
115
- }
116
- };
117
-
118
- /**
119
- * Recursively converts nested lists to the target list type.
120
- * This function handles the conversion of both the list container and its items,
121
- * including any nested lists within those items.
122
- *
123
- * Important: taskList has a different nesting structure than bulletList/orderedList:
124
- * - taskList: nested taskLists are SIBLINGS of taskItems in the parent taskList
125
- * - bulletList/orderedList: nested lists are CHILDREN of listItems
126
- */
127
- var _transformList = function transformList(node, targetListType, targetItemType) {
128
- var schema = node.type.schema;
129
- var targetListNodeType = schema.nodes[targetListType];
130
- var targetItemNodeType = schema.nodes[targetItemType];
131
- var taskListType = schema.nodes.taskList;
132
- if (!targetListNodeType || !targetItemNodeType) {
133
- return node;
134
- }
135
- var isSourceTaskList = node.type === taskListType;
136
- var isTargetTaskList = targetListType === 'taskList';
107
+ return targetItemNodeType.create({}, transformedContent);
108
+ };
109
+ var convertList = function convertList(node, schema, targetListType, targetItemType) {
110
+ var targetListNodeType = schema.nodes[targetListType];
111
+ var transformedContent = [];
112
+ node.forEach(function (childNode) {
113
+ var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetItemType, targetListType);
114
+ if (transformedItem) {
115
+ transformedContent.push(transformedItem);
116
+ }
117
+ });
118
+ return targetListNodeType.create(node.attrs, transformedContent);
119
+ };
137
120
  if (isSourceTaskList && !isTargetTaskList) {
138
121
  return convertFromTaskListStructure(node, targetListType, targetItemType);
139
122
  } else if (!isSourceTaskList && isTargetTaskList) {
140
123
  return convertToTaskListStructure(node, targetListType, targetItemType);
141
- } else {
142
- var transformedItems = [];
143
- node.content.forEach(function (childNode) {
144
- var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType) : transformListItem(childNode, targetItemType, targetListType);
145
- if (transformedItem) {
146
- transformedItems.push(transformedItem);
147
- }
148
- });
149
- return targetListNodeType.create(node.attrs, _model.Fragment.from(transformedItems));
150
124
  }
125
+ return convertList(node, schema, targetListType, targetItemType);
151
126
  };
152
127
 
153
128
  /**
@@ -216,11 +191,13 @@ var _transformList = function transformList(node, targetListType, targetItemType
216
191
  var listToListStep = exports.listToListStep = function listToListStep(nodes, context) {
217
192
  var schema = context.schema,
218
193
  targetNodeTypeName = context.targetNodeTypeName;
219
- return nodes.map(function (node) {
194
+ var unsupportedContent = [];
195
+ var transformedNodes = nodes.map(function (node) {
220
196
  if ((0, _utils.isListType)(node, schema)) {
221
197
  var targetItemType = targetNodeTypeName === 'taskList' ? 'taskItem' : 'listItem';
222
- return _transformList(node, targetNodeTypeName, targetItemType);
198
+ return _transformList(node, targetNodeTypeName, targetItemType, unsupportedContent);
223
199
  }
224
200
  return node;
225
201
  });
202
+ return [].concat((0, _toConsumableArray2.default)(transformedNodes), unsupportedContent);
226
203
  };
@@ -19,6 +19,7 @@ var _types = require("./types");
19
19
  var _unwrapExpandStep = require("./unwrapExpandStep");
20
20
  var _unwrapStep = require("./unwrapStep");
21
21
  var _wrapIntoLayoutStep = require("./wrapIntoLayoutStep");
22
+ var _wrapIntoListStep = require("./wrapIntoListStep");
22
23
  var _wrapStep = require("./wrapStep");
23
24
  // Exampled step for overrides:
24
25
  // - open Block menu on a paragraph, click 'Panel' in the Turn into'
@@ -33,7 +34,7 @@ var TRANSFORM_STEPS = {
33
34
  atomic: {
34
35
  atomic: undefined,
35
36
  container: [_wrapStep.wrapStep],
36
- list: undefined,
37
+ list: [_wrapIntoListStep.wrapIntoListStep],
37
38
  text: undefined
38
39
  },
39
40
  container: {
@@ -121,7 +122,12 @@ var TRANSFORM_STEPS_OVERRIDE = {
121
122
  decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep]
122
123
  },
123
124
  table: {
124
- expand: [_wrapStep.wrapStep],
125
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
126
+ },
127
+ mediaSingle: {
128
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
129
+ },
130
+ mediaGroup: {
125
131
  layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
126
132
  },
127
133
  decisionList: {
@@ -76,13 +76,29 @@ var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function
76
76
  var table = (0, _utils2.findTable)(selection);
77
77
  if (table) {
78
78
  var $from = selection.$from.doc.resolve(table.pos);
79
- var $to = selection.$from.doc.resolve(table.pos + table.node.nodeSize - 1);
79
+ var $to = selection.$from.doc.resolve(table.pos + table.node.nodeSize);
80
80
  return {
81
81
  $from: $from,
82
82
  $to: $to
83
83
  };
84
84
  }
85
85
  }
86
+
87
+ // when selecting a file, selection is on media
88
+ // need to find media group and return its pos
89
+ if (selection instanceof _state.NodeSelection) {
90
+ if (selection.node.type === nodes.media) {
91
+ var mediaGroup = (0, _utils.findParentNodeOfType)(nodes.mediaGroup)(selection);
92
+ if (mediaGroup) {
93
+ var _$from = selection.$from.doc.resolve(mediaGroup.pos);
94
+ var _$to = selection.$from.doc.resolve(mediaGroup.pos + mediaGroup.node.nodeSize);
95
+ return {
96
+ $from: _$from,
97
+ $to: _$to
98
+ };
99
+ }
100
+ }
101
+ }
86
102
  return (0, _selection.expandToBlockRange)(selection.$from, selection.$to, function (node) {
87
103
  if (nodesNeedToExpandRange.includes(node.type)) {
88
104
  return false;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapIntoListStep = void 0;
7
+ /** wrap nodes into bullet list or numbered list, does not work for task list */
8
+ var wrapIntoListStep = exports.wrapIntoListStep = function wrapIntoListStep(nodes, context) {
9
+ var schema = context.schema,
10
+ 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;
17
+ };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.transformNode = void 0;
7
7
  var _model = require("@atlaskit/editor-prosemirror/model");
8
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
9
  var _isNestedNode = require("../ui/utils/isNestedNode");
9
10
  var _transform = require("./transform-node-utils/transform");
10
11
  var _utils = require("./transform-node-utils/utils");
@@ -20,7 +21,9 @@ var transformNode = exports.transformNode = function transformNode(api) {
20
21
  if (!preservedSelection) {
21
22
  return tr;
22
23
  }
23
- var _expandSelectionToBlo = (0, _utils.expandSelectionToBlockRange)(preservedSelection, tr.doc.type.schema),
24
+ var schema = tr.doc.type.schema;
25
+ var nodes = schema.nodes;
26
+ var _expandSelectionToBlo = (0, _utils.expandSelectionToBlockRange)(preservedSelection, schema),
24
27
  $from = _expandSelectionToBlo.$from,
25
28
  $to = _expandSelectionToBlo.$to;
26
29
  var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
@@ -39,9 +42,15 @@ var transformNode = exports.transformNode = function transformNode(api) {
39
42
  fragment = fragment.append(_model.Fragment.fromArray(outputNode));
40
43
  }
41
44
  });
42
-
43
- // TODO: ED-12345 - selection is broken post transaction, to fix.
44
- tr.replaceWith(isList ? $from.pos - 1 : $from.pos, $to.pos, fragment);
45
+ var nodesToDeleteAndInsert = [nodes.mediaSingle];
46
+ if (preservedSelection instanceof _state.NodeSelection && nodesToDeleteAndInsert.includes(preservedSelection.node.type)) {
47
+ // when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
48
+ tr.deleteRange($from.pos, $to.pos);
49
+ tr.insert($from.pos, fragment);
50
+ } else {
51
+ // TODO: ED-12345 - selection is broken post transaction, to fix.
52
+ tr.replaceWith(isList ? $from.pos - 1 : $from.pos, $to.pos, fragment);
53
+ }
45
54
  return tr;
46
55
  };
47
56
  }
@@ -48,17 +48,7 @@
48
48
  export const createBlockMenuRegistry = () => {
49
49
  const components = [];
50
50
  const register = blockMenuComponents => {
51
- blockMenuComponents.forEach(newComponent => {
52
- // Find if a component with the same key already exists
53
- const existingIndex = components.findIndex(comp => comp.key === newComponent.key);
54
- if (existingIndex !== -1) {
55
- // Replace the existing component
56
- components[existingIndex] = newComponent;
57
- } else {
58
- // Add new component
59
- components.push(newComponent);
60
- }
61
- });
51
+ components.push(...blockMenuComponents);
62
52
  };
63
53
  return {
64
54
  register,
@@ -1,4 +1,3 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
1
  import { isListType } from '../utils';
3
2
 
4
3
  /**
@@ -29,7 +28,8 @@ export const listToDecisionListStep = (nodes, context) => {
29
28
  schema
30
29
  } = context;
31
30
  const paragraphType = schema.nodes.paragraph;
32
- return nodes.map(node => {
31
+ const unsupportedContent = [];
32
+ const transformedNodes = nodes.map(node => {
33
33
  if (!isListType(node, schema)) {
34
34
  return node;
35
35
  }
@@ -39,20 +39,18 @@ export const listToDecisionListStep = (nodes, context) => {
39
39
  item.forEach(child => {
40
40
  if (child.type === paragraphType) {
41
41
  // paragraph may contain hard breaks etc.
42
- child.content.forEach(inline => {
43
- itemContent.push(inline);
44
- });
45
- } else {
42
+ itemContent.push(...child.children);
43
+ } else if (child.isText) {
46
44
  itemContent.push(child);
45
+ } else if (!isListType(child, schema)) {
46
+ unsupportedContent.push(child);
47
47
  }
48
- // TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
49
48
  });
50
- const decisionItem = schema.nodes.decisionItem.create({}, Fragment.from(itemContent));
51
- if (decisionItem) {
52
- decisionItems.push(decisionItem);
53
- }
49
+ const decisionItem = schema.nodes.decisionItem.create({}, itemContent);
50
+ decisionItems.push(decisionItem);
54
51
  });
55
- const decisionList = schema.nodes.decisionList.create({}, Fragment.from(decisionItems));
52
+ const decisionList = schema.nodes.decisionList.create({}, decisionItems);
56
53
  return decisionList || node;
57
54
  });
55
+ return [...transformedNodes, ...unsupportedContent];
58
56
  };