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

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 (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/editor-commands/formatNode.js +1 -1
  3. package/dist/cjs/editor-commands/transforms/container-transforms.js +60 -4
  4. package/dist/cjs/editor-commands/transforms/list/transformBetweenListTypes.js +22 -26
  5. package/dist/cjs/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +54 -0
  6. package/dist/cjs/editor-commands/transforms/list/transformTaskListToBlockNodes.js +59 -0
  7. package/dist/cjs/editor-commands/transforms/list/transformToTaskList.js +44 -0
  8. package/dist/cjs/editor-commands/transforms/list-transforms.js +19 -5
  9. package/dist/cjs/ui/block-menu.compiled.css +1 -1
  10. package/dist/cjs/ui/block-menu.js +1 -1
  11. package/dist/es2019/editor-commands/formatNode.js +1 -1
  12. package/dist/es2019/editor-commands/transforms/container-transforms.js +64 -4
  13. package/dist/es2019/editor-commands/transforms/list/transformBetweenListTypes.js +24 -26
  14. package/dist/es2019/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +42 -0
  15. package/dist/es2019/editor-commands/transforms/list/transformTaskListToBlockNodes.js +47 -0
  16. package/dist/es2019/editor-commands/transforms/list/transformToTaskList.js +38 -0
  17. package/dist/es2019/editor-commands/transforms/list-transforms.js +20 -4
  18. package/dist/es2019/ui/block-menu.compiled.css +1 -1
  19. package/dist/es2019/ui/block-menu.js +1 -1
  20. package/dist/esm/editor-commands/formatNode.js +1 -1
  21. package/dist/esm/editor-commands/transforms/container-transforms.js +60 -4
  22. package/dist/esm/editor-commands/transforms/list/transformBetweenListTypes.js +22 -26
  23. package/dist/esm/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +48 -0
  24. package/dist/esm/editor-commands/transforms/list/transformTaskListToBlockNodes.js +53 -0
  25. package/dist/esm/editor-commands/transforms/list/transformToTaskList.js +37 -0
  26. package/dist/esm/editor-commands/transforms/list-transforms.js +18 -4
  27. package/dist/esm/ui/block-menu.compiled.css +1 -1
  28. package/dist/esm/ui/block-menu.js +1 -1
  29. package/dist/types/editor-commands/transforms/container-transforms.d.ts +1 -1
  30. package/dist/types/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.d.ts +3 -0
  31. package/dist/types/editor-commands/transforms/list/transformTaskListToBlockNodes.d.ts +3 -0
  32. package/dist/types/editor-commands/transforms/list/transformToTaskList.d.ts +10 -0
  33. package/dist/types/editor-commands/transforms/list-transforms.d.ts +4 -0
  34. package/dist/types-ts4.5/editor-commands/transforms/container-transforms.d.ts +1 -1
  35. package/dist/types-ts4.5/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.d.ts +3 -0
  36. package/dist/types-ts4.5/editor-commands/transforms/list/transformTaskListToBlockNodes.d.ts +3 -0
  37. package/dist/types-ts4.5/editor-commands/transforms/list/transformToTaskList.d.ts +10 -0
  38. package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +4 -0
  39. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
+ export const transformTaskListToBlockNodes = context => {
4
+ const {
5
+ tr,
6
+ targetNodeType,
7
+ targetAttrs,
8
+ sourceNode,
9
+ sourcePos
10
+ } = context;
11
+ const {
12
+ selection
13
+ } = tr;
14
+ const schema = selection.$from.doc.type.schema;
15
+ const taskItemsResult = findChildrenByType(sourceNode, schema.nodes.taskItem);
16
+ const taskItems = taskItemsResult.map(item => item.node);
17
+ const taskItemFragments = taskItems.map(taskItem => taskItem.content);
18
+ let targetNodes = [];
19
+
20
+ // Convert fragments to headings if target is heading
21
+ if (targetNodeType === schema.nodes.heading && targetAttrs) {
22
+ // convert the fragments to headings
23
+ const targetHeadingLevel = targetAttrs.level;
24
+ targetNodes = taskItemFragments.map(fragment => schema.nodes.heading.createChecked({
25
+ level: targetHeadingLevel
26
+ }, fragment.content));
27
+ }
28
+
29
+ // Convert fragments to paragraphs if target is paragraphs
30
+ if (targetNodeType === schema.nodes.paragraph) {
31
+ // convert the fragments to paragraphs
32
+ targetNodes = taskItemFragments.map(fragment => schema.nodes.paragraph.createChecked({}, fragment.content));
33
+ }
34
+
35
+ // Convert fragments to code block if target is code block
36
+ if (targetNodeType === schema.nodes.codeBlock) {
37
+ // convert the fragments to one code block
38
+ const codeBlockContent = taskItemFragments.map(fragment => fragment.textBetween(0, fragment.size, '\n')).join('\n');
39
+ targetNodes = [schema.nodes.codeBlock.createChecked({}, schema.text(codeBlockContent))];
40
+ }
41
+
42
+ // Replace the task list node with the new content in the transaction
43
+ const slice = new Slice(Fragment.fromArray(targetNodes), 0, 0);
44
+ const rangeStart = sourcePos !== null ? sourcePos : selection.from;
45
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
46
+ return tr;
47
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Transform selection to task list
3
+ * Handles the special structure where taskItem contains text directly (no paragraph wrapper)
4
+ */
5
+ export const transformToTaskList = (tr, range, targetNodeType, targetAttrs, nodes) => {
6
+ try {
7
+ const {
8
+ taskItem
9
+ } = nodes;
10
+ const listItems = [];
11
+
12
+ // Process each block in the range
13
+ tr.doc.nodesBetween(range.start, range.end, node => {
14
+ if (node.isBlock) {
15
+ // For block nodes like paragraphs, directly use their inline content
16
+ const inlineContent = [...node.content.content];
17
+ if (inlineContent.length > 0) {
18
+ // Create task item with inline content directly
19
+ const listItem = taskItem.create(targetAttrs, inlineContent);
20
+ listItems.push(listItem);
21
+ }
22
+ }
23
+ return false; // Don't traverse into children
24
+ });
25
+ if (listItems.length === 0) {
26
+ return null;
27
+ }
28
+
29
+ // Create the new task list
30
+ const newList = targetNodeType.create(targetAttrs, listItems);
31
+
32
+ // Replace the range with the new list
33
+ tr.replaceWith(range.start, range.end, newList);
34
+ return tr;
35
+ } catch {
36
+ return null;
37
+ }
38
+ };
@@ -1,6 +1,9 @@
1
1
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
2
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { transformListStructure } from './list/transformBetweenListTypes';
4
+ import { transformOrderedUnorderedListToBlockNodes } from './list/transformOrderedUnorderedListToBlockNodes';
5
+ import { transformTaskListToBlockNodes } from './list/transformTaskListToBlockNodes';
6
+ import { transformToTaskList } from './list/transformToTaskList';
4
7
  import { isBlockNodeType, isContainerNodeType, isListNodeType } from './utils';
5
8
 
6
9
  /**
@@ -9,6 +12,7 @@ import { isBlockNodeType, isContainerNodeType, isListNodeType } from './utils';
9
12
  export const transformBlockToList = context => {
10
13
  const {
11
14
  tr,
15
+ sourceNode,
12
16
  targetNodeType,
13
17
  targetAttrs
14
18
  } = context;
@@ -26,13 +30,11 @@ export const transformBlockToList = context => {
26
30
  const isTargetTask = targetNodeType === nodes.taskList;
27
31
 
28
32
  // Handle task lists differently due to their structure
29
- // TODO: ED-29152 - Implement task list transformation
30
33
  if (isTargetTask) {
31
- return null;
34
+ return transformToTaskList(tr, range, targetNodeType, targetAttrs, nodes);
32
35
  }
33
36
 
34
37
  // For headings, convert to paragraph first since headings cannot be direct children of list items
35
- const sourceNode = tr.doc.nodeAt(range.start);
36
38
  if (sourceNode && sourceNode.type.name.startsWith('heading')) {
37
39
  tr.setBlockType(range.start, range.end, nodes.paragraph);
38
40
  }
@@ -49,6 +51,20 @@ export const transformBlockToList = context => {
49
51
  return tr;
50
52
  };
51
53
 
54
+ /**
55
+ * Transform list to block nodes
56
+ */
57
+ export const transformListToBlockNodes = context => {
58
+ const {
59
+ sourceNode
60
+ } = context;
61
+ if (sourceNode.type.name === 'taskList') {
62
+ return transformTaskListToBlockNodes(context);
63
+ } else {
64
+ return transformOrderedUnorderedListToBlockNodes(context);
65
+ }
66
+ };
67
+
52
68
  /**
53
69
  * Transform list nodes
54
70
  */
@@ -59,7 +75,7 @@ export const transformListNode = context => {
59
75
  // Transform list to block type
60
76
  if (isBlockNodeType(targetNodeType)) {
61
77
  // Lift list items out of the list and convert to target block type
62
- return null;
78
+ return transformListToBlockNodes(context);
63
79
  }
64
80
 
65
81
  // Transform list to container type
@@ -1,3 +1,3 @@
1
1
 
2
- ._2rkoglpi{border-radius:var(--ds-border-radius,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
3
3
  ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
@@ -13,7 +13,7 @@ import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownM
13
13
  import { Box } from '@atlaskit/primitives/compiled';
14
14
  import { BlockMenuRenderer } from './block-menu-renderer';
15
15
  const styles = {
16
- base: "_2rkoglpi _bfhk1bhr _16qs1cd0"
16
+ base: "_2rko12b0 _bfhk1bhr _16qs1cd0"
17
17
  };
18
18
  const DEFAULT_MENU_WIDTH = 230;
19
19
  const DRAG_HANDLE_OFFSET_PADDING = 5;
@@ -34,7 +34,7 @@ export var formatNode = function formatNode(targetType) {
34
34
  nodeToFormat = listParent.node;
35
35
  nodePos = listParent.pos;
36
36
  }
37
- } else if (paragraphOrHeadingNode) {
37
+ } else if (parentNode.node.type !== nodes.blockquote && paragraphOrHeadingNode) {
38
38
  nodeToFormat = paragraphOrHeadingNode.node;
39
39
  nodePos = paragraphOrHeadingNode.pos;
40
40
  }
@@ -44,6 +44,7 @@ export var transformToContainer = function transformToContainer(_ref) {
44
44
  */
45
45
  export var transformContainerNode = function transformContainerNode(_ref2) {
46
46
  var tr = _ref2.tr,
47
+ sourceNode = _ref2.sourceNode,
47
48
  sourcePos = _ref2.sourcePos,
48
49
  targetNodeType = _ref2.targetNodeType,
49
50
  targetAttrs = _ref2.targetAttrs;
@@ -58,7 +59,13 @@ export var transformContainerNode = function transformContainerNode(_ref2) {
58
59
 
59
60
  // Transform container to list type
60
61
  if (isListNodeType(targetNodeType)) {
61
- return unwrapAndConvertToList();
62
+ return unwrapAndConvertToList({
63
+ tr: tr,
64
+ sourceNode: sourceNode,
65
+ sourcePos: sourcePos,
66
+ targetNodeType: targetNodeType,
67
+ targetAttrs: targetAttrs
68
+ });
62
69
  }
63
70
 
64
71
  // Transform between container types
@@ -80,7 +87,56 @@ export var unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType()
80
87
  /**
81
88
  * Unwrap container node and convert content to list
82
89
  */
83
- export var unwrapAndConvertToList = function unwrapAndConvertToList() {
84
- // Convert to list directly
85
- return null;
90
+ export var unwrapAndConvertToList = function unwrapAndConvertToList(_ref3) {
91
+ var tr = _ref3.tr,
92
+ sourceNode = _ref3.sourceNode,
93
+ sourcePos = _ref3.sourcePos,
94
+ targetNodeType = _ref3.targetNodeType,
95
+ targetAttrs = _ref3.targetAttrs;
96
+ if (sourcePos === null) {
97
+ return tr;
98
+ }
99
+ var schema = tr.doc.type.schema;
100
+ var _schema$nodes = schema.nodes,
101
+ listItem = _schema$nodes.listItem,
102
+ paragraph = _schema$nodes.paragraph,
103
+ taskList = _schema$nodes.taskList,
104
+ taskItem = _schema$nodes.taskItem;
105
+ var isTargetTaskList = targetNodeType === taskList;
106
+ var createListItemFromInline = function createListItemFromInline(inlineFrag) {
107
+ return isTargetTaskList ? taskItem.create(null, inlineFrag) : listItem.create(null, paragraph.create(null, inlineFrag));
108
+ };
109
+ var getInlineContent = function getInlineContent(textblock) {
110
+ var inlineContent = [];
111
+ textblock.forEach(function (inline) {
112
+ inlineContent.push(inline);
113
+ });
114
+ return inlineContent;
115
+ };
116
+ var items = [];
117
+
118
+ // Expand's title should become the first item of the list
119
+ if (sourceNode.type.name === 'expand') {
120
+ var _sourceNode$attrs;
121
+ var title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
122
+ if (title) {
123
+ var titleContent = schema.text(title);
124
+ items.push(isTargetTaskList ? taskItem.create(null, titleContent) : listItem.create(null, paragraph.create(null, titleContent)));
125
+ }
126
+ }
127
+ for (var i = 0; i < sourceNode.childCount; i++) {
128
+ var node = sourceNode.child(i);
129
+
130
+ // Abort early if unsupported content (e.g. table) encounted inside of the container
131
+ if (!node.isTextblock) {
132
+ return tr;
133
+ }
134
+ var inline = Fragment.from(getInlineContent(node));
135
+ items.push(createListItemFromInline(inline));
136
+ }
137
+ if (!items.length) {
138
+ return tr;
139
+ }
140
+ var list = targetNodeType.create(targetAttrs || null, Fragment.from(items));
141
+ return tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, list);
86
142
  };
@@ -1,13 +1,24 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  /**
3
- * Extract all inline content from a node
3
+ * Convert a block node to inline content suitable for task items
4
4
  */
5
- var extractInlineContent = function extractInlineContent(node) {
6
- var inlineContent = [];
7
- for (var i = 0; i < node.childCount; i++) {
8
- inlineContent.push(node.child(i));
5
+ var convertBlockToInlineContent = function convertBlockToInlineContent(node, schema) {
6
+ var paragraph = schema.nodes.paragraph;
7
+ if (node.type === paragraph) {
8
+ // Extract inline content from paragraphs
9
+ return _toConsumableArray(node.content.content);
10
+ } else if (node.isBlock) {
11
+ // For other block content types eg. codeBlock, extract their text content and create text nodes
12
+ var textContent = node.textContent;
13
+ if (textContent) {
14
+ var textNode = schema.text(textContent);
15
+ return [textNode];
16
+ }
17
+ } else {
18
+ // Already inline content, add directly
19
+ return [node];
9
20
  }
10
- return inlineContent;
21
+ return [];
11
22
  };
12
23
 
13
24
  /**
@@ -41,25 +52,10 @@ export var transformListStructure = function transformListStructure(tr, listNode
41
52
  // Extract inline content from all children within listItem
42
53
  if (node.type === listItem) {
43
54
  var inlineContent = [];
44
-
45
- // Extract all inline content from all child nodes
46
- for (var i = 0; i < node.childCount; i++) {
47
- var child = node.child(i);
48
- if (child.type === paragraph) {
49
- // Extract inline content from paragraphs
50
- inlineContent.push.apply(inlineContent, _toConsumableArray(extractInlineContent(child)));
51
- } else if (child.isBlock) {
52
- // For other block content types eg. codeBlock, extract their text content and create text nodes
53
- var textContent = child.textContent;
54
- if (textContent) {
55
- var textNode = tr.doc.type.schema.text(textContent);
56
- inlineContent.push(textNode);
57
- }
58
- } else {
59
- // Already inline content, add directly
60
- inlineContent.push(child);
61
- }
62
- }
55
+ // Extract inline content from all child nodes
56
+ node.forEach(function (child) {
57
+ inlineContent.push.apply(inlineContent, _toConsumableArray(convertBlockToInlineContent(child, tr.doc.type.schema)));
58
+ });
63
59
  if (inlineContent.length > 0) {
64
60
  var newItem = taskItem.create(null, inlineContent);
65
61
  newListItems.push(newItem);
@@ -69,7 +65,7 @@ export var transformListStructure = function transformListStructure(tr, listNode
69
65
  // Converting from task list to bullet/ordered list
70
66
  // Structure: taskItem > inline content -> listItem > paragraph > inline content
71
67
  if (node.type === taskItem) {
72
- var _inlineContent = extractInlineContent(node);
68
+ var _inlineContent = _toConsumableArray(node.content.content);
73
69
  if (_inlineContent.length > 0) {
74
70
  var paragraphNode = paragraph.create(null, _inlineContent);
75
71
  var newListItem = listItem.create(null, paragraphNode);
@@ -0,0 +1,48 @@
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
+ export var transformOrderedUnorderedListToBlockNodes = function transformOrderedUnorderedListToBlockNodes(context) {
4
+ var tr = context.tr,
5
+ targetNodeType = context.targetNodeType,
6
+ targetAttrs = context.targetAttrs,
7
+ sourceNode = context.sourceNode,
8
+ sourcePos = context.sourcePos;
9
+ var selection = tr.selection;
10
+ var schema = selection.$from.doc.type.schema;
11
+ // find all paragraph nodes inside the list node
12
+ var paragraphs = findChildrenByType(sourceNode, schema.nodes.paragraph);
13
+ var paragraphNodes = paragraphs.map(function (paragraph) {
14
+ return paragraph.node;
15
+ });
16
+ var targetNodes = paragraphNodes;
17
+
18
+ // Convert paragraphs to headings if target is heading
19
+ if (targetNodeType === schema.nodes.heading && targetAttrs) {
20
+ var targetHeadingLevel = targetAttrs.level;
21
+ targetNodes = paragraphNodes.map(function (paragraphNode) {
22
+ return schema.nodes.heading.createChecked({
23
+ level: targetHeadingLevel
24
+ }, paragraphNode.content);
25
+ });
26
+ }
27
+
28
+ // Convert paragraphs to code block if target is code block
29
+ if (targetNodeType === schema.nodes.codeBlock) {
30
+ // convert the paragraphNodes to one code block
31
+ var listItemsResult = findChildrenByType(sourceNode, schema.nodes.listItem);
32
+ var listItems = listItemsResult.map(function (item) {
33
+ return item.node;
34
+ });
35
+ var listItemFragments = listItems.map(function (listItem) {
36
+ return listItem.content;
37
+ });
38
+ var codeBlockContent = listItemFragments.map(function (fragment) {
39
+ return fragment.textBetween(0, fragment.size, '\n');
40
+ }).join('\n');
41
+ targetNodes = [schema.nodes.codeBlock.createChecked({}, schema.text(codeBlockContent))];
42
+ }
43
+ var fragment = Fragment.fromArray(targetNodes);
44
+ var slice = new Slice(fragment, 0, 0);
45
+ var rangeStart = sourcePos !== null ? sourcePos : selection.from;
46
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
47
+ return tr;
48
+ };
@@ -0,0 +1,53 @@
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
+ export var transformTaskListToBlockNodes = function transformTaskListToBlockNodes(context) {
4
+ var tr = context.tr,
5
+ targetNodeType = context.targetNodeType,
6
+ targetAttrs = context.targetAttrs,
7
+ sourceNode = context.sourceNode,
8
+ sourcePos = context.sourcePos;
9
+ var selection = tr.selection;
10
+ var schema = selection.$from.doc.type.schema;
11
+ var taskItemsResult = findChildrenByType(sourceNode, schema.nodes.taskItem);
12
+ var taskItems = taskItemsResult.map(function (item) {
13
+ return item.node;
14
+ });
15
+ var taskItemFragments = taskItems.map(function (taskItem) {
16
+ return taskItem.content;
17
+ });
18
+ var targetNodes = [];
19
+
20
+ // Convert fragments to headings if target is heading
21
+ if (targetNodeType === schema.nodes.heading && targetAttrs) {
22
+ // convert the fragments to headings
23
+ var targetHeadingLevel = targetAttrs.level;
24
+ targetNodes = taskItemFragments.map(function (fragment) {
25
+ return schema.nodes.heading.createChecked({
26
+ level: targetHeadingLevel
27
+ }, fragment.content);
28
+ });
29
+ }
30
+
31
+ // Convert fragments to paragraphs if target is paragraphs
32
+ if (targetNodeType === schema.nodes.paragraph) {
33
+ // convert the fragments to paragraphs
34
+ targetNodes = taskItemFragments.map(function (fragment) {
35
+ return schema.nodes.paragraph.createChecked({}, fragment.content);
36
+ });
37
+ }
38
+
39
+ // Convert fragments to code block if target is code block
40
+ if (targetNodeType === schema.nodes.codeBlock) {
41
+ // convert the fragments to one code block
42
+ var codeBlockContent = taskItemFragments.map(function (fragment) {
43
+ return fragment.textBetween(0, fragment.size, '\n');
44
+ }).join('\n');
45
+ targetNodes = [schema.nodes.codeBlock.createChecked({}, schema.text(codeBlockContent))];
46
+ }
47
+
48
+ // Replace the task list node with the new content in the transaction
49
+ var slice = new Slice(Fragment.fromArray(targetNodes), 0, 0);
50
+ var rangeStart = sourcePos !== null ? sourcePos : selection.from;
51
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
52
+ return tr;
53
+ };
@@ -0,0 +1,37 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ /**
3
+ * Transform selection to task list
4
+ * Handles the special structure where taskItem contains text directly (no paragraph wrapper)
5
+ */
6
+ export var transformToTaskList = function transformToTaskList(tr, range, targetNodeType, targetAttrs, nodes) {
7
+ try {
8
+ var taskItem = nodes.taskItem;
9
+ var listItems = [];
10
+
11
+ // Process each block in the range
12
+ tr.doc.nodesBetween(range.start, range.end, function (node) {
13
+ if (node.isBlock) {
14
+ // For block nodes like paragraphs, directly use their inline content
15
+ var inlineContent = _toConsumableArray(node.content.content);
16
+ if (inlineContent.length > 0) {
17
+ // Create task item with inline content directly
18
+ var listItem = taskItem.create(targetAttrs, inlineContent);
19
+ listItems.push(listItem);
20
+ }
21
+ }
22
+ return false; // Don't traverse into children
23
+ });
24
+ if (listItems.length === 0) {
25
+ return null;
26
+ }
27
+
28
+ // Create the new task list
29
+ var newList = targetNodeType.create(targetAttrs, listItems);
30
+
31
+ // Replace the range with the new list
32
+ tr.replaceWith(range.start, range.end, newList);
33
+ return tr;
34
+ } catch (_unused) {
35
+ return null;
36
+ }
37
+ };
@@ -1,6 +1,9 @@
1
1
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
2
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { transformListStructure } from './list/transformBetweenListTypes';
4
+ import { transformOrderedUnorderedListToBlockNodes } from './list/transformOrderedUnorderedListToBlockNodes';
5
+ import { transformTaskListToBlockNodes } from './list/transformTaskListToBlockNodes';
6
+ import { transformToTaskList } from './list/transformToTaskList';
4
7
  import { isBlockNodeType, isContainerNodeType, isListNodeType } from './utils';
5
8
 
6
9
  /**
@@ -8,6 +11,7 @@ import { isBlockNodeType, isContainerNodeType, isListNodeType } from './utils';
8
11
  */
9
12
  export var transformBlockToList = function transformBlockToList(context) {
10
13
  var tr = context.tr,
14
+ sourceNode = context.sourceNode,
11
15
  targetNodeType = context.targetNodeType,
12
16
  targetAttrs = context.targetAttrs;
13
17
  var _tr$selection = tr.selection,
@@ -21,13 +25,11 @@ export var transformBlockToList = function transformBlockToList(context) {
21
25
  var isTargetTask = targetNodeType === nodes.taskList;
22
26
 
23
27
  // Handle task lists differently due to their structure
24
- // TODO: ED-29152 - Implement task list transformation
25
28
  if (isTargetTask) {
26
- return null;
29
+ return transformToTaskList(tr, range, targetNodeType, targetAttrs, nodes);
27
30
  }
28
31
 
29
32
  // For headings, convert to paragraph first since headings cannot be direct children of list items
30
- var sourceNode = tr.doc.nodeAt(range.start);
31
33
  if (sourceNode && sourceNode.type.name.startsWith('heading')) {
32
34
  tr.setBlockType(range.start, range.end, nodes.paragraph);
33
35
  }
@@ -44,6 +46,18 @@ export var transformBlockToList = function transformBlockToList(context) {
44
46
  return tr;
45
47
  };
46
48
 
49
+ /**
50
+ * Transform list to block nodes
51
+ */
52
+ export var transformListToBlockNodes = function transformListToBlockNodes(context) {
53
+ var sourceNode = context.sourceNode;
54
+ if (sourceNode.type.name === 'taskList') {
55
+ return transformTaskListToBlockNodes(context);
56
+ } else {
57
+ return transformOrderedUnorderedListToBlockNodes(context);
58
+ }
59
+ };
60
+
47
61
  /**
48
62
  * Transform list nodes
49
63
  */
@@ -52,7 +66,7 @@ export var transformListNode = function transformListNode(context) {
52
66
  // Transform list to block type
53
67
  if (isBlockNodeType(targetNodeType)) {
54
68
  // Lift list items out of the list and convert to target block type
55
- return null;
69
+ return transformListToBlockNodes(context);
56
70
  }
57
71
 
58
72
  // Transform list to container type
@@ -1,3 +1,3 @@
1
1
 
2
- ._2rkoglpi{border-radius:var(--ds-border-radius,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
3
3
  ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
@@ -13,7 +13,7 @@ import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownM
13
13
  import { Box } from '@atlaskit/primitives/compiled';
14
14
  import { BlockMenuRenderer } from './block-menu-renderer';
15
15
  var styles = {
16
- base: "_2rkoglpi _bfhk1bhr _16qs1cd0"
16
+ base: "_2rko12b0 _bfhk1bhr _16qs1cd0"
17
17
  };
18
18
  var DEFAULT_MENU_WIDTH = 230;
19
19
  var DRAG_HANDLE_OFFSET_PADDING = 5;
@@ -14,4 +14,4 @@ export declare const unwrapAndConvertToBlockType: () => null;
14
14
  /**
15
15
  * Unwrap container node and convert content to list
16
16
  */
17
- export declare const unwrapAndConvertToList: () => null;
17
+ export declare const unwrapAndConvertToList: ({ tr, sourceNode, sourcePos, targetNodeType, targetAttrs, }: TransformContext) => import("prosemirror-state").Transaction;
@@ -0,0 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { TransformContext } from '.././types';
3
+ export declare const transformOrderedUnorderedListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -0,0 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { TransformContext } from '.././types';
3
+ export declare const transformTaskListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -0,0 +1,10 @@
1
+ import type { NodeType } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ /**
4
+ * Transform selection to task list
5
+ * Handles the special structure where taskItem contains text directly (no paragraph wrapper)
6
+ */
7
+ export declare const transformToTaskList: (tr: Transaction, range: {
8
+ end: number;
9
+ start: number;
10
+ }, targetNodeType: NodeType, targetAttrs: Record<string, unknown> | undefined, nodes: Record<string, NodeType>) => Transaction | null;
@@ -4,6 +4,10 @@ import type { TransformContext, TransformFunction } from './types';
4
4
  * Transform selection to list type
5
5
  */
6
6
  export declare const transformBlockToList: (context: TransformContext) => Transaction | null;
7
+ /**
8
+ * Transform list to block nodes
9
+ */
10
+ export declare const transformListToBlockNodes: (context: TransformContext) => Transaction | null;
7
11
  /**
8
12
  * Transform list nodes
9
13
  */
@@ -14,4 +14,4 @@ export declare const unwrapAndConvertToBlockType: () => null;
14
14
  /**
15
15
  * Unwrap container node and convert content to list
16
16
  */
17
- export declare const unwrapAndConvertToList: () => null;
17
+ export declare const unwrapAndConvertToList: ({ tr, sourceNode, sourcePos, targetNodeType, targetAttrs, }: TransformContext) => import("prosemirror-state").Transaction;
@@ -0,0 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { TransformContext } from '.././types';
3
+ export declare const transformOrderedUnorderedListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -0,0 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { TransformContext } from '.././types';
3
+ export declare const transformTaskListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -0,0 +1,10 @@
1
+ import type { NodeType } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ /**
4
+ * Transform selection to task list
5
+ * Handles the special structure where taskItem contains text directly (no paragraph wrapper)
6
+ */
7
+ export declare const transformToTaskList: (tr: Transaction, range: {
8
+ end: number;
9
+ start: number;
10
+ }, targetNodeType: NodeType, targetAttrs: Record<string, unknown> | undefined, nodes: Record<string, NodeType>) => Transaction | null;
@@ -4,6 +4,10 @@ import type { TransformContext, TransformFunction } from './types';
4
4
  * Transform selection to list type
5
5
  */
6
6
  export declare const transformBlockToList: (context: TransformContext) => Transaction | null;
7
+ /**
8
+ * Transform list to block nodes
9
+ */
10
+ export declare const transformListToBlockNodes: (context: TransformContext) => Transaction | null;
7
11
  /**
8
12
  * Transform list nodes
9
13
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",