@atlaskit/editor-plugin-selection-extension 4.2.0 → 4.2.1
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 +8 -0
- package/dist/cjs/ui/extension/SelectionExtensionComponentWrapper.js +63 -6
- package/dist/cjs/ui/toolbar-components.js +26 -2
- package/dist/es2019/ui/extension/SelectionExtensionComponentWrapper.js +63 -6
- package/dist/es2019/ui/toolbar-components.js +22 -2
- package/dist/esm/ui/extension/SelectionExtensionComponentWrapper.js +63 -6
- package/dist/esm/ui/toolbar-components.js +26 -2
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 4.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`57592deee923b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57592deee923b) -
|
|
8
|
+
[ux] ED-29142 [Selection Extension] Support forge apps
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 4.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -8,11 +8,17 @@ 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 _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
14
|
var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrapper = function SelectionExtensionComponentWrapper(_ref) {
|
|
13
15
|
var api = _ref.api,
|
|
14
16
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
15
17
|
var componentRef = (0, _react.useRef)();
|
|
18
|
+
var isToolbarAIFCEnabled = (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true, {
|
|
19
|
+
exposure: true
|
|
20
|
+
});
|
|
21
|
+
var isToolbarAIFCSelectionExtensionEnabled = (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true);
|
|
16
22
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selectionExtension', 'editorViewMode'], function (states) {
|
|
17
23
|
var _states$selectionExte, _states$editorViewMod;
|
|
18
24
|
return {
|
|
@@ -47,7 +53,33 @@ var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrap
|
|
|
47
53
|
|
|
48
54
|
// Viewed analytics event for component mount
|
|
49
55
|
(0, _react.useEffect)(function () {
|
|
50
|
-
|
|
56
|
+
var extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
57
|
+
if (!extension) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
61
|
+
var currentComponent;
|
|
62
|
+
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
63
|
+
currentComponent = extension.contentComponent;
|
|
64
|
+
} else if ('component' in extension && extension.component !== undefined) {
|
|
65
|
+
currentComponent = extension.component;
|
|
66
|
+
}
|
|
67
|
+
if (componentRef.current !== currentComponent && currentComponent !== undefined) {
|
|
68
|
+
if (editorAnalyticsAPI) {
|
|
69
|
+
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
70
|
+
action: _analytics.ACTION.VIEWED,
|
|
71
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR_PLUGIN_SELECTION_EXTENSION,
|
|
72
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.EDITOR_PLUGIN_SELECTION_EXTENSION_COMPONENT,
|
|
73
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Sets reference to active component
|
|
77
|
+
componentRef.current = currentComponent;
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
82
|
+
if (extension && 'component' in extension && componentRef.current !== extension.component && extension.component !== undefined) {
|
|
51
83
|
if (editorAnalyticsAPI) {
|
|
52
84
|
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
53
85
|
action: _analytics.ACTION.VIEWED,
|
|
@@ -57,15 +89,40 @@ var SelectionExtensionComponentWrapper = exports.SelectionExtensionComponentWrap
|
|
|
57
89
|
});
|
|
58
90
|
}
|
|
59
91
|
// Sets reference to active component
|
|
60
|
-
componentRef.current =
|
|
92
|
+
componentRef.current = extension.component;
|
|
61
93
|
}
|
|
62
|
-
}, [activeExtension, editorAnalyticsAPI]);
|
|
63
|
-
|
|
94
|
+
}, [activeExtension, editorAnalyticsAPI, isToolbarAIFCEnabled, isToolbarAIFCSelectionExtensionEnabled]);
|
|
95
|
+
var extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
96
|
+
if (!extension) {
|
|
64
97
|
return null;
|
|
65
98
|
}
|
|
99
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
100
|
+
var hasContentComponent = function hasContentComponent(ext) {
|
|
101
|
+
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
102
|
+
};
|
|
103
|
+
var hasComponent = function hasComponent(ext) {
|
|
104
|
+
return 'component' in ext && ext.component !== undefined;
|
|
105
|
+
};
|
|
106
|
+
var _ExtensionComponent;
|
|
107
|
+
if (hasContentComponent(extension)) {
|
|
108
|
+
_ExtensionComponent = extension.contentComponent;
|
|
109
|
+
} else if (hasComponent(extension)) {
|
|
110
|
+
_ExtensionComponent = extension.component;
|
|
111
|
+
}
|
|
112
|
+
if (!_ExtensionComponent) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/_react.default.createElement(_ExtensionComponent, {
|
|
116
|
+
closeExtension: handleOnClose,
|
|
117
|
+
selection: activeExtension.selection
|
|
118
|
+
});
|
|
119
|
+
}
|
|
66
120
|
|
|
67
|
-
//
|
|
68
|
-
|
|
121
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
122
|
+
if (!('component' in extension) || !extension.component) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
var ExtensionComponent = extension.component;
|
|
69
126
|
return /*#__PURE__*/_react.default.createElement(ExtensionComponent, {
|
|
70
127
|
closeExtension: handleOnClose,
|
|
71
128
|
selection: activeExtension.selection
|
|
@@ -12,7 +12,7 @@ var _MenuItem = require("./toolbar-components/MenuItem");
|
|
|
12
12
|
var _registerInlineToolbar = require("./toolbar-components/register-inline-toolbar");
|
|
13
13
|
var _migrateSelectionExtention = require("./utils/migrate-selection-extention");
|
|
14
14
|
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(_ref) {
|
|
15
|
-
var _config$extensionList, _config$extensions;
|
|
15
|
+
var _config$extensionList, _config$extensions, _config$extensions2;
|
|
16
16
|
var api = _ref.api,
|
|
17
17
|
config = _ref.config;
|
|
18
18
|
var extensionToolbarComponents = (config === null || config === void 0 || (_config$extensionList = config.extensionList) === null || _config$extensionList === void 0 ? void 0 : _config$extensionList.flatMap(function (extension, index) {
|
|
@@ -35,6 +35,11 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
35
35
|
}).filter(function (extension) {
|
|
36
36
|
return extension !== undefined;
|
|
37
37
|
})) || [];
|
|
38
|
+
var externalExtensions = (config === null || config === void 0 || (_config$extensions2 = config.extensions) === null || _config$extensions2 === void 0 || (_config$extensions2 = _config$extensions2.external) === null || _config$extensions2 === void 0 ? void 0 : _config$extensions2.map(function (extension) {
|
|
39
|
+
return (0, _migrateSelectionExtention.migrateSelectionExtensionToMenuItem)(extension, api);
|
|
40
|
+
}).filter(function (extension) {
|
|
41
|
+
return extension !== undefined;
|
|
42
|
+
})) || [];
|
|
38
43
|
return [{
|
|
39
44
|
type: _toolbar.APPS_SECTION.type,
|
|
40
45
|
key: _toolbar.APPS_SECTION.key,
|
|
@@ -57,7 +62,7 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
57
62
|
type: _toolbar.OVERFLOW_MENU.type,
|
|
58
63
|
rank: _toolbar.OVERFLOW_MENU_RANK[_toolbar.SELECTION_EXTENSION_MENU_SECTION.key]
|
|
59
64
|
}]
|
|
60
|
-
}].concat((0, _toConsumableArray2.default)(extensionToolbarComponents), (0, _toConsumableArray2.default)(registerFirstPartyExtensions(api, firstPartyExtensions)));
|
|
65
|
+
}].concat((0, _toConsumableArray2.default)(extensionToolbarComponents), (0, _toConsumableArray2.default)(registerFirstPartyExtensions(api, firstPartyExtensions)), (0, _toConsumableArray2.default)(registerExternalExtensions(api, externalExtensions)));
|
|
61
66
|
};
|
|
62
67
|
var registerFirstPartyExtensions = function registerFirstPartyExtensions(api, extensions) {
|
|
63
68
|
var components = [];
|
|
@@ -77,4 +82,23 @@ var registerFirstPartyExtensions = function registerFirstPartyExtensions(api, ex
|
|
|
77
82
|
}
|
|
78
83
|
});
|
|
79
84
|
return components;
|
|
85
|
+
};
|
|
86
|
+
var registerExternalExtensions = function registerExternalExtensions(api, extensions) {
|
|
87
|
+
var components = [];
|
|
88
|
+
components.push({
|
|
89
|
+
type: 'menu-item',
|
|
90
|
+
key: 'external-extensions-menu-item',
|
|
91
|
+
parents: [{
|
|
92
|
+
type: 'menu-section',
|
|
93
|
+
key: _toolbar.SELECTION_EXTENSION_MENU_SECTION.key,
|
|
94
|
+
rank: 200
|
|
95
|
+
}],
|
|
96
|
+
component: function component() {
|
|
97
|
+
return /*#__PURE__*/_react.default.createElement(_MenuItem.MenuItem, {
|
|
98
|
+
api: api,
|
|
99
|
+
extensionMenuItems: extensions
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return components;
|
|
80
104
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
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 { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export const SelectionExtensionComponentWrapper = ({
|
|
5
7
|
api,
|
|
6
8
|
editorAnalyticsAPI
|
|
7
9
|
}) => {
|
|
8
10
|
const componentRef = useRef();
|
|
11
|
+
const isToolbarAIFCEnabled = editorExperiment('platform_editor_toolbar_aifc', true, {
|
|
12
|
+
exposure: true
|
|
13
|
+
});
|
|
14
|
+
const isToolbarAIFCSelectionExtensionEnabled = expValEquals('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true);
|
|
9
15
|
const {
|
|
10
16
|
activeExtension,
|
|
11
17
|
mode
|
|
@@ -41,7 +47,33 @@ export const SelectionExtensionComponentWrapper = ({
|
|
|
41
47
|
|
|
42
48
|
// Viewed analytics event for component mount
|
|
43
49
|
useEffect(() => {
|
|
44
|
-
|
|
50
|
+
const extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
51
|
+
if (!extension) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
55
|
+
let currentComponent;
|
|
56
|
+
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
57
|
+
currentComponent = extension.contentComponent;
|
|
58
|
+
} else if ('component' in extension && extension.component !== undefined) {
|
|
59
|
+
currentComponent = extension.component;
|
|
60
|
+
}
|
|
61
|
+
if (componentRef.current !== currentComponent && currentComponent !== undefined) {
|
|
62
|
+
if (editorAnalyticsAPI) {
|
|
63
|
+
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
64
|
+
action: ACTION.VIEWED,
|
|
65
|
+
actionSubject: ACTION_SUBJECT.EDITOR_PLUGIN_SELECTION_EXTENSION,
|
|
66
|
+
actionSubjectId: ACTION_SUBJECT_ID.EDITOR_PLUGIN_SELECTION_EXTENSION_COMPONENT,
|
|
67
|
+
eventType: EVENT_TYPE.TRACK
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Sets reference to active component
|
|
71
|
+
componentRef.current = currentComponent;
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
76
|
+
if (extension && 'component' in extension && componentRef.current !== extension.component && extension.component !== undefined) {
|
|
45
77
|
if (editorAnalyticsAPI) {
|
|
46
78
|
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
47
79
|
action: ACTION.VIEWED,
|
|
@@ -51,15 +83,40 @@ export const SelectionExtensionComponentWrapper = ({
|
|
|
51
83
|
});
|
|
52
84
|
}
|
|
53
85
|
// Sets reference to active component
|
|
54
|
-
componentRef.current =
|
|
86
|
+
componentRef.current = extension.component;
|
|
55
87
|
}
|
|
56
|
-
}, [activeExtension, editorAnalyticsAPI]);
|
|
57
|
-
|
|
88
|
+
}, [activeExtension, editorAnalyticsAPI, isToolbarAIFCEnabled, isToolbarAIFCSelectionExtensionEnabled]);
|
|
89
|
+
const extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
90
|
+
if (!extension) {
|
|
58
91
|
return null;
|
|
59
92
|
}
|
|
93
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
94
|
+
const hasContentComponent = ext => {
|
|
95
|
+
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
96
|
+
};
|
|
97
|
+
const hasComponent = ext => {
|
|
98
|
+
return 'component' in ext && ext.component !== undefined;
|
|
99
|
+
};
|
|
100
|
+
let ExtensionComponent;
|
|
101
|
+
if (hasContentComponent(extension)) {
|
|
102
|
+
ExtensionComponent = extension.contentComponent;
|
|
103
|
+
} else if (hasComponent(extension)) {
|
|
104
|
+
ExtensionComponent = extension.component;
|
|
105
|
+
}
|
|
106
|
+
if (!ExtensionComponent) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/React.createElement(ExtensionComponent, {
|
|
110
|
+
closeExtension: handleOnClose,
|
|
111
|
+
selection: activeExtension.selection
|
|
112
|
+
});
|
|
113
|
+
}
|
|
60
114
|
|
|
61
|
-
//
|
|
62
|
-
|
|
115
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
116
|
+
if (!('component' in extension) || !extension.component) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const ExtensionComponent = extension.component;
|
|
63
120
|
return /*#__PURE__*/React.createElement(ExtensionComponent, {
|
|
64
121
|
closeExtension: handleOnClose,
|
|
65
122
|
selection: activeExtension.selection
|
|
@@ -7,7 +7,7 @@ export const getToolbarComponents = ({
|
|
|
7
7
|
api,
|
|
8
8
|
config
|
|
9
9
|
}) => {
|
|
10
|
-
var _config$extensionList, _config$extensions, _config$extensions$fi;
|
|
10
|
+
var _config$extensionList, _config$extensions, _config$extensions$fi, _config$extensions2, _config$extensions2$e;
|
|
11
11
|
const extensionToolbarComponents = (config === null || config === void 0 ? void 0 : (_config$extensionList = config.extensionList) === null || _config$extensionList === void 0 ? void 0 : _config$extensionList.flatMap((extension, index) => registerInlineToolbar({
|
|
12
12
|
api,
|
|
13
13
|
extension,
|
|
@@ -22,6 +22,7 @@ export const getToolbarComponents = ({
|
|
|
22
22
|
* fresh and up to date.
|
|
23
23
|
*/
|
|
24
24
|
const firstPartyExtensions = (config === null || config === void 0 ? void 0 : (_config$extensions = config.extensions) === null || _config$extensions === void 0 ? void 0 : (_config$extensions$fi = _config$extensions.firstParty) === null || _config$extensions$fi === void 0 ? void 0 : _config$extensions$fi.map(extension => migrateSelectionExtensionToMenuItem(extension, api)).filter(extension => extension !== undefined)) || [];
|
|
25
|
+
const externalExtensions = (config === null || config === void 0 ? void 0 : (_config$extensions2 = config.extensions) === null || _config$extensions2 === void 0 ? void 0 : (_config$extensions2$e = _config$extensions2.external) === null || _config$extensions2$e === void 0 ? void 0 : _config$extensions2$e.map(extension => migrateSelectionExtensionToMenuItem(extension, api)).filter(extension => extension !== undefined)) || [];
|
|
25
26
|
return [{
|
|
26
27
|
type: APPS_SECTION.type,
|
|
27
28
|
key: APPS_SECTION.key,
|
|
@@ -44,7 +45,7 @@ export const getToolbarComponents = ({
|
|
|
44
45
|
type: OVERFLOW_MENU.type,
|
|
45
46
|
rank: OVERFLOW_MENU_RANK[SELECTION_EXTENSION_MENU_SECTION.key]
|
|
46
47
|
}]
|
|
47
|
-
}, ...extensionToolbarComponents, ...registerFirstPartyExtensions(api, firstPartyExtensions)];
|
|
48
|
+
}, ...extensionToolbarComponents, ...registerFirstPartyExtensions(api, firstPartyExtensions), ...registerExternalExtensions(api, externalExtensions)];
|
|
48
49
|
};
|
|
49
50
|
const registerFirstPartyExtensions = (api, extensions) => {
|
|
50
51
|
const components = [];
|
|
@@ -64,4 +65,23 @@ const registerFirstPartyExtensions = (api, extensions) => {
|
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
67
|
return components;
|
|
68
|
+
};
|
|
69
|
+
const registerExternalExtensions = (api, extensions) => {
|
|
70
|
+
const components = [];
|
|
71
|
+
components.push({
|
|
72
|
+
type: 'menu-item',
|
|
73
|
+
key: 'external-extensions-menu-item',
|
|
74
|
+
parents: [{
|
|
75
|
+
type: 'menu-section',
|
|
76
|
+
key: SELECTION_EXTENSION_MENU_SECTION.key,
|
|
77
|
+
rank: 200
|
|
78
|
+
}],
|
|
79
|
+
component: () => {
|
|
80
|
+
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
81
|
+
api: api,
|
|
82
|
+
extensionMenuItems: extensions
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return components;
|
|
67
87
|
};
|
|
@@ -1,10 +1,16 @@
|
|
|
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 { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export var SelectionExtensionComponentWrapper = function SelectionExtensionComponentWrapper(_ref) {
|
|
5
7
|
var api = _ref.api,
|
|
6
8
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
7
9
|
var componentRef = useRef();
|
|
10
|
+
var isToolbarAIFCEnabled = editorExperiment('platform_editor_toolbar_aifc', true, {
|
|
11
|
+
exposure: true
|
|
12
|
+
});
|
|
13
|
+
var isToolbarAIFCSelectionExtensionEnabled = expValEquals('platform_editor_toolbar_aifc_selection_extension', 'isEnabled', true);
|
|
8
14
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['selectionExtension', 'editorViewMode'], function (states) {
|
|
9
15
|
var _states$selectionExte, _states$editorViewMod;
|
|
10
16
|
return {
|
|
@@ -39,7 +45,33 @@ export var SelectionExtensionComponentWrapper = function SelectionExtensionCompo
|
|
|
39
45
|
|
|
40
46
|
// Viewed analytics event for component mount
|
|
41
47
|
useEffect(function () {
|
|
42
|
-
|
|
48
|
+
var extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
49
|
+
if (!extension) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
53
|
+
var currentComponent;
|
|
54
|
+
if ('contentComponent' in extension && extension.contentComponent !== undefined) {
|
|
55
|
+
currentComponent = extension.contentComponent;
|
|
56
|
+
} else if ('component' in extension && extension.component !== undefined) {
|
|
57
|
+
currentComponent = extension.component;
|
|
58
|
+
}
|
|
59
|
+
if (componentRef.current !== currentComponent && currentComponent !== undefined) {
|
|
60
|
+
if (editorAnalyticsAPI) {
|
|
61
|
+
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
62
|
+
action: ACTION.VIEWED,
|
|
63
|
+
actionSubject: ACTION_SUBJECT.EDITOR_PLUGIN_SELECTION_EXTENSION,
|
|
64
|
+
actionSubjectId: ACTION_SUBJECT_ID.EDITOR_PLUGIN_SELECTION_EXTENSION_COMPONENT,
|
|
65
|
+
eventType: EVENT_TYPE.TRACK
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Sets reference to active component
|
|
69
|
+
componentRef.current = currentComponent;
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
74
|
+
if (extension && 'component' in extension && componentRef.current !== extension.component && extension.component !== undefined) {
|
|
43
75
|
if (editorAnalyticsAPI) {
|
|
44
76
|
editorAnalyticsAPI.fireAnalyticsEvent({
|
|
45
77
|
action: ACTION.VIEWED,
|
|
@@ -49,15 +81,40 @@ export var SelectionExtensionComponentWrapper = function SelectionExtensionCompo
|
|
|
49
81
|
});
|
|
50
82
|
}
|
|
51
83
|
// Sets reference to active component
|
|
52
|
-
componentRef.current =
|
|
84
|
+
componentRef.current = extension.component;
|
|
53
85
|
}
|
|
54
|
-
}, [activeExtension, editorAnalyticsAPI]);
|
|
55
|
-
|
|
86
|
+
}, [activeExtension, editorAnalyticsAPI, isToolbarAIFCEnabled, isToolbarAIFCSelectionExtensionEnabled]);
|
|
87
|
+
var extension = activeExtension === null || activeExtension === void 0 ? void 0 : activeExtension.extension;
|
|
88
|
+
if (!extension) {
|
|
56
89
|
return null;
|
|
57
90
|
}
|
|
91
|
+
if (isToolbarAIFCEnabled && isToolbarAIFCSelectionExtensionEnabled) {
|
|
92
|
+
var hasContentComponent = function hasContentComponent(ext) {
|
|
93
|
+
return 'contentComponent' in ext && ext.contentComponent !== undefined;
|
|
94
|
+
};
|
|
95
|
+
var hasComponent = function hasComponent(ext) {
|
|
96
|
+
return 'component' in ext && ext.component !== undefined;
|
|
97
|
+
};
|
|
98
|
+
var _ExtensionComponent;
|
|
99
|
+
if (hasContentComponent(extension)) {
|
|
100
|
+
_ExtensionComponent = extension.contentComponent;
|
|
101
|
+
} else if (hasComponent(extension)) {
|
|
102
|
+
_ExtensionComponent = extension.component;
|
|
103
|
+
}
|
|
104
|
+
if (!_ExtensionComponent) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React.createElement(_ExtensionComponent, {
|
|
108
|
+
closeExtension: handleOnClose,
|
|
109
|
+
selection: activeExtension.selection
|
|
110
|
+
});
|
|
111
|
+
}
|
|
58
112
|
|
|
59
|
-
//
|
|
60
|
-
|
|
113
|
+
// delete this when cleanup platform_editor_toolbar_aifc_selection_extension
|
|
114
|
+
if (!('component' in extension) || !extension.component) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
var ExtensionComponent = extension.component;
|
|
61
118
|
return /*#__PURE__*/React.createElement(ExtensionComponent, {
|
|
62
119
|
closeExtension: handleOnClose,
|
|
63
120
|
selection: activeExtension.selection
|
|
@@ -5,7 +5,7 @@ import { MenuItem } from './toolbar-components/MenuItem';
|
|
|
5
5
|
import { registerInlineToolbar } from './toolbar-components/register-inline-toolbar';
|
|
6
6
|
import { migrateSelectionExtensionToMenuItem } from './utils/migrate-selection-extention';
|
|
7
7
|
export var getToolbarComponents = function getToolbarComponents(_ref) {
|
|
8
|
-
var _config$extensionList, _config$extensions;
|
|
8
|
+
var _config$extensionList, _config$extensions, _config$extensions2;
|
|
9
9
|
var api = _ref.api,
|
|
10
10
|
config = _ref.config;
|
|
11
11
|
var extensionToolbarComponents = (config === null || config === void 0 || (_config$extensionList = config.extensionList) === null || _config$extensionList === void 0 ? void 0 : _config$extensionList.flatMap(function (extension, index) {
|
|
@@ -28,6 +28,11 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
|
|
|
28
28
|
}).filter(function (extension) {
|
|
29
29
|
return extension !== undefined;
|
|
30
30
|
})) || [];
|
|
31
|
+
var externalExtensions = (config === null || config === void 0 || (_config$extensions2 = config.extensions) === null || _config$extensions2 === void 0 || (_config$extensions2 = _config$extensions2.external) === null || _config$extensions2 === void 0 ? void 0 : _config$extensions2.map(function (extension) {
|
|
32
|
+
return migrateSelectionExtensionToMenuItem(extension, api);
|
|
33
|
+
}).filter(function (extension) {
|
|
34
|
+
return extension !== undefined;
|
|
35
|
+
})) || [];
|
|
31
36
|
return [{
|
|
32
37
|
type: APPS_SECTION.type,
|
|
33
38
|
key: APPS_SECTION.key,
|
|
@@ -50,7 +55,7 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
|
|
|
50
55
|
type: OVERFLOW_MENU.type,
|
|
51
56
|
rank: OVERFLOW_MENU_RANK[SELECTION_EXTENSION_MENU_SECTION.key]
|
|
52
57
|
}]
|
|
53
|
-
}].concat(_toConsumableArray(extensionToolbarComponents), _toConsumableArray(registerFirstPartyExtensions(api, firstPartyExtensions)));
|
|
58
|
+
}].concat(_toConsumableArray(extensionToolbarComponents), _toConsumableArray(registerFirstPartyExtensions(api, firstPartyExtensions)), _toConsumableArray(registerExternalExtensions(api, externalExtensions)));
|
|
54
59
|
};
|
|
55
60
|
var registerFirstPartyExtensions = function registerFirstPartyExtensions(api, extensions) {
|
|
56
61
|
var components = [];
|
|
@@ -70,4 +75,23 @@ var registerFirstPartyExtensions = function registerFirstPartyExtensions(api, ex
|
|
|
70
75
|
}
|
|
71
76
|
});
|
|
72
77
|
return components;
|
|
78
|
+
};
|
|
79
|
+
var registerExternalExtensions = function registerExternalExtensions(api, extensions) {
|
|
80
|
+
var components = [];
|
|
81
|
+
components.push({
|
|
82
|
+
type: 'menu-item',
|
|
83
|
+
key: 'external-extensions-menu-item',
|
|
84
|
+
parents: [{
|
|
85
|
+
type: 'menu-section',
|
|
86
|
+
key: SELECTION_EXTENSION_MENU_SECTION.key,
|
|
87
|
+
rank: 200
|
|
88
|
+
}],
|
|
89
|
+
component: function component() {
|
|
90
|
+
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
91
|
+
api: api,
|
|
92
|
+
extensionMenuItems: extensions
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return components;
|
|
73
97
|
};
|
|
@@ -15,14 +15,14 @@ export declare const createPlugin: () => SafePlugin<SelectionExtensionPluginStat
|
|
|
15
15
|
docChangedAfterClick: boolean;
|
|
16
16
|
activeExtension?: {
|
|
17
17
|
coords: import("../types").SelectionExtensionCoords;
|
|
18
|
-
extension: import("../types").SelectionExtension;
|
|
18
|
+
extension: import("../types").SelectionExtension | import("../types").ExtensionMenuItemConfiguration;
|
|
19
19
|
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
20
20
|
};
|
|
21
21
|
} | {
|
|
22
22
|
startTrackChanges: any;
|
|
23
23
|
activeExtension?: {
|
|
24
24
|
coords: import("../types").SelectionExtensionCoords;
|
|
25
|
-
extension: import("../types").SelectionExtension;
|
|
25
|
+
extension: import("../types").SelectionExtension | import("../types").ExtensionMenuItemConfiguration;
|
|
26
26
|
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
27
27
|
};
|
|
28
28
|
docChangedAfterClick?: boolean;
|
|
@@ -106,7 +106,7 @@ export type UpdateActiveExtensionAction = {
|
|
|
106
106
|
export type SelectionExtensionPluginState = {
|
|
107
107
|
activeExtension?: {
|
|
108
108
|
coords: SelectionExtensionCoords;
|
|
109
|
-
extension: SelectionExtension;
|
|
109
|
+
extension: SelectionExtension | ExtensionMenuItemConfiguration;
|
|
110
110
|
selection: SelectionExtensionSelectionInfo;
|
|
111
111
|
};
|
|
112
112
|
docChangedAfterClick?: boolean;
|
|
@@ -15,14 +15,14 @@ export declare const createPlugin: () => SafePlugin<SelectionExtensionPluginStat
|
|
|
15
15
|
docChangedAfterClick: boolean;
|
|
16
16
|
activeExtension?: {
|
|
17
17
|
coords: import("../types").SelectionExtensionCoords;
|
|
18
|
-
extension: import("../types").SelectionExtension;
|
|
18
|
+
extension: import("../types").SelectionExtension | import("../types").ExtensionMenuItemConfiguration;
|
|
19
19
|
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
20
20
|
};
|
|
21
21
|
} | {
|
|
22
22
|
startTrackChanges: any;
|
|
23
23
|
activeExtension?: {
|
|
24
24
|
coords: import("../types").SelectionExtensionCoords;
|
|
25
|
-
extension: import("../types").SelectionExtension;
|
|
25
|
+
extension: import("../types").SelectionExtension | import("../types").ExtensionMenuItemConfiguration;
|
|
26
26
|
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
27
27
|
};
|
|
28
28
|
docChangedAfterClick?: boolean;
|
|
@@ -106,7 +106,7 @@ export type UpdateActiveExtensionAction = {
|
|
|
106
106
|
export type SelectionExtensionPluginState = {
|
|
107
107
|
activeExtension?: {
|
|
108
108
|
coords: SelectionExtensionCoords;
|
|
109
|
-
extension: SelectionExtension;
|
|
109
|
+
extension: SelectionExtension | ExtensionMenuItemConfiguration;
|
|
110
110
|
selection: SelectionExtensionSelectionInfo;
|
|
111
111
|
};
|
|
112
112
|
docChangedAfterClick?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/icon": "^28.1.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
50
|
"@atlaskit/primitives": "^14.13.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^12.6.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
54
|
"react-intl-next": "npm:react-intl@^5.18.1",
|