@atlaskit/editor-plugin-block-menu 5.1.7 → 5.1.9
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/transform.js +5 -4
- package/dist/cjs/editor-commands/transform-node-utils/wrapMixedContentStep.js +141 -0
- package/dist/cjs/ui/block-menu-components.js +29 -24
- package/dist/cjs/ui/block-menu-provider.js +19 -2
- package/dist/cjs/ui/move-down.js +18 -7
- package/dist/cjs/ui/move-up.js +18 -7
- package/dist/cjs/ui/suggested-items-renderer.js +62 -0
- package/dist/cjs/ui/utils/suggested-items-rank.js +0 -41
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -4
- package/dist/es2019/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
- package/dist/es2019/ui/block-menu-components.js +12 -9
- package/dist/es2019/ui/block-menu-provider.js +20 -3
- package/dist/es2019/ui/move-down.js +17 -7
- package/dist/es2019/ui/move-up.js +17 -7
- package/dist/es2019/ui/suggested-items-renderer.js +48 -0
- package/dist/es2019/ui/utils/suggested-items-rank.js +17 -110
- package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -4
- package/dist/esm/editor-commands/transform-node-utils/wrapMixedContentStep.js +135 -0
- package/dist/esm/ui/block-menu-components.js +30 -25
- package/dist/esm/ui/block-menu-provider.js +20 -3
- package/dist/esm/ui/move-down.js +16 -7
- package/dist/esm/ui/move-up.js +16 -7
- package/dist/esm/ui/suggested-items-renderer.js +54 -0
- package/dist/esm/ui/utils/suggested-items-rank.js +0 -41
- package/dist/types/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
- package/dist/types/ui/block-menu-provider.d.ts +8 -0
- package/dist/types/ui/suggested-items-renderer.d.ts +8 -0
- package/dist/types/ui/utils/suggested-items-rank.d.ts +0 -36
- package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapMixedContentStep.d.ts +20 -0
- package/dist/types-ts4.5/ui/block-menu-provider.d.ts +8 -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 +0 -36
- package/package.json +3 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
4
|
+
import { unwrapStep } from './unwrapStep';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Determines if a node can be flattened (unwrapped and its contents merged).
|
|
8
|
+
*
|
|
9
|
+
* According to the text transformations list, flattenable nodes are:
|
|
10
|
+
* - Bulleted list, Numbered list, Task list
|
|
11
|
+
* - Text nodes (heading, paragraph)
|
|
12
|
+
*
|
|
13
|
+
* Containers (panels, expands, layouts, blockquotes) and atomic nodes (tables, media, macros) break out.
|
|
14
|
+
*/
|
|
15
|
+
var canFlatten = function canFlatten(node) {
|
|
16
|
+
var category = NODE_CATEGORY_BY_TYPE[node.type.name];
|
|
17
|
+
// Text and list nodes can be flattened (converted to simpler forms)
|
|
18
|
+
return category === 'text' || category === 'list';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Flattens a node by extracting its contents using the appropriate unwrap step.
|
|
23
|
+
* This is only called for text and list nodes that can be converted to simpler forms.
|
|
24
|
+
* Uses unwrapStep to extract children from list containers.
|
|
25
|
+
*/
|
|
26
|
+
var flattenNode = function flattenNode(node, context) {
|
|
27
|
+
return unwrapStep([node], context);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Determines if a node can be wrapped in the target container type.
|
|
32
|
+
* Uses the schema's validContent to check if the target container can hold this node.
|
|
33
|
+
*
|
|
34
|
+
* Note: What can be wrapped depends on the target container type - for example:
|
|
35
|
+
* - Tables and media CAN go inside expand nodes
|
|
36
|
+
* - Tables CANNOT go inside panels or blockquotes
|
|
37
|
+
*/
|
|
38
|
+
var canWrapInTarget = function canWrapInTarget(node, targetNodeType, targetNodeTypeName) {
|
|
39
|
+
// Same-type containers should break out as separate containers
|
|
40
|
+
if (node.type.name === targetNodeTypeName) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Use the schema to determine if this node can be contained in the target
|
|
45
|
+
try {
|
|
46
|
+
return targetNodeType.validContent(Fragment.from(node));
|
|
47
|
+
} catch (_unused) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Converts a nestedExpand to a regular expand node.
|
|
54
|
+
* NestedExpands can only exist inside expands, so when breaking out they must be converted.
|
|
55
|
+
*/
|
|
56
|
+
var convertNestedExpandToExpand = function convertNestedExpandToExpand(node, schema) {
|
|
57
|
+
var _node$attrs;
|
|
58
|
+
var expandType = schema.nodes.expand;
|
|
59
|
+
if (!expandType) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return expandType.createAndFill({
|
|
63
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
64
|
+
}, node.content);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A wrap step that handles mixed content according to the Compatibility Matrix:
|
|
69
|
+
* - Wraps consecutive compatible nodes into the target container
|
|
70
|
+
* - Same-type containers break out as separate containers (preserved as-is)
|
|
71
|
+
* - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
|
|
72
|
+
* - Container structures that can't be nested in target break out (not flattened)
|
|
73
|
+
* - Text/list nodes that can't be wrapped are flattened and merged into the container
|
|
74
|
+
* - Atomic nodes (tables, media, macros) break out
|
|
75
|
+
*
|
|
76
|
+
* What can be wrapped depends on the target container's schema:
|
|
77
|
+
* - expand → panel: tables break out, nestedExpands convert to expands and break out
|
|
78
|
+
* - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
|
|
79
|
+
* - expand → expand: tables/media stay inside (expands can contain them)
|
|
80
|
+
*
|
|
81
|
+
* Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
|
|
82
|
+
* Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
|
|
83
|
+
* Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
|
|
84
|
+
*/
|
|
85
|
+
export var wrapMixedContentStep = function wrapMixedContentStep(nodes, context) {
|
|
86
|
+
var schema = context.schema,
|
|
87
|
+
targetNodeTypeName = context.targetNodeTypeName;
|
|
88
|
+
var targetNodeType = schema.nodes[targetNodeTypeName];
|
|
89
|
+
if (!targetNodeType) {
|
|
90
|
+
return nodes;
|
|
91
|
+
}
|
|
92
|
+
var result = [];
|
|
93
|
+
var currentContainerContent = [];
|
|
94
|
+
var flushCurrentContainer = function flushCurrentContainer() {
|
|
95
|
+
if (currentContainerContent.length > 0) {
|
|
96
|
+
var containerNode = targetNodeType.createAndFill({}, Fragment.fromArray(currentContainerContent));
|
|
97
|
+
if (containerNode) {
|
|
98
|
+
result.push(containerNode);
|
|
99
|
+
}
|
|
100
|
+
currentContainerContent = [];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
nodes.forEach(function (node) {
|
|
104
|
+
if (canWrapInTarget(node, targetNodeType, targetNodeTypeName)) {
|
|
105
|
+
// Node can be wrapped - add to current container content
|
|
106
|
+
currentContainerContent.push(node);
|
|
107
|
+
} else if (node.type.name === targetNodeTypeName) {
|
|
108
|
+
// Same-type container - breaks out as a separate container (preserved as-is)
|
|
109
|
+
// This handles: "If there's a panel in the expand, it breaks out into a separate panel"
|
|
110
|
+
flushCurrentContainer();
|
|
111
|
+
result.push(node);
|
|
112
|
+
} else if (node.type.name === 'nestedExpand') {
|
|
113
|
+
// NestedExpand can't be wrapped and can't exist outside an expand
|
|
114
|
+
// Convert to regular expand and break out
|
|
115
|
+
flushCurrentContainer();
|
|
116
|
+
var expandNode = convertNestedExpandToExpand(node, schema);
|
|
117
|
+
if (expandNode) {
|
|
118
|
+
result.push(expandNode);
|
|
119
|
+
}
|
|
120
|
+
} else if (canFlatten(node)) {
|
|
121
|
+
var _currentContainerCont;
|
|
122
|
+
// Node cannot be wrapped but CAN be flattened - flatten and add to container
|
|
123
|
+
var flattenedNodes = flattenNode(node, context);
|
|
124
|
+
(_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, _toConsumableArray(flattenedNodes));
|
|
125
|
+
} else {
|
|
126
|
+
// Node cannot be wrapped AND cannot be flattened (containers, tables, media, macros) - break out
|
|
127
|
+
flushCurrentContainer();
|
|
128
|
+
result.push(node);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Flush any remaining content into a container
|
|
133
|
+
flushCurrentContainer();
|
|
134
|
+
return result.length > 0 ? result : nodes;
|
|
135
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
3
|
+
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
4
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
5
5
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
6
6
|
import { CopySection } from './copy-section';
|
|
@@ -10,6 +10,7 @@ import { FormatMenuComponent } from './format-menu-nested';
|
|
|
10
10
|
import { FormatMenuSection } from './format-menu-section';
|
|
11
11
|
import { MoveDownDropdownItem } from './move-down';
|
|
12
12
|
import { MoveUpDropdownItem } from './move-up';
|
|
13
|
+
import { SuggestedItemsRenderer } from './suggested-items-renderer';
|
|
13
14
|
var getMoveUpMoveDownMenuComponents = function getMoveUpMoveDownMenuComponents(api) {
|
|
14
15
|
return [{
|
|
15
16
|
type: 'block-menu-item',
|
|
@@ -66,13 +67,17 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
66
67
|
rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_SUGGESTED_MENU_SECTION.key]
|
|
67
68
|
},
|
|
68
69
|
component: function component() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
return /*#__PURE__*/React.createElement(SuggestedItemsRenderer, {
|
|
71
|
+
api: api
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
type: 'block-menu-item',
|
|
76
|
+
key: TRANSFORM_SUGGESTED_MENU_ITEM.key,
|
|
77
|
+
parent: {
|
|
78
|
+
type: 'block-menu-section',
|
|
79
|
+
key: TRANSFORM_SUGGESTED_MENU_SECTION.key,
|
|
80
|
+
rank: TRANSFORM_SUGGESTED_MENU_SECTION_RANK[TRANSFORM_SUGGESTED_MENU_ITEM.key]
|
|
76
81
|
}
|
|
77
82
|
}, {
|
|
78
83
|
type: 'block-menu-section',
|
|
@@ -83,10 +88,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
83
88
|
rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_CREATE_MENU_SECTION.key]
|
|
84
89
|
},
|
|
85
90
|
component: function component() {
|
|
86
|
-
var
|
|
91
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
87
92
|
children: null
|
|
88
93
|
},
|
|
89
|
-
children =
|
|
94
|
+
children = _ref2.children;
|
|
90
95
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
91
96
|
title: "Create"
|
|
92
97
|
}, children);
|
|
@@ -100,10 +105,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
100
105
|
rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_STRUCTURE_MENU_SECTION.key]
|
|
101
106
|
},
|
|
102
107
|
component: function component() {
|
|
103
|
-
var
|
|
108
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
104
109
|
children: null
|
|
105
110
|
},
|
|
106
|
-
children =
|
|
111
|
+
children = _ref3.children;
|
|
107
112
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
108
113
|
title: "Structure"
|
|
109
114
|
}, children);
|
|
@@ -117,10 +122,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
117
122
|
rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_HEADINGS_MENU_SECTION.key]
|
|
118
123
|
},
|
|
119
124
|
component: function component() {
|
|
120
|
-
var
|
|
125
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
121
126
|
children: null
|
|
122
127
|
},
|
|
123
|
-
children =
|
|
128
|
+
children = _ref4.children;
|
|
124
129
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
125
130
|
title: "Headings",
|
|
126
131
|
hasSeparator: true
|
|
@@ -130,23 +135,23 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
130
135
|
type: 'block-menu-section',
|
|
131
136
|
key: TRANSFORM_MENU_SECTION.key,
|
|
132
137
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[TRANSFORM_MENU_SECTION.key],
|
|
133
|
-
component: function component(
|
|
134
|
-
var children =
|
|
138
|
+
component: function component(_ref5) {
|
|
139
|
+
var children = _ref5.children;
|
|
135
140
|
return /*#__PURE__*/React.createElement(FormatMenuSection, {
|
|
136
141
|
api: api
|
|
137
142
|
}, children);
|
|
138
143
|
}
|
|
139
144
|
}];
|
|
140
145
|
};
|
|
141
|
-
export var getBlockMenuComponents = function getBlockMenuComponents(
|
|
142
|
-
var api =
|
|
143
|
-
config =
|
|
146
|
+
export var getBlockMenuComponents = function getBlockMenuComponents(_ref6) {
|
|
147
|
+
var api = _ref6.api,
|
|
148
|
+
config = _ref6.config;
|
|
144
149
|
return [].concat(_toConsumableArray(getTurnIntoMenuComponents(api)), [{
|
|
145
150
|
type: 'block-menu-section',
|
|
146
151
|
key: BLOCK_ACTIONS_MENU_SECTION.key,
|
|
147
152
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[BLOCK_ACTIONS_MENU_SECTION.key],
|
|
148
|
-
component: function component(
|
|
149
|
-
var children =
|
|
153
|
+
component: function component(_ref7) {
|
|
154
|
+
var children = _ref7.children;
|
|
150
155
|
return /*#__PURE__*/React.createElement(CopySection, {
|
|
151
156
|
api: api
|
|
152
157
|
}, children);
|
|
@@ -169,8 +174,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref7) {
|
|
|
169
174
|
type: 'block-menu-section',
|
|
170
175
|
key: POSITION_MENU_SECTION.key,
|
|
171
176
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[POSITION_MENU_SECTION.key],
|
|
172
|
-
component: function component(
|
|
173
|
-
var children =
|
|
177
|
+
component: function component(_ref8) {
|
|
178
|
+
var children = _ref8.children;
|
|
174
179
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
175
180
|
hasSeparator: true
|
|
176
181
|
}, children);
|
|
@@ -179,8 +184,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref7) {
|
|
|
179
184
|
type: 'block-menu-section',
|
|
180
185
|
key: DELETE_MENU_SECTION.key,
|
|
181
186
|
rank: MAIN_BLOCK_MENU_SECTION_RANK[DELETE_MENU_SECTION.key],
|
|
182
|
-
component: function component(
|
|
183
|
-
var children =
|
|
187
|
+
component: function component(_ref9) {
|
|
188
|
+
var children = _ref9.children;
|
|
184
189
|
return /*#__PURE__*/React.createElement(DeleteSection, {
|
|
185
190
|
api: api
|
|
186
191
|
}, children);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, createContext, useContext } from 'react';
|
|
1
|
+
import React, { useCallback, createContext, useContext, useRef } from 'react';
|
|
2
2
|
var BlockMenuContext = /*#__PURE__*/createContext({
|
|
3
|
-
onDropdownOpenChanged: function onDropdownOpenChanged() {}
|
|
3
|
+
onDropdownOpenChanged: function onDropdownOpenChanged() {},
|
|
4
|
+
moveFocusTo: function moveFocusTo() {},
|
|
5
|
+
moveDownRef: /*#__PURE__*/React.createRef(),
|
|
6
|
+
moveUpRef: /*#__PURE__*/React.createRef()
|
|
4
7
|
});
|
|
5
8
|
export var useBlockMenu = function useBlockMenu() {
|
|
6
9
|
var context = useContext(BlockMenuContext);
|
|
@@ -12,6 +15,8 @@ export var useBlockMenu = function useBlockMenu() {
|
|
|
12
15
|
export var BlockMenuProvider = function BlockMenuProvider(_ref) {
|
|
13
16
|
var children = _ref.children,
|
|
14
17
|
api = _ref.api;
|
|
18
|
+
var moveUpRef = useRef(null);
|
|
19
|
+
var moveDownRef = useRef(null);
|
|
15
20
|
var onDropdownOpenChanged = useCallback(function (isOpen) {
|
|
16
21
|
if (!isOpen) {
|
|
17
22
|
// On Dropdown closed, return focus to editor
|
|
@@ -24,9 +29,21 @@ export var BlockMenuProvider = function BlockMenuProvider(_ref) {
|
|
|
24
29
|
}, 1);
|
|
25
30
|
}
|
|
26
31
|
}, [api]);
|
|
32
|
+
var moveFocusTo = useCallback(function (direction) {
|
|
33
|
+
if (direction === 'moveUp') {
|
|
34
|
+
var _moveUpRef$current;
|
|
35
|
+
(_moveUpRef$current = moveUpRef.current) === null || _moveUpRef$current === void 0 || _moveUpRef$current.focus();
|
|
36
|
+
} else if (direction === 'moveDown') {
|
|
37
|
+
var _moveDownRef$current;
|
|
38
|
+
(_moveDownRef$current = moveDownRef.current) === null || _moveDownRef$current === void 0 || _moveDownRef$current.focus();
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
27
41
|
return /*#__PURE__*/React.createElement(BlockMenuContext.Provider, {
|
|
28
42
|
value: {
|
|
29
|
-
onDropdownOpenChanged: onDropdownOpenChanged
|
|
43
|
+
onDropdownOpenChanged: onDropdownOpenChanged,
|
|
44
|
+
moveFocusTo: moveFocusTo,
|
|
45
|
+
moveDownRef: moveDownRef,
|
|
46
|
+
moveUpRef: moveUpRef
|
|
30
47
|
}
|
|
31
48
|
}, children);
|
|
32
49
|
};
|
package/dist/esm/ui/move-down.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { useIntl, injectIntl } from 'react-intl-next';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
@@ -6,11 +6,15 @@ import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages'
|
|
|
6
6
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
7
7
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
|
|
9
|
+
import { useBlockMenu } from './block-menu-provider';
|
|
9
10
|
import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
10
11
|
var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
|
|
11
12
|
var api = _ref.api;
|
|
12
13
|
var _useIntl = useIntl(),
|
|
13
14
|
formatMessage = _useIntl.formatMessage;
|
|
15
|
+
var _useBlockMenu = useBlockMenu(),
|
|
16
|
+
moveFocusTo = _useBlockMenu.moveFocusTo,
|
|
17
|
+
moveDownRef = _useBlockMenu.moveDownRef;
|
|
14
18
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (_ref2) {
|
|
15
19
|
var _blockControlsState$b;
|
|
16
20
|
var blockControlsState = _ref2.blockControlsState;
|
|
@@ -19,9 +23,18 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
|
|
|
19
23
|
};
|
|
20
24
|
}),
|
|
21
25
|
canMoveDown = _useSharedPluginState.canMoveDown;
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
var moveDownElement = moveDownRef.current;
|
|
28
|
+
if (!moveDownElement) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!canMoveDown && moveDownElement === document.activeElement) {
|
|
32
|
+
moveFocusTo('moveUp');
|
|
33
|
+
}
|
|
34
|
+
}, [canMoveDown, moveFocusTo, moveDownRef]);
|
|
22
35
|
var handleClick = function handleClick() {
|
|
23
36
|
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
24
|
-
var _api$analytics, _api$blockControls
|
|
37
|
+
var _api$analytics, _api$blockControls;
|
|
25
38
|
var tr = _ref3.tr;
|
|
26
39
|
var payload = {
|
|
27
40
|
action: ACTION.CLICKED,
|
|
@@ -35,15 +48,11 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
|
|
|
35
48
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(DIRECTION.DOWN)({
|
|
36
49
|
tr: tr
|
|
37
50
|
});
|
|
38
|
-
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
|
|
39
|
-
closeMenu: true
|
|
40
|
-
})({
|
|
41
|
-
tr: tr
|
|
42
|
-
});
|
|
43
51
|
return tr;
|
|
44
52
|
});
|
|
45
53
|
};
|
|
46
54
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
55
|
+
triggerRef: moveDownRef,
|
|
47
56
|
onClick: handleClick,
|
|
48
57
|
elemBefore: /*#__PURE__*/React.createElement(ArrowDownIcon, {
|
|
49
58
|
label: ""
|
package/dist/esm/ui/move-up.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { useIntl, injectIntl } from 'react-intl-next';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
@@ -6,11 +6,15 @@ import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages'
|
|
|
6
6
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
7
7
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
|
|
9
|
+
import { useBlockMenu } from './block-menu-provider';
|
|
9
10
|
import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
10
11
|
var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
|
|
11
12
|
var api = _ref.api;
|
|
12
13
|
var _useIntl = useIntl(),
|
|
13
14
|
formatMessage = _useIntl.formatMessage;
|
|
15
|
+
var _useBlockMenu = useBlockMenu(),
|
|
16
|
+
moveFocusTo = _useBlockMenu.moveFocusTo,
|
|
17
|
+
moveUpRef = _useBlockMenu.moveUpRef;
|
|
14
18
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (_ref2) {
|
|
15
19
|
var _blockControlsState$b;
|
|
16
20
|
var blockControlsState = _ref2.blockControlsState;
|
|
@@ -19,9 +23,18 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
|
|
|
19
23
|
};
|
|
20
24
|
}),
|
|
21
25
|
canMoveUp = _useSharedPluginState.canMoveUp;
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
var moveUpElement = moveUpRef.current;
|
|
28
|
+
if (!moveUpElement) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!canMoveUp && moveUpElement === document.activeElement) {
|
|
32
|
+
moveFocusTo('moveDown');
|
|
33
|
+
}
|
|
34
|
+
}, [canMoveUp, moveFocusTo, moveUpRef]);
|
|
22
35
|
var handleClick = function handleClick() {
|
|
23
36
|
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
24
|
-
var _api$analytics, _api$blockControls
|
|
37
|
+
var _api$analytics, _api$blockControls;
|
|
25
38
|
var tr = _ref3.tr;
|
|
26
39
|
var payload = {
|
|
27
40
|
action: ACTION.CLICKED,
|
|
@@ -35,15 +48,11 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
|
|
|
35
48
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.moveNodeWithBlockMenu(DIRECTION.UP)({
|
|
36
49
|
tr: tr
|
|
37
50
|
});
|
|
38
|
-
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
|
|
39
|
-
closeMenu: true
|
|
40
|
-
})({
|
|
41
|
-
tr: tr
|
|
42
|
-
});
|
|
43
51
|
return tr;
|
|
44
52
|
});
|
|
45
53
|
};
|
|
46
54
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
55
|
+
triggerRef: moveUpRef,
|
|
47
56
|
onClick: handleClick,
|
|
48
57
|
elemBefore: /*#__PURE__*/React.createElement(ArrowUpIcon, {
|
|
49
58
|
label: ""
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { getSelectedNode } from '../editor-commands/transform-node-utils/utils';
|
|
5
|
+
import { getSortedSuggestedItems } from './utils/suggested-items-rank';
|
|
6
|
+
export var SuggestedItemsRenderer = /*#__PURE__*/React.memo(function (_ref) {
|
|
7
|
+
var _api$blockMenu;
|
|
8
|
+
var api = _ref.api;
|
|
9
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
10
|
+
var _states$blockControls;
|
|
11
|
+
return {
|
|
12
|
+
preservedSelection: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.preservedSelection
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
preservedSelection = _useSharedPluginState.preservedSelection;
|
|
16
|
+
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
17
|
+
var menuItemsMap = useMemo(function () {
|
|
18
|
+
if (!blockMenuComponents) {
|
|
19
|
+
return new Map();
|
|
20
|
+
}
|
|
21
|
+
return new Map(blockMenuComponents.filter(function (c) {
|
|
22
|
+
return c.type === 'block-menu-item';
|
|
23
|
+
}).map(function (item) {
|
|
24
|
+
return [item.key, item];
|
|
25
|
+
}));
|
|
26
|
+
}, [blockMenuComponents]);
|
|
27
|
+
var suggestedItems = useMemo(function () {
|
|
28
|
+
if (!preservedSelection || menuItemsMap.size === 0) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
var selectedNode = getSelectedNode(preservedSelection);
|
|
32
|
+
if (!selectedNode) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
var nodeTypeName = selectedNode.node.type.name;
|
|
36
|
+
var sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
37
|
+
return sortedKeys.map(function (key) {
|
|
38
|
+
return menuItemsMap.get(key);
|
|
39
|
+
}).filter(function (item) {
|
|
40
|
+
return item !== undefined;
|
|
41
|
+
});
|
|
42
|
+
}, [menuItemsMap, preservedSelection]);
|
|
43
|
+
if (suggestedItems.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
47
|
+
title: "Suggested"
|
|
48
|
+
}, suggestedItems.map(function (item) {
|
|
49
|
+
var ItemComponent = item.component;
|
|
50
|
+
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
51
|
+
key: item.key
|
|
52
|
+
}) : null;
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
@@ -18,22 +18,6 @@ var _TRANSFORM_SUGGESTED_;
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { TRANSFORM_STRUCTURE_PANEL_MENU_ITEM, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM, TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM, TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_HEADINGS_H2_MENU_ITEM, TRANSFORM_HEADINGS_H3_MENU_ITEM, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
21
|
-
/**
|
|
22
|
-
* Node type keys that map to ProseMirror node types from the ADF schema.
|
|
23
|
-
* These values must match the NodeTypeName type.
|
|
24
|
-
*
|
|
25
|
-
* TypeScript will enforce that all values are valid NodeTypeName values.
|
|
26
|
-
* If a new node type is added, it must be added to NodeTypeName first.
|
|
27
|
-
*
|
|
28
|
-
* Reference: packages/editor/editor-plugin-block-menu/src/editor-commands/transform-node-utils/types.ts
|
|
29
|
-
*
|
|
30
|
-
* Note: 'heading' represents all heading levels (1-6) as a single node type.
|
|
31
|
-
* The specific level is determined by the node's `attrs.level` property at runtime.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // Usage:
|
|
35
|
-
* const nodeType = BLOCK_MENU_NODE_TYPES.PARAGRAPH; // Type: "paragraph"
|
|
36
|
-
*/
|
|
37
21
|
export var BLOCK_MENU_NODE_TYPES = {
|
|
38
22
|
PARAGRAPH: 'paragraph',
|
|
39
23
|
EXPAND: 'expand',
|
|
@@ -53,35 +37,10 @@ export var BLOCK_MENU_NODE_TYPES = {
|
|
|
53
37
|
EMBED_CARD: 'embedCard',
|
|
54
38
|
TABLE: 'table'
|
|
55
39
|
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Type for node type values extracted from BLOCK_MENU_NODE_TYPES
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Type for the suggested items rank mapping
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Mapping of source node types to suggested transformation menu items with their ranks.
|
|
67
|
-
* Lower rank number = higher priority in the suggested menu section.
|
|
68
|
-
*/
|
|
69
40
|
export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H3_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BODIED_EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCK_CARD, _defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200)), BLOCK_MENU_NODE_TYPES.EMBED_CARD, _defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 200)), BLOCK_MENU_NODE_TYPES.TABLE, _defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200)));
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get suggested menu items for a given node type
|
|
73
|
-
* @param nodeType - The source node type (e.g., 'paragraph', 'heading')
|
|
74
|
-
* @returns Object mapping menu item keys to their ranks, or undefined if no suggestions
|
|
75
|
-
*/
|
|
76
41
|
export var getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
|
|
77
42
|
return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
|
|
78
43
|
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get sorted suggested menu item keys for a given node type
|
|
82
|
-
* @param nodeType - The source node type
|
|
83
|
-
* @returns Array of menu item keys sorted by rank (highest priority first)
|
|
84
|
-
*/
|
|
85
44
|
export var getSortedSuggestedItems = function getSortedSuggestedItems(nodeType) {
|
|
86
45
|
var suggestions = getSuggestedItemsForNodeType(nodeType);
|
|
87
46
|
if (!suggestions) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TransformStep } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A wrap step that handles mixed content according to the Compatibility Matrix:
|
|
4
|
+
* - Wraps consecutive compatible nodes into the target container
|
|
5
|
+
* - Same-type containers break out as separate containers (preserved as-is)
|
|
6
|
+
* - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
|
|
7
|
+
* - Container structures that can't be nested in target break out (not flattened)
|
|
8
|
+
* - Text/list nodes that can't be wrapped are flattened and merged into the container
|
|
9
|
+
* - Atomic nodes (tables, media, macros) break out
|
|
10
|
+
*
|
|
11
|
+
* What can be wrapped depends on the target container's schema:
|
|
12
|
+
* - expand → panel: tables break out, nestedExpands convert to expands and break out
|
|
13
|
+
* - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
|
|
14
|
+
* - expand → expand: tables/media stay inside (expands can contain them)
|
|
15
|
+
*
|
|
16
|
+
* Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
|
|
17
|
+
* Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
|
|
18
|
+
* Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
|
|
19
|
+
*/
|
|
20
|
+
export declare const wrapMixedContentStep: TransformStep;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
+
export type Direction = 'moveUp' | 'moveDown';
|
|
4
5
|
type BlockMenuProviderProps = {
|
|
5
6
|
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
};
|
|
8
9
|
export type BlockMenuContextType = {
|
|
10
|
+
moveDownRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Function to move focus between move up and move down items.
|
|
13
|
+
* Used when one item is disabled and focused.
|
|
14
|
+
*/
|
|
15
|
+
moveFocusTo: (direction: Direction) => void;
|
|
16
|
+
moveUpRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
9
17
|
/**
|
|
10
18
|
* Callback for when the dropdown is open/closed. Receives an object with `isOpen` state.
|
|
11
19
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
+
type SuggestedItemsRendererProps = {
|
|
5
|
+
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const SuggestedItemsRenderer: React.NamedExoticComponent<SuggestedItemsRendererProps>;
|
|
8
|
+
export {};
|
|
@@ -13,22 +13,6 @@
|
|
|
13
13
|
* }
|
|
14
14
|
* }
|
|
15
15
|
*/
|
|
16
|
-
/**
|
|
17
|
-
* Node type keys that map to ProseMirror node types from the ADF schema.
|
|
18
|
-
* These values must match the NodeTypeName type.
|
|
19
|
-
*
|
|
20
|
-
* TypeScript will enforce that all values are valid NodeTypeName values.
|
|
21
|
-
* If a new node type is added, it must be added to NodeTypeName first.
|
|
22
|
-
*
|
|
23
|
-
* Reference: packages/editor/editor-plugin-block-menu/src/editor-commands/transform-node-utils/types.ts
|
|
24
|
-
*
|
|
25
|
-
* Note: 'heading' represents all heading levels (1-6) as a single node type.
|
|
26
|
-
* The specific level is determined by the node's `attrs.level` property at runtime.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // Usage:
|
|
30
|
-
* const nodeType = BLOCK_MENU_NODE_TYPES.PARAGRAPH; // Type: "paragraph"
|
|
31
|
-
*/
|
|
32
16
|
export declare const BLOCK_MENU_NODE_TYPES: {
|
|
33
17
|
readonly PARAGRAPH: "paragraph";
|
|
34
18
|
readonly EXPAND: "expand";
|
|
@@ -48,34 +32,14 @@ export declare const BLOCK_MENU_NODE_TYPES: {
|
|
|
48
32
|
readonly EMBED_CARD: "embedCard";
|
|
49
33
|
readonly TABLE: "table";
|
|
50
34
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Type for node type values extracted from BLOCK_MENU_NODE_TYPES
|
|
53
|
-
*/
|
|
54
35
|
export type BlockMenuNodeType = (typeof BLOCK_MENU_NODE_TYPES)[keyof typeof BLOCK_MENU_NODE_TYPES];
|
|
55
|
-
/**
|
|
56
|
-
* Type for the suggested items rank mapping
|
|
57
|
-
*/
|
|
58
36
|
export type SuggestedItemsRankMap = {
|
|
59
37
|
[nodeType: string]: {
|
|
60
38
|
[menuItemKey: string]: number;
|
|
61
39
|
};
|
|
62
40
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Mapping of source node types to suggested transformation menu items with their ranks.
|
|
65
|
-
* Lower rank number = higher priority in the suggested menu section.
|
|
66
|
-
*/
|
|
67
41
|
export declare const TRANSFORM_SUGGESTED_ITEMS_RANK: SuggestedItemsRankMap;
|
|
68
|
-
/**
|
|
69
|
-
* Get suggested menu items for a given node type
|
|
70
|
-
* @param nodeType - The source node type (e.g., 'paragraph', 'heading')
|
|
71
|
-
* @returns Object mapping menu item keys to their ranks, or undefined if no suggestions
|
|
72
|
-
*/
|
|
73
42
|
export declare const getSuggestedItemsForNodeType: (nodeType: string) => {
|
|
74
43
|
[menuItemKey: string]: number;
|
|
75
44
|
} | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Get sorted suggested menu item keys for a given node type
|
|
78
|
-
* @param nodeType - The source node type
|
|
79
|
-
* @returns Array of menu item keys sorted by rank (highest priority first)
|
|
80
|
-
*/
|
|
81
45
|
export declare const getSortedSuggestedItems: (nodeType: string) => string[];
|