@atlaskit/editor-plugin-selection-extension 15.0.17 → 15.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/ui/menu/SelectionExtensionMenuItems.js +18 -1
- package/dist/cjs/ui/utils/getBlockMenuTriggerExtensionKey.js +18 -0
- package/dist/cjs/ui/utils/registerBlockMenuItems.js +18 -2
- package/dist/es2019/ui/menu/SelectionExtensionMenuItems.js +19 -1
- package/dist/es2019/ui/utils/getBlockMenuTriggerExtensionKey.js +13 -0
- package/dist/es2019/ui/utils/registerBlockMenuItems.js +14 -2
- package/dist/esm/ui/menu/SelectionExtensionMenuItems.js +18 -1
- package/dist/esm/ui/utils/getBlockMenuTriggerExtensionKey.js +12 -0
- package/dist/esm/ui/utils/registerBlockMenuItems.js +18 -2
- package/dist/types/entry-points/types.d.ts +1 -1
- package/dist/types/types/index.d.ts +8 -1
- package/dist/types/ui/SelectionExtensionComponentContext.d.ts +3 -2
- package/dist/types/ui/menu/SelectionExtensionMenuItems.d.ts +2 -2
- package/dist/types/ui/utils/getBlockMenuTriggerExtensionKey.d.ts +9 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 15.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 15.0.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`6a73f3cc58350`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6a73f3cc58350) -
|
|
14
|
+
Hide block template action for agent-managed blocks behind the agent-managed block template
|
|
15
|
+
experiment.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 15.0.17
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -6,12 +6,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.SelectionExtensionMenuItems = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
|
+
var _SelectionExtensionComponentContext = require("../SelectionExtensionComponentContext");
|
|
11
|
+
var _getBlockMenuTriggerExtensionKey = require("../utils/getBlockMenuTriggerExtensionKey");
|
|
9
12
|
var _menuItems = require("../utils/menu-items");
|
|
10
13
|
var _SelectionExtensionDropdownItem = require("./SelectionExtensionDropdownItem");
|
|
11
14
|
var _SelectionExtensionNestedDropdownMenu = require("./SelectionExtensionNestedDropdownMenu");
|
|
12
15
|
var SelectionExtensionMenuItems = exports.SelectionExtensionMenuItems = function SelectionExtensionMenuItems(_ref) {
|
|
13
16
|
var getMenuItems = _ref.getMenuItems;
|
|
14
|
-
var
|
|
17
|
+
var _useSelectionExtensio = (0, _SelectionExtensionComponentContext.useSelectionExtensionComponentContext)(),
|
|
18
|
+
api = _useSelectionExtensio.api,
|
|
19
|
+
editorView = _useSelectionExtensio.editorView,
|
|
20
|
+
extensionKey = _useSelectionExtensio.extensionKey,
|
|
21
|
+
extensionLocation = _useSelectionExtensio.extensionLocation,
|
|
22
|
+
extensionSource = _useSelectionExtensio.extensionSource;
|
|
23
|
+
var extensionMenuItems = getMenuItems((0, _expValEquals.expValEquals)('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? {
|
|
24
|
+
blockMenuTriggerExtensionKey: (0, _getBlockMenuTriggerExtensionKey.getBlockMenuTriggerExtensionKey)({
|
|
25
|
+
api: api,
|
|
26
|
+
editorView: editorView
|
|
27
|
+
}),
|
|
28
|
+
extensionKey: extensionKey,
|
|
29
|
+
extensionLocation: extensionLocation,
|
|
30
|
+
extensionSource: extensionSource
|
|
31
|
+
} : undefined);
|
|
15
32
|
if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
|
|
16
33
|
return null;
|
|
17
34
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBlockMenuTriggerExtensionKey = void 0;
|
|
7
|
+
var getBlockMenuTriggerExtensionKey = exports.getBlockMenuTriggerExtensionKey = function getBlockMenuTriggerExtensionKey(_ref) {
|
|
8
|
+
var _api$blockControls, _menuTriggerByNode$ro, _editorView$state$doc;
|
|
9
|
+
var api = _ref.api,
|
|
10
|
+
editorView = _ref.editorView;
|
|
11
|
+
var menuTriggerByNode = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.menuTriggerByNode;
|
|
12
|
+
var pos = (_menuTriggerByNode$ro = menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.rootPos) !== null && _menuTriggerByNode$ro !== void 0 ? _menuTriggerByNode$ro : menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.pos;
|
|
13
|
+
if (!editorView || pos === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
var extensionKey = (_editorView$state$doc = editorView.state.doc.nodeAt(pos)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.attrs.extensionKey;
|
|
17
|
+
return typeof extensionKey === 'string' ? extensionKey : undefined;
|
|
18
|
+
};
|
|
@@ -9,8 +9,10 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
10
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var _SelectionExtensionMenuItems = require("../menu/SelectionExtensionMenuItems");
|
|
13
14
|
var _SelectionExtensionComponentContext = require("../SelectionExtensionComponentContext");
|
|
15
|
+
var _getBlockMenuTriggerExtensionKey = require("./getBlockMenuTriggerExtensionKey");
|
|
14
16
|
/**
|
|
15
17
|
* Registers first-party selection extension menu items with the block menu plugin.
|
|
16
18
|
*/
|
|
@@ -30,6 +32,20 @@ function registerBlockMenuItems(_ref) {
|
|
|
30
32
|
if (!(api !== null && api !== void 0 && api.blockMenu)) {
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
35
|
+
var getMenuItemsContext = function getMenuItemsContext() {
|
|
36
|
+
return {
|
|
37
|
+
blockMenuTriggerExtensionKey: (0, _getBlockMenuTriggerExtensionKey.getBlockMenuTriggerExtensionKey)({
|
|
38
|
+
api: api,
|
|
39
|
+
editorView: editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current
|
|
40
|
+
}),
|
|
41
|
+
extensionKey: key,
|
|
42
|
+
extensionSource: source,
|
|
43
|
+
extensionLocation: 'block-menu'
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var getMenuItems = function getMenuItems() {
|
|
47
|
+
return blockMenu.getMenuItems((0, _expValEquals.expValEquals)('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? getMenuItemsContext() : undefined);
|
|
48
|
+
};
|
|
33
49
|
|
|
34
50
|
/**
|
|
35
51
|
* Renders the registered selection-extension menu items with the correct block-menu context.
|
|
@@ -56,7 +72,7 @@ function registerBlockMenuItems(_ref) {
|
|
|
56
72
|
if (blockMenu.placement === 'featured-section' && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_2')) {
|
|
57
73
|
// Block menu sections do not support isHidden. Check menu items before registering
|
|
58
74
|
// the section to avoid rendering an orphan separator when there are no items.
|
|
59
|
-
if (
|
|
75
|
+
if (getMenuItems().length === 0 || !blockMenu.sectionKey) {
|
|
60
76
|
return;
|
|
61
77
|
}
|
|
62
78
|
var sectionRank = _blockMenu.MAIN_BLOCK_MENU_SECTION_RANK[blockMenu.sectionKey];
|
|
@@ -108,7 +124,7 @@ function registerBlockMenuItems(_ref) {
|
|
|
108
124
|
type: 'block-menu-item',
|
|
109
125
|
key: "selection-extension-".concat(key),
|
|
110
126
|
isHidden: function isHidden() {
|
|
111
|
-
return
|
|
127
|
+
return getMenuItems().length === 0;
|
|
112
128
|
},
|
|
113
129
|
parent: {
|
|
114
130
|
type: 'block-menu-section',
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
+
import { useSelectionExtensionComponentContext } from '../SelectionExtensionComponentContext';
|
|
4
|
+
import { getBlockMenuTriggerExtensionKey } from '../utils/getBlockMenuTriggerExtensionKey';
|
|
2
5
|
import { isNestedDropdownMenuConfiguration } from '../utils/menu-items';
|
|
3
6
|
import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
|
|
4
7
|
import { SelectionExtensionNestedDropdownMenu } from './SelectionExtensionNestedDropdownMenu';
|
|
5
8
|
export const SelectionExtensionMenuItems = ({
|
|
6
9
|
getMenuItems
|
|
7
10
|
}) => {
|
|
8
|
-
const
|
|
11
|
+
const {
|
|
12
|
+
api,
|
|
13
|
+
editorView,
|
|
14
|
+
extensionKey,
|
|
15
|
+
extensionLocation,
|
|
16
|
+
extensionSource
|
|
17
|
+
} = useSelectionExtensionComponentContext();
|
|
18
|
+
const extensionMenuItems = getMenuItems(expValEquals('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? {
|
|
19
|
+
blockMenuTriggerExtensionKey: getBlockMenuTriggerExtensionKey({
|
|
20
|
+
api,
|
|
21
|
+
editorView
|
|
22
|
+
}),
|
|
23
|
+
extensionKey,
|
|
24
|
+
extensionLocation,
|
|
25
|
+
extensionSource
|
|
26
|
+
} : undefined);
|
|
9
27
|
if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
|
|
10
28
|
return null;
|
|
11
29
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getBlockMenuTriggerExtensionKey = ({
|
|
2
|
+
api,
|
|
3
|
+
editorView
|
|
4
|
+
}) => {
|
|
5
|
+
var _api$blockControls, _api$blockControls$sh, _menuTriggerByNode$ro, _editorView$state$doc;
|
|
6
|
+
const menuTriggerByNode = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.menuTriggerByNode;
|
|
7
|
+
const pos = (_menuTriggerByNode$ro = menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.rootPos) !== null && _menuTriggerByNode$ro !== void 0 ? _menuTriggerByNode$ro : menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.pos;
|
|
8
|
+
if (!editorView || pos === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const extensionKey = (_editorView$state$doc = editorView.state.doc.nodeAt(pos)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.attrs.extensionKey;
|
|
12
|
+
return typeof extensionKey === 'string' ? extensionKey : undefined;
|
|
13
|
+
};
|
|
@@ -2,8 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, BLOCK_ACTIONS_FEATURED_EXTENSION_SLOT_MENU_ITEM, BLOCK_ACTIONS_FEATURED_EXTENSION_ITEM_RANK, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_CREATE_MENU_SECTION_RANK, TRANSFORM_DEFAULT_EXTENSION_SLOT_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
import { SelectionExtensionMenuItems } from '../menu/SelectionExtensionMenuItems';
|
|
6
7
|
import { SelectionExtensionComponentContextProvider } from '../SelectionExtensionComponentContext';
|
|
8
|
+
import { getBlockMenuTriggerExtensionKey } from './getBlockMenuTriggerExtensionKey';
|
|
7
9
|
/**
|
|
8
10
|
* Registers first-party selection extension menu items with the block menu plugin.
|
|
9
11
|
*/
|
|
@@ -25,6 +27,16 @@ export function registerBlockMenuItems({
|
|
|
25
27
|
if (!(api !== null && api !== void 0 && api.blockMenu)) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
30
|
+
const getMenuItemsContext = () => ({
|
|
31
|
+
blockMenuTriggerExtensionKey: getBlockMenuTriggerExtensionKey({
|
|
32
|
+
api,
|
|
33
|
+
editorView: editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current
|
|
34
|
+
}),
|
|
35
|
+
extensionKey: key,
|
|
36
|
+
extensionSource: source,
|
|
37
|
+
extensionLocation: 'block-menu'
|
|
38
|
+
});
|
|
39
|
+
const getMenuItems = () => blockMenu.getMenuItems(expValEquals('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? getMenuItemsContext() : undefined);
|
|
28
40
|
|
|
29
41
|
/**
|
|
30
42
|
* Renders the registered selection-extension menu items with the correct block-menu context.
|
|
@@ -51,7 +63,7 @@ export function registerBlockMenuItems({
|
|
|
51
63
|
if (blockMenu.placement === 'featured-section' && fg('platform_editor_block_menu_v2_patch_2')) {
|
|
52
64
|
// Block menu sections do not support isHidden. Check menu items before registering
|
|
53
65
|
// the section to avoid rendering an orphan separator when there are no items.
|
|
54
|
-
if (
|
|
66
|
+
if (getMenuItems().length === 0 || !blockMenu.sectionKey) {
|
|
55
67
|
return;
|
|
56
68
|
}
|
|
57
69
|
const sectionRank = MAIN_BLOCK_MENU_SECTION_RANK[blockMenu.sectionKey];
|
|
@@ -101,7 +113,7 @@ export function registerBlockMenuItems({
|
|
|
101
113
|
componentsToRegister.push({
|
|
102
114
|
type: 'block-menu-item',
|
|
103
115
|
key: `selection-extension-${key}`,
|
|
104
|
-
isHidden: () =>
|
|
116
|
+
isHidden: () => getMenuItems().length === 0,
|
|
105
117
|
parent: {
|
|
106
118
|
type: 'block-menu-section',
|
|
107
119
|
key: TRANSFORM_CREATE_MENU_SECTION.key,
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
+
import { useSelectionExtensionComponentContext } from '../SelectionExtensionComponentContext';
|
|
4
|
+
import { getBlockMenuTriggerExtensionKey } from '../utils/getBlockMenuTriggerExtensionKey';
|
|
2
5
|
import { isNestedDropdownMenuConfiguration } from '../utils/menu-items';
|
|
3
6
|
import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
|
|
4
7
|
import { SelectionExtensionNestedDropdownMenu } from './SelectionExtensionNestedDropdownMenu';
|
|
5
8
|
export var SelectionExtensionMenuItems = function SelectionExtensionMenuItems(_ref) {
|
|
6
9
|
var getMenuItems = _ref.getMenuItems;
|
|
7
|
-
var
|
|
10
|
+
var _useSelectionExtensio = useSelectionExtensionComponentContext(),
|
|
11
|
+
api = _useSelectionExtensio.api,
|
|
12
|
+
editorView = _useSelectionExtensio.editorView,
|
|
13
|
+
extensionKey = _useSelectionExtensio.extensionKey,
|
|
14
|
+
extensionLocation = _useSelectionExtensio.extensionLocation,
|
|
15
|
+
extensionSource = _useSelectionExtensio.extensionSource;
|
|
16
|
+
var extensionMenuItems = getMenuItems(expValEquals('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? {
|
|
17
|
+
blockMenuTriggerExtensionKey: getBlockMenuTriggerExtensionKey({
|
|
18
|
+
api: api,
|
|
19
|
+
editorView: editorView
|
|
20
|
+
}),
|
|
21
|
+
extensionKey: extensionKey,
|
|
22
|
+
extensionLocation: extensionLocation,
|
|
23
|
+
extensionSource: extensionSource
|
|
24
|
+
} : undefined);
|
|
8
25
|
if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
|
|
9
26
|
return null;
|
|
10
27
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var getBlockMenuTriggerExtensionKey = function getBlockMenuTriggerExtensionKey(_ref) {
|
|
2
|
+
var _api$blockControls, _menuTriggerByNode$ro, _editorView$state$doc;
|
|
3
|
+
var api = _ref.api,
|
|
4
|
+
editorView = _ref.editorView;
|
|
5
|
+
var menuTriggerByNode = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.menuTriggerByNode;
|
|
6
|
+
var pos = (_menuTriggerByNode$ro = menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.rootPos) !== null && _menuTriggerByNode$ro !== void 0 ? _menuTriggerByNode$ro : menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.pos;
|
|
7
|
+
if (!editorView || pos === undefined) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
var extensionKey = (_editorView$state$doc = editorView.state.doc.nodeAt(pos)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.attrs.extensionKey;
|
|
11
|
+
return typeof extensionKey === 'string' ? extensionKey : undefined;
|
|
12
|
+
};
|
|
@@ -2,8 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, BLOCK_ACTIONS_FEATURED_EXTENSION_SLOT_MENU_ITEM, BLOCK_ACTIONS_FEATURED_EXTENSION_ITEM_RANK, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_CREATE_MENU_SECTION_RANK, TRANSFORM_DEFAULT_EXTENSION_SLOT_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
import { SelectionExtensionMenuItems } from '../menu/SelectionExtensionMenuItems';
|
|
6
7
|
import { SelectionExtensionComponentContextProvider } from '../SelectionExtensionComponentContext';
|
|
8
|
+
import { getBlockMenuTriggerExtensionKey } from './getBlockMenuTriggerExtensionKey';
|
|
7
9
|
/**
|
|
8
10
|
* Registers first-party selection extension menu items with the block menu plugin.
|
|
9
11
|
*/
|
|
@@ -23,6 +25,20 @@ export function registerBlockMenuItems(_ref) {
|
|
|
23
25
|
if (!(api !== null && api !== void 0 && api.blockMenu)) {
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
28
|
+
var getMenuItemsContext = function getMenuItemsContext() {
|
|
29
|
+
return {
|
|
30
|
+
blockMenuTriggerExtensionKey: getBlockMenuTriggerExtensionKey({
|
|
31
|
+
api: api,
|
|
32
|
+
editorView: editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current
|
|
33
|
+
}),
|
|
34
|
+
extensionKey: key,
|
|
35
|
+
extensionSource: source,
|
|
36
|
+
extensionLocation: 'block-menu'
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
var getMenuItems = function getMenuItems() {
|
|
40
|
+
return blockMenu.getMenuItems(expValEquals('agent-managed-blocks-stop-block-template', 'isEnabled', true) ? getMenuItemsContext() : undefined);
|
|
41
|
+
};
|
|
26
42
|
|
|
27
43
|
/**
|
|
28
44
|
* Renders the registered selection-extension menu items with the correct block-menu context.
|
|
@@ -49,7 +65,7 @@ export function registerBlockMenuItems(_ref) {
|
|
|
49
65
|
if (blockMenu.placement === 'featured-section' && fg('platform_editor_block_menu_v2_patch_2')) {
|
|
50
66
|
// Block menu sections do not support isHidden. Check menu items before registering
|
|
51
67
|
// the section to avoid rendering an orphan separator when there are no items.
|
|
52
|
-
if (
|
|
68
|
+
if (getMenuItems().length === 0 || !blockMenu.sectionKey) {
|
|
53
69
|
return;
|
|
54
70
|
}
|
|
55
71
|
var sectionRank = MAIN_BLOCK_MENU_SECTION_RANK[blockMenu.sectionKey];
|
|
@@ -101,7 +117,7 @@ export function registerBlockMenuItems(_ref) {
|
|
|
101
117
|
type: 'block-menu-item',
|
|
102
118
|
key: "selection-extension-".concat(key),
|
|
103
119
|
isHidden: function isHidden() {
|
|
104
|
-
return
|
|
120
|
+
return getMenuItems().length === 0;
|
|
105
121
|
},
|
|
106
122
|
parent: {
|
|
107
123
|
type: 'block-menu-section',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { BlockMenuExtensionConfiguration, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, SelectionAdfResult, SelectionExtensionCallbackOptions, SelectionRange, } from '../types/index';
|
|
1
|
+
export type { BlockMenuExtensionConfiguration, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, GetMenuItemsContext, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, SelectionAdfResult, SelectionExtensionCallbackOptions, SelectionRange, } from '../types/index';
|
|
@@ -119,6 +119,13 @@ export type SelectionAdfResult = {
|
|
|
119
119
|
selectionRanges?: SelectionRange[];
|
|
120
120
|
} | null;
|
|
121
121
|
export type ExtensionSource = 'first-party' | 'external';
|
|
122
|
+
export type SelectionExtensionLocation = 'inline-toolbar' | 'primary-toolbar' | 'block-menu';
|
|
123
|
+
export type GetMenuItemsContext = {
|
|
124
|
+
blockMenuTriggerExtensionKey?: string | undefined;
|
|
125
|
+
extensionKey?: string;
|
|
126
|
+
extensionLocation?: SelectionExtensionLocation;
|
|
127
|
+
extensionSource?: ExtensionSource;
|
|
128
|
+
};
|
|
122
129
|
export type ExtensionConfiguration = {
|
|
123
130
|
blockMenu?: BlockMenuExtensionConfiguration;
|
|
124
131
|
inlineToolbar?: ToolbarExtensionConfiguration;
|
|
@@ -127,7 +134,7 @@ export type ExtensionConfiguration = {
|
|
|
127
134
|
source: ExtensionSource;
|
|
128
135
|
};
|
|
129
136
|
export type GetToolbarItemFn = () => ExtensionToolbarItemConfiguration;
|
|
130
|
-
export type GetMenuItemsFn = () => Array<ExtensionMenuItemConfiguration>;
|
|
137
|
+
export type GetMenuItemsFn = (context?: GetMenuItemsContext) => Array<ExtensionMenuItemConfiguration>;
|
|
131
138
|
export type GetNestedMenuItemsFn = () => Array<ExtensionMenuItemNestedConfiguration>;
|
|
132
139
|
export type ToolbarExtensionConfiguration = {
|
|
133
140
|
getMenuItems?: GetMenuItemsFn;
|
|
@@ -2,12 +2,13 @@ import { type Provider } from 'react';
|
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { SelectionExtensionPlugin } from '../selectionExtensionPluginType';
|
|
5
|
+
import type { ExtensionSource, SelectionExtensionLocation } from '../types';
|
|
5
6
|
type SelectionExtensionComponentContextValue = {
|
|
6
7
|
api: ExtractInjectionAPI<SelectionExtensionPlugin>;
|
|
7
8
|
editorView: EditorView;
|
|
8
9
|
extensionKey: string;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
extensionLocation: SelectionExtensionLocation;
|
|
11
|
+
extensionSource: ExtensionSource;
|
|
11
12
|
};
|
|
12
13
|
export declare const SelectionExtensionComponentContextProvider: Provider<SelectionExtensionComponentContextValue | undefined>;
|
|
13
14
|
export declare const useSelectionExtensionComponentContext: () => SelectionExtensionComponentContextValue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetMenuItemsFn } from '../../types';
|
|
3
3
|
type SelectionExtensionMenuItemsProps = {
|
|
4
|
-
getMenuItems:
|
|
4
|
+
getMenuItems: GetMenuItemsFn;
|
|
5
5
|
};
|
|
6
6
|
export declare const SelectionExtensionMenuItems: ({ getMenuItems, }: SelectionExtensionMenuItemsProps) => React.JSX.Element | null;
|
|
7
7
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { SelectionExtensionPlugin } from '../../selectionExtensionPluginType';
|
|
4
|
+
type GetBlockMenuTriggerExtensionKeyOptions = {
|
|
5
|
+
api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined;
|
|
6
|
+
editorView?: EditorView;
|
|
7
|
+
};
|
|
8
|
+
export declare const getBlockMenuTriggerExtensionKey: ({ api, editorView, }: GetBlockMenuTriggerExtensionKeyOptions) => string | undefined;
|
|
9
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.19",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
41
41
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
42
42
|
"@atlaskit/editor-toolbar": "^2.1.0",
|
|
43
|
-
"@atlaskit/icon": "^36.
|
|
43
|
+
"@atlaskit/icon": "^36.2.0",
|
|
44
44
|
"@atlaskit/lozenge": "^14.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
46
46
|
"@atlaskit/primitives": "^20.3.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
48
|
-
"@atlaskit/tokens": "^15.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^121.0.0",
|
|
48
|
+
"@atlaskit/tokens": "^15.4.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"lodash": "^4.17.21",
|
|
51
51
|
"uuid": "^3.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@atlaskit/editor-common": "^116.
|
|
54
|
+
"@atlaskit/editor-common": "^116.22.0",
|
|
55
55
|
"react": "^18.2.0",
|
|
56
56
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
57
57
|
},
|