@atlaskit/editor-plugin-block-menu 18.0.2 → 18.0.3
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/blockMenuPlugin.js +1 -3
- package/dist/cjs/ui/block-menu.js +12 -6
- package/dist/es2019/blockMenuPlugin.js +1 -3
- package/dist/es2019/ui/block-menu.js +12 -6
- package/dist/esm/blockMenuPlugin.js +1 -3
- package/dist/esm/ui/block-menu.js +12 -6
- package/dist/types/ui/block-menu.d.ts +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 18.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fc26bfc51dd5c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fc26bfc51dd5c) -
|
|
8
|
+
Add sparse block-control surface anchors, intersection-driven candidates, and explicit visibility
|
|
9
|
+
invalidation for registry-backed block controls. Expose registration change subscriptions from the
|
|
10
|
+
UI control registry model, and refresh cached visibility from suggestion and collapse transaction
|
|
11
|
+
metadata. Under `platform_editor_block_control_migration`, use native node-anchor identity across
|
|
12
|
+
Editor and Block Controls, and route expand keyboard focus through the shared Block Controls
|
|
13
|
+
command. Preserve Show Diff visibility checks in both migration cohorts so block controls stay
|
|
14
|
+
hidden while a diff is displayed. Keep the block menu closed when a migrated layout-column handle
|
|
15
|
+
opens the layout menu, and close the layout menu when the selection moves away from its selected
|
|
16
|
+
columns.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 18.0.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -24,7 +24,6 @@ var _flag = require("./ui/flag");
|
|
|
24
24
|
var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
25
25
|
var api = _ref.api,
|
|
26
26
|
config = _ref.config;
|
|
27
|
-
var blockControlMigrationEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
|
|
28
27
|
var registry = (0, _editorActions.createBlockMenuRegistry)();
|
|
29
28
|
var transformSourceRegistry = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_menu_transform_extensions') ? (0, _transformSourceRegistry.createBlockMenuTransformSourceRegistry)() : undefined;
|
|
30
29
|
registry.register((0, _blockMenuComponents.getBlockMenuComponents)({
|
|
@@ -134,8 +133,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
134
133
|
api: api,
|
|
135
134
|
mountTo: popupsMountPoint,
|
|
136
135
|
boundariesElement: popupsBoundariesElement,
|
|
137
|
-
scrollableElement: popupsScrollableElement
|
|
138
|
-
useRegistryAnchor: blockControlMigrationEnabled
|
|
136
|
+
scrollableElement: popupsScrollableElement
|
|
139
137
|
}), /*#__PURE__*/_react.default.createElement(_flag.Flag, {
|
|
140
138
|
api: api
|
|
141
139
|
}));
|
|
@@ -180,8 +180,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
180
180
|
api = _ref5.api,
|
|
181
181
|
mountTo = _ref5.mountTo,
|
|
182
182
|
boundariesElement = _ref5.boundariesElement,
|
|
183
|
-
scrollableElement = _ref5.scrollableElement
|
|
184
|
-
useRegistryAnchor = _ref5.useRegistryAnchor;
|
|
183
|
+
scrollableElement = _ref5.scrollableElement;
|
|
185
184
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls', 'userIntent'], function (states) {
|
|
186
185
|
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$userIntentSta, _states$blockControls4;
|
|
187
186
|
return {
|
|
@@ -206,7 +205,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
206
205
|
surfaceDragHandle = _React$useState2[0],
|
|
207
206
|
setSurfaceDragHandle = _React$useState2[1];
|
|
208
207
|
_react.default.useLayoutEffect(function () {
|
|
209
|
-
if (!
|
|
208
|
+
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
210
209
|
return;
|
|
211
210
|
}
|
|
212
211
|
var readElement = function readElement() {
|
|
@@ -218,7 +217,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
218
217
|
readElement();
|
|
219
218
|
}
|
|
220
219
|
});
|
|
221
|
-
}, [editorView
|
|
220
|
+
}, [editorView]);
|
|
222
221
|
var openMenuHandleRef = _react.default.useRef(null);
|
|
223
222
|
var anchoredToRef = _react.default.useRef(undefined);
|
|
224
223
|
if (!isMenuOpen) {
|
|
@@ -229,7 +228,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
229
228
|
openMenuHandleRef.current = (_ref6 = (_surfaceDragHandleEle = _surfaceDragHandleElement.surfaceDragHandleElementStore.get(editorView)) !== null && _surfaceDragHandleEle !== void 0 ? _surfaceDragHandleEle : openMenuHandleRef.current) !== null && _ref6 !== void 0 ? _ref6 : surfaceDragHandle;
|
|
230
229
|
anchoredToRef.current = menuTriggerBy;
|
|
231
230
|
}
|
|
232
|
-
var targetHandleRef =
|
|
231
|
+
var targetHandleRef = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? (_openMenuHandleRef$cu = openMenuHandleRef.current) !== null && _openMenuHandleRef$cu !== void 0 ? _openMenuHandleRef$cu : surfaceDragHandle : editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(_styles.DRAG_HANDLE_SELECTOR);
|
|
233
232
|
var closeMenu = _react.default.useCallback(function () {
|
|
234
233
|
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
235
234
|
var _api$blockControls, _api$userIntent2;
|
|
@@ -268,13 +267,20 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
268
267
|
onDropdownOpenChanged(true);
|
|
269
268
|
setMenuHeight(((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.clientHeight) || FALLBACK_MENU_HEIGHT);
|
|
270
269
|
}, [isMenuOpen, onDropdownOpenChanged]);
|
|
270
|
+
|
|
271
|
+
// Nested dropdowns are portaled outside the block-menu popup. Sparse surface reconciliation
|
|
272
|
+
// dispatches after the menu opens, so a re-render can occur while focus is inside that portal.
|
|
271
273
|
var hasFocus = (_ref8 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) ||
|
|
272
274
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
273
275
|
document.activeElement === targetHandleRef || popupRef.current && (
|
|
274
276
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
275
277
|
popupRef.current.contains(document.activeElement) ||
|
|
276
278
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
277
|
-
popupRef.current === document.activeElement)
|
|
279
|
+
popupRef.current === document.activeElement) || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') &&
|
|
280
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
281
|
+
document.activeElement instanceof HTMLElement &&
|
|
282
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
283
|
+
document.activeElement.closest(_styles.NESTED_DROPDOWN_MENU) !== null) !== null && _ref8 !== void 0 ? _ref8 : false;
|
|
278
284
|
var selectedByShortcutOrDragHandle = !!isSelectedViaDragHandle || !!openedViaKeyboard;
|
|
279
285
|
|
|
280
286
|
// Use conditional hook based on feature flag
|
|
@@ -17,7 +17,6 @@ export const blockMenuPlugin = ({
|
|
|
17
17
|
api,
|
|
18
18
|
config
|
|
19
19
|
}) => {
|
|
20
|
-
const blockControlMigrationEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
21
20
|
const registry = createBlockMenuRegistry();
|
|
22
21
|
const transformSourceRegistry = isExperimentEnabled('platform_editor_block_menu_transform_extensions') ? createBlockMenuTransformSourceRegistry() : undefined;
|
|
23
22
|
registry.register(getBlockMenuComponents({
|
|
@@ -118,8 +117,7 @@ export const blockMenuPlugin = ({
|
|
|
118
117
|
api: api,
|
|
119
118
|
mountTo: popupsMountPoint,
|
|
120
119
|
boundariesElement: popupsBoundariesElement,
|
|
121
|
-
scrollableElement: popupsScrollableElement
|
|
122
|
-
useRegistryAnchor: blockControlMigrationEnabled
|
|
120
|
+
scrollableElement: popupsScrollableElement
|
|
123
121
|
}), /*#__PURE__*/React.createElement(Flag, {
|
|
124
122
|
api: api
|
|
125
123
|
}));
|
|
@@ -166,8 +166,7 @@ const BlockMenu = ({
|
|
|
166
166
|
api,
|
|
167
167
|
mountTo,
|
|
168
168
|
boundariesElement,
|
|
169
|
-
scrollableElement
|
|
170
|
-
useRegistryAnchor
|
|
169
|
+
scrollableElement
|
|
171
170
|
}) => {
|
|
172
171
|
var _openMenuHandleRef$cu, _editorView$dom, _ref2, _api$analytics2;
|
|
173
172
|
const {
|
|
@@ -193,7 +192,7 @@ const BlockMenu = ({
|
|
|
193
192
|
isMenuOpenRef.current = isMenuOpen;
|
|
194
193
|
const [surfaceDragHandle, setSurfaceDragHandle] = React.useState(null);
|
|
195
194
|
React.useLayoutEffect(() => {
|
|
196
|
-
if (!
|
|
195
|
+
if (!isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
197
196
|
return;
|
|
198
197
|
}
|
|
199
198
|
const readElement = () => setSurfaceDragHandle(surfaceDragHandleElementStore.get(editorView));
|
|
@@ -203,7 +202,7 @@ const BlockMenu = ({
|
|
|
203
202
|
readElement();
|
|
204
203
|
}
|
|
205
204
|
});
|
|
206
|
-
}, [editorView
|
|
205
|
+
}, [editorView]);
|
|
207
206
|
const openMenuHandleRef = React.useRef(null);
|
|
208
207
|
const anchoredToRef = React.useRef(undefined);
|
|
209
208
|
if (!isMenuOpen) {
|
|
@@ -214,7 +213,7 @@ const BlockMenu = ({
|
|
|
214
213
|
openMenuHandleRef.current = (_ref = (_surfaceDragHandleEle = surfaceDragHandleElementStore.get(editorView)) !== null && _surfaceDragHandleEle !== void 0 ? _surfaceDragHandleEle : openMenuHandleRef.current) !== null && _ref !== void 0 ? _ref : surfaceDragHandle;
|
|
215
214
|
anchoredToRef.current = menuTriggerBy;
|
|
216
215
|
}
|
|
217
|
-
const targetHandleRef =
|
|
216
|
+
const targetHandleRef = isExperimentEnabled('platform_editor_block_control_migration') ? (_openMenuHandleRef$cu = openMenuHandleRef.current) !== null && _openMenuHandleRef$cu !== void 0 ? _openMenuHandleRef$cu : surfaceDragHandle : editorView === null || editorView === void 0 ? void 0 : (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
|
|
218
217
|
const closeMenu = React.useCallback(() => {
|
|
219
218
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
220
219
|
tr
|
|
@@ -251,13 +250,20 @@ const BlockMenu = ({
|
|
|
251
250
|
onDropdownOpenChanged(true);
|
|
252
251
|
setMenuHeight(((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.clientHeight) || FALLBACK_MENU_HEIGHT);
|
|
253
252
|
}, [isMenuOpen, onDropdownOpenChanged]);
|
|
253
|
+
|
|
254
|
+
// Nested dropdowns are portaled outside the block-menu popup. Sparse surface reconciliation
|
|
255
|
+
// dispatches after the menu opens, so a re-render can occur while focus is inside that portal.
|
|
254
256
|
const hasFocus = (_ref2 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) ||
|
|
255
257
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
256
258
|
document.activeElement === targetHandleRef || popupRef.current && (
|
|
257
259
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
258
260
|
popupRef.current.contains(document.activeElement) ||
|
|
259
261
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
260
|
-
popupRef.current === document.activeElement)
|
|
262
|
+
popupRef.current === document.activeElement) || isExperimentEnabled('platform_editor_block_control_migration') &&
|
|
263
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
264
|
+
document.activeElement instanceof HTMLElement &&
|
|
265
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
266
|
+
document.activeElement.closest(NESTED_DROPDOWN_MENU) !== null) !== null && _ref2 !== void 0 ? _ref2 : false;
|
|
261
267
|
const selectedByShortcutOrDragHandle = !!isSelectedViaDragHandle || !!openedViaKeyboard;
|
|
262
268
|
|
|
263
269
|
// Use conditional hook based on feature flag
|
|
@@ -17,7 +17,6 @@ import { Flag } from './ui/flag';
|
|
|
17
17
|
export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
18
18
|
var api = _ref.api,
|
|
19
19
|
config = _ref.config;
|
|
20
|
-
var blockControlMigrationEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
21
20
|
var registry = createBlockMenuRegistry();
|
|
22
21
|
var transformSourceRegistry = isExperimentEnabled('platform_editor_block_menu_transform_extensions') ? createBlockMenuTransformSourceRegistry() : undefined;
|
|
23
22
|
registry.register(getBlockMenuComponents({
|
|
@@ -127,8 +126,7 @@ export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
127
126
|
api: api,
|
|
128
127
|
mountTo: popupsMountPoint,
|
|
129
128
|
boundariesElement: popupsBoundariesElement,
|
|
130
|
-
scrollableElement: popupsScrollableElement
|
|
131
|
-
useRegistryAnchor: blockControlMigrationEnabled
|
|
129
|
+
scrollableElement: popupsScrollableElement
|
|
132
130
|
}), /*#__PURE__*/React.createElement(Flag, {
|
|
133
131
|
api: api
|
|
134
132
|
}));
|
|
@@ -171,8 +171,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
171
171
|
api = _ref5.api,
|
|
172
172
|
mountTo = _ref5.mountTo,
|
|
173
173
|
boundariesElement = _ref5.boundariesElement,
|
|
174
|
-
scrollableElement = _ref5.scrollableElement
|
|
175
|
-
useRegistryAnchor = _ref5.useRegistryAnchor;
|
|
174
|
+
scrollableElement = _ref5.scrollableElement;
|
|
176
175
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'userIntent'], function (states) {
|
|
177
176
|
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$userIntentSta, _states$blockControls4;
|
|
178
177
|
return {
|
|
@@ -197,7 +196,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
197
196
|
surfaceDragHandle = _React$useState2[0],
|
|
198
197
|
setSurfaceDragHandle = _React$useState2[1];
|
|
199
198
|
React.useLayoutEffect(function () {
|
|
200
|
-
if (!
|
|
199
|
+
if (!isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
201
200
|
return;
|
|
202
201
|
}
|
|
203
202
|
var readElement = function readElement() {
|
|
@@ -209,7 +208,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
209
208
|
readElement();
|
|
210
209
|
}
|
|
211
210
|
});
|
|
212
|
-
}, [editorView
|
|
211
|
+
}, [editorView]);
|
|
213
212
|
var openMenuHandleRef = React.useRef(null);
|
|
214
213
|
var anchoredToRef = React.useRef(undefined);
|
|
215
214
|
if (!isMenuOpen) {
|
|
@@ -220,7 +219,7 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
220
219
|
openMenuHandleRef.current = (_ref6 = (_surfaceDragHandleEle = surfaceDragHandleElementStore.get(editorView)) !== null && _surfaceDragHandleEle !== void 0 ? _surfaceDragHandleEle : openMenuHandleRef.current) !== null && _ref6 !== void 0 ? _ref6 : surfaceDragHandle;
|
|
221
220
|
anchoredToRef.current = menuTriggerBy;
|
|
222
221
|
}
|
|
223
|
-
var targetHandleRef =
|
|
222
|
+
var targetHandleRef = isExperimentEnabled('platform_editor_block_control_migration') ? (_openMenuHandleRef$cu = openMenuHandleRef.current) !== null && _openMenuHandleRef$cu !== void 0 ? _openMenuHandleRef$cu : surfaceDragHandle : editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
|
|
224
223
|
var closeMenu = React.useCallback(function () {
|
|
225
224
|
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
226
225
|
var _api$blockControls, _api$userIntent2;
|
|
@@ -259,13 +258,20 @@ var BlockMenu = function BlockMenu(_ref5) {
|
|
|
259
258
|
onDropdownOpenChanged(true);
|
|
260
259
|
setMenuHeight(((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.clientHeight) || FALLBACK_MENU_HEIGHT);
|
|
261
260
|
}, [isMenuOpen, onDropdownOpenChanged]);
|
|
261
|
+
|
|
262
|
+
// Nested dropdowns are portaled outside the block-menu popup. Sparse surface reconciliation
|
|
263
|
+
// dispatches after the menu opens, so a re-render can occur while focus is inside that portal.
|
|
262
264
|
var hasFocus = (_ref8 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) ||
|
|
263
265
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
264
266
|
document.activeElement === targetHandleRef || popupRef.current && (
|
|
265
267
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
266
268
|
popupRef.current.contains(document.activeElement) ||
|
|
267
269
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
268
|
-
popupRef.current === document.activeElement)
|
|
270
|
+
popupRef.current === document.activeElement) || isExperimentEnabled('platform_editor_block_control_migration') &&
|
|
271
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
272
|
+
document.activeElement instanceof HTMLElement &&
|
|
273
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
274
|
+
document.activeElement.closest(NESTED_DROPDOWN_MENU) !== null) !== null && _ref8 !== void 0 ? _ref8 : false;
|
|
269
275
|
var selectedByShortcutOrDragHandle = !!isSelectedViaDragHandle || !!openedViaKeyboard;
|
|
270
276
|
|
|
271
277
|
// Use conditional hook based on feature flag
|
|
@@ -9,7 +9,6 @@ export type BlockMenuProps = {
|
|
|
9
9
|
editorView: EditorView | undefined;
|
|
10
10
|
mountTo?: HTMLElement;
|
|
11
11
|
scrollableElement?: HTMLElement;
|
|
12
|
-
useRegistryAnchor: boolean;
|
|
13
12
|
};
|
|
14
13
|
declare const _default_1: React.FC<WithIntlProps<BlockMenuProps & WrappedComponentProps>> & {
|
|
15
14
|
WrappedComponent: React.ComponentType<BlockMenuProps & WrappedComponentProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.3",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
29
29
|
"@atlaskit/css": "^1.1.0",
|
|
30
30
|
"@atlaskit/editor-plugin-analytics": "^19.0.0",
|
|
31
|
-
"@atlaskit/editor-plugin-block-controls": "^20.
|
|
31
|
+
"@atlaskit/editor-plugin-block-controls": "^20.1.0",
|
|
32
32
|
"@atlaskit/editor-plugin-decorations": "^19.0.0",
|
|
33
33
|
"@atlaskit/editor-plugin-selection": "^19.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-user-intent": "^17.0.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"memoize-one": "^6.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@atlaskit/editor-common": "^123.
|
|
52
|
+
"@atlaskit/editor-common": "^123.3.0",
|
|
53
53
|
"react": "^18.2.0 || ^19.2.0",
|
|
54
54
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
55
55
|
},
|