@atlaskit/editor-plugin-block-menu 1.0.3 → 1.0.5

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 (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/editor-commands/formatNode.js +1 -1
  3. package/dist/cjs/editor-commands/transforms/layout-transforms.js +30 -0
  4. package/dist/cjs/editor-commands/transforms/list/transformBetweenListTypes.js +65 -63
  5. package/dist/cjs/editor-commands/transforms/list-transforms.js +97 -30
  6. package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +4 -0
  7. package/dist/cjs/editor-commands/transforms/utils.js +23 -2
  8. package/dist/cjs/ui/block-menu-components.js +2 -1
  9. package/dist/es2019/editor-commands/formatNode.js +1 -1
  10. package/dist/es2019/editor-commands/transforms/layout-transforms.js +25 -0
  11. package/dist/es2019/editor-commands/transforms/list/transformBetweenListTypes.js +67 -62
  12. package/dist/es2019/editor-commands/transforms/list-transforms.js +97 -27
  13. package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +5 -1
  14. package/dist/es2019/editor-commands/transforms/utils.js +22 -1
  15. package/dist/es2019/ui/block-menu-components.js +2 -1
  16. package/dist/esm/editor-commands/formatNode.js +1 -1
  17. package/dist/esm/editor-commands/transforms/layout-transforms.js +24 -0
  18. package/dist/esm/editor-commands/transforms/list/transformBetweenListTypes.js +66 -63
  19. package/dist/esm/editor-commands/transforms/list-transforms.js +92 -26
  20. package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +5 -1
  21. package/dist/esm/editor-commands/transforms/utils.js +22 -1
  22. package/dist/esm/ui/block-menu-components.js +2 -1
  23. package/dist/types/editor-commands/transforms/layout-transforms.d.ts +2 -0
  24. package/dist/types/editor-commands/transforms/list/transformBetweenListTypes.d.ts +3 -7
  25. package/dist/types/editor-commands/transforms/list-transforms.d.ts +5 -1
  26. package/dist/types/editor-commands/transforms/transformNodeToTargetType.d.ts +1 -1
  27. package/dist/types/editor-commands/transforms/types.d.ts +2 -2
  28. package/dist/types/editor-commands/transforms/utils.d.ts +5 -0
  29. package/dist/types-ts4.5/editor-commands/transforms/layout-transforms.d.ts +2 -0
  30. package/dist/types-ts4.5/editor-commands/transforms/list/transformBetweenListTypes.d.ts +3 -7
  31. package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +5 -1
  32. package/dist/types-ts4.5/editor-commands/transforms/transformNodeToTargetType.d.ts +1 -1
  33. package/dist/types-ts4.5/editor-commands/transforms/types.d.ts +2 -2
  34. package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +5 -0
  35. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 1.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b76a419d23d3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b76a419d23d3d) -
8
+ [ux] ED-29143 Transform nodes into layout
9
+ - [`0d741324d534a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0d741324d534a) -
10
+ [ux] Adds wrapping of list node types in container node types.
11
+ - Updated dependencies
12
+
13
+ ## 1.0.4
14
+
15
+ ### Patch Changes
16
+
17
+ - [`30454d0f4baf2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/30454d0f4baf2) -
18
+ Support multiple levels list to list transform
19
+ - [`cb4decb701766`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cb4decb701766) -
20
+ [ux] Enable max height on block menu flyout menu
21
+ - Updated dependencies
22
+
3
23
  ## 1.0.3
4
24
 
5
25
  ### Patch Changes
@@ -18,7 +18,7 @@ var formatNode = exports.formatNode = function formatNode(targetType) {
18
18
 
19
19
  // Find the node to format from the current selection
20
20
  var nodeToFormat;
21
- var nodePos = null;
21
+ var nodePos = selection.from;
22
22
 
23
23
  // Try to find the current node from selection
24
24
  var selectedNode = (0, _utils.findSelectedNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.expand, nodes.codeBlock, nodes.bulletList, nodes.orderedList, nodes.taskList, nodes.layoutSection])(selection);
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertToLayout = void 0;
7
+ var _styles = require("@atlaskit/editor-common/styles");
8
+ var _model = require("@atlaskit/editor-prosemirror/model");
9
+ var convertToLayout = exports.convertToLayout = function convertToLayout(context) {
10
+ var tr = context.tr,
11
+ sourceNode = context.sourceNode,
12
+ sourcePos = context.sourcePos;
13
+ var _ref = tr.doc.type.schema.nodes || {},
14
+ layoutSection = _ref.layoutSection,
15
+ layoutColumn = _ref.layoutColumn,
16
+ paragraph = _ref.paragraph;
17
+ var content = sourceNode.mark(sourceNode.marks.filter(function (mark) {
18
+ return mark.type.name !== 'breakout';
19
+ }));
20
+ var layoutContent = _model.Fragment.fromArray([layoutColumn.createChecked({
21
+ width: _styles.DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
22
+ }, content), layoutColumn.create({
23
+ width: _styles.DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
24
+ }, paragraph.createAndFill())]);
25
+ var layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
26
+
27
+ // Replace the original node with the new layout node
28
+ tr.replaceRangeWith(sourcePos || 0, (sourcePos || 0) + sourceNode.nodeSize, layoutSectionNode);
29
+ return tr;
30
+ };
@@ -6,91 +6,93 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.transformListStructure = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _utils = require("../utils");
9
10
  /**
10
11
  * Convert a block node to inline content suitable for task items
11
12
  */
12
13
  var convertBlockToInlineContent = function convertBlockToInlineContent(node, schema) {
13
14
  var paragraph = schema.nodes.paragraph;
14
15
  if (node.type === paragraph) {
15
- // Extract inline content from paragraphs
16
16
  return (0, _toConsumableArray2.default)(node.content.content);
17
- } else if (node.isBlock) {
18
- // For other block content types eg. codeBlock, extract their text content and create text nodes
17
+ }
18
+ if (node.isBlock) {
19
19
  var textContent = node.textContent;
20
- if (textContent) {
21
- var textNode = schema.text(textContent);
22
- return [textNode];
23
- }
24
- } else {
25
- // Already inline content, add directly
26
- return [node];
20
+ return textContent ? [schema.text(textContent)] : [];
27
21
  }
28
- return [];
22
+ return [node];
29
23
  };
30
24
 
31
25
  /**
32
- * Transform list structure
26
+ * Transform list structure between different list types
33
27
  */
34
- var transformListStructure = exports.transformListStructure = function transformListStructure(tr, listNode, targetNodeType, nodes) {
28
+ var transformListStructure = exports.transformListStructure = function transformListStructure(context) {
29
+ var tr = context.tr,
30
+ sourceNode = context.sourceNode,
31
+ sourcePos = context.sourcePos,
32
+ targetNodeType = context.targetNodeType;
33
+ var nodes = tr.doc.type.schema.nodes;
35
34
  try {
35
+ var listNode = {
36
+ node: sourceNode,
37
+ pos: sourcePos
38
+ };
36
39
  var sourceList = listNode.node,
37
40
  listPos = listNode.pos;
38
- var bulletList = nodes.bulletList,
39
- orderedList = nodes.orderedList,
40
- taskList = nodes.taskList,
41
+ var taskList = nodes.taskList,
41
42
  listItem = nodes.listItem,
42
43
  taskItem = nodes.taskItem,
43
44
  paragraph = nodes.paragraph;
44
- var isSourceBulletOrOrdered = sourceList.type === bulletList || sourceList.type === orderedList;
45
- var isTargetTask = targetNodeType === taskList;
46
- var isSourceTask = sourceList.type === taskList;
47
- var newListItems = [];
48
- var listStart = listPos;
49
- var listEnd = listPos + sourceList.nodeSize;
50
-
51
- // Use nodesBetween to efficiently traverse the list structure
52
- tr.doc.nodesBetween(listStart, listEnd, function (node, pos, parent) {
53
- // Only process direct children of the list (depth 1)
54
- if (parent !== sourceList) {
55
- return true; // Continue traversal
56
- }
57
- if (isSourceBulletOrOrdered && isTargetTask) {
58
- // Converting from bullet/ordered list to task list
59
- // Extract inline content from all children within listItem
60
- if (node.type === listItem) {
61
- var inlineContent = [];
62
- // Extract inline content from all child nodes
63
- node.forEach(function (child) {
64
- inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(convertBlockToInlineContent(child, tr.doc.type.schema)));
65
- });
66
- if (inlineContent.length > 0) {
67
- var newItem = taskItem.create(null, inlineContent);
68
- newListItems.push(newItem);
45
+ var isSourceBulletOrOrdered = (0, _utils.isBulletOrOrderedList)(sourceList.type);
46
+ var isTargetTask = (0, _utils.isTaskList)(targetNodeType);
47
+ var isSourceTask = (0, _utils.isTaskList)(sourceList.type);
48
+ var isTargetBulletOrOrdered = (0, _utils.isBulletOrOrderedList)(targetNodeType);
49
+ var supportedListTypes = (0, _utils.getSupportedListTypesSet)(nodes);
50
+ var _transformListRecursively = function transformListRecursively(listNode) {
51
+ var transformedItems = [];
52
+ listNode.forEach(function (child) {
53
+ if (isSourceBulletOrOrdered && isTargetTask) {
54
+ // Convert bullet/ordered => task
55
+ if (child.type === listItem) {
56
+ var inlineContent = [];
57
+ var nestedTaskLists = [];
58
+ child.forEach(function (grandChild) {
59
+ if (supportedListTypes.has(grandChild.type) && grandChild.type !== taskList) {
60
+ nestedTaskLists.push(_transformListRecursively(grandChild));
61
+ } else {
62
+ inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(convertBlockToInlineContent(grandChild, tr.doc.type.schema)));
63
+ }
64
+ });
65
+ if (inlineContent.length > 0) {
66
+ transformedItems.push(taskItem.create(null, inlineContent));
67
+ }
68
+ transformedItems.push.apply(transformedItems, nestedTaskLists);
69
69
  }
70
- }
71
- } else if (isSourceTask && !isTargetTask) {
72
- // Converting from task list to bullet/ordered list
73
- // Structure: taskItem > inline content -> listItem > paragraph > inline content
74
- if (node.type === taskItem) {
75
- var _inlineContent = (0, _toConsumableArray2.default)(node.content.content);
76
- if (_inlineContent.length > 0) {
77
- var paragraphNode = paragraph.create(null, _inlineContent);
78
- var newListItem = listItem.create(null, paragraphNode);
79
- newListItems.push(newListItem);
70
+ } else if (isSourceTask && isTargetBulletOrOrdered) {
71
+ // Convert task => bullet/ordered
72
+ if (child.type === taskItem) {
73
+ var _inlineContent = (0, _toConsumableArray2.default)(child.content.content);
74
+ if (_inlineContent.length > 0) {
75
+ var paragraphNode = paragraph.create(null, _inlineContent);
76
+ transformedItems.push(listItem.create(null, [paragraphNode]));
77
+ }
78
+ } else if (child.type === taskList) {
79
+ var transformedNestedList = _transformListRecursively(child);
80
+ var lastItem = transformedItems[transformedItems.length - 1];
81
+ if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === listItem) {
82
+ // Attach nested list to previous item
83
+ var updatedContent = [].concat((0, _toConsumableArray2.default)(lastItem.content.content), [transformedNestedList]);
84
+ transformedItems[transformedItems.length - 1] = listItem.create(lastItem.attrs, updatedContent);
85
+ } else {
86
+ // No previous item, flatten nested items
87
+ transformedItems.push.apply(transformedItems, (0, _toConsumableArray2.default)(transformedNestedList.content.content));
88
+ }
80
89
  }
81
90
  }
82
- }
83
- return false; // Don't traverse into children of list items
84
- });
85
- if (newListItems.length === 0) {
86
- return tr;
87
- }
88
-
89
- // Create new list with transformed items
90
- var newList = targetNodeType.create(null, newListItems);
91
-
92
- // Replace the entire list
93
- tr.replaceWith(listStart, listEnd, newList);
91
+ });
92
+ return targetNodeType.create(null, transformedItems);
93
+ };
94
+ var newList = _transformListRecursively(sourceList);
95
+ tr.replaceWith(listPos, listPos + sourceList.nodeSize, newList);
94
96
  return tr;
95
97
  } catch (_unused) {
96
98
  return tr;
@@ -1,16 +1,18 @@
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
- exports.transformListToBlockNodes = exports.transformListNode = exports.transformBlockToList = exports.transformBetweenListTypes = exports.liftListToBlockType = void 0;
7
+ exports.transformListToContainer = exports.transformListToBlockNodes = exports.transformListNode = exports.transformBlockToList = exports.transformBetweenListTypes = exports.liftListToBlockType = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _model = require("@atlaskit/editor-prosemirror/model");
7
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
8
- var _utils = require("@atlaskit/editor-prosemirror/utils");
9
11
  var _transformBetweenListTypes = require("./list/transformBetweenListTypes");
10
12
  var _transformOrderedUnorderedListToBlockNodes = require("./list/transformOrderedUnorderedListToBlockNodes");
11
13
  var _transformTaskListToBlockNodes = require("./list/transformTaskListToBlockNodes");
12
14
  var _transformToTaskList = require("./list/transformToTaskList");
13
- var _utils2 = require("./utils");
15
+ var _utils = require("./utils");
14
16
  /**
15
17
  * Transform selection to list type
16
18
  */
@@ -27,7 +29,7 @@ var transformBlockToList = exports.transformBlockToList = function transformBloc
27
29
  return null;
28
30
  }
29
31
  var nodes = tr.doc.type.schema.nodes;
30
- var isTargetTask = targetNodeType === nodes.taskList;
32
+ var isTargetTask = (0, _utils.isTaskList)(targetNodeType);
31
33
 
32
34
  // Handle task lists differently due to their structure
33
35
  if (isTargetTask) {
@@ -63,25 +65,79 @@ var transformListToBlockNodes = exports.transformListToBlockNodes = function tra
63
65
  }
64
66
  };
65
67
 
68
+ /**
69
+ * Wraps bulletList, orderedList or taskList in node of container type
70
+ */
71
+ var transformListToContainer = exports.transformListToContainer = function transformListToContainer(context) {
72
+ var tr = context.tr,
73
+ sourceNode = context.sourceNode,
74
+ sourcePos = context.sourcePos,
75
+ targetNodeType = context.targetNodeType,
76
+ targetAttrs = context.targetAttrs;
77
+ if (sourcePos === null) {
78
+ return null;
79
+ }
80
+ var schema = tr.doc.type.schema;
81
+ var _schema$nodes = schema.nodes,
82
+ blockquote = _schema$nodes.blockquote,
83
+ taskList = _schema$nodes.taskList,
84
+ taskItem = _schema$nodes.taskItem,
85
+ paragraph = _schema$nodes.paragraph;
86
+
87
+ // Special case: Task list -> Blockquote
88
+ // Flattens the task list before wrapping by blockquote
89
+ if (sourceNode.type === taskList && targetNodeType === blockquote) {
90
+ var _extractParagraphsFromTaskList = function extractParagraphsFromTaskList(node) {
91
+ var paragraphs = [];
92
+ node.forEach(function (child) {
93
+ if (child.type === taskItem) {
94
+ if (child.content.size > 0) {
95
+ var paragraphNode = paragraph.createChecked({}, child.content.content);
96
+ paragraphs.push(paragraphNode);
97
+ }
98
+ } else if (child.type === taskList) {
99
+ paragraphs.push.apply(paragraphs, (0, _toConsumableArray2.default)(_extractParagraphsFromTaskList(child)));
100
+ }
101
+ });
102
+ return paragraphs;
103
+ };
104
+ var liftedParagraphs = _extractParagraphsFromTaskList(sourceNode);
105
+ var _containerNode = targetNodeType.createAndFill(targetAttrs, _model.Fragment.from(liftedParagraphs));
106
+ if (!_containerNode) {
107
+ return null;
108
+ }
109
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, _containerNode);
110
+ return tr;
111
+ }
112
+
113
+ // Default case
114
+ var containerNode = targetNodeType.createAndFill(targetAttrs, [sourceNode]);
115
+ if (!containerNode) {
116
+ return null;
117
+ }
118
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
119
+ return tr;
120
+ };
121
+
66
122
  /**
67
123
  * Transform list nodes
68
124
  */
69
125
  var transformListNode = exports.transformListNode = function transformListNode(context) {
70
126
  var targetNodeType = context.targetNodeType;
71
127
  // Transform list to block type
72
- if ((0, _utils2.isBlockNodeType)(targetNodeType)) {
128
+ if ((0, _utils.isBlockNodeType)(targetNodeType)) {
73
129
  // Lift list items out of the list and convert to target block type
74
130
  return transformListToBlockNodes(context);
75
131
  }
76
132
 
77
133
  // Transform list to container type
78
- if ((0, _utils2.isContainerNodeType)(targetNodeType)) {
79
- // Lift list items out of the list and convert to container type
80
- return null;
134
+ if ((0, _utils.isContainerNodeType)(targetNodeType)) {
135
+ // Wrap list items into container type, where possible
136
+ return transformListToContainer(context);
81
137
  }
82
138
 
83
139
  // Transform between list types
84
- if ((0, _utils2.isListNodeType)(targetNodeType)) {
140
+ if ((0, _utils.isListNodeType)(targetNodeType)) {
85
141
  return transformBetweenListTypes(context);
86
142
  }
87
143
  return null;
@@ -98,37 +154,48 @@ var liftListToBlockType = exports.liftListToBlockType = function liftListToBlock
98
154
  /**
99
155
  * Transform between different list types
100
156
  */
101
- var transformBetweenListTypes = exports.transformBetweenListTypes = function transformBetweenListTypes(_ref) {
102
- var tr = _ref.tr,
103
- targetNodeType = _ref.targetNodeType;
104
- var _tr = tr,
105
- selection = _tr.selection;
157
+ var transformBetweenListTypes = exports.transformBetweenListTypes = function transformBetweenListTypes(context) {
158
+ var tr = context.tr,
159
+ sourceNode = context.sourceNode,
160
+ sourcePos = context.sourcePos,
161
+ targetNodeType = context.targetNodeType;
106
162
  var nodes = tr.doc.type.schema.nodes;
107
-
108
- // Find the list node - support bullet lists, ordered lists, and task lists
109
- var supportedListTypes = [nodes.bulletList, nodes.orderedList, nodes.taskList].filter(Boolean); // Filter out undefined nodes in case some schemas don't have all types
110
-
111
- var listNode = (0, _utils.findParentNodeOfType)(supportedListTypes)(selection);
112
- if (!listNode) {
113
- return null;
114
- }
115
- var sourceListType = listNode.node.type;
116
- var isSourceBulletOrOrdered = sourceListType === nodes.bulletList || sourceListType === nodes.orderedList;
117
- var isTargetTask = targetNodeType === nodes.taskList;
118
- var isSourceTask = sourceListType === nodes.taskList;
119
- var isTargetBulletOrOrdered = targetNodeType === nodes.bulletList || targetNodeType === nodes.orderedList;
163
+ var sourceListType = sourceNode.type;
164
+ var isSourceBulletOrOrdered = (0, _utils.isBulletOrOrderedList)(sourceListType);
165
+ var isTargetTask = (0, _utils.isTaskList)(targetNodeType);
166
+ var isSourceTask = (0, _utils.isTaskList)(sourceListType);
167
+ var isTargetBulletOrOrdered = (0, _utils.isBulletOrOrderedList)(targetNodeType);
120
168
 
121
169
  // Check if we need structure transformation
122
170
  var needsStructureTransform = isSourceBulletOrOrdered && isTargetTask || isSourceTask && isTargetBulletOrOrdered;
123
171
  try {
124
172
  if (!needsStructureTransform) {
125
173
  // Simple type change for same structure lists (bullet <-> ordered)
126
- tr.setNodeMarkup(listNode.pos, targetNodeType);
174
+ // Apply to the main list
175
+ tr.setNodeMarkup(sourcePos, targetNodeType);
176
+
177
+ // Apply to nested lists
178
+ var listStart = sourcePos;
179
+ var listEnd = sourcePos + sourceNode.nodeSize;
180
+ var supportedListTypesSet = (0, _utils.getSupportedListTypesSet)(nodes);
181
+ tr.doc.nodesBetween(listStart, listEnd, function (node, pos, parent) {
182
+ // Only process nested lists (not the root list we already handled)
183
+ if (supportedListTypesSet.has(node.type) && pos !== sourcePos) {
184
+ var isNestedList = parent && (supportedListTypesSet.has(parent.type) || parent.type === nodes.listItem);
185
+ if (isNestedList) {
186
+ var shouldTransformNode = node.type === sourceListType || (0, _utils.isBulletOrOrderedList)(node.type) && isTargetBulletOrOrdered;
187
+ if (shouldTransformNode) {
188
+ tr.setNodeMarkup(pos, targetNodeType);
189
+ }
190
+ }
191
+ }
192
+ return true; // Continue traversing
193
+ });
194
+ return tr;
127
195
  } else {
128
- tr = (0, _transformBetweenListTypes.transformListStructure)(tr, listNode, targetNodeType, nodes);
196
+ return (0, _transformBetweenListTypes.transformListStructure)(context);
129
197
  }
130
198
  } catch (_unused) {
131
199
  return null;
132
200
  }
133
- return tr;
134
201
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.transformNodeToTargetType = transformNodeToTargetType;
7
7
  var _blockTransforms = require("./block-transforms");
8
8
  var _containerTransforms = require("./container-transforms");
9
+ var _layoutTransforms = require("./layout-transforms");
9
10
  var _listTransforms = require("./list-transforms");
10
11
  var _utils = require("./utils");
11
12
  function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
@@ -43,6 +44,9 @@ function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
43
44
 
44
45
  // Route to appropriate transformation strategy based on source node type
45
46
  try {
47
+ if ((0, _utils.isLayoutNodeType)(targetNodeType)) {
48
+ return (0, _layoutTransforms.convertToLayout)(transformationContext);
49
+ }
46
50
  if ((0, _utils.isBlockNode)(sourceNode)) {
47
51
  return (0, _blockTransforms.transformBlockNode)(transformationContext);
48
52
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isListNodeType = exports.isListNode = exports.isContainerNodeType = exports.isContainerNode = exports.isBlockNodeType = exports.isBlockNode = exports.getTargetNodeInfo = void 0;
6
+ exports.isTaskList = exports.isListNodeType = exports.isListNode = exports.isLayoutNodeType = exports.isContainerNodeType = exports.isContainerNode = exports.isBulletOrOrderedList = exports.isBlockNodeType = exports.isBlockNode = exports.getTargetNodeInfo = exports.getSupportedListTypesSet = exports.getSupportedListTypes = void 0;
7
7
  var getTargetNodeInfo = exports.getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
8
8
  switch (targetType) {
9
9
  case 'heading1':
@@ -83,6 +83,10 @@ var getTargetNodeInfo = exports.getTargetNodeInfo = function getTargetNodeInfo(t
83
83
  return {
84
84
  nodeType: nodes.taskList
85
85
  };
86
+ case 'layoutSection':
87
+ return {
88
+ nodeType: nodes.layoutSection
89
+ };
86
90
  default:
87
91
  return null;
88
92
  }
@@ -93,7 +97,7 @@ var isBlockNode = exports.isBlockNode = function isBlockNode(node) {
93
97
  return ['paragraph', 'heading', 'codeBlock'].includes(node.type.name);
94
98
  };
95
99
  var isListNode = exports.isListNode = function isListNode(node) {
96
- return ['bulletList', 'orderedList', 'taskList', 'listItem'].includes(node.type.name);
100
+ return ['bulletList', 'orderedList', 'taskList'].includes(node.type.name);
97
101
  };
98
102
  var isContainerNode = exports.isContainerNode = function isContainerNode(node) {
99
103
  return ['panel', 'expand', 'blockquote'].includes(node.type.name);
@@ -106,4 +110,21 @@ var isListNodeType = exports.isListNodeType = function isListNodeType(nodeType)
106
110
  };
107
111
  var isContainerNodeType = exports.isContainerNodeType = function isContainerNodeType(nodeType) {
108
112
  return ['panel', 'expand', 'blockquote'].includes(nodeType.name);
113
+ };
114
+
115
+ // List type utilities
116
+ var isBulletOrOrderedList = exports.isBulletOrOrderedList = function isBulletOrOrderedList(nodeType) {
117
+ return nodeType.name === 'bulletList' || nodeType.name === 'orderedList';
118
+ };
119
+ var isTaskList = exports.isTaskList = function isTaskList(nodeType) {
120
+ return nodeType.name === 'taskList';
121
+ };
122
+ var getSupportedListTypes = exports.getSupportedListTypes = function getSupportedListTypes(nodes) {
123
+ return [nodes.bulletList, nodes.orderedList, nodes.taskList].filter(Boolean);
124
+ };
125
+ var getSupportedListTypesSet = exports.getSupportedListTypesSet = function getSupportedListTypesSet(nodes) {
126
+ return new Set(getSupportedListTypes(nodes));
127
+ };
128
+ var isLayoutNodeType = exports.isLayoutNodeType = function isLayoutNodeType(nodeType) {
129
+ return nodeType.name === 'layoutSection';
109
130
  };
@@ -66,7 +66,8 @@ var getFormatMenuComponents = function getFormatMenuComponents() {
66
66
  }),
67
67
  elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
68
68
  label: 'example nested menu'
69
- })
69
+ }),
70
+ enableMaxHeight: true
70
71
  }, children);
71
72
  }
72
73
  }, {
@@ -17,7 +17,7 @@ export const formatNode = targetType => {
17
17
 
18
18
  // Find the node to format from the current selection
19
19
  let nodeToFormat;
20
- let nodePos = null;
20
+ let nodePos = selection.from;
21
21
 
22
22
  // Try to find the current node from selection
23
23
  const selectedNode = findSelectedNodeOfType([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.expand, nodes.codeBlock, nodes.bulletList, nodes.orderedList, nodes.taskList, nodes.layoutSection])(selection);
@@ -0,0 +1,25 @@
1
+ import { DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH } from '@atlaskit/editor-common/styles';
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ export const convertToLayout = context => {
4
+ const {
5
+ tr,
6
+ sourceNode,
7
+ sourcePos
8
+ } = context;
9
+ const {
10
+ layoutSection,
11
+ layoutColumn,
12
+ paragraph
13
+ } = tr.doc.type.schema.nodes || {};
14
+ const content = sourceNode.mark(sourceNode.marks.filter(mark => mark.type.name !== 'breakout'));
15
+ const layoutContent = Fragment.fromArray([layoutColumn.createChecked({
16
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
17
+ }, content), layoutColumn.create({
18
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
19
+ }, paragraph.createAndFill())]);
20
+ const layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
21
+
22
+ // Replace the original node with the new layout node
23
+ tr.replaceRangeWith(sourcePos || 0, (sourcePos || 0) + sourceNode.nodeSize, layoutSectionNode);
24
+ return tr;
25
+ };