@atlaskit/editor-plugin-block-menu 5.2.8 → 5.2.10
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 +16 -0
- package/dist/cjs/editor-actions/index.js +3 -13
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +12 -12
- package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +96 -119
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/cjs/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -4
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +17 -1
- package/dist/es2019/editor-actions/index.js +1 -11
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +10 -12
- package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +93 -118
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/es2019/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -2
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +16 -0
- package/dist/esm/editor-actions/index.js +2 -13
- package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +11 -12
- package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +95 -119
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/esm/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -3
- package/dist/esm/editor-commands/transform-node-utils/utils.js +16 -0
- package/dist/types/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +5 -0
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +6 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +6 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.2.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`eb116a739e7c2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eb116a739e7c2) -
|
|
8
|
+
[ux] Fix bug / make unwrap of expand convert nestedExpand node to regular expand node
|
|
9
|
+
|
|
10
|
+
## 5.2.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`3d03e8b001dab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d03e8b001dab) -
|
|
15
|
+
Add logic to handle unsupported content for list to task/decision list
|
|
16
|
+
- [`b831109342cdf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b831109342cdf) -
|
|
17
|
+
EDITOR-3880 Register block menu selection extensions statically
|
|
18
|
+
|
|
3
19
|
## 5.2.8
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.createBlockMenuRegistry = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
/**
|
|
8
10
|
* Create a simple registry for block menu components.
|
|
9
11
|
*
|
|
@@ -54,19 +56,7 @@ exports.createBlockMenuRegistry = void 0;
|
|
|
54
56
|
var createBlockMenuRegistry = exports.createBlockMenuRegistry = function createBlockMenuRegistry() {
|
|
55
57
|
var components = [];
|
|
56
58
|
var register = function register(blockMenuComponents) {
|
|
57
|
-
|
|
58
|
-
// Find if a component with the same key already exists
|
|
59
|
-
var existingIndex = components.findIndex(function (comp) {
|
|
60
|
-
return comp.key === newComponent.key;
|
|
61
|
-
});
|
|
62
|
-
if (existingIndex !== -1) {
|
|
63
|
-
// Replace the existing component
|
|
64
|
-
components[existingIndex] = newComponent;
|
|
65
|
-
} else {
|
|
66
|
-
// Add new component
|
|
67
|
-
components.push(newComponent);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
59
|
+
components.push.apply(components, (0, _toConsumableArray2.default)(blockMenuComponents));
|
|
70
60
|
};
|
|
71
61
|
return {
|
|
72
62
|
register: register,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.listToDecisionListStep = void 0;
|
|
7
|
-
var
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _utils = require("../utils");
|
|
9
10
|
/**
|
|
10
11
|
* Transforms a bulletList, orderedList, or taskList into a decisionList.
|
|
@@ -32,7 +33,8 @@ var _utils = require("../utils");
|
|
|
32
33
|
var listToDecisionListStep = exports.listToDecisionListStep = function listToDecisionListStep(nodes, context) {
|
|
33
34
|
var schema = context.schema;
|
|
34
35
|
var paragraphType = schema.nodes.paragraph;
|
|
35
|
-
|
|
36
|
+
var unsupportedContent = [];
|
|
37
|
+
var transformedNodes = nodes.map(function (node) {
|
|
36
38
|
if (!(0, _utils.isListType)(node, schema)) {
|
|
37
39
|
return node;
|
|
38
40
|
}
|
|
@@ -42,20 +44,18 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
|
|
|
42
44
|
item.forEach(function (child) {
|
|
43
45
|
if (child.type === paragraphType) {
|
|
44
46
|
// paragraph may contain hard breaks etc.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
47
|
+
itemContent.push.apply(itemContent, (0, _toConsumableArray2.default)(child.children));
|
|
48
|
+
} else if (child.isText) {
|
|
49
49
|
itemContent.push(child);
|
|
50
|
+
} else if (!(0, _utils.isListType)(child, schema)) {
|
|
51
|
+
unsupportedContent.push(child);
|
|
50
52
|
}
|
|
51
|
-
// TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
|
|
52
53
|
});
|
|
53
|
-
var decisionItem = schema.nodes.decisionItem.create({},
|
|
54
|
-
|
|
55
|
-
decisionItems.push(decisionItem);
|
|
56
|
-
}
|
|
54
|
+
var decisionItem = schema.nodes.decisionItem.create({}, itemContent);
|
|
55
|
+
decisionItems.push(decisionItem);
|
|
57
56
|
});
|
|
58
|
-
var decisionList = schema.nodes.decisionList.create({},
|
|
57
|
+
var decisionList = schema.nodes.decisionList.create({}, decisionItems);
|
|
59
58
|
return decisionList || node;
|
|
60
59
|
});
|
|
60
|
+
return [].concat((0, _toConsumableArray2.default)(transformedNodes), unsupportedContent);
|
|
61
61
|
};
|
|
@@ -1,153 +1,128 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.listToListStep = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
10
|
var _utils = require("../utils");
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if ((0, _utils.isListType)(child, schema)) {
|
|
18
|
-
// This is a nested list - it should become a child of the previous item
|
|
19
|
-
if (convertedItems.length > 0) {
|
|
20
|
-
var previousItem = convertedItems[convertedItems.length - 1];
|
|
21
|
-
// Convert the nested list and add it to the previous item's content
|
|
22
|
-
var convertedNestedList = _transformList(child, targetListType, targetItemType);
|
|
23
|
-
var newContent = previousItem.content.append(_model.Fragment.from([convertedNestedList]));
|
|
24
|
-
var updatedItem = previousItem.type.create(previousItem.attrs, newContent);
|
|
25
|
-
convertedItems[convertedItems.length - 1] = updatedItem;
|
|
26
|
-
}
|
|
27
|
-
// If there's no previous item, skip this nested list (orphaned)
|
|
28
|
-
} else {
|
|
29
|
-
var convertedItem = transformListItem(child, targetItemType, targetListType);
|
|
30
|
-
if (convertedItem) {
|
|
31
|
-
convertedItems.push(convertedItem);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return targetListNodeType.create(node.attrs, _model.Fragment.from(convertedItems));
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Converts FROM bulletList/orderedList structure TO taskList structure.
|
|
12
|
+
* Recursively converts nested lists to the target list type.
|
|
13
|
+
* This function handles the conversion of both the list container and its items,
|
|
14
|
+
* including any nested lists within those items.
|
|
15
|
+
*
|
|
16
|
+
* Important: taskList has a different nesting structure than bulletList/orderedList:
|
|
17
|
+
* - taskList: nested taskLists are SIBLINGS of taskItems in the parent taskList
|
|
18
|
+
* - bulletList/orderedList: nested lists are CHILDREN of listItems
|
|
40
19
|
*/
|
|
41
|
-
var
|
|
20
|
+
var _transformList = function transformList(node, targetListType, targetItemType, unsupportedContent) {
|
|
42
21
|
var schema = node.type.schema;
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
22
|
+
var taskListType = schema.nodes.taskList;
|
|
23
|
+
var isSourceTaskList = node.type === taskListType;
|
|
24
|
+
var isTargetTaskList = targetListType === 'taskList';
|
|
25
|
+
var convertFromTaskListStructure = function convertFromTaskListStructure(node, targetListType, targetItemType) {
|
|
26
|
+
var schema = node.type.schema;
|
|
27
|
+
var targetListNodeType = schema.nodes[targetListType];
|
|
28
|
+
var transformedContent = [];
|
|
29
|
+
node.forEach(function (child) {
|
|
51
30
|
if ((0, _utils.isListType)(child, schema)) {
|
|
52
|
-
|
|
53
|
-
transformedContent.
|
|
31
|
+
// This is a nested list - it should become a child of the previous item
|
|
32
|
+
if (transformedContent.length > 0) {
|
|
33
|
+
var previousItem = transformedContent[transformedContent.length - 1];
|
|
34
|
+
// Convert the nested list and add it to the previous item's content
|
|
35
|
+
var transformedNestedList = _transformList(child, targetListType, targetItemType, unsupportedContent);
|
|
36
|
+
var newContent = previousItem.content.append(_model.Fragment.from([transformedNestedList]));
|
|
37
|
+
var updatedItem = previousItem.type.create(previousItem.attrs, newContent);
|
|
38
|
+
transformedContent[transformedContent.length - 1] = updatedItem;
|
|
39
|
+
}
|
|
40
|
+
// If there's no previous item, skip this nested list (orphaned)
|
|
41
|
+
} else {
|
|
42
|
+
var transformedItem = transformListItem(child, targetItemType, targetListType);
|
|
43
|
+
if (transformedItem) {
|
|
44
|
+
transformedContent.push(transformedItem);
|
|
45
|
+
}
|
|
54
46
|
}
|
|
55
47
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param excludeNestedLists - When true, nested lists are excluded from the item's content
|
|
67
|
-
* (used when converting to taskList where nested lists become siblings)
|
|
68
|
-
*/
|
|
69
|
-
var transformListItem = function transformListItem(itemNode, targetItemType, targetListType) {
|
|
70
|
-
var excludeNestedLists = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
71
|
-
var schema = itemNode.type.schema;
|
|
72
|
-
var targetItemNodeType = schema.nodes[targetItemType];
|
|
73
|
-
var isTargetTaskItem = targetItemType === 'taskItem';
|
|
74
|
-
var isSourceTaskItem = itemNode.type.name === 'taskItem';
|
|
75
|
-
var paragraphType = schema.nodes.paragraph;
|
|
76
|
-
if (!targetItemNodeType) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
if (isTargetTaskItem) {
|
|
80
|
-
var inlineContent = [];
|
|
81
|
-
itemNode.content.forEach(function (child) {
|
|
82
|
-
if (child.type === paragraphType) {
|
|
83
|
-
child.content.forEach(function (inline) {
|
|
84
|
-
inlineContent.push(inline);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (child.isText) {
|
|
88
|
-
inlineContent.push(child);
|
|
48
|
+
return targetListNodeType.create(node.attrs, transformedContent);
|
|
49
|
+
};
|
|
50
|
+
var convertToTaskListStructure = function convertToTaskListStructure(node, targetListType, targetItemType) {
|
|
51
|
+
var schema = node.type.schema;
|
|
52
|
+
var targetListNodeType = schema.nodes[targetListType];
|
|
53
|
+
var transformedContent = [];
|
|
54
|
+
node.forEach(function (itemNode) {
|
|
55
|
+
var transformedItem = transformListItem(itemNode, targetItemType, targetListType, true);
|
|
56
|
+
if (transformedItem) {
|
|
57
|
+
transformedContent.push(transformedItem);
|
|
89
58
|
}
|
|
90
|
-
|
|
91
|
-
|
|
59
|
+
itemNode.forEach(function (child) {
|
|
60
|
+
if ((0, _utils.isListType)(child, schema)) {
|
|
61
|
+
transformedContent.push(_transformList(child, targetListType, targetItemType, unsupportedContent));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
92
64
|
});
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
65
|
+
return targetListNodeType.create(node.attrs, transformedContent);
|
|
66
|
+
};
|
|
67
|
+
var transformListItem = function transformListItem(itemNode, targetItemType, targetListType) {
|
|
68
|
+
var excludeNestedLists = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
69
|
+
var schema = itemNode.type.schema;
|
|
70
|
+
var targetItemNodeType = schema.nodes[targetItemType];
|
|
71
|
+
var isTargetTaskItem = targetItemType === 'taskItem';
|
|
72
|
+
var isSourceTaskItem = itemNode.type.name === 'taskItem';
|
|
73
|
+
var paragraphType = schema.nodes.paragraph;
|
|
74
|
+
if (isTargetTaskItem) {
|
|
75
|
+
var inlineContent = [];
|
|
76
|
+
itemNode.forEach(function (child) {
|
|
77
|
+
if (child.type === paragraphType) {
|
|
78
|
+
inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(child.children));
|
|
79
|
+
} else if (child.isText) {
|
|
80
|
+
inlineContent.push(child);
|
|
81
|
+
// Nested lists will be extracted and placed as siblings in the taskList
|
|
82
|
+
} else if (!(0, _utils.isListType)(child, schema)) {
|
|
83
|
+
unsupportedContent.push(child);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return targetItemNodeType.create({}, inlineContent);
|
|
87
|
+
}
|
|
88
|
+
var transformedContent = [];
|
|
96
89
|
if (isSourceTaskItem) {
|
|
97
|
-
|
|
90
|
+
transformedContent.push(paragraphType.create(null, itemNode.content));
|
|
98
91
|
} else {
|
|
99
|
-
itemNode.
|
|
92
|
+
itemNode.forEach(function (child) {
|
|
100
93
|
if ((0, _utils.isListType)(child, schema)) {
|
|
101
94
|
if (excludeNestedLists) {
|
|
102
95
|
// Skip nested lists - they will be handled separately as siblings
|
|
103
96
|
return;
|
|
104
97
|
}
|
|
105
|
-
|
|
98
|
+
transformedContent.push(_transformList(child, targetListType, targetItemType, unsupportedContent));
|
|
106
99
|
} else {
|
|
107
|
-
|
|
100
|
+
transformedContent.push(child);
|
|
108
101
|
}
|
|
109
102
|
});
|
|
110
103
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
104
|
+
if (transformedContent.length === 0) {
|
|
105
|
+
transformedContent.push(paragraphType.create());
|
|
113
106
|
}
|
|
114
|
-
return targetItemNodeType.create({},
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var _transformList = function transformList(node, targetListType, targetItemType) {
|
|
128
|
-
var schema = node.type.schema;
|
|
129
|
-
var targetListNodeType = schema.nodes[targetListType];
|
|
130
|
-
var targetItemNodeType = schema.nodes[targetItemType];
|
|
131
|
-
var taskListType = schema.nodes.taskList;
|
|
132
|
-
if (!targetListNodeType || !targetItemNodeType) {
|
|
133
|
-
return node;
|
|
134
|
-
}
|
|
135
|
-
var isSourceTaskList = node.type === taskListType;
|
|
136
|
-
var isTargetTaskList = targetListType === 'taskList';
|
|
107
|
+
return targetItemNodeType.create({}, transformedContent);
|
|
108
|
+
};
|
|
109
|
+
var convertList = function convertList(node, schema, targetListType, targetItemType) {
|
|
110
|
+
var targetListNodeType = schema.nodes[targetListType];
|
|
111
|
+
var transformedContent = [];
|
|
112
|
+
node.forEach(function (childNode) {
|
|
113
|
+
var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType, unsupportedContent) : transformListItem(childNode, targetItemType, targetListType);
|
|
114
|
+
if (transformedItem) {
|
|
115
|
+
transformedContent.push(transformedItem);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return targetListNodeType.create(node.attrs, transformedContent);
|
|
119
|
+
};
|
|
137
120
|
if (isSourceTaskList && !isTargetTaskList) {
|
|
138
121
|
return convertFromTaskListStructure(node, targetListType, targetItemType);
|
|
139
122
|
} else if (!isSourceTaskList && isTargetTaskList) {
|
|
140
123
|
return convertToTaskListStructure(node, targetListType, targetItemType);
|
|
141
|
-
} else {
|
|
142
|
-
var transformedItems = [];
|
|
143
|
-
node.content.forEach(function (childNode) {
|
|
144
|
-
var transformedItem = (0, _utils.isListType)(childNode, schema) ? _transformList(childNode, targetListType, targetItemType) : transformListItem(childNode, targetItemType, targetListType);
|
|
145
|
-
if (transformedItem) {
|
|
146
|
-
transformedItems.push(transformedItem);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return targetListNodeType.create(node.attrs, _model.Fragment.from(transformedItems));
|
|
150
124
|
}
|
|
125
|
+
return convertList(node, schema, targetListType, targetItemType);
|
|
151
126
|
};
|
|
152
127
|
|
|
153
128
|
/**
|
|
@@ -216,11 +191,13 @@ var _transformList = function transformList(node, targetListType, targetItemType
|
|
|
216
191
|
var listToListStep = exports.listToListStep = function listToListStep(nodes, context) {
|
|
217
192
|
var schema = context.schema,
|
|
218
193
|
targetNodeTypeName = context.targetNodeTypeName;
|
|
219
|
-
|
|
194
|
+
var unsupportedContent = [];
|
|
195
|
+
var transformedNodes = nodes.map(function (node) {
|
|
220
196
|
if ((0, _utils.isListType)(node, schema)) {
|
|
221
197
|
var targetItemType = targetNodeTypeName === 'taskList' ? 'taskItem' : 'listItem';
|
|
222
|
-
return _transformList(node, targetNodeTypeName, targetItemType);
|
|
198
|
+
return _transformList(node, targetNodeTypeName, targetItemType, unsupportedContent);
|
|
223
199
|
}
|
|
224
200
|
return node;
|
|
225
201
|
});
|
|
202
|
+
return [].concat((0, _toConsumableArray2.default)(transformedNodes), unsupportedContent);
|
|
226
203
|
};
|
|
@@ -48,21 +48,6 @@ var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeT
|
|
|
48
48
|
return targetNodeType.validContent(_model.Fragment.from(node));
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Converts a nestedExpand to a regular expand node.
|
|
53
|
-
* NestedExpands can only exist inside expands, so when breaking out they must be converted.
|
|
54
|
-
*/
|
|
55
|
-
var convertNestedExpandToExpand = function convertNestedExpandToExpand(node, schema) {
|
|
56
|
-
var _node$attrs;
|
|
57
|
-
var expandType = schema.nodes.expand;
|
|
58
|
-
if (!expandType) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return expandType.createAndFill({
|
|
62
|
-
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
63
|
-
}, node.content);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
51
|
/**
|
|
67
52
|
* A wrap step that handles mixed content according to the Compatibility Matrix:
|
|
68
53
|
* - Wraps consecutive compatible nodes into the target container
|
|
@@ -108,14 +93,6 @@ var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedCont
|
|
|
108
93
|
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
109
94
|
flushCurrentContainer();
|
|
110
95
|
result.push(node);
|
|
111
|
-
} else if (node.type.name === 'nestedExpand') {
|
|
112
|
-
// NestedExpand can't be wrapped and can't exist outside an expand
|
|
113
|
-
// Convert to regular expand and break out
|
|
114
|
-
flushCurrentContainer();
|
|
115
|
-
var expandNode = convertNestedExpandToExpand(node, schema);
|
|
116
|
-
if (expandNode) {
|
|
117
|
-
result.push(expandNode);
|
|
118
|
-
}
|
|
119
96
|
} else if (isTextNode(node)) {
|
|
120
97
|
// Text node (heading, paragraph) that can't be wrapped - convert to paragraph
|
|
121
98
|
// Example: heading can't go in blockquote, so convert to paragraph with same content
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.unwrapExpandStep = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
7
|
var _unwrapStep = require("./unwrapStep");
|
|
8
|
+
var _utils = require("./utils");
|
|
10
9
|
/**
|
|
11
10
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
12
11
|
* and prepending it to the children.
|
|
13
12
|
*
|
|
13
|
+
* Any nestedExpand children are converted to regular expands since nestedExpand
|
|
14
|
+
* can only exist inside an expand.
|
|
15
|
+
*
|
|
14
16
|
* Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
|
|
17
|
+
* Example: expand({ title: 'outer' })(nestedExpand({ title: 'inner' })(p('x')))
|
|
18
|
+
* → [p('outer'), expand({ title: 'inner' })(p('x'))]
|
|
15
19
|
*/
|
|
16
20
|
var unwrapExpandStep = exports.unwrapExpandStep = function unwrapExpandStep(nodes, context) {
|
|
17
21
|
var schema = context.schema;
|
|
@@ -33,8 +37,20 @@ var unwrapExpandStep = exports.unwrapExpandStep = function unwrapExpandStep(node
|
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
// Add the children
|
|
37
|
-
|
|
40
|
+
// Add the children, converting any nestedExpands to regular expands
|
|
41
|
+
// since nestedExpand can only exist inside an expand
|
|
42
|
+
node.children.forEach(function (child) {
|
|
43
|
+
if (child.type.name === nestedExpand.name) {
|
|
44
|
+
var expandNode = (0, _utils.convertNestedExpandToExpand)(child, schema);
|
|
45
|
+
if (expandNode) {
|
|
46
|
+
outputNodes.push(expandNode);
|
|
47
|
+
} else {
|
|
48
|
+
outputNodes.push(child);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
outputNodes.push(child);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
38
54
|
} else {
|
|
39
55
|
(0, _unwrapStep.unwrapStep)([node], context);
|
|
40
56
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.expandSelectionToBlockRange = void 0;
|
|
6
|
+
exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.expandSelectionToBlockRange = exports.convertNestedExpandToExpand = 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");
|
|
@@ -112,6 +112,22 @@ var isListType = exports.isListType = function isListType(node, schema) {
|
|
|
112
112
|
return list === node.type;
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Converts a nestedExpand to a regular expand node.
|
|
118
|
+
* NestedExpands can only exist inside expands, so when breaking out or placing
|
|
119
|
+
* in containers that don't support nesting, they must be converted.
|
|
120
|
+
*/
|
|
121
|
+
var convertNestedExpandToExpand = exports.convertNestedExpandToExpand = function convertNestedExpandToExpand(node, schema) {
|
|
122
|
+
var _node$attrs;
|
|
123
|
+
var expandType = schema.nodes.expand;
|
|
124
|
+
if (!expandType) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return expandType.createAndFill({
|
|
128
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
129
|
+
}, node.content);
|
|
130
|
+
};
|
|
115
131
|
var getBlockNodesInRange = exports.getBlockNodesInRange = function getBlockNodesInRange(range) {
|
|
116
132
|
if (range.endIndex - range.startIndex <= 1) {
|
|
117
133
|
return [range.parent.child(range.startIndex)];
|
|
@@ -48,17 +48,7 @@
|
|
|
48
48
|
export const createBlockMenuRegistry = () => {
|
|
49
49
|
const components = [];
|
|
50
50
|
const register = blockMenuComponents => {
|
|
51
|
-
|
|
52
|
-
// Find if a component with the same key already exists
|
|
53
|
-
const existingIndex = components.findIndex(comp => comp.key === newComponent.key);
|
|
54
|
-
if (existingIndex !== -1) {
|
|
55
|
-
// Replace the existing component
|
|
56
|
-
components[existingIndex] = newComponent;
|
|
57
|
-
} else {
|
|
58
|
-
// Add new component
|
|
59
|
-
components.push(newComponent);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
51
|
+
components.push(...blockMenuComponents);
|
|
62
52
|
};
|
|
63
53
|
return {
|
|
64
54
|
register,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
1
|
import { isListType } from '../utils';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -29,7 +28,8 @@ export const listToDecisionListStep = (nodes, context) => {
|
|
|
29
28
|
schema
|
|
30
29
|
} = context;
|
|
31
30
|
const paragraphType = schema.nodes.paragraph;
|
|
32
|
-
|
|
31
|
+
const unsupportedContent = [];
|
|
32
|
+
const transformedNodes = nodes.map(node => {
|
|
33
33
|
if (!isListType(node, schema)) {
|
|
34
34
|
return node;
|
|
35
35
|
}
|
|
@@ -39,20 +39,18 @@ export const listToDecisionListStep = (nodes, context) => {
|
|
|
39
39
|
item.forEach(child => {
|
|
40
40
|
if (child.type === paragraphType) {
|
|
41
41
|
// paragraph may contain hard breaks etc.
|
|
42
|
-
child.
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
42
|
+
itemContent.push(...child.children);
|
|
43
|
+
} else if (child.isText) {
|
|
46
44
|
itemContent.push(child);
|
|
45
|
+
} else if (!isListType(child, schema)) {
|
|
46
|
+
unsupportedContent.push(child);
|
|
47
47
|
}
|
|
48
|
-
// TODO: EDITOR-3887 - Skip mediaSingle, codeBlock, and nested lists
|
|
49
48
|
});
|
|
50
|
-
const decisionItem = schema.nodes.decisionItem.create({},
|
|
51
|
-
|
|
52
|
-
decisionItems.push(decisionItem);
|
|
53
|
-
}
|
|
49
|
+
const decisionItem = schema.nodes.decisionItem.create({}, itemContent);
|
|
50
|
+
decisionItems.push(decisionItem);
|
|
54
51
|
});
|
|
55
|
-
const decisionList = schema.nodes.decisionList.create({},
|
|
52
|
+
const decisionList = schema.nodes.decisionList.create({}, decisionItems);
|
|
56
53
|
return decisionList || node;
|
|
57
54
|
});
|
|
55
|
+
return [...transformedNodes, ...unsupportedContent];
|
|
58
56
|
};
|