@atlaskit/editor-plugin-selection-extension 11.1.4 → 11.1.6
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 +14 -0
- package/dist/cjs/selectionExtensionPlugin.js +10 -3
- package/dist/cjs/ui/LegacyToolbarComponent.js +10 -4
- package/dist/cjs/ui/extension/SelectionExtensionComponentWrapper.js +7 -3
- package/dist/cjs/ui/toolbar/SelectionExtensionDropdownMenu.js +6 -2
- package/dist/cjs/ui/toolbar-components/register-inline-toolbar.js +3 -1
- package/dist/cjs/ui/utils/registerBlockMenuItems.js +6 -2
- package/dist/es2019/selectionExtensionPlugin.js +10 -3
- package/dist/es2019/ui/LegacyToolbarComponent.js +10 -4
- package/dist/es2019/ui/extension/SelectionExtensionComponentWrapper.js +7 -3
- package/dist/es2019/ui/toolbar/SelectionExtensionDropdownMenu.js +6 -2
- package/dist/es2019/ui/toolbar-components/register-inline-toolbar.js +3 -1
- package/dist/es2019/ui/utils/registerBlockMenuItems.js +6 -2
- package/dist/esm/selectionExtensionPlugin.js +10 -3
- package/dist/esm/ui/LegacyToolbarComponent.js +10 -4
- package/dist/esm/ui/extension/SelectionExtensionComponentWrapper.js +7 -3
- package/dist/esm/ui/toolbar/SelectionExtensionDropdownMenu.js +6 -2
- package/dist/esm/ui/toolbar-components/register-inline-toolbar.js +3 -1
- package/dist/esm/ui/utils/registerBlockMenuItems.js +6 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 11.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 11.1.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`9ed32aea2c1d3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9ed32aea2c1d3) -
|
|
14
|
+
Replace feature experiment util with cross platform alternative for platform_editor_block_menu
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 11.1.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -12,6 +12,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
13
|
var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
|
|
14
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
16
|
var _insertAdfAtEndOfDoc2 = require("./pm-plugins/actions/insertAdfAtEndOfDoc");
|
|
16
17
|
var _replaceWithAdf2 = require("./pm-plugins/actions/replaceWithAdf");
|
|
17
18
|
var _main = require("./pm-plugins/main");
|
|
@@ -54,7 +55,9 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
if ((0,
|
|
58
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
59
|
+
exposure: true
|
|
60
|
+
})) {
|
|
58
61
|
(0, _registerBlockMenuItems.registerBlockMenuItems)({
|
|
59
62
|
extensionList: extensionList,
|
|
60
63
|
api: api,
|
|
@@ -116,7 +119,9 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
116
119
|
return null;
|
|
117
120
|
}
|
|
118
121
|
var state = editorViewRef.current.state;
|
|
119
|
-
if ((0,
|
|
122
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
123
|
+
exposure: true
|
|
124
|
+
})) {
|
|
120
125
|
var _api$blockControls;
|
|
121
126
|
var selection = (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.preservedSelection) || state.selection;
|
|
122
127
|
return (0, _utils.getSelectionAdfInfoNew)(selection);
|
|
@@ -134,7 +139,9 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
134
139
|
return null;
|
|
135
140
|
}
|
|
136
141
|
var state = editorViewRef.current.state;
|
|
137
|
-
if ((0,
|
|
142
|
+
if ((0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
143
|
+
exposure: true
|
|
144
|
+
})) {
|
|
138
145
|
var _api$blockControls2;
|
|
139
146
|
var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
|
|
140
147
|
return (0, _utils.getFragmentInfoFromSelectionNew)(selection);
|
|
@@ -13,7 +13,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
13
13
|
var LegacyPrimaryToolbarComponent = exports.LegacyPrimaryToolbarComponent = function LegacyPrimaryToolbarComponent(_ref) {
|
|
14
14
|
var primaryToolbarItemExtensions = _ref.primaryToolbarItemExtensions;
|
|
15
15
|
// NEXT PR: need to render a separator after – if there are extensions added
|
|
16
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, primaryToolbarItemExtensions.map(function (toolbarItemExtension,
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, primaryToolbarItemExtensions.map(function (toolbarItemExtension, _i) {
|
|
17
17
|
var toolbarItem = toolbarItemExtension.getToolbarItem();
|
|
18
18
|
return /*#__PURE__*/_react.default.createElement(LegacyExtensionToolbarItem, {
|
|
19
19
|
key: toolbarItem.tooltip,
|
|
@@ -72,7 +72,9 @@ var LegacyExtensionToolbarItem = exports.LegacyExtensionToolbarItem = function L
|
|
|
72
72
|
var handleOnOpenChange = function handleOnOpenChange(attrs) {
|
|
73
73
|
setIsOpen(!!(attrs !== null && attrs !== void 0 && attrs.isOpen));
|
|
74
74
|
};
|
|
75
|
-
var items = isOpen
|
|
75
|
+
var items = isOpen
|
|
76
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
77
|
+
? getMenuItems().map(function (menuItem, i) {
|
|
76
78
|
// Only process ExtensionMenuItemConfiguration, skip ExtensionMenuSectionConfiguration
|
|
77
79
|
if ('label' in menuItem && 'icon' in menuItem) {
|
|
78
80
|
return {
|
|
@@ -98,10 +100,14 @@ var LegacyExtensionToolbarItem = exports.LegacyExtensionToolbarItem = function L
|
|
|
98
100
|
}).filter(function (item) {
|
|
99
101
|
return item !== undefined;
|
|
100
102
|
}) : [];
|
|
101
|
-
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation
|
|
104
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
105
|
+
, {
|
|
102
106
|
arrowKeyNavigationProviderOptions: {
|
|
103
107
|
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
104
|
-
}
|
|
108
|
+
}
|
|
109
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
110
|
+
,
|
|
105
111
|
items: [{
|
|
106
112
|
items: items
|
|
107
113
|
}],
|
|
@@ -8,7 +8,7 @@ exports.SelectionExtensionComponentWrapper = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
-
var
|
|
11
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
12
|
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); }
|
|
13
13
|
var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrapper = function SelectionExtensionComponentWrapper(_ref) {
|
|
14
14
|
var api = _ref.api,
|
|
@@ -53,7 +53,9 @@ var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrap
|
|
|
53
53
|
if (!extension) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
if (isToolbarAIFCEnabled || (0,
|
|
56
|
+
if (isToolbarAIFCEnabled || (0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
57
|
+
exposure: true
|
|
58
|
+
})) {
|
|
57
59
|
var currentComponent;
|
|
58
60
|
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
59
61
|
currentComponent = extension.contentComponent;
|
|
@@ -92,7 +94,9 @@ var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrap
|
|
|
92
94
|
if (!extension) {
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
95
|
-
if (isToolbarAIFCEnabled || (0,
|
|
97
|
+
if (isToolbarAIFCEnabled || (0, _experiments.editorExperiment)('platform_editor_block_menu', true, {
|
|
98
|
+
exposure: true
|
|
99
|
+
})) {
|
|
96
100
|
var hasContentComponent = function hasContentComponent(ext) {
|
|
97
101
|
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
98
102
|
};
|
|
@@ -21,7 +21,9 @@ var SelectionExtensionDropdownMenuComponent = /*#__PURE__*/_react.default.memo(f
|
|
|
21
21
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
22
22
|
isMenuOpen = _useState2[0],
|
|
23
23
|
setIsMenuOpen = _useState2[1];
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenuWithKeyboardNavigation
|
|
25
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
26
|
+
, {
|
|
25
27
|
section: {
|
|
26
28
|
hasSeparator: true
|
|
27
29
|
},
|
|
@@ -33,7 +35,9 @@ var SelectionExtensionDropdownMenuComponent = /*#__PURE__*/_react.default.memo(f
|
|
|
33
35
|
"data-testid": "selection-extension-dropdown-menu"
|
|
34
36
|
}, /*#__PURE__*/_react.default.createElement(_SelectionExtensionDropdownMenuButton.SelectionExtensionDropdownMenuButton, {
|
|
35
37
|
"aria-expanded": isMenuOpen,
|
|
36
|
-
selected: isMenuOpen
|
|
38
|
+
selected: isMenuOpen
|
|
39
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
40
|
+
,
|
|
37
41
|
onClick: function onClick() {
|
|
38
42
|
return setIsMenuOpen(function (prevIsMenuOpen) {
|
|
39
43
|
var nextIsMenuOpen = !prevIsMenuOpen;
|
|
@@ -23,7 +23,9 @@ var InlineToolbarMenuItemComponent = function InlineToolbarMenuItemComponent(_re
|
|
|
23
23
|
if (!editorView || !api) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
27
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
28
|
+
, {
|
|
27
29
|
value: {
|
|
28
30
|
api: api,
|
|
29
31
|
editorView: editorView,
|
|
@@ -43,7 +43,9 @@ function registerBlockMenuItems(_ref) {
|
|
|
43
43
|
if (!editorView) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
-
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
47
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
48
|
+
, {
|
|
47
49
|
value: {
|
|
48
50
|
api: api,
|
|
49
51
|
editorView: editorView,
|
|
@@ -73,7 +75,9 @@ function registerBlockMenuItems(_ref) {
|
|
|
73
75
|
if (!editorView) {
|
|
74
76
|
return null;
|
|
75
77
|
}
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_SelectionExtensionComponentContext.SelectionExtensionComponentContextProvider
|
|
79
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
80
|
+
, {
|
|
77
81
|
value: {
|
|
78
82
|
api: api,
|
|
79
83
|
editorView: editorView,
|
|
@@ -4,6 +4,7 @@ import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
8
9
|
import { replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
9
10
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
@@ -43,7 +44,9 @@ export const selectionExtensionPlugin = ({
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
if (
|
|
47
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
48
|
+
exposure: true
|
|
49
|
+
})) {
|
|
47
50
|
registerBlockMenuItems({
|
|
48
51
|
extensionList,
|
|
49
52
|
api,
|
|
@@ -107,7 +110,9 @@ export const selectionExtensionPlugin = ({
|
|
|
107
110
|
const {
|
|
108
111
|
state
|
|
109
112
|
} = editorViewRef.current;
|
|
110
|
-
if (
|
|
113
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
114
|
+
exposure: true
|
|
115
|
+
})) {
|
|
111
116
|
var _api$blockControls, _api$blockControls$sh;
|
|
112
117
|
const selection = (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.preservedSelection) || state.selection;
|
|
113
118
|
return getSelectionAdfInfoNew(selection);
|
|
@@ -128,7 +133,9 @@ export const selectionExtensionPlugin = ({
|
|
|
128
133
|
const {
|
|
129
134
|
state
|
|
130
135
|
} = editorViewRef.current;
|
|
131
|
-
if (
|
|
136
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
137
|
+
exposure: true
|
|
138
|
+
})) {
|
|
132
139
|
var _api$blockControls2, _api$blockControls2$s;
|
|
133
140
|
const selection = (api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$s = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2$s === void 0 ? void 0 : _api$blockControls2$s.preservedSelection) || state.selection;
|
|
134
141
|
return getFragmentInfoFromSelectionNew(selection);
|
|
@@ -4,7 +4,7 @@ export const LegacyPrimaryToolbarComponent = ({
|
|
|
4
4
|
primaryToolbarItemExtensions
|
|
5
5
|
}) => {
|
|
6
6
|
// NEXT PR: need to render a separator after – if there are extensions added
|
|
7
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, primaryToolbarItemExtensions.map((toolbarItemExtension,
|
|
7
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, primaryToolbarItemExtensions.map((toolbarItemExtension, _i) => {
|
|
8
8
|
const toolbarItem = toolbarItemExtension.getToolbarItem();
|
|
9
9
|
return /*#__PURE__*/React.createElement(LegacyExtensionToolbarItem, {
|
|
10
10
|
key: toolbarItem.tooltip,
|
|
@@ -61,7 +61,9 @@ export const LegacyExtensionToolbarItem = ({
|
|
|
61
61
|
const handleOnOpenChange = attrs => {
|
|
62
62
|
setIsOpen(!!(attrs !== null && attrs !== void 0 && attrs.isOpen));
|
|
63
63
|
};
|
|
64
|
-
const items = isOpen
|
|
64
|
+
const items = isOpen
|
|
65
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
66
|
+
? getMenuItems().map((menuItem, i) => {
|
|
65
67
|
// Only process ExtensionMenuItemConfiguration, skip ExtensionMenuSectionConfiguration
|
|
66
68
|
if ('label' in menuItem && 'icon' in menuItem) {
|
|
67
69
|
return {
|
|
@@ -85,10 +87,14 @@ export const LegacyExtensionToolbarItem = ({
|
|
|
85
87
|
}
|
|
86
88
|
return undefined;
|
|
87
89
|
}).filter(item => item !== undefined) : [];
|
|
88
|
-
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
90
|
+
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
91
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
92
|
+
, {
|
|
89
93
|
arrowKeyNavigationProviderOptions: {
|
|
90
94
|
type: ArrowKeyNavigationType.MENU
|
|
91
|
-
}
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
97
|
+
,
|
|
92
98
|
items: [{
|
|
93
99
|
items
|
|
94
100
|
}],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
import {
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
export const SelectionExtensionComponentWrapper = ({
|
|
6
6
|
api,
|
|
7
7
|
editorAnalyticsAPI
|
|
@@ -47,7 +47,9 @@ export const SelectionExtensionComponentWrapper = ({
|
|
|
47
47
|
if (!extension) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
if (isToolbarAIFCEnabled ||
|
|
50
|
+
if (isToolbarAIFCEnabled || editorExperiment('platform_editor_block_menu', true, {
|
|
51
|
+
exposure: true
|
|
52
|
+
})) {
|
|
51
53
|
let currentComponent;
|
|
52
54
|
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
53
55
|
currentComponent = extension.contentComponent;
|
|
@@ -86,7 +88,9 @@ export const SelectionExtensionComponentWrapper = ({
|
|
|
86
88
|
if (!extension) {
|
|
87
89
|
return null;
|
|
88
90
|
}
|
|
89
|
-
if (isToolbarAIFCEnabled ||
|
|
91
|
+
if (isToolbarAIFCEnabled || editorExperiment('platform_editor_block_menu', true, {
|
|
92
|
+
exposure: true
|
|
93
|
+
})) {
|
|
90
94
|
const hasContentComponent = ext => {
|
|
91
95
|
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
92
96
|
};
|
|
@@ -9,7 +9,9 @@ const SelectionExtensionDropdownMenuComponent = /*#__PURE__*/React.memo(({
|
|
|
9
9
|
editorAnalyticsAPI
|
|
10
10
|
}) => {
|
|
11
11
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
12
|
-
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
12
|
+
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
13
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
14
|
+
, {
|
|
13
15
|
section: {
|
|
14
16
|
hasSeparator: true
|
|
15
17
|
},
|
|
@@ -21,7 +23,9 @@ const SelectionExtensionDropdownMenuComponent = /*#__PURE__*/React.memo(({
|
|
|
21
23
|
"data-testid": "selection-extension-dropdown-menu"
|
|
22
24
|
}, /*#__PURE__*/React.createElement(SelectionExtensionDropdownMenuButton, {
|
|
23
25
|
"aria-expanded": isMenuOpen,
|
|
24
|
-
selected: isMenuOpen
|
|
26
|
+
selected: isMenuOpen
|
|
27
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
28
|
+
,
|
|
25
29
|
onClick: () => setIsMenuOpen(prevIsMenuOpen => {
|
|
26
30
|
const nextIsMenuOpen = !prevIsMenuOpen;
|
|
27
31
|
if (editorAnalyticsAPI) {
|
|
@@ -18,7 +18,9 @@ const InlineToolbarMenuItemComponent = ({
|
|
|
18
18
|
if (!editorView || !api) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
21
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
22
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
23
|
+
, {
|
|
22
24
|
value: {
|
|
23
25
|
api,
|
|
24
26
|
editorView,
|
|
@@ -38,7 +38,9 @@ export function registerBlockMenuItems({
|
|
|
38
38
|
if (!editorView) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
41
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
42
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
43
|
+
, {
|
|
42
44
|
value: {
|
|
43
45
|
api,
|
|
44
46
|
editorView,
|
|
@@ -66,7 +68,9 @@ export function registerBlockMenuItems({
|
|
|
66
68
|
if (!editorView) {
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
69
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
71
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
72
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
73
|
+
, {
|
|
70
74
|
value: {
|
|
71
75
|
api,
|
|
72
76
|
editorView,
|
|
@@ -5,6 +5,7 @@ import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
9
10
|
import { replaceWithAdf as _replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
10
11
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
@@ -47,7 +48,9 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
if (
|
|
51
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
52
|
+
exposure: true
|
|
53
|
+
})) {
|
|
51
54
|
registerBlockMenuItems({
|
|
52
55
|
extensionList: extensionList,
|
|
53
56
|
api: api,
|
|
@@ -109,7 +112,9 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
109
112
|
return null;
|
|
110
113
|
}
|
|
111
114
|
var state = editorViewRef.current.state;
|
|
112
|
-
if (
|
|
115
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
116
|
+
exposure: true
|
|
117
|
+
})) {
|
|
113
118
|
var _api$blockControls;
|
|
114
119
|
var selection = (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.preservedSelection) || state.selection;
|
|
115
120
|
return getSelectionAdfInfoNew(selection);
|
|
@@ -127,7 +132,9 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
127
132
|
return null;
|
|
128
133
|
}
|
|
129
134
|
var state = editorViewRef.current.state;
|
|
130
|
-
if (
|
|
135
|
+
if (editorExperiment('platform_editor_block_menu', true, {
|
|
136
|
+
exposure: true
|
|
137
|
+
})) {
|
|
131
138
|
var _api$blockControls2;
|
|
132
139
|
var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
|
|
133
140
|
return getFragmentInfoFromSelectionNew(selection);
|
|
@@ -4,7 +4,7 @@ import { ArrowKeyNavigationType, DropdownMenuWithKeyboardNavigation as DropdownM
|
|
|
4
4
|
export var LegacyPrimaryToolbarComponent = function LegacyPrimaryToolbarComponent(_ref) {
|
|
5
5
|
var primaryToolbarItemExtensions = _ref.primaryToolbarItemExtensions;
|
|
6
6
|
// NEXT PR: need to render a separator after – if there are extensions added
|
|
7
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, primaryToolbarItemExtensions.map(function (toolbarItemExtension,
|
|
7
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, primaryToolbarItemExtensions.map(function (toolbarItemExtension, _i) {
|
|
8
8
|
var toolbarItem = toolbarItemExtension.getToolbarItem();
|
|
9
9
|
return /*#__PURE__*/React.createElement(LegacyExtensionToolbarItem, {
|
|
10
10
|
key: toolbarItem.tooltip,
|
|
@@ -63,7 +63,9 @@ export var LegacyExtensionToolbarItem = function LegacyExtensionToolbarItem(_ref
|
|
|
63
63
|
var handleOnOpenChange = function handleOnOpenChange(attrs) {
|
|
64
64
|
setIsOpen(!!(attrs !== null && attrs !== void 0 && attrs.isOpen));
|
|
65
65
|
};
|
|
66
|
-
var items = isOpen
|
|
66
|
+
var items = isOpen
|
|
67
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
68
|
+
? getMenuItems().map(function (menuItem, i) {
|
|
67
69
|
// Only process ExtensionMenuItemConfiguration, skip ExtensionMenuSectionConfiguration
|
|
68
70
|
if ('label' in menuItem && 'icon' in menuItem) {
|
|
69
71
|
return {
|
|
@@ -89,10 +91,14 @@ export var LegacyExtensionToolbarItem = function LegacyExtensionToolbarItem(_ref
|
|
|
89
91
|
}).filter(function (item) {
|
|
90
92
|
return item !== undefined;
|
|
91
93
|
}) : [];
|
|
92
|
-
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
94
|
+
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
95
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
96
|
+
, {
|
|
93
97
|
arrowKeyNavigationProviderOptions: {
|
|
94
98
|
type: ArrowKeyNavigationType.MENU
|
|
95
|
-
}
|
|
99
|
+
}
|
|
100
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
101
|
+
,
|
|
96
102
|
items: [{
|
|
97
103
|
items: items
|
|
98
104
|
}],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
import {
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
export var SelectionExtensionComponentWrapper = function SelectionExtensionComponentWrapper(_ref) {
|
|
6
6
|
var api = _ref.api,
|
|
7
7
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
@@ -45,7 +45,9 @@ export var SelectionExtensionComponentWrapper = function SelectionExtensionCompo
|
|
|
45
45
|
if (!extension) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
if (isToolbarAIFCEnabled ||
|
|
48
|
+
if (isToolbarAIFCEnabled || editorExperiment('platform_editor_block_menu', true, {
|
|
49
|
+
exposure: true
|
|
50
|
+
})) {
|
|
49
51
|
var currentComponent;
|
|
50
52
|
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
51
53
|
currentComponent = extension.contentComponent;
|
|
@@ -84,7 +86,9 @@ export var SelectionExtensionComponentWrapper = function SelectionExtensionCompo
|
|
|
84
86
|
if (!extension) {
|
|
85
87
|
return null;
|
|
86
88
|
}
|
|
87
|
-
if (isToolbarAIFCEnabled ||
|
|
89
|
+
if (isToolbarAIFCEnabled || editorExperiment('platform_editor_block_menu', true, {
|
|
90
|
+
exposure: true
|
|
91
|
+
})) {
|
|
88
92
|
var hasContentComponent = function hasContentComponent(ext) {
|
|
89
93
|
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
90
94
|
};
|
|
@@ -12,7 +12,9 @@ var SelectionExtensionDropdownMenuComponent = /*#__PURE__*/React.memo(function (
|
|
|
12
12
|
_useState2 = _slicedToArray(_useState, 2),
|
|
13
13
|
isMenuOpen = _useState2[0],
|
|
14
14
|
setIsMenuOpen = _useState2[1];
|
|
15
|
-
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
15
|
+
return /*#__PURE__*/React.createElement(DropdownMenu
|
|
16
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
17
|
+
, {
|
|
16
18
|
section: {
|
|
17
19
|
hasSeparator: true
|
|
18
20
|
},
|
|
@@ -24,7 +26,9 @@ var SelectionExtensionDropdownMenuComponent = /*#__PURE__*/React.memo(function (
|
|
|
24
26
|
"data-testid": "selection-extension-dropdown-menu"
|
|
25
27
|
}, /*#__PURE__*/React.createElement(SelectionExtensionDropdownMenuButton, {
|
|
26
28
|
"aria-expanded": isMenuOpen,
|
|
27
|
-
selected: isMenuOpen
|
|
29
|
+
selected: isMenuOpen
|
|
30
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
31
|
+
,
|
|
28
32
|
onClick: function onClick() {
|
|
29
33
|
return setIsMenuOpen(function (prevIsMenuOpen) {
|
|
30
34
|
var nextIsMenuOpen = !prevIsMenuOpen;
|
|
@@ -16,7 +16,9 @@ var InlineToolbarMenuItemComponent = function InlineToolbarMenuItemComponent(_re
|
|
|
16
16
|
if (!editorView || !api) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
19
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
20
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
21
|
+
, {
|
|
20
22
|
value: {
|
|
21
23
|
api: api,
|
|
22
24
|
editorView: editorView,
|
|
@@ -36,7 +36,9 @@ export function registerBlockMenuItems(_ref) {
|
|
|
36
36
|
if (!editorView) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
39
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
40
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
41
|
+
, {
|
|
40
42
|
value: {
|
|
41
43
|
api: api,
|
|
42
44
|
editorView: editorView,
|
|
@@ -66,7 +68,9 @@ export function registerBlockMenuItems(_ref) {
|
|
|
66
68
|
if (!editorView) {
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
69
|
-
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
71
|
+
return /*#__PURE__*/React.createElement(SelectionExtensionComponentContextProvider
|
|
72
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
73
|
+
, {
|
|
70
74
|
value: {
|
|
71
75
|
api: api,
|
|
72
76
|
editorView: editorView,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.6",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@atlaskit/lozenge": "^13.5.0",
|
|
53
53
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
54
54
|
"@atlaskit/primitives": "^18.0.0",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^44.0.0",
|
|
56
56
|
"@atlaskit/tokens": "^11.1.0",
|
|
57
57
|
"@babel/runtime": "^7.0.0",
|
|
58
58
|
"lodash": "^4.17.21",
|