@atlaskit/editor-plugin-block-menu 5.2.3 → 5.2.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 (48) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/steps/decisionListToListStep.js +88 -0
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +61 -0
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +6 -12
  5. package/dist/cjs/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -25
  6. package/dist/cjs/editor-commands/transform-node-utils/transform.js +23 -17
  7. package/dist/cjs/editor-commands/transform-node-utils/utils.js +7 -1
  8. package/dist/es2019/editor-commands/transform-node-utils/steps/decisionListToListStep.js +85 -0
  9. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +58 -0
  10. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +1 -4
  11. package/dist/es2019/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -22
  12. package/dist/es2019/editor-commands/transform-node-utils/transform.js +23 -17
  13. package/dist/es2019/editor-commands/transform-node-utils/utils.js +4 -0
  14. package/dist/esm/editor-commands/transform-node-utils/steps/decisionListToListStep.js +82 -0
  15. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +56 -0
  16. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +1 -6
  17. package/dist/esm/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -24
  18. package/dist/esm/editor-commands/transform-node-utils/transform.js +23 -17
  19. package/dist/esm/editor-commands/transform-node-utils/utils.js +6 -0
  20. package/dist/types/editor-commands/transform-node-utils/steps/decisionListToListStep.d.ts +30 -0
  21. package/dist/types/editor-commands/transform-node-utils/steps/listToDecisionListStep.d.ts +25 -0
  22. package/dist/types/editor-commands/transform-node-utils/{wrapMixedContentStep.d.ts → steps/wrapMixedContentStep.d.ts} +1 -1
  23. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +2 -0
  24. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/decisionListToListStep.d.ts +30 -0
  25. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/listToDecisionListStep.d.ts +25 -0
  26. package/dist/types-ts4.5/editor-commands/transform-node-utils/{wrapMixedContentStep.d.ts → steps/wrapMixedContentStep.d.ts} +1 -1
  27. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/dist/cjs/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -34
  30. package/dist/cjs/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -62
  31. package/dist/cjs/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -39
  32. package/dist/cjs/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -90
  33. package/dist/es2019/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -27
  34. package/dist/es2019/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -55
  35. package/dist/es2019/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -34
  36. package/dist/es2019/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -86
  37. package/dist/esm/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -29
  38. package/dist/esm/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -57
  39. package/dist/esm/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -34
  40. package/dist/esm/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -85
  41. package/dist/types/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +0 -18
  42. package/dist/types/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +0 -19
  43. package/dist/types/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +0 -22
  44. package/dist/types/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +0 -38
  45. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +0 -18
  46. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +0 -19
  47. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +0 -22
  48. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +0 -38
@@ -1,18 +1,17 @@
1
1
  import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
2
2
  import { flattenStep } from './flattenStep';
3
- import { convertBulletListToTextStep } from './steps/convertBulletListToTextStep';
4
- import { convertOrderedListToTextStep } from './steps/convertOrderedListToTextStep';
5
- import { convertTaskListToTextStep } from './steps/convertTaskListToTextStep';
3
+ import { decisionListToListStep } from './steps/decisionListToListStep';
6
4
  import { flattenListStep } from './steps/flattenListStep';
5
+ import { listToDecisionListStep } from './steps/listToDecisionListStep';
7
6
  import { listToListStep } from './steps/listToListStep';
8
7
  import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
9
8
  import { unwrapListStep } from './steps/unwrapListStep';
9
+ import { wrapMixedContentStep } from './steps/wrapMixedContentStep';
10
10
  import { stubStep } from './stubStep';
11
11
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
12
12
  import { unwrapExpandStep } from './unwrapExpandStep';
13
13
  import { unwrapStep } from './unwrapStep';
14
14
  import { wrapIntoLayoutStep } from './wrapIntoLayoutStep';
15
- import { wrapMixedContentStep } from './wrapMixedContentStep';
16
15
  import { wrapStep } from './wrapStep';
17
16
 
18
17
  // Exampled step for overrides:
@@ -59,7 +58,8 @@ const TRANSFORM_STEPS_OVERRIDE = {
59
58
  },
60
59
  panel: {
61
60
  layoutSection: [unwrapStep, wrapIntoLayoutStep],
62
- codeBlock: [unwrapStep, flattenStep, wrapStep]
61
+ codeBlock: [unwrapStep, flattenStep, wrapStep],
62
+ blockquote: [unwrapStep, wrapMixedContentStep]
63
63
  },
64
64
  expand: {
65
65
  panel: [unwrapExpandStep, wrapMixedContentStep],
@@ -95,26 +95,32 @@ const TRANSFORM_STEPS_OVERRIDE = {
95
95
  panel: [wrapStep]
96
96
  },
97
97
  bulletList: {
98
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
99
- codeBlock: [convertBulletListToTextStep, flattenStep, wrapStep],
100
- layoutSection: [wrapIntoLayoutStep]
98
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
99
+ codeBlock: [stubStep],
100
+ layoutSection: [wrapIntoLayoutStep],
101
+ decisionList: [flattenListStep, listToDecisionListStep]
101
102
  },
102
103
  orderedList: {
103
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
104
- codeBlock: [convertOrderedListToTextStep, flattenStep, wrapStep],
105
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
106
- layoutSection: [wrapIntoLayoutStep]
104
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
105
+ codeBlock: [stubStep],
106
+ layoutSection: [wrapIntoLayoutStep],
107
+ decisionList: [flattenListStep, listToDecisionListStep]
107
108
  },
108
109
  taskList: {
109
- // Warning: Actuall transformation logic not complete (Skeptical that prosemirror-markdown can be used)
110
- blockquote: [convertTaskListToTextStep, wrapStep],
111
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
112
- codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
113
- layoutSection: [wrapIntoLayoutStep]
110
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
111
+ blockquote: [stubStep],
112
+ codeBlock: [stubStep],
113
+ layoutSection: [wrapIntoLayoutStep],
114
+ decisionList: [flattenListStep, listToDecisionListStep]
114
115
  },
115
116
  table: {
116
117
  expand: [wrapStep],
117
118
  layoutSection: [wrapIntoLayoutStep]
119
+ },
120
+ decisionList: {
121
+ bulletList: [decisionListToListStep],
122
+ orderedList: [decisionListToListStep],
123
+ taskList: [decisionListToListStep]
118
124
  }
119
125
  };
120
126
  const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
@@ -86,4 +86,8 @@ export const expandSelectionToBlockRange = (selection, schema) => {
86
86
  }
87
87
  return true;
88
88
  });
89
+ };
90
+ export const isListType = (node, schema) => {
91
+ const lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
92
+ return lists.some(list => list === node.type);
89
93
  };
@@ -0,0 +1,82 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ var targets = function targets(targetNodeTypeName, schema) {
3
+ var targetListType;
4
+ var targetItemType;
5
+ switch (targetNodeTypeName) {
6
+ case 'bulletList':
7
+ targetListType = schema.nodes.bulletList;
8
+ targetItemType = schema.nodes.listItem;
9
+ break;
10
+ case 'orderedList':
11
+ targetListType = schema.nodes.orderedList;
12
+ targetItemType = schema.nodes.listItem;
13
+ break;
14
+ case 'taskList':
15
+ targetListType = schema.nodes.taskList;
16
+ targetItemType = schema.nodes.taskItem;
17
+ break;
18
+ default:
19
+ }
20
+ return {
21
+ targetListType: targetListType,
22
+ targetItemType: targetItemType
23
+ };
24
+ };
25
+
26
+ /**
27
+ * Transforms a decisionList into a bulletList, orderedList, or taskList.
28
+ * Decision items are converted to the appropriate list item type.
29
+ *
30
+ * @example
31
+ * Input (decisionList):
32
+ * - decisionList
33
+ * - decisionItem "Task 1"
34
+ * - decisionItem "Task 2"
35
+ *
36
+ * Output (bulletList):
37
+ * - bulletList
38
+ * - listItem
39
+ * - paragraph "Task 1"
40
+ * - listItem
41
+ * - paragraph "Task 2"
42
+ *
43
+ * Output (taskList):
44
+ * - taskList
45
+ * - taskItem
46
+ * - paragraph "Task 1"
47
+ * - taskItem
48
+ * - paragraph "Task 2"
49
+ *
50
+ * @param nodes - Array of nodes to transform
51
+ * @param context - Transform context with schema and target node type
52
+ * @returns array of transformed nodes
53
+ */
54
+ export var decisionListToListStep = function decisionListToListStep(nodes, context) {
55
+ var schema = context.schema,
56
+ targetNodeTypeName = context.targetNodeTypeName;
57
+ var paragraphType = schema.nodes.paragraph;
58
+ return nodes.map(function (node) {
59
+ if (node.type !== schema.nodes.decisionList) {
60
+ return node;
61
+ }
62
+ var _targets = targets(targetNodeTypeName, schema),
63
+ targetListType = _targets.targetListType,
64
+ targetItemType = _targets.targetItemType;
65
+ if (!targetListType || !targetItemType) {
66
+ return node;
67
+ }
68
+ var newItems = [];
69
+ node.forEach(function (decisionItem) {
70
+ var itemContent = [];
71
+ decisionItem.forEach(function (child) {
72
+ itemContent.push(child);
73
+ });
74
+ var newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
75
+ if (newItem) {
76
+ newItems.push(newItem);
77
+ }
78
+ });
79
+ var newList = targetListType.create({}, Fragment.from(newItems));
80
+ return newList || node;
81
+ });
82
+ };
@@ -0,0 +1,56 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ import { isListType } from '../utils';
3
+
4
+ /**
5
+ * Transforms a bulletList, orderedList, or taskList into a decisionList.
6
+ *
7
+ * Notes
8
+ * - decisionLists and taskList only support text as children - need to ensure content is converted to text
9
+ *
10
+ * @example
11
+ * Input (nested bulletList):
12
+ * - bulletList
13
+ * - listItem "1.1"
14
+ * - listItem "1.2"
15
+ * - listItem "1.3"
16
+ *
17
+ * Output (flat decisionList):
18
+ * - decisionList
19
+ * - decisionItem "1"
20
+ * - decisionItem "1.1"
21
+ * - decisionItem "2"
22
+ *
23
+ * @param nodes - Array of nodes to transform
24
+ * @param context - Transform context with schema and target node type
25
+ * @returns array of transformed nodes
26
+ */
27
+ export var listToDecisionListStep = function listToDecisionListStep(nodes, context) {
28
+ var schema = context.schema;
29
+ var paragraphType = schema.nodes.paragraph;
30
+ return nodes.map(function (node) {
31
+ if (!isListType(node, schema)) {
32
+ return node;
33
+ }
34
+ var decisionItems = [];
35
+ node.forEach(function (item) {
36
+ var itemContent = [];
37
+ item.forEach(function (child) {
38
+ if (child.type === paragraphType) {
39
+ // paragraph may contain hard breaks etc.
40
+ child.content.forEach(function (inline) {
41
+ itemContent.push(inline);
42
+ });
43
+ } else {
44
+ itemContent.push(child);
45
+ }
46
+ // TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
47
+ });
48
+ var decisionItem = schema.nodes.decisionItem.create({}, Fragment.from(itemContent));
49
+ if (decisionItem) {
50
+ decisionItems.push(decisionItem);
51
+ }
52
+ });
53
+ var decisionList = schema.nodes.decisionList.create({}, Fragment.from(decisionItems));
54
+ return decisionList || node;
55
+ });
56
+ };
@@ -1,10 +1,5 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- var isListType = function isListType(node, schema) {
3
- var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
4
- return lists.some(function (list) {
5
- return list === node.type;
6
- });
7
- };
2
+ import { isListType } from '../utils';
8
3
 
9
4
  /**
10
5
  * Converts FROM taskList structure TO bulletList/orderedList structure.
@@ -1,30 +1,28 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
- import { NODE_CATEGORY_BY_TYPE } from './types';
4
- import { unwrapStep } from './unwrapStep';
2
+ import { NODE_CATEGORY_BY_TYPE } from '../types';
5
3
 
6
4
  /**
7
- * Determines if a node can be flattened (unwrapped and its contents merged).
8
- *
9
- * According to the text transformations list, flattenable nodes are:
10
- * - Bulleted list, Numbered list, Task list
11
- * - Text nodes (heading, paragraph)
12
- *
13
- * Containers (panels, expands, layouts, blockquotes) and atomic nodes (tables, media, macros) break out.
5
+ * Determines if a node is a text node (heading or paragraph).
6
+ * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
14
7
  */
15
- var canFlatten = function canFlatten(node) {
8
+ var isTextNode = function isTextNode(node) {
16
9
  var category = NODE_CATEGORY_BY_TYPE[node.type.name];
17
- // Text and list nodes can be flattened (converted to simpler forms)
18
- return category === 'text' || category === 'list';
10
+ return category === 'text';
19
11
  };
20
12
 
21
13
  /**
22
- * Flattens a node by extracting its contents using the appropriate unwrap step.
23
- * This is only called for text and list nodes that can be converted to simpler forms.
24
- * Uses unwrapStep to extract children from list containers.
14
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
15
+ * This is used when a text node can't be wrapped directly in the target container
16
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
25
17
  */
26
- var flattenNode = function flattenNode(node, context) {
27
- return unwrapStep([node], context);
18
+ var convertTextNodeToParagraph = function convertTextNodeToParagraph(node, schema) {
19
+ var _schema$nodes$paragra;
20
+ // If it's already a paragraph, return as-is
21
+ if (node.type.name === 'paragraph') {
22
+ return node;
23
+ }
24
+ // Convert heading (or other text node) to paragraph with same inline content
25
+ return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
28
26
  };
29
27
 
30
28
  /**
@@ -117,13 +115,16 @@ export var wrapMixedContentStep = function wrapMixedContentStep(nodes, context)
117
115
  if (expandNode) {
118
116
  result.push(expandNode);
119
117
  }
120
- } else if (canFlatten(node)) {
121
- var _currentContainerCont;
122
- // Node cannot be wrapped but CAN be flattened - flatten and add to container
123
- var flattenedNodes = flattenNode(node, context);
124
- (_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, _toConsumableArray(flattenedNodes));
118
+ } else if (isTextNode(node)) {
119
+ // Text node (heading, paragraph) that can't be wrapped - convert to paragraph
120
+ // Example: heading can't go in blockquote, so convert to paragraph with same content
121
+ var paragraph = convertTextNodeToParagraph(node, schema);
122
+ if (paragraph) {
123
+ currentContainerContent.push(paragraph);
124
+ }
125
125
  } else {
126
- // Node cannot be wrapped AND cannot be flattened (containers, tables, media, macros) - break out
126
+ // All other nodes that cannot be wrapped (lists, containers, tables, media, macros) - break out
127
+ // This includes list nodes like taskList that can't be placed in certain containers
127
128
  flushCurrentContainer();
128
129
  result.push(node);
129
130
  }
@@ -1,18 +1,17 @@
1
1
  import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
2
2
  import { flattenStep } from './flattenStep';
3
- import { convertBulletListToTextStep } from './steps/convertBulletListToTextStep';
4
- import { convertOrderedListToTextStep } from './steps/convertOrderedListToTextStep';
5
- import { convertTaskListToTextStep } from './steps/convertTaskListToTextStep';
3
+ import { decisionListToListStep } from './steps/decisionListToListStep';
6
4
  import { flattenListStep } from './steps/flattenListStep';
5
+ import { listToDecisionListStep } from './steps/listToDecisionListStep';
7
6
  import { listToListStep } from './steps/listToListStep';
8
7
  import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
9
8
  import { unwrapListStep } from './steps/unwrapListStep';
9
+ import { wrapMixedContentStep } from './steps/wrapMixedContentStep';
10
10
  import { stubStep } from './stubStep';
11
11
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
12
12
  import { unwrapExpandStep } from './unwrapExpandStep';
13
13
  import { unwrapStep } from './unwrapStep';
14
14
  import { wrapIntoLayoutStep } from './wrapIntoLayoutStep';
15
- import { wrapMixedContentStep } from './wrapMixedContentStep';
16
15
  import { wrapStep } from './wrapStep';
17
16
 
18
17
  // Exampled step for overrides:
@@ -59,7 +58,8 @@ var TRANSFORM_STEPS_OVERRIDE = {
59
58
  },
60
59
  panel: {
61
60
  layoutSection: [unwrapStep, wrapIntoLayoutStep],
62
- codeBlock: [unwrapStep, flattenStep, wrapStep]
61
+ codeBlock: [unwrapStep, flattenStep, wrapStep],
62
+ blockquote: [unwrapStep, wrapMixedContentStep]
63
63
  },
64
64
  expand: {
65
65
  panel: [unwrapExpandStep, wrapMixedContentStep],
@@ -95,26 +95,32 @@ var TRANSFORM_STEPS_OVERRIDE = {
95
95
  panel: [wrapStep]
96
96
  },
97
97
  bulletList: {
98
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
99
- codeBlock: [convertBulletListToTextStep, flattenStep, wrapStep],
100
- layoutSection: [wrapIntoLayoutStep]
98
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
99
+ codeBlock: [stubStep],
100
+ layoutSection: [wrapIntoLayoutStep],
101
+ decisionList: [flattenListStep, listToDecisionListStep]
101
102
  },
102
103
  orderedList: {
103
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
104
- codeBlock: [convertOrderedListToTextStep, flattenStep, wrapStep],
105
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
106
- layoutSection: [wrapIntoLayoutStep]
104
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
105
+ codeBlock: [stubStep],
106
+ layoutSection: [wrapIntoLayoutStep],
107
+ decisionList: [flattenListStep, listToDecisionListStep]
107
108
  },
108
109
  taskList: {
109
- // Warning: Actuall transformation logic not complete (Skeptical that prosemirror-markdown can be used)
110
- blockquote: [convertTaskListToTextStep, wrapStep],
111
- // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
112
- codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
113
- layoutSection: [wrapIntoLayoutStep]
110
+ // Text transformations currently not in scope > options will be disabled > stubbing in case
111
+ blockquote: [stubStep],
112
+ codeBlock: [stubStep],
113
+ layoutSection: [wrapIntoLayoutStep],
114
+ decisionList: [flattenListStep, listToDecisionListStep]
114
115
  },
115
116
  table: {
116
117
  expand: [wrapStep],
117
118
  layoutSection: [wrapIntoLayoutStep]
119
+ },
120
+ decisionList: {
121
+ bulletList: [decisionListToListStep],
122
+ orderedList: [decisionListToListStep],
123
+ taskList: [decisionListToListStep]
118
124
  }
119
125
  };
120
126
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -83,4 +83,10 @@ export var expandSelectionToBlockRange = function expandSelectionToBlockRange(se
83
83
  }
84
84
  return true;
85
85
  });
86
+ };
87
+ export var isListType = function isListType(node, schema) {
88
+ var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
89
+ return lists.some(function (list) {
90
+ return list === node.type;
91
+ });
86
92
  };
@@ -0,0 +1,30 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Transforms a decisionList into a bulletList, orderedList, or taskList.
4
+ * Decision items are converted to the appropriate list item type.
5
+ *
6
+ * @example
7
+ * Input (decisionList):
8
+ * - decisionList
9
+ * - decisionItem "Task 1"
10
+ * - decisionItem "Task 2"
11
+ *
12
+ * Output (bulletList):
13
+ * - bulletList
14
+ * - listItem
15
+ * - paragraph "Task 1"
16
+ * - listItem
17
+ * - paragraph "Task 2"
18
+ *
19
+ * Output (taskList):
20
+ * - taskList
21
+ * - taskItem
22
+ * - paragraph "Task 1"
23
+ * - taskItem
24
+ * - paragraph "Task 2"
25
+ *
26
+ * @param nodes - Array of nodes to transform
27
+ * @param context - Transform context with schema and target node type
28
+ * @returns array of transformed nodes
29
+ */
30
+ export declare const decisionListToListStep: TransformStep;
@@ -0,0 +1,25 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Transforms a bulletList, orderedList, or taskList into a decisionList.
4
+ *
5
+ * Notes
6
+ * - decisionLists and taskList only support text as children - need to ensure content is converted to text
7
+ *
8
+ * @example
9
+ * Input (nested bulletList):
10
+ * - bulletList
11
+ * - listItem "1.1"
12
+ * - listItem "1.2"
13
+ * - listItem "1.3"
14
+ *
15
+ * Output (flat decisionList):
16
+ * - decisionList
17
+ * - decisionItem "1"
18
+ * - decisionItem "1.1"
19
+ * - decisionItem "2"
20
+ *
21
+ * @param nodes - Array of nodes to transform
22
+ * @param context - Transform context with schema and target node type
23
+ * @returns array of transformed nodes
24
+ */
25
+ export declare const listToDecisionListStep: TransformStep;
@@ -1,4 +1,4 @@
1
- import type { TransformStep } from './types';
1
+ import type { TransformStep } from '../types';
2
2
  /**
3
3
  * A wrap step that handles mixed content according to the Compatibility Matrix:
4
4
  * - Wraps consecutive compatible nodes into the target container
@@ -1,4 +1,5 @@
1
1
  import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
5
  import type { NodeTypeName } from './types';
@@ -15,3 +16,4 @@ export declare const expandSelectionToBlockRange: (selection: Selection, schema:
15
16
  $from: import("prosemirror-model").ResolvedPos;
16
17
  $to: import("prosemirror-model").ResolvedPos;
17
18
  };
19
+ export declare const isListType: (node: PMNode, schema: Schema) => boolean;
@@ -0,0 +1,30 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Transforms a decisionList into a bulletList, orderedList, or taskList.
4
+ * Decision items are converted to the appropriate list item type.
5
+ *
6
+ * @example
7
+ * Input (decisionList):
8
+ * - decisionList
9
+ * - decisionItem "Task 1"
10
+ * - decisionItem "Task 2"
11
+ *
12
+ * Output (bulletList):
13
+ * - bulletList
14
+ * - listItem
15
+ * - paragraph "Task 1"
16
+ * - listItem
17
+ * - paragraph "Task 2"
18
+ *
19
+ * Output (taskList):
20
+ * - taskList
21
+ * - taskItem
22
+ * - paragraph "Task 1"
23
+ * - taskItem
24
+ * - paragraph "Task 2"
25
+ *
26
+ * @param nodes - Array of nodes to transform
27
+ * @param context - Transform context with schema and target node type
28
+ * @returns array of transformed nodes
29
+ */
30
+ export declare const decisionListToListStep: TransformStep;
@@ -0,0 +1,25 @@
1
+ import type { TransformStep } from '../types';
2
+ /**
3
+ * Transforms a bulletList, orderedList, or taskList into a decisionList.
4
+ *
5
+ * Notes
6
+ * - decisionLists and taskList only support text as children - need to ensure content is converted to text
7
+ *
8
+ * @example
9
+ * Input (nested bulletList):
10
+ * - bulletList
11
+ * - listItem "1.1"
12
+ * - listItem "1.2"
13
+ * - listItem "1.3"
14
+ *
15
+ * Output (flat decisionList):
16
+ * - decisionList
17
+ * - decisionItem "1"
18
+ * - decisionItem "1.1"
19
+ * - decisionItem "2"
20
+ *
21
+ * @param nodes - Array of nodes to transform
22
+ * @param context - Transform context with schema and target node type
23
+ * @returns array of transformed nodes
24
+ */
25
+ export declare const listToDecisionListStep: TransformStep;
@@ -1,4 +1,4 @@
1
- import type { TransformStep } from './types';
1
+ import type { TransformStep } from '../types';
2
2
  /**
3
3
  * A wrap step that handles mixed content according to the Compatibility Matrix:
4
4
  * - Wraps consecutive compatible nodes into the target container
@@ -1,4 +1,5 @@
1
1
  import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
5
  import type { NodeTypeName } from './types';
@@ -15,3 +16,4 @@ export declare const expandSelectionToBlockRange: (selection: Selection, schema:
15
16
  $from: import("prosemirror-model").ResolvedPos;
16
17
  $to: import("prosemirror-model").ResolvedPos;
17
18
  };
19
+ export declare const isListType: (node: PMNode, schema: Schema) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.2.3",
3
+ "version": "5.2.5",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.convertBulletListToTextStep = void 0;
7
- var _createListToTextStep = require("./createListToTextStep");
8
- /**
9
- * Given an array of nodes, processes each bullet list by converting its items
10
- * to paragraphs with "- " prefix.
11
- *
12
- * Handles nested bullet lists recursively with 3-space indentation per level.
13
- *
14
- * @example
15
- * Input:
16
- * - bulletList()(
17
- * listItem()(p()('Item 1')),
18
- * bulletList()(listItem()(p()('Sub item 1')))
19
- * )
20
- *
21
- * Output:
22
- * - p()('- Item 1')
23
- * - p()(' - Sub item 1')
24
- */
25
- var convertBulletListToTextStep = exports.convertBulletListToTextStep = (0, _createListToTextStep.createListToTextStep)({
26
- listTypeName: 'bulletList',
27
- itemTypeName: 'listItem',
28
- indent: ' ',
29
- // 3 spaces per nesting level
30
- getPrefix: function getPrefix() {
31
- return '- ';
32
- },
33
- unwrapParagraphContent: true
34
- });
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.convertOrderedListToTextStep = void 0;
7
- var _createListToTextStep = require("./createListToTextStep");
8
- /**
9
- * Converts a number to a letter (1=a, 2=b, etc.)
10
- * For numbers > 26, continues with aa, ab, etc.
11
- */
12
- var numberToLetter = function numberToLetter(num) {
13
- var result = '';
14
- var n = num;
15
- while (n > 0) {
16
- n--;
17
- result = String.fromCharCode(97 + n % 26) + result;
18
- n = Math.floor(n / 26);
19
- }
20
- return result;
21
- };
22
-
23
- /**
24
- * Gets the appropriate prefix for an ordered list item based on depth and index.
25
- * - Level 0: "1. ", "2. ", "3. ", etc.
26
- * - Level 1+: "a. ", "b. ", "c. ", etc.
27
- */
28
- var getOrderedListPrefix = function getOrderedListPrefix(depth, index) {
29
- if (depth === 0) {
30
- return "".concat(index, ". ");
31
- }
32
- return "".concat(numberToLetter(index), ". ");
33
- };
34
-
35
- /**
36
- * Given an array of nodes, processes each ordered list by converting its items
37
- * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
38
- * lettered prefixes (a., b., c.) for nested levels.
39
- *
40
- * Handles nested ordered lists recursively with 3-space indentation per level.
41
- *
42
- * @example
43
- * Input:
44
- * - orderedList({ order: 1 })(
45
- * listItem()(p()('Item 1')),
46
- * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
47
- * )
48
- *
49
- * Output:
50
- * - p()('1. Item 1')
51
- * - p()(' a. Sub item 1')
52
- */
53
- var convertOrderedListToTextStep = exports.convertOrderedListToTextStep = (0, _createListToTextStep.createListToTextStep)({
54
- listTypeName: 'orderedList',
55
- itemTypeName: 'listItem',
56
- indent: ' ',
57
- // 3 spaces per nesting level
58
- getPrefix: function getPrefix(depth, index) {
59
- return getOrderedListPrefix(depth, index);
60
- },
61
- unwrapParagraphContent: true
62
- });