@atlaskit/editor-plugin-block-menu 5.1.6 → 5.1.8
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 +18 -0
- package/dist/cjs/editor-commands/transform-node-utils/flattenListStep.js +9 -32
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +5 -4
- package/dist/cjs/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +30 -1
- package/dist/cjs/editor-commands/transform-node-utils/wrapMixedContentStep.js +141 -0
- package/dist/cjs/editor-commands/transformNode.js +6 -6
- package/dist/cjs/ui/block-menu-components.js +29 -24
- package/dist/cjs/ui/suggested-items-renderer.js +62 -0
- package/dist/cjs/ui/utils/suggested-items-rank.js +66 -0
- package/dist/es2019/editor-commands/transform-node-utils/flattenListStep.js +9 -32
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -4
- package/dist/es2019/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +29 -1
- package/dist/es2019/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
- package/dist/es2019/editor-commands/transformNode.js +2 -2
- package/dist/es2019/ui/block-menu-components.js +12 -9
- package/dist/es2019/ui/suggested-items-renderer.js +48 -0
- package/dist/es2019/ui/utils/suggested-items-rank.js +130 -0
- package/dist/esm/editor-commands/transform-node-utils/flattenListStep.js +9 -32
- package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -4
- package/dist/esm/editor-commands/transform-node-utils/unwrapListStep.js +16 -1
- package/dist/esm/editor-commands/transform-node-utils/utils.js +30 -1
- package/dist/esm/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
- package/dist/esm/editor-commands/transformNode.js +4 -4
- package/dist/esm/ui/block-menu-components.js +30 -25
- package/dist/esm/ui/suggested-items-renderer.js +54 -0
- package/dist/esm/ui/utils/suggested-items-rank.js +60 -0
- package/dist/types/editor-commands/transform-node-utils/flattenListStep.d.ts +0 -18
- package/dist/types/editor-commands/transform-node-utils/unwrapListStep.d.ts +16 -1
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +12 -0
- package/dist/types/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
- package/dist/types/ui/suggested-items-renderer.d.ts +8 -0
- package/dist/types/ui/utils/suggested-items-rank.d.ts +45 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/flattenListStep.d.ts +0 -18
- package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapListStep.d.ts +16 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +12 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
- package/dist/types-ts4.5/ui/suggested-items-renderer.d.ts +8 -0
- package/dist/types-ts4.5/ui/utils/suggested-items-rank.d.ts +45 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1ce87340b7e3e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1ce87340b7e3e) -
|
|
8
|
+
[ux] Implement wrapMixedContentStep function to handle complex container transformations
|
|
9
|
+
- [`4e0c1ce981b5e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4e0c1ce981b5e) -
|
|
10
|
+
EDITOR-2930: Add SuggestedItemsRenderer for suggested block menu section
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 5.1.7
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`65ef204463ce4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65ef204463ce4) -
|
|
18
|
+
Add predicate param to expandBlockRange, add logic to cater for selection being broken in lists
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 5.1.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -5,39 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.flattenListStep = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
-
var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes) {
|
|
8
|
+
var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes, schema) {
|
|
9
9
|
var items = [];
|
|
10
|
+
var paragraph = schema.nodes.paragraph;
|
|
10
11
|
var _extract = function extract(currentNode) {
|
|
11
12
|
currentNode.forEach(function (child) {
|
|
12
|
-
// list item -> take content without nested lists, then recurse into nested lists
|
|
13
13
|
if (itemTypes.some(function (type) {
|
|
14
14
|
return child.type === type;
|
|
15
15
|
})) {
|
|
16
|
-
// Filter out nested list nodes from the list item's content
|
|
17
16
|
var contentWithoutNestedLists = [];
|
|
18
17
|
var nestedLists = [];
|
|
19
18
|
child.forEach(function (grandChild) {
|
|
20
19
|
if (listTypes.some(function (type) {
|
|
21
20
|
return grandChild.type === type;
|
|
22
21
|
})) {
|
|
23
|
-
// This is a nested list - collect it for later processing
|
|
24
22
|
nestedLists.push(grandChild);
|
|
25
23
|
} else {
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (grandChild.isText) {
|
|
25
|
+
contentWithoutNestedLists.push(paragraph.createAndFill({}, grandChild));
|
|
26
|
+
} else {
|
|
27
|
+
contentWithoutNestedLists.push(grandChild);
|
|
28
|
+
}
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
-
// Add the list item with only its non-list content
|
|
32
31
|
items.push(child.copy(_model.Fragment.from(contentWithoutNestedLists)));
|
|
33
|
-
|
|
34
|
-
// Now process nested lists to maintain document order
|
|
35
32
|
nestedLists.forEach(function (nestedList) {
|
|
36
33
|
_extract(nestedList);
|
|
37
34
|
});
|
|
38
|
-
}
|
|
39
|
-
// lists -> keep operating
|
|
40
|
-
else if (listTypes.some(function (type) {
|
|
35
|
+
} else if (listTypes.some(function (type) {
|
|
41
36
|
return child.type === type;
|
|
42
37
|
})) {
|
|
43
38
|
_extract(child);
|
|
@@ -53,24 +48,6 @@ var extractNestedLists = function extractNestedLists(node, listTypes, itemTypes)
|
|
|
53
48
|
* to it's first ancestor list, maintaining document order.
|
|
54
49
|
*
|
|
55
50
|
* @example
|
|
56
|
-
* Input:
|
|
57
|
-
* - bulletList
|
|
58
|
-
* - listItem "A"
|
|
59
|
-
* - listItem "B"
|
|
60
|
-
* - bulletList
|
|
61
|
-
* - listItem "C"
|
|
62
|
-
* - listItem "D"
|
|
63
|
-
* - listItem "E"
|
|
64
|
-
*
|
|
65
|
-
* Output:
|
|
66
|
-
* - bulletList
|
|
67
|
-
* - listItem "A"
|
|
68
|
-
* - listItem "B"
|
|
69
|
-
* - listItem "C"
|
|
70
|
-
* - listItem "D"
|
|
71
|
-
* - listItem "E"
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
51
|
* Input (deeply nested):
|
|
75
52
|
* - bulletList
|
|
76
53
|
* - listItem "1"
|
|
@@ -101,7 +78,7 @@ var flattenListStep = exports.flattenListStep = function flattenListStep(nodes,
|
|
|
101
78
|
if (listTypes.some(function (type) {
|
|
102
79
|
return node.type === type;
|
|
103
80
|
})) {
|
|
104
|
-
return node.copy(_model.Fragment.from(extractNestedLists(node, listTypes, [context.schema.nodes.listItem, context.schema.nodes.taskItem])));
|
|
81
|
+
return node.copy(_model.Fragment.from(extractNestedLists(node, listTypes, [context.schema.nodes.listItem, context.schema.nodes.taskItem], context.schema)));
|
|
105
82
|
}
|
|
106
83
|
return node;
|
|
107
84
|
});
|
|
@@ -14,6 +14,7 @@ var _unwrapExpandStep = require("./unwrapExpandStep");
|
|
|
14
14
|
var _unwrapListStep = require("./unwrapListStep");
|
|
15
15
|
var _unwrapStep = require("./unwrapStep");
|
|
16
16
|
var _wrapIntoLayoutStep = require("./wrapIntoLayoutStep");
|
|
17
|
+
var _wrapMixedContentStep = require("./wrapMixedContentStep");
|
|
17
18
|
var _wrapStep = require("./wrapStep");
|
|
18
19
|
// Exampled step for overrides:
|
|
19
20
|
// - open Block menu on a paragraph, click 'Panel' in the Turn into'
|
|
@@ -62,15 +63,15 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
62
63
|
codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
|
|
63
64
|
},
|
|
64
65
|
expand: {
|
|
65
|
-
panel: [_unwrapExpandStep.unwrapExpandStep,
|
|
66
|
-
blockquote: [_unwrapExpandStep.unwrapExpandStep,
|
|
66
|
+
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
67
|
+
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
67
68
|
layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
68
69
|
paragraph: [_unwrapExpandStep.unwrapExpandStep],
|
|
69
70
|
codeBlock: [_unwrapExpandStep.unwrapExpandStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
|
|
70
71
|
},
|
|
71
72
|
nestedExpand: {
|
|
72
|
-
panel: [_unwrapExpandStep.unwrapExpandStep,
|
|
73
|
-
blockquote: [_unwrapExpandStep.unwrapExpandStep,
|
|
73
|
+
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
74
|
+
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
74
75
|
paragraph: [_unwrapExpandStep.unwrapExpandStep],
|
|
75
76
|
codeBlock: [_unwrapExpandStep.unwrapExpandStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
|
|
76
77
|
},
|
|
@@ -7,8 +7,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.unwrapListStep = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
/**
|
|
10
|
-
* Given an array of nodes,
|
|
10
|
+
* Given an array of nodes, processes each list removing all parent list nodes and
|
|
11
|
+
* just returning their child contents.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* Input:
|
|
15
|
+
* - bulletList
|
|
16
|
+
* - listItem "1"
|
|
17
|
+
* - paragraph "1"
|
|
18
|
+
* - listItem "2"
|
|
19
|
+
* - paragraph "2"
|
|
20
|
+
*
|
|
21
|
+
* Output:
|
|
22
|
+
* - paragraph "1"
|
|
23
|
+
* - paragraph "2"
|
|
24
|
+
*
|
|
11
25
|
* @param nodes
|
|
26
|
+
* @param context
|
|
12
27
|
* @returns
|
|
13
28
|
*/
|
|
14
29
|
var unwrapListStep = exports.unwrapListStep = function unwrapListStep(nodes, context) {
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = void 0;
|
|
6
|
+
exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.expandSelectionToBlockRange = void 0;
|
|
7
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
7
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
10
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
@@ -54,4 +55,32 @@ var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = fu
|
|
|
54
55
|
return 'nestedExpand';
|
|
55
56
|
}
|
|
56
57
|
return nodeTypeName;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Use common expandToBlockRange function, but account for edge cases with lists.
|
|
62
|
+
*
|
|
63
|
+
* @param selection
|
|
64
|
+
* @param schema
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function expandSelectionToBlockRange(selection, schema) {
|
|
68
|
+
var isListInSelection = (0, _utils.hasParentNode)(function (node) {
|
|
69
|
+
return node.type === schema.nodes.bulletList || node.type === schema.nodes.orderedList;
|
|
70
|
+
})(selection);
|
|
71
|
+
var _expandToBlockRange = (0, _selection.expandToBlockRange)(selection.$from, selection.$to, function (node) {
|
|
72
|
+
if (!isListInSelection) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (node.type === schema.nodes.bulletList || node.type === schema.nodes.orderedList) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}),
|
|
80
|
+
$from = _expandToBlockRange.$from,
|
|
81
|
+
$to = _expandToBlockRange.$to;
|
|
82
|
+
return {
|
|
83
|
+
$from: $from,
|
|
84
|
+
$to: $to
|
|
85
|
+
};
|
|
57
86
|
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.wrapMixedContentStep = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
+
var _types = require("./types");
|
|
11
|
+
var _unwrapStep = require("./unwrapStep");
|
|
12
|
+
/**
|
|
13
|
+
* Determines if a node can be flattened (unwrapped and its contents merged).
|
|
14
|
+
*
|
|
15
|
+
* According to the text transformations list, flattenable nodes are:
|
|
16
|
+
* - Bulleted list, Numbered list, Task list
|
|
17
|
+
* - Text nodes (heading, paragraph)
|
|
18
|
+
*
|
|
19
|
+
* Containers (panels, expands, layouts, blockquotes) and atomic nodes (tables, media, macros) break out.
|
|
20
|
+
*/
|
|
21
|
+
var canFlatten = function canFlatten(node) {
|
|
22
|
+
var category = _types.NODE_CATEGORY_BY_TYPE[node.type.name];
|
|
23
|
+
// Text and list nodes can be flattened (converted to simpler forms)
|
|
24
|
+
return category === 'text' || category === 'list';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Flattens a node by extracting its contents using the appropriate unwrap step.
|
|
29
|
+
* This is only called for text and list nodes that can be converted to simpler forms.
|
|
30
|
+
* Uses unwrapStep to extract children from list containers.
|
|
31
|
+
*/
|
|
32
|
+
var flattenNode = function flattenNode(node, context) {
|
|
33
|
+
return (0, _unwrapStep.unwrapStep)([node], context);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Determines if a node can be wrapped in the target container type.
|
|
38
|
+
* Uses the schema's validContent to check if the target container can hold this node.
|
|
39
|
+
*
|
|
40
|
+
* Note: What can be wrapped depends on the target container type - for example:
|
|
41
|
+
* - Tables and media CAN go inside expand nodes
|
|
42
|
+
* - Tables CANNOT go inside panels or blockquotes
|
|
43
|
+
*/
|
|
44
|
+
var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeTypeName) {
|
|
45
|
+
// Same-type containers should break out as separate containers
|
|
46
|
+
if (node.type.name === targetNodeTypeName) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Use the schema to determine if this node can be contained in the target
|
|
51
|
+
try {
|
|
52
|
+
return targetNodeType.validContent(_model.Fragment.from(node));
|
|
53
|
+
} catch (_unused) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Converts a nestedExpand to a regular expand node.
|
|
60
|
+
* NestedExpands can only exist inside expands, so when breaking out they must be converted.
|
|
61
|
+
*/
|
|
62
|
+
var convertNestedExpandToExpand = function convertNestedExpandToExpand(node, schema) {
|
|
63
|
+
var _node$attrs;
|
|
64
|
+
var expandType = schema.nodes.expand;
|
|
65
|
+
if (!expandType) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return expandType.createAndFill({
|
|
69
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
70
|
+
}, node.content);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A wrap step that handles mixed content according to the Compatibility Matrix:
|
|
75
|
+
* - Wraps consecutive compatible nodes into the target container
|
|
76
|
+
* - Same-type containers break out as separate containers (preserved as-is)
|
|
77
|
+
* - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
|
|
78
|
+
* - Container structures that can't be nested in target break out (not flattened)
|
|
79
|
+
* - Text/list nodes that can't be wrapped are flattened and merged into the container
|
|
80
|
+
* - Atomic nodes (tables, media, macros) break out
|
|
81
|
+
*
|
|
82
|
+
* What can be wrapped depends on the target container's schema:
|
|
83
|
+
* - expand → panel: tables break out, nestedExpands convert to expands and break out
|
|
84
|
+
* - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
|
|
85
|
+
* - expand → expand: tables/media stay inside (expands can contain them)
|
|
86
|
+
*
|
|
87
|
+
* Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
|
|
88
|
+
* Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
|
|
89
|
+
* Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
|
|
90
|
+
*/
|
|
91
|
+
var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedContentStep(nodes, context) {
|
|
92
|
+
var schema = context.schema,
|
|
93
|
+
targetNodeTypeName = context.targetNodeTypeName;
|
|
94
|
+
var targetNodeType = schema.nodes[targetNodeTypeName];
|
|
95
|
+
if (!targetNodeType) {
|
|
96
|
+
return nodes;
|
|
97
|
+
}
|
|
98
|
+
var result = [];
|
|
99
|
+
var currentContainerContent = [];
|
|
100
|
+
var flushCurrentContainer = function flushCurrentContainer() {
|
|
101
|
+
if (currentContainerContent.length > 0) {
|
|
102
|
+
var containerNode = targetNodeType.createAndFill({}, _model.Fragment.fromArray(currentContainerContent));
|
|
103
|
+
if (containerNode) {
|
|
104
|
+
result.push(containerNode);
|
|
105
|
+
}
|
|
106
|
+
currentContainerContent = [];
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
nodes.forEach(function (node) {
|
|
110
|
+
if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
|
|
111
|
+
// Node can be wrapped - add to current container content
|
|
112
|
+
currentContainerContent.push(node);
|
|
113
|
+
} else if (node.type.name === targetNodeTypeName) {
|
|
114
|
+
// Same-type container - breaks out as a separate container (preserved as-is)
|
|
115
|
+
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
116
|
+
flushCurrentContainer();
|
|
117
|
+
result.push(node);
|
|
118
|
+
} else if (node.type.name === 'nestedExpand') {
|
|
119
|
+
// NestedExpand can't be wrapped and can't exist outside an expand
|
|
120
|
+
// Convert to regular expand and break out
|
|
121
|
+
flushCurrentContainer();
|
|
122
|
+
var expandNode = convertNestedExpandToExpand(node, schema);
|
|
123
|
+
if (expandNode) {
|
|
124
|
+
result.push(expandNode);
|
|
125
|
+
}
|
|
126
|
+
} else if (canFlatten(node)) {
|
|
127
|
+
var _currentContainerCont;
|
|
128
|
+
// Node cannot be wrapped but CAN be flattened - flatten and add to container
|
|
129
|
+
var flattenedNodes = flattenNode(node, context);
|
|
130
|
+
(_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, (0, _toConsumableArray2.default)(flattenedNodes));
|
|
131
|
+
} else {
|
|
132
|
+
// Node cannot be wrapped AND cannot be flattened (containers, tables, media, macros) - break out
|
|
133
|
+
flushCurrentContainer();
|
|
134
|
+
result.push(node);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Flush any remaining content into a container
|
|
139
|
+
flushCurrentContainer();
|
|
140
|
+
return result.length > 0 ? result : nodes;
|
|
141
|
+
};
|
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformNode = void 0;
|
|
7
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
8
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
10
9
|
var _transform = require("./transform-node-utils/transform");
|
|
11
|
-
var _utils = require("./
|
|
10
|
+
var _utils = require("./transform-node-utils/utils");
|
|
11
|
+
var _utils2 = require("./transforms/utils");
|
|
12
12
|
var transformNode = exports.transformNode = function transformNode(api) {
|
|
13
13
|
return (
|
|
14
14
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -20,13 +20,13 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
20
20
|
if (!preservedSelection) {
|
|
21
21
|
return tr;
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
$from =
|
|
25
|
-
$to =
|
|
23
|
+
var _expandSelectionToBlo = (0, _utils.expandSelectionToBlockRange)(preservedSelection, tr.doc.type.schema),
|
|
24
|
+
$from = _expandSelectionToBlo.$from,
|
|
25
|
+
$to = _expandSelectionToBlo.$to;
|
|
26
26
|
var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
|
|
27
27
|
var selectedParent = $from.parent;
|
|
28
28
|
var fragment = _model.Fragment.empty;
|
|
29
|
-
var isList = (0,
|
|
29
|
+
var isList = (0, _utils2.isListNode)(selectedParent);
|
|
30
30
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
31
31
|
slice.content.forEach(function (node) {
|
|
32
32
|
var outputNode = (0, _transform.getOutputNodes)({
|
|
@@ -17,6 +17,7 @@ var _formatMenuNested = require("./format-menu-nested");
|
|
|
17
17
|
var _formatMenuSection = require("./format-menu-section");
|
|
18
18
|
var _moveDown = require("./move-down");
|
|
19
19
|
var _moveUp = require("./move-up");
|
|
20
|
+
var _suggestedItemsRenderer = require("./suggested-items-renderer");
|
|
20
21
|
var getMoveUpMoveDownMenuComponents = function getMoveUpMoveDownMenuComponents(api) {
|
|
21
22
|
return [{
|
|
22
23
|
type: 'block-menu-item',
|
|
@@ -73,13 +74,17 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
73
74
|
rank: _blockMenu.TRANSFORM_MENU_ITEM_RANK[_blockMenu.TRANSFORM_SUGGESTED_MENU_SECTION.key]
|
|
74
75
|
},
|
|
75
76
|
component: function component() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
return /*#__PURE__*/_react.default.createElement(_suggestedItemsRenderer.SuggestedItemsRenderer, {
|
|
78
|
+
api: api
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
type: 'block-menu-item',
|
|
83
|
+
key: _blockMenu.TRANSFORM_SUGGESTED_MENU_ITEM.key,
|
|
84
|
+
parent: {
|
|
85
|
+
type: 'block-menu-section',
|
|
86
|
+
key: _blockMenu.TRANSFORM_SUGGESTED_MENU_SECTION.key,
|
|
87
|
+
rank: _blockMenu.TRANSFORM_SUGGESTED_MENU_SECTION_RANK[_blockMenu.TRANSFORM_SUGGESTED_MENU_ITEM.key]
|
|
83
88
|
}
|
|
84
89
|
}, {
|
|
85
90
|
type: 'block-menu-section',
|
|
@@ -90,10 +95,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
90
95
|
rank: _blockMenu.TRANSFORM_MENU_ITEM_RANK[_blockMenu.TRANSFORM_CREATE_MENU_SECTION.key]
|
|
91
96
|
},
|
|
92
97
|
component: function component() {
|
|
93
|
-
var
|
|
98
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
94
99
|
children: null
|
|
95
100
|
},
|
|
96
|
-
children =
|
|
101
|
+
children = _ref2.children;
|
|
97
102
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
98
103
|
title: "Create"
|
|
99
104
|
}, children);
|
|
@@ -107,10 +112,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
107
112
|
rank: _blockMenu.TRANSFORM_MENU_ITEM_RANK[_blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key]
|
|
108
113
|
},
|
|
109
114
|
component: function component() {
|
|
110
|
-
var
|
|
115
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
111
116
|
children: null
|
|
112
117
|
},
|
|
113
|
-
children =
|
|
118
|
+
children = _ref3.children;
|
|
114
119
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
115
120
|
title: "Structure"
|
|
116
121
|
}, children);
|
|
@@ -124,10 +129,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
124
129
|
rank: _blockMenu.TRANSFORM_MENU_ITEM_RANK[_blockMenu.TRANSFORM_HEADINGS_MENU_SECTION.key]
|
|
125
130
|
},
|
|
126
131
|
component: function component() {
|
|
127
|
-
var
|
|
132
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
128
133
|
children: null
|
|
129
134
|
},
|
|
130
|
-
children =
|
|
135
|
+
children = _ref4.children;
|
|
131
136
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
132
137
|
title: "Headings",
|
|
133
138
|
hasSeparator: true
|
|
@@ -137,23 +142,23 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
137
142
|
type: 'block-menu-section',
|
|
138
143
|
key: _blockMenu.TRANSFORM_MENU_SECTION.key,
|
|
139
144
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.TRANSFORM_MENU_SECTION.key],
|
|
140
|
-
component: function component(
|
|
141
|
-
var children =
|
|
145
|
+
component: function component(_ref5) {
|
|
146
|
+
var children = _ref5.children;
|
|
142
147
|
return /*#__PURE__*/_react.default.createElement(_formatMenuSection.FormatMenuSection, {
|
|
143
148
|
api: api
|
|
144
149
|
}, children);
|
|
145
150
|
}
|
|
146
151
|
}];
|
|
147
152
|
};
|
|
148
|
-
var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(
|
|
149
|
-
var api =
|
|
150
|
-
config =
|
|
153
|
+
var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(_ref6) {
|
|
154
|
+
var api = _ref6.api,
|
|
155
|
+
config = _ref6.config;
|
|
151
156
|
return [].concat((0, _toConsumableArray2.default)(getTurnIntoMenuComponents(api)), [{
|
|
152
157
|
type: 'block-menu-section',
|
|
153
158
|
key: _blockMenu.BLOCK_ACTIONS_MENU_SECTION.key,
|
|
154
159
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.BLOCK_ACTIONS_MENU_SECTION.key],
|
|
155
|
-
component: function component(
|
|
156
|
-
var children =
|
|
160
|
+
component: function component(_ref7) {
|
|
161
|
+
var children = _ref7.children;
|
|
157
162
|
return /*#__PURE__*/_react.default.createElement(_copySection.CopySection, {
|
|
158
163
|
api: api
|
|
159
164
|
}, children);
|
|
@@ -176,8 +181,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
176
181
|
type: 'block-menu-section',
|
|
177
182
|
key: _blockMenu.POSITION_MENU_SECTION.key,
|
|
178
183
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.POSITION_MENU_SECTION.key],
|
|
179
|
-
component: function component(
|
|
180
|
-
var children =
|
|
184
|
+
component: function component(_ref8) {
|
|
185
|
+
var children = _ref8.children;
|
|
181
186
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
182
187
|
hasSeparator: true
|
|
183
188
|
}, children);
|
|
@@ -186,8 +191,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
186
191
|
type: 'block-menu-section',
|
|
187
192
|
key: _blockMenu.DELETE_MENU_SECTION.key,
|
|
188
193
|
rank: _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[_blockMenu.DELETE_MENU_SECTION.key],
|
|
189
|
-
component: function component(
|
|
190
|
-
var children =
|
|
194
|
+
component: function component(_ref9) {
|
|
195
|
+
var children = _ref9.children;
|
|
191
196
|
return /*#__PURE__*/_react.default.createElement(_deleteSection.DeleteSection, {
|
|
192
197
|
api: api
|
|
193
198
|
}, children);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SuggestedItemsRenderer = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var _utils = require("../editor-commands/transform-node-utils/utils");
|
|
12
|
+
var _suggestedItemsRank = require("./utils/suggested-items-rank");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
var SuggestedItemsRenderer = exports.SuggestedItemsRenderer = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
15
|
+
var _api$blockMenu;
|
|
16
|
+
var api = _ref.api;
|
|
17
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
18
|
+
var _states$blockControls;
|
|
19
|
+
return {
|
|
20
|
+
preservedSelection: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.preservedSelection
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
preservedSelection = _useSharedPluginState.preservedSelection;
|
|
24
|
+
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
25
|
+
var menuItemsMap = (0, _react.useMemo)(function () {
|
|
26
|
+
if (!blockMenuComponents) {
|
|
27
|
+
return new Map();
|
|
28
|
+
}
|
|
29
|
+
return new Map(blockMenuComponents.filter(function (c) {
|
|
30
|
+
return c.type === 'block-menu-item';
|
|
31
|
+
}).map(function (item) {
|
|
32
|
+
return [item.key, item];
|
|
33
|
+
}));
|
|
34
|
+
}, [blockMenuComponents]);
|
|
35
|
+
var suggestedItems = (0, _react.useMemo)(function () {
|
|
36
|
+
if (!preservedSelection || menuItemsMap.size === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
var selectedNode = (0, _utils.getSelectedNode)(preservedSelection);
|
|
40
|
+
if (!selectedNode) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
var nodeTypeName = selectedNode.node.type.name;
|
|
44
|
+
var sortedKeys = (0, _suggestedItemsRank.getSortedSuggestedItems)(nodeTypeName);
|
|
45
|
+
return sortedKeys.map(function (key) {
|
|
46
|
+
return menuItemsMap.get(key);
|
|
47
|
+
}).filter(function (item) {
|
|
48
|
+
return item !== undefined;
|
|
49
|
+
});
|
|
50
|
+
}, [menuItemsMap, preservedSelection]);
|
|
51
|
+
if (suggestedItems.length === 0) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
55
|
+
title: "Suggested"
|
|
56
|
+
}, suggestedItems.map(function (item) {
|
|
57
|
+
var ItemComponent = item.component;
|
|
58
|
+
return ItemComponent ? /*#__PURE__*/_react.default.createElement(ItemComponent, {
|
|
59
|
+
key: item.key
|
|
60
|
+
}) : null;
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getSuggestedItemsForNodeType = exports.getSortedSuggestedItems = exports.TRANSFORM_SUGGESTED_ITEMS_RANK = exports.BLOCK_MENU_NODE_TYPES = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
11
|
+
var _TRANSFORM_SUGGESTED_;
|
|
12
|
+
/**
|
|
13
|
+
* Suggested transformations mapping for each block type.
|
|
14
|
+
* Based on the Block Menu Compatibility Matrix:
|
|
15
|
+
* https://hello.atlassian.net/wiki/spaces/egcuc/pages/5868774224/Block+Menu+Compatibility+Matrix#Suggested-for-each-block-type
|
|
16
|
+
*
|
|
17
|
+
* This mapping defines which transform items should appear in the TRANSFORM_SUGGESTED_MENU_SECTION
|
|
18
|
+
* for each block type, ranked by priority (lower rank = higher priority).
|
|
19
|
+
*
|
|
20
|
+
* Structure:
|
|
21
|
+
* {
|
|
22
|
+
* [sourceNodeType]: {
|
|
23
|
+
* [targetMenuItemKey]: rank
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
var BLOCK_MENU_NODE_TYPES = exports.BLOCK_MENU_NODE_TYPES = {
|
|
28
|
+
PARAGRAPH: 'paragraph',
|
|
29
|
+
EXPAND: 'expand',
|
|
30
|
+
BLOCKQUOTE: 'blockquote',
|
|
31
|
+
LAYOUT_SECTION: 'layoutSection',
|
|
32
|
+
PANEL: 'panel',
|
|
33
|
+
CODE_BLOCK: 'codeBlock',
|
|
34
|
+
DECISION: 'decisionList',
|
|
35
|
+
BULLET_LIST: 'bulletList',
|
|
36
|
+
ORDERED_LIST: 'orderedList',
|
|
37
|
+
HEADING: 'heading',
|
|
38
|
+
TASK_LIST: 'taskList',
|
|
39
|
+
MEDIA_SINGLE: 'mediaSingle',
|
|
40
|
+
EXTENSION: 'extension',
|
|
41
|
+
BODIED_EXTENSION: 'bodiedExtension',
|
|
42
|
+
BLOCK_CARD: 'blockCard',
|
|
43
|
+
EMBED_CARD: 'embedCard',
|
|
44
|
+
TABLE: 'table'
|
|
45
|
+
};
|
|
46
|
+
var TRANSFORM_SUGGESTED_ITEMS_RANK = exports.TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_HEADINGS_H3_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BODIED_EXTENSION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCK_CARD, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200)), BLOCK_MENU_NODE_TYPES.EMBED_CARD, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200)), BLOCK_MENU_NODE_TYPES.TABLE, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200)));
|
|
47
|
+
var getSuggestedItemsForNodeType = exports.getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
|
|
48
|
+
return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
|
|
49
|
+
};
|
|
50
|
+
var getSortedSuggestedItems = exports.getSortedSuggestedItems = function getSortedSuggestedItems(nodeType) {
|
|
51
|
+
var suggestions = getSuggestedItemsForNodeType(nodeType);
|
|
52
|
+
if (!suggestions) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return Object.entries(suggestions).sort(function (_ref, _ref2) {
|
|
56
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref, 2),
|
|
57
|
+
rankA = _ref3[1];
|
|
58
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
59
|
+
rankB = _ref4[1];
|
|
60
|
+
return rankA - rankB;
|
|
61
|
+
}).map(function (_ref5) {
|
|
62
|
+
var _ref6 = (0, _slicedToArray2.default)(_ref5, 1),
|
|
63
|
+
key = _ref6[0];
|
|
64
|
+
return key;
|
|
65
|
+
});
|
|
66
|
+
};
|