@atlaskit/editor-plugin-block-menu 5.2.4 → 5.2.6
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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/decisionListToListStep.js +88 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +61 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +6 -12
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +13 -3
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +19 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/decisionListToListStep.js +85 -0
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +58 -0
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +1 -4
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +13 -3
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +16 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/decisionListToListStep.js +82 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +56 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +1 -6
- package/dist/esm/editor-commands/transform-node-utils/transform.js +13 -3
- package/dist/esm/editor-commands/transform-node-utils/utils.js +18 -0
- package/dist/types/editor-commands/transform-node-utils/steps/decisionListToListStep.d.ts +30 -0
- package/dist/types/editor-commands/transform-node-utils/steps/listToDecisionListStep.d.ts +25 -0
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +3 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/decisionListToListStep.d.ts +30 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/listToDecisionListStep.d.ts +25 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.2.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fa50da8ee6860`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa50da8ee6860) -
|
|
8
|
+
EDITOR-3879 [multi-select] Detect nodes from multi-selection
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.2.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`c125e9935090b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c125e9935090b) -
|
|
16
|
+
Add decision list transformation support in block menu
|
|
17
|
+
|
|
3
18
|
## 5.2.4
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decisionListToListStep = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var targets = function targets(targetNodeTypeName, schema) {
|
|
9
|
+
var targetListType;
|
|
10
|
+
var targetItemType;
|
|
11
|
+
switch (targetNodeTypeName) {
|
|
12
|
+
case 'bulletList':
|
|
13
|
+
targetListType = schema.nodes.bulletList;
|
|
14
|
+
targetItemType = schema.nodes.listItem;
|
|
15
|
+
break;
|
|
16
|
+
case 'orderedList':
|
|
17
|
+
targetListType = schema.nodes.orderedList;
|
|
18
|
+
targetItemType = schema.nodes.listItem;
|
|
19
|
+
break;
|
|
20
|
+
case 'taskList':
|
|
21
|
+
targetListType = schema.nodes.taskList;
|
|
22
|
+
targetItemType = schema.nodes.taskItem;
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
targetListType: targetListType,
|
|
28
|
+
targetItemType: targetItemType
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Transforms a decisionList into a bulletList, orderedList, or taskList.
|
|
34
|
+
* Decision items are converted to the appropriate list item type.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* Input (decisionList):
|
|
38
|
+
* - decisionList
|
|
39
|
+
* - decisionItem "Task 1"
|
|
40
|
+
* - decisionItem "Task 2"
|
|
41
|
+
*
|
|
42
|
+
* Output (bulletList):
|
|
43
|
+
* - bulletList
|
|
44
|
+
* - listItem
|
|
45
|
+
* - paragraph "Task 1"
|
|
46
|
+
* - listItem
|
|
47
|
+
* - paragraph "Task 2"
|
|
48
|
+
*
|
|
49
|
+
* Output (taskList):
|
|
50
|
+
* - taskList
|
|
51
|
+
* - taskItem
|
|
52
|
+
* - paragraph "Task 1"
|
|
53
|
+
* - taskItem
|
|
54
|
+
* - paragraph "Task 2"
|
|
55
|
+
*
|
|
56
|
+
* @param nodes - Array of nodes to transform
|
|
57
|
+
* @param context - Transform context with schema and target node type
|
|
58
|
+
* @returns array of transformed nodes
|
|
59
|
+
*/
|
|
60
|
+
var decisionListToListStep = exports.decisionListToListStep = function decisionListToListStep(nodes, context) {
|
|
61
|
+
var schema = context.schema,
|
|
62
|
+
targetNodeTypeName = context.targetNodeTypeName;
|
|
63
|
+
var paragraphType = schema.nodes.paragraph;
|
|
64
|
+
return nodes.map(function (node) {
|
|
65
|
+
if (node.type !== schema.nodes.decisionList) {
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
var _targets = targets(targetNodeTypeName, schema),
|
|
69
|
+
targetListType = _targets.targetListType,
|
|
70
|
+
targetItemType = _targets.targetItemType;
|
|
71
|
+
if (!targetListType || !targetItemType) {
|
|
72
|
+
return node;
|
|
73
|
+
}
|
|
74
|
+
var newItems = [];
|
|
75
|
+
node.forEach(function (decisionItem) {
|
|
76
|
+
var itemContent = [];
|
|
77
|
+
decisionItem.forEach(function (child) {
|
|
78
|
+
itemContent.push(child);
|
|
79
|
+
});
|
|
80
|
+
var newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
|
|
81
|
+
if (newItem) {
|
|
82
|
+
newItems.push(newItem);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var newList = targetListType.create({}, _model.Fragment.from(newItems));
|
|
86
|
+
return newList || node;
|
|
87
|
+
});
|
|
88
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.listToDecisionListStep = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
/**
|
|
10
|
+
* Transforms a bulletList, orderedList, or taskList into a decisionList.
|
|
11
|
+
*
|
|
12
|
+
* Notes
|
|
13
|
+
* - decisionLists and taskList only support text as children - need to ensure content is converted to text
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* Input (nested bulletList):
|
|
17
|
+
* - bulletList
|
|
18
|
+
* - listItem "1.1"
|
|
19
|
+
* - listItem "1.2"
|
|
20
|
+
* - listItem "1.3"
|
|
21
|
+
*
|
|
22
|
+
* Output (flat decisionList):
|
|
23
|
+
* - decisionList
|
|
24
|
+
* - decisionItem "1"
|
|
25
|
+
* - decisionItem "1.1"
|
|
26
|
+
* - decisionItem "2"
|
|
27
|
+
*
|
|
28
|
+
* @param nodes - Array of nodes to transform
|
|
29
|
+
* @param context - Transform context with schema and target node type
|
|
30
|
+
* @returns array of transformed nodes
|
|
31
|
+
*/
|
|
32
|
+
var listToDecisionListStep = exports.listToDecisionListStep = function listToDecisionListStep(nodes, context) {
|
|
33
|
+
var schema = context.schema;
|
|
34
|
+
var paragraphType = schema.nodes.paragraph;
|
|
35
|
+
return nodes.map(function (node) {
|
|
36
|
+
if (!(0, _utils.isListType)(node, schema)) {
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
var decisionItems = [];
|
|
40
|
+
node.forEach(function (item) {
|
|
41
|
+
var itemContent = [];
|
|
42
|
+
item.forEach(function (child) {
|
|
43
|
+
if (child.type === paragraphType) {
|
|
44
|
+
// paragraph may contain hard breaks etc.
|
|
45
|
+
child.content.forEach(function (inline) {
|
|
46
|
+
itemContent.push(inline);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
itemContent.push(child);
|
|
50
|
+
}
|
|
51
|
+
// TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
|
|
52
|
+
});
|
|
53
|
+
var decisionItem = schema.nodes.decisionItem.create({}, _model.Fragment.from(itemContent));
|
|
54
|
+
if (decisionItem) {
|
|
55
|
+
decisionItems.push(decisionItem);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var decisionList = schema.nodes.decisionList.create({}, _model.Fragment.from(decisionItems));
|
|
59
|
+
return decisionList || node;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -5,13 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.listToListStep = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
-
var
|
|
9
|
-
var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
10
|
-
return lists.some(function (list) {
|
|
11
|
-
return list === node.type;
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
8
|
+
var _utils = require("../utils");
|
|
15
9
|
/**
|
|
16
10
|
* Converts FROM taskList structure TO bulletList/orderedList structure.
|
|
17
11
|
*/
|
|
@@ -20,7 +14,7 @@ var convertFromTaskListStructure = function convertFromTaskListStructure(node, t
|
|
|
20
14
|
var targetListNodeType = schema.nodes[targetListType];
|
|
21
15
|
var convertedItems = [];
|
|
22
16
|
node.content.forEach(function (child) {
|
|
23
|
-
if (isListType(child, schema)) {
|
|
17
|
+
if ((0, _utils.isListType)(child, schema)) {
|
|
24
18
|
// This is a nested list - it should become a child of the previous item
|
|
25
19
|
if (convertedItems.length > 0) {
|
|
26
20
|
var previousItem = convertedItems[convertedItems.length - 1];
|
|
@@ -54,7 +48,7 @@ var convertToTaskListStructure = function convertToTaskListStructure(node, targe
|
|
|
54
48
|
transformedContent.push(transformedItem);
|
|
55
49
|
}
|
|
56
50
|
itemNode.content.forEach(function (child) {
|
|
57
|
-
if (isListType(child, schema)) {
|
|
51
|
+
if ((0, _utils.isListType)(child, schema)) {
|
|
58
52
|
var transformedNestedList = _transformList(child, targetListType, targetItemType);
|
|
59
53
|
transformedContent.push(transformedNestedList);
|
|
60
54
|
}
|
|
@@ -103,7 +97,7 @@ var transformListItem = function transformListItem(itemNode, targetItemType, tar
|
|
|
103
97
|
newContent.push(paragraphType.create(null, itemNode.content));
|
|
104
98
|
} else {
|
|
105
99
|
itemNode.content.forEach(function (child) {
|
|
106
|
-
if (isListType(child, schema)) {
|
|
100
|
+
if ((0, _utils.isListType)(child, schema)) {
|
|
107
101
|
if (excludeNestedLists) {
|
|
108
102
|
// Skip nested lists - they will be handled separately as siblings
|
|
109
103
|
return;
|
|
@@ -147,7 +141,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
|
|
|
147
141
|
} else {
|
|
148
142
|
var transformedItems = [];
|
|
149
143
|
node.content.forEach(function (childNode) {
|
|
150
|
-
var transformedItem = isListType(childNode, schema) ? _transformList(childNode, targetListType, targetItemType) : transformListItem(childNode, targetItemType, targetListType);
|
|
144
|
+
var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType) : transformListItem(childNode, targetItemType, targetListType);
|
|
151
145
|
if (transformedItem) {
|
|
152
146
|
transformedItems.push(transformedItem);
|
|
153
147
|
}
|
|
@@ -223,7 +217,7 @@ var listToListStep = exports.listToListStep = function listToListStep(nodes, con
|
|
|
223
217
|
var schema = context.schema,
|
|
224
218
|
targetNodeTypeName = context.targetNodeTypeName;
|
|
225
219
|
return nodes.map(function (node) {
|
|
226
|
-
if (isListType(node, schema)) {
|
|
220
|
+
if ((0, _utils.isListType)(node, schema)) {
|
|
227
221
|
var targetItemType = targetNodeTypeName === 'taskList' ? 'taskItem' : 'listItem';
|
|
228
222
|
return _transformList(node, targetNodeTypeName, targetItemType);
|
|
229
223
|
}
|
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getOutputNodes = void 0;
|
|
7
7
|
var _utils = require("../transform-node-utils/utils");
|
|
8
8
|
var _flattenStep = require("./flattenStep");
|
|
9
|
+
var _decisionListToListStep = require("./steps/decisionListToListStep");
|
|
9
10
|
var _flattenListStep = require("./steps/flattenListStep");
|
|
11
|
+
var _listToDecisionListStep = require("./steps/listToDecisionListStep");
|
|
10
12
|
var _listToListStep = require("./steps/listToListStep");
|
|
11
13
|
var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
|
|
12
14
|
var _unwrapListStep = require("./steps/unwrapListStep");
|
|
@@ -100,22 +102,30 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
100
102
|
bulletList: {
|
|
101
103
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
102
104
|
codeBlock: [_stubStep.stubStep],
|
|
103
|
-
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
105
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
106
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep]
|
|
104
107
|
},
|
|
105
108
|
orderedList: {
|
|
106
109
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
107
110
|
codeBlock: [_stubStep.stubStep],
|
|
108
|
-
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
111
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
112
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep]
|
|
109
113
|
},
|
|
110
114
|
taskList: {
|
|
111
115
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
112
116
|
blockquote: [_stubStep.stubStep],
|
|
113
117
|
codeBlock: [_stubStep.stubStep],
|
|
114
|
-
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
118
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
119
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep]
|
|
115
120
|
},
|
|
116
121
|
table: {
|
|
117
122
|
expand: [_wrapStep.wrapStep],
|
|
118
123
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
124
|
+
},
|
|
125
|
+
decisionList: {
|
|
126
|
+
bulletList: [_decisionListToListStep.decisionListToListStep],
|
|
127
|
+
orderedList: [_decisionListToListStep.decisionListToListStep],
|
|
128
|
+
taskList: [_decisionListToListStep.decisionListToListStep]
|
|
119
129
|
}
|
|
120
130
|
};
|
|
121
131
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.expandSelectionToBlockRange = void 0;
|
|
6
|
+
exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.expandSelectionToBlockRange = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -89,4 +89,22 @@ var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function
|
|
|
89
89
|
}
|
|
90
90
|
return true;
|
|
91
91
|
});
|
|
92
|
+
};
|
|
93
|
+
var isListType = exports.isListType = function isListType(node, schema) {
|
|
94
|
+
var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
95
|
+
return lists.some(function (list) {
|
|
96
|
+
return list === node.type;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
var getBlockNodesInRange = exports.getBlockNodesInRange = function getBlockNodesInRange(range) {
|
|
100
|
+
if (range.endIndex - range.startIndex <= 1) {
|
|
101
|
+
return [range.parent.child(range.startIndex)];
|
|
102
|
+
}
|
|
103
|
+
var blockNodes = [];
|
|
104
|
+
for (var i = range.startIndex; i < range.endIndex; i++) {
|
|
105
|
+
if (range.parent.child(i).isBlock) {
|
|
106
|
+
blockNodes.push(range.parent.child(i));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return blockNodes;
|
|
92
110
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
const targets = (targetNodeTypeName, schema) => {
|
|
3
|
+
let targetListType;
|
|
4
|
+
let 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,
|
|
22
|
+
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 const decisionListToListStep = (nodes, context) => {
|
|
55
|
+
const {
|
|
56
|
+
schema,
|
|
57
|
+
targetNodeTypeName
|
|
58
|
+
} = context;
|
|
59
|
+
const paragraphType = schema.nodes.paragraph;
|
|
60
|
+
return nodes.map(node => {
|
|
61
|
+
if (node.type !== schema.nodes.decisionList) {
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
const {
|
|
65
|
+
targetListType,
|
|
66
|
+
targetItemType
|
|
67
|
+
} = targets(targetNodeTypeName, schema);
|
|
68
|
+
if (!targetListType || !targetItemType) {
|
|
69
|
+
return node;
|
|
70
|
+
}
|
|
71
|
+
const newItems = [];
|
|
72
|
+
node.forEach(decisionItem => {
|
|
73
|
+
const itemContent = [];
|
|
74
|
+
decisionItem.forEach(child => {
|
|
75
|
+
itemContent.push(child);
|
|
76
|
+
});
|
|
77
|
+
const newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
|
|
78
|
+
if (newItem) {
|
|
79
|
+
newItems.push(newItem);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const newList = targetListType.create({}, Fragment.from(newItems));
|
|
83
|
+
return newList || node;
|
|
84
|
+
});
|
|
85
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 const listToDecisionListStep = (nodes, context) => {
|
|
28
|
+
const {
|
|
29
|
+
schema
|
|
30
|
+
} = context;
|
|
31
|
+
const paragraphType = schema.nodes.paragraph;
|
|
32
|
+
return nodes.map(node => {
|
|
33
|
+
if (!isListType(node, schema)) {
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
const decisionItems = [];
|
|
37
|
+
node.forEach(item => {
|
|
38
|
+
const itemContent = [];
|
|
39
|
+
item.forEach(child => {
|
|
40
|
+
if (child.type === paragraphType) {
|
|
41
|
+
// paragraph may contain hard breaks etc.
|
|
42
|
+
child.content.forEach(inline => {
|
|
43
|
+
itemContent.push(inline);
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
itemContent.push(child);
|
|
47
|
+
}
|
|
48
|
+
// TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
|
|
49
|
+
});
|
|
50
|
+
const decisionItem = schema.nodes.decisionItem.create({}, Fragment.from(itemContent));
|
|
51
|
+
if (decisionItem) {
|
|
52
|
+
decisionItems.push(decisionItem);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const decisionList = schema.nodes.decisionList.create({}, Fragment.from(decisionItems));
|
|
56
|
+
return decisionList || node;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
|
|
3
|
-
const lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
4
|
-
return lists.some(list => list === node.type);
|
|
5
|
-
};
|
|
2
|
+
import { isListType } from '../utils';
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Converts FROM taskList structure TO bulletList/orderedList structure.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
|
|
2
2
|
import { flattenStep } from './flattenStep';
|
|
3
|
+
import { decisionListToListStep } from './steps/decisionListToListStep';
|
|
3
4
|
import { flattenListStep } from './steps/flattenListStep';
|
|
5
|
+
import { listToDecisionListStep } from './steps/listToDecisionListStep';
|
|
4
6
|
import { listToListStep } from './steps/listToListStep';
|
|
5
7
|
import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
|
|
6
8
|
import { unwrapListStep } from './steps/unwrapListStep';
|
|
@@ -95,22 +97,30 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
95
97
|
bulletList: {
|
|
96
98
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
97
99
|
codeBlock: [stubStep],
|
|
98
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
100
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
101
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
99
102
|
},
|
|
100
103
|
orderedList: {
|
|
101
104
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
102
105
|
codeBlock: [stubStep],
|
|
103
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
106
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
107
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
104
108
|
},
|
|
105
109
|
taskList: {
|
|
106
110
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
107
111
|
blockquote: [stubStep],
|
|
108
112
|
codeBlock: [stubStep],
|
|
109
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
113
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
114
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
110
115
|
},
|
|
111
116
|
table: {
|
|
112
117
|
expand: [wrapStep],
|
|
113
118
|
layoutSection: [wrapIntoLayoutStep]
|
|
119
|
+
},
|
|
120
|
+
decisionList: {
|
|
121
|
+
bulletList: [decisionListToListStep],
|
|
122
|
+
orderedList: [decisionListToListStep],
|
|
123
|
+
taskList: [decisionListToListStep]
|
|
114
124
|
}
|
|
115
125
|
};
|
|
116
126
|
const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
|
|
@@ -86,4 +86,20 @@ 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);
|
|
93
|
+
};
|
|
94
|
+
export const getBlockNodesInRange = range => {
|
|
95
|
+
if (range.endIndex - range.startIndex <= 1) {
|
|
96
|
+
return [range.parent.child(range.startIndex)];
|
|
97
|
+
}
|
|
98
|
+
const blockNodes = [];
|
|
99
|
+
for (let i = range.startIndex; i < range.endIndex; i++) {
|
|
100
|
+
if (range.parent.child(i).isBlock) {
|
|
101
|
+
blockNodes.push(range.parent.child(i));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return blockNodes;
|
|
89
105
|
};
|
|
@@ -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
|
-
|
|
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,6 +1,8 @@
|
|
|
1
1
|
import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
|
|
2
2
|
import { flattenStep } from './flattenStep';
|
|
3
|
+
import { decisionListToListStep } from './steps/decisionListToListStep';
|
|
3
4
|
import { flattenListStep } from './steps/flattenListStep';
|
|
5
|
+
import { listToDecisionListStep } from './steps/listToDecisionListStep';
|
|
4
6
|
import { listToListStep } from './steps/listToListStep';
|
|
5
7
|
import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
|
|
6
8
|
import { unwrapListStep } from './steps/unwrapListStep';
|
|
@@ -95,22 +97,30 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
95
97
|
bulletList: {
|
|
96
98
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
97
99
|
codeBlock: [stubStep],
|
|
98
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
100
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
101
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
99
102
|
},
|
|
100
103
|
orderedList: {
|
|
101
104
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
102
105
|
codeBlock: [stubStep],
|
|
103
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
106
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
107
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
104
108
|
},
|
|
105
109
|
taskList: {
|
|
106
110
|
// Text transformations currently not in scope > options will be disabled > stubbing in case
|
|
107
111
|
blockquote: [stubStep],
|
|
108
112
|
codeBlock: [stubStep],
|
|
109
|
-
layoutSection: [wrapIntoLayoutStep]
|
|
113
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
114
|
+
decisionList: [flattenListStep, listToDecisionListStep]
|
|
110
115
|
},
|
|
111
116
|
table: {
|
|
112
117
|
expand: [wrapStep],
|
|
113
118
|
layoutSection: [wrapIntoLayoutStep]
|
|
119
|
+
},
|
|
120
|
+
decisionList: {
|
|
121
|
+
bulletList: [decisionListToListStep],
|
|
122
|
+
orderedList: [decisionListToListStep],
|
|
123
|
+
taskList: [decisionListToListStep]
|
|
114
124
|
}
|
|
115
125
|
};
|
|
116
126
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -83,4 +83,22 @@ 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
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export var getBlockNodesInRange = function getBlockNodesInRange(range) {
|
|
94
|
+
if (range.endIndex - range.startIndex <= 1) {
|
|
95
|
+
return [range.parent.child(range.startIndex)];
|
|
96
|
+
}
|
|
97
|
+
var blockNodes = [];
|
|
98
|
+
for (var i = range.startIndex; i < range.endIndex; i++) {
|
|
99
|
+
if (range.parent.child(i).isBlock) {
|
|
100
|
+
blockNodes.push(range.parent.child(i));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return blockNodes;
|
|
86
104
|
};
|
|
@@ -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 { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Schema, Node as PMNode, NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import type { NodeTypeName } from './types';
|
|
@@ -15,3 +15,5 @@ export declare const expandSelectionToBlockRange: (selection: Selection, schema:
|
|
|
15
15
|
$from: import("prosemirror-model").ResolvedPos;
|
|
16
16
|
$to: import("prosemirror-model").ResolvedPos;
|
|
17
17
|
};
|
|
18
|
+
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
19
|
+
export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
|
package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/decisionListToListStep.d.ts
ADDED
|
@@ -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;
|
package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/listToDecisionListStep.d.ts
ADDED
|
@@ -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 { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Schema, Node as PMNode, NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import type { NodeTypeName } from './types';
|
|
@@ -15,3 +15,5 @@ export declare const expandSelectionToBlockRange: (selection: Selection, schema:
|
|
|
15
15
|
$from: import("prosemirror-model").ResolvedPos;
|
|
16
16
|
$to: import("prosemirror-model").ResolvedPos;
|
|
17
17
|
};
|
|
18
|
+
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
19
|
+
export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.6",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
46
46
|
"@atlaskit/primitives": "^16.4.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^15.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^15.9.0",
|
|
48
48
|
"@atlaskit/tokens": "^8.4.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0"
|
|
50
50
|
},
|