@atlaskit/editor-plugin-extension 5.0.6 → 5.0.8
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/extensionPlugin.js +13 -9
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +7 -2
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +5 -1
- package/dist/cjs/ui/useConfigPanelPluginHook.js +13 -1
- package/dist/es2019/extensionPlugin.js +13 -9
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +7 -2
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +6 -1
- package/dist/es2019/ui/useConfigPanelPluginHook.js +14 -2
- package/dist/esm/extensionPlugin.js +13 -9
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +7 -2
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +5 -1
- package/dist/esm/ui/useConfigPanelPluginHook.js +14 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -0
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +2 -1
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +2 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-extension
|
|
2
2
|
|
|
3
|
+
## 5.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#129262](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129262)
|
|
8
|
+
[`9408a99b473bb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9408a99b473bb) -
|
|
9
|
+
EDF-2570 Fixed config panel not closing when navigating to other page issue is fixed.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 5.0.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 5.0.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -25,7 +25,7 @@ var _useConfigPanelPluginHook = require("./ui/useConfigPanelPluginHook");
|
|
|
25
25
|
// Remove below line when cleaning up platform_editor_ai_object_sidebar_injection feature flag
|
|
26
26
|
|
|
27
27
|
var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
28
|
-
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$
|
|
28
|
+
var _api$featureFlags, _api$contextPanel, _api$analytics2, _api$analytics3, _api$contextPanel4, _api$decorations, _api$contextPanel5, _api$analytics4;
|
|
29
29
|
var _ref$config = _ref.config,
|
|
30
30
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
31
31
|
_api = _ref.api;
|
|
@@ -35,6 +35,7 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
35
35
|
var editorViewRef = {
|
|
36
36
|
current: null
|
|
37
37
|
};
|
|
38
|
+
var showContextPanel = _api === null || _api === void 0 || (_api$contextPanel = _api.contextPanel) === null || _api$contextPanel === void 0 || (_api$contextPanel = _api$contextPanel.actions) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.showPanel;
|
|
38
39
|
return {
|
|
39
40
|
name: 'extension',
|
|
40
41
|
nodes: function nodes() {
|
|
@@ -83,8 +84,8 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
83
84
|
}, {
|
|
84
85
|
name: 'extensionKeymap',
|
|
85
86
|
plugin: function plugin() {
|
|
86
|
-
var _api$
|
|
87
|
-
return (0, _keymap.default)(_api === null || _api === void 0 || (_api$
|
|
87
|
+
var _api$contextPanel2;
|
|
88
|
+
return (0, _keymap.default)(_api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange);
|
|
88
89
|
}
|
|
89
90
|
}, {
|
|
90
91
|
name: 'extensionUniqueId',
|
|
@@ -118,12 +119,12 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
118
119
|
},
|
|
119
120
|
actions: {
|
|
120
121
|
api: function api() {
|
|
121
|
-
var _api$
|
|
122
|
+
var _api$contextPanel3, _api$analytics;
|
|
122
123
|
return (0, _extensionApi.createExtensionAPI)({
|
|
123
124
|
// Ignored via go/ees005
|
|
124
125
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
126
|
editorView: editorViewRef.current,
|
|
126
|
-
applyChange: _api === null || _api === void 0 || (_api$
|
|
127
|
+
applyChange: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
|
|
127
128
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics = _api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
128
129
|
});
|
|
129
130
|
},
|
|
@@ -167,7 +168,7 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
167
168
|
editSelectedExtension: (0, _actions.createEditSelectedExtensionAction)({
|
|
168
169
|
editorViewRef: editorViewRef,
|
|
169
170
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
170
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$
|
|
171
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange
|
|
171
172
|
}),
|
|
172
173
|
runMacroAutoConvert: _actions2.runMacroAutoConvert,
|
|
173
174
|
forceAutoSave: _commands.forceAutoSave
|
|
@@ -179,16 +180,19 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
179
180
|
}) : (0, _toolbar.getToolbarConfig)({
|
|
180
181
|
breakoutEnabled: options.breakoutEnabled,
|
|
181
182
|
hoverDecoration: _api === null || _api === void 0 || (_api$decorations = _api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
|
|
182
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$
|
|
183
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel5 = _api.contextPanel) === null || _api$contextPanel5 === void 0 ? void 0 : _api$contextPanel5.actions.applyChange,
|
|
183
184
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
184
185
|
extensionApi: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? _api : undefined
|
|
185
186
|
}),
|
|
186
|
-
contextPanel:
|
|
187
|
+
contextPanel:
|
|
188
|
+
// if showContextPanel action is not available, or platform_editor_ai_object_sidebar_injection feature flag is off
|
|
189
|
+
// then keep using old context panel.
|
|
190
|
+
!showContextPanel || !(0, _platformFeatureFlags.fg)('platform_editor_ai_object_sidebar_injection') ? (0, _contextPanel.getContextPanel)(function () {
|
|
187
191
|
var _editorViewRef$curren;
|
|
188
192
|
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
189
193
|
})(_api, featureFlags) : undefined
|
|
190
194
|
},
|
|
191
|
-
usePluginHook: (0, _platformFeatureFlags.fg)('platform_editor_ai_object_sidebar_injection') ? function (_ref6) {
|
|
195
|
+
usePluginHook: showContextPanel && (0, _platformFeatureFlags.fg)('platform_editor_ai_object_sidebar_injection') ? function (_ref6) {
|
|
192
196
|
var editorView = _ref6.editorView;
|
|
193
197
|
(0, _useConfigPanelPluginHook.useConfigPanelPluginHook)({
|
|
194
198
|
editorView: editorView,
|
|
@@ -270,10 +270,15 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
270
270
|
return _ref4.apply(this, arguments);
|
|
271
271
|
};
|
|
272
272
|
}());
|
|
273
|
+
/**
|
|
274
|
+
* Remove renderHeader when when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
275
|
+
* Because header will br rendered separately outside of ConfigPanel.
|
|
276
|
+
* ConfigPanel will be body component of ContextPanel.
|
|
277
|
+
*/
|
|
273
278
|
// memoized to prevent rerender on new parameters
|
|
274
279
|
(0, _defineProperty2.default)(_this, "renderHeader", (0, _memoizeOne.default)(function (extensionManifest) {
|
|
275
|
-
//
|
|
276
|
-
if (
|
|
280
|
+
// Remove below line when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
281
|
+
if (_this.props.usingObjectSidebarPanel) {
|
|
277
282
|
return null;
|
|
278
283
|
}
|
|
279
284
|
var _this$props2 = _this.props,
|
|
@@ -115,7 +115,8 @@ function FieldsLoader(_ref) {
|
|
|
115
115
|
featureFlags = _ref.featureFlags,
|
|
116
116
|
onChange = _ref.onChange,
|
|
117
117
|
onCancel = _ref.onCancel,
|
|
118
|
-
api = _ref.api
|
|
118
|
+
api = _ref.api,
|
|
119
|
+
usingObjectSidebarPanel = _ref.usingObjectSidebarPanel;
|
|
119
120
|
var _useStateFromPromise = (0, _useStateFromPromise3.useStateFromPromise)(function () {
|
|
120
121
|
return extensionProvider.getExtension(extensionType, extensionKey);
|
|
121
122
|
}, [extensionProvider, extensionType, extensionKey]),
|
|
@@ -145,6 +146,9 @@ function FieldsLoader(_ref) {
|
|
|
145
146
|
onCancel: onCancel,
|
|
146
147
|
errorMessage: errorMessage,
|
|
147
148
|
featureFlags: featureFlags
|
|
149
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
150
|
+
,
|
|
151
|
+
usingObjectSidebarPanel: usingObjectSidebarPanel
|
|
148
152
|
});
|
|
149
153
|
});
|
|
150
154
|
}
|
|
@@ -57,6 +57,11 @@ function useConfigPanelPluginHook(_ref) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}, [api, editorState, editorView, extensionState]);
|
|
60
|
+
(0, _react.useEffect)(function () {
|
|
61
|
+
return function () {
|
|
62
|
+
hideConfigPanel(api);
|
|
63
|
+
};
|
|
64
|
+
}, [api]);
|
|
60
65
|
}
|
|
61
66
|
function hideConfigPanel(api) {
|
|
62
67
|
var _api$contextPanel;
|
|
@@ -111,12 +116,15 @@ function showConfigPanel(_ref2) {
|
|
|
111
116
|
id: _constants.CONFIG_PANEL_ID,
|
|
112
117
|
headerComponentElements: {
|
|
113
118
|
HeaderIcon: HeadeIconWrapper,
|
|
114
|
-
headerLabel: _extensions.configPanelMessages.objectSidebarPanelHeaderLabel,
|
|
115
119
|
HeaderAfterIconElement: HeaderAfterIconElementWrapper
|
|
116
120
|
},
|
|
117
121
|
BodyComponent: BodyComponent,
|
|
118
122
|
closeOptions: {
|
|
119
123
|
canClosePanel: function canClosePanel() {
|
|
124
|
+
// When navigating away from the editor, the editorView is destroyed.
|
|
125
|
+
if (editorView.isDestroyed) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
120
128
|
var extensionState = (0, _pluginFactory.getPluginState)(editorView.state);
|
|
121
129
|
/**
|
|
122
130
|
* If context panel is open, then first update extension plugin state.
|
|
@@ -244,6 +252,10 @@ var getContextPanelBodyComponent = exports.getContextPanelBodyComponent = functi
|
|
|
244
252
|
});
|
|
245
253
|
},
|
|
246
254
|
featureFlags: featureFlags
|
|
255
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
256
|
+
// Becuase it will always be true
|
|
257
|
+
,
|
|
258
|
+
usingObjectSidebarPanel: true
|
|
247
259
|
});
|
|
248
260
|
}));
|
|
249
261
|
};
|
|
@@ -20,13 +20,14 @@ export const extensionPlugin = ({
|
|
|
20
20
|
config: options = {},
|
|
21
21
|
api
|
|
22
22
|
}) => {
|
|
23
|
-
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$
|
|
23
|
+
var _api$featureFlags, _api$contextPanel, _api$contextPanel$act, _api$analytics2, _api$analytics3, _api$contextPanel4, _api$decorations, _api$contextPanel5, _api$analytics4;
|
|
24
24
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
25
25
|
//Note: This is a hack to get the editor view reference in the plugin. Copied from table plugin.
|
|
26
26
|
//This is needed to get the current selection in the editor
|
|
27
27
|
const editorViewRef = {
|
|
28
28
|
current: null
|
|
29
29
|
};
|
|
30
|
+
const showContextPanel = api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : (_api$contextPanel$act = _api$contextPanel.actions) === null || _api$contextPanel$act === void 0 ? void 0 : _api$contextPanel$act.showPanel;
|
|
30
31
|
return {
|
|
31
32
|
name: 'extension',
|
|
32
33
|
nodes() {
|
|
@@ -76,8 +77,8 @@ export const extensionPlugin = ({
|
|
|
76
77
|
}, {
|
|
77
78
|
name: 'extensionKeymap',
|
|
78
79
|
plugin: () => {
|
|
79
|
-
var _api$
|
|
80
|
-
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$
|
|
80
|
+
var _api$contextPanel2;
|
|
81
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$contextPanel2 = api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange);
|
|
81
82
|
}
|
|
82
83
|
}, {
|
|
83
84
|
name: 'extensionUniqueId',
|
|
@@ -108,12 +109,12 @@ export const extensionPlugin = ({
|
|
|
108
109
|
},
|
|
109
110
|
actions: {
|
|
110
111
|
api: () => {
|
|
111
|
-
var _api$
|
|
112
|
+
var _api$contextPanel3, _api$analytics;
|
|
112
113
|
return createExtensionAPI({
|
|
113
114
|
// Ignored via go/ees005
|
|
114
115
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
115
116
|
editorView: editorViewRef.current,
|
|
116
|
-
applyChange: api === null || api === void 0 ? void 0 : (_api$
|
|
117
|
+
applyChange: api === null || api === void 0 ? void 0 : (_api$contextPanel3 = api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
|
|
117
118
|
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
118
119
|
});
|
|
119
120
|
},
|
|
@@ -155,7 +156,7 @@ export const extensionPlugin = ({
|
|
|
155
156
|
editSelectedExtension: createEditSelectedExtensionAction({
|
|
156
157
|
editorViewRef,
|
|
157
158
|
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
158
|
-
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$
|
|
159
|
+
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel4 = api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange
|
|
159
160
|
}),
|
|
160
161
|
runMacroAutoConvert,
|
|
161
162
|
forceAutoSave
|
|
@@ -167,16 +168,19 @@ export const extensionPlugin = ({
|
|
|
167
168
|
}) : getToolbarConfig({
|
|
168
169
|
breakoutEnabled: options.breakoutEnabled,
|
|
169
170
|
hoverDecoration: api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
|
|
170
|
-
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$
|
|
171
|
+
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel5 = api.contextPanel) === null || _api$contextPanel5 === void 0 ? void 0 : _api$contextPanel5.actions.applyChange,
|
|
171
172
|
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
172
173
|
extensionApi: editorExperiment('platform_editor_controls', 'variant1') ? api : undefined
|
|
173
174
|
}),
|
|
174
|
-
contextPanel:
|
|
175
|
+
contextPanel:
|
|
176
|
+
// if showContextPanel action is not available, or platform_editor_ai_object_sidebar_injection feature flag is off
|
|
177
|
+
// then keep using old context panel.
|
|
178
|
+
!showContextPanel || !fg('platform_editor_ai_object_sidebar_injection') ? getContextPanel(() => {
|
|
175
179
|
var _editorViewRef$curren;
|
|
176
180
|
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
177
181
|
})(api, featureFlags) : undefined
|
|
178
182
|
},
|
|
179
|
-
usePluginHook: fg('platform_editor_ai_object_sidebar_injection') ? ({
|
|
183
|
+
usePluginHook: showContextPanel && fg('platform_editor_ai_object_sidebar_injection') ? ({
|
|
180
184
|
editorView
|
|
181
185
|
}) => {
|
|
182
186
|
useConfigPanelPluginHook({
|
|
@@ -213,10 +213,15 @@ class ConfigPanel extends React.Component {
|
|
|
213
213
|
hasParsedParameters: true
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
|
+
/**
|
|
217
|
+
* Remove renderHeader when when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
218
|
+
* Because header will br rendered separately outside of ConfigPanel.
|
|
219
|
+
* ConfigPanel will be body component of ContextPanel.
|
|
220
|
+
*/
|
|
216
221
|
// memoized to prevent rerender on new parameters
|
|
217
222
|
_defineProperty(this, "renderHeader", memoizeOne(extensionManifest => {
|
|
218
|
-
//
|
|
219
|
-
if (
|
|
223
|
+
// Remove below line when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
224
|
+
if (this.props.usingObjectSidebarPanel) {
|
|
220
225
|
return null;
|
|
221
226
|
}
|
|
222
227
|
const {
|
|
@@ -100,7 +100,9 @@ export default function FieldsLoader({
|
|
|
100
100
|
featureFlags,
|
|
101
101
|
onChange,
|
|
102
102
|
onCancel,
|
|
103
|
-
api
|
|
103
|
+
api,
|
|
104
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
105
|
+
usingObjectSidebarPanel
|
|
104
106
|
}) {
|
|
105
107
|
const [extensionManifest] = useStateFromPromise(() => extensionProvider.getExtension(extensionType, extensionKey), [extensionProvider, extensionType, extensionKey]);
|
|
106
108
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
@@ -123,5 +125,8 @@ export default function FieldsLoader({
|
|
|
123
125
|
onCancel: onCancel,
|
|
124
126
|
errorMessage: errorMessage,
|
|
125
127
|
featureFlags: featureFlags
|
|
128
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
129
|
+
,
|
|
130
|
+
usingObjectSidebarPanel: usingObjectSidebarPanel
|
|
126
131
|
}));
|
|
127
132
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { Box } from '@atlaskit/primitives';
|
|
5
5
|
import { clearEditingContext, forceAutoSave } from '../editor-commands/commands';
|
|
@@ -44,6 +44,11 @@ export function useConfigPanelPluginHook({
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}, [api, editorState, editorView, extensionState]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
return () => {
|
|
49
|
+
hideConfigPanel(api);
|
|
50
|
+
};
|
|
51
|
+
}, [api]);
|
|
47
52
|
}
|
|
48
53
|
export function hideConfigPanel(api) {
|
|
49
54
|
var _api$contextPanel, _api$contextPanel$act;
|
|
@@ -96,12 +101,15 @@ export function showConfigPanel({
|
|
|
96
101
|
id: CONFIG_PANEL_ID,
|
|
97
102
|
headerComponentElements: {
|
|
98
103
|
HeaderIcon: HeadeIconWrapper,
|
|
99
|
-
headerLabel: configPanelMessages.objectSidebarPanelHeaderLabel,
|
|
100
104
|
HeaderAfterIconElement: HeaderAfterIconElementWrapper
|
|
101
105
|
},
|
|
102
106
|
BodyComponent,
|
|
103
107
|
closeOptions: {
|
|
104
108
|
canClosePanel: () => {
|
|
109
|
+
// When navigating away from the editor, the editorView is destroyed.
|
|
110
|
+
if (editorView.isDestroyed) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
105
113
|
const extensionState = getPluginState(editorView.state);
|
|
106
114
|
/**
|
|
107
115
|
* If context panel is open, then first update extension plugin state.
|
|
@@ -196,6 +204,10 @@ export const getContextPanelBodyComponent = ({
|
|
|
196
204
|
editorView
|
|
197
205
|
}),
|
|
198
206
|
featureFlags: featureFlags
|
|
207
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
208
|
+
// Becuase it will always be true
|
|
209
|
+
,
|
|
210
|
+
usingObjectSidebarPanel: true
|
|
199
211
|
});
|
|
200
212
|
}));
|
|
201
213
|
};
|
|
@@ -17,7 +17,7 @@ import { createPlugin as createUniqueIdPlugin } from './pm-plugins/unique-id';
|
|
|
17
17
|
import { getContextPanel } from './ui/context-panel';
|
|
18
18
|
import { useConfigPanelPluginHook } from './ui/useConfigPanelPluginHook';
|
|
19
19
|
export var extensionPlugin = function extensionPlugin(_ref) {
|
|
20
|
-
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$
|
|
20
|
+
var _api$featureFlags, _api$contextPanel, _api$analytics2, _api$analytics3, _api$contextPanel4, _api$decorations, _api$contextPanel5, _api$analytics4;
|
|
21
21
|
var _ref$config = _ref.config,
|
|
22
22
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
23
23
|
_api = _ref.api;
|
|
@@ -27,6 +27,7 @@ export var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
27
27
|
var editorViewRef = {
|
|
28
28
|
current: null
|
|
29
29
|
};
|
|
30
|
+
var showContextPanel = _api === null || _api === void 0 || (_api$contextPanel = _api.contextPanel) === null || _api$contextPanel === void 0 || (_api$contextPanel = _api$contextPanel.actions) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.showPanel;
|
|
30
31
|
return {
|
|
31
32
|
name: 'extension',
|
|
32
33
|
nodes: function nodes() {
|
|
@@ -75,8 +76,8 @@ export var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
75
76
|
}, {
|
|
76
77
|
name: 'extensionKeymap',
|
|
77
78
|
plugin: function plugin() {
|
|
78
|
-
var _api$
|
|
79
|
-
return keymapPlugin(_api === null || _api === void 0 || (_api$
|
|
79
|
+
var _api$contextPanel2;
|
|
80
|
+
return keymapPlugin(_api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange);
|
|
80
81
|
}
|
|
81
82
|
}, {
|
|
82
83
|
name: 'extensionUniqueId',
|
|
@@ -110,12 +111,12 @@ export var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
110
111
|
},
|
|
111
112
|
actions: {
|
|
112
113
|
api: function api() {
|
|
113
|
-
var _api$
|
|
114
|
+
var _api$contextPanel3, _api$analytics;
|
|
114
115
|
return createExtensionAPI({
|
|
115
116
|
// Ignored via go/ees005
|
|
116
117
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
117
118
|
editorView: editorViewRef.current,
|
|
118
|
-
applyChange: _api === null || _api === void 0 || (_api$
|
|
119
|
+
applyChange: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
|
|
119
120
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics = _api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
120
121
|
});
|
|
121
122
|
},
|
|
@@ -159,7 +160,7 @@ export var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
159
160
|
editSelectedExtension: createEditSelectedExtensionAction({
|
|
160
161
|
editorViewRef: editorViewRef,
|
|
161
162
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
162
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$
|
|
163
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange
|
|
163
164
|
}),
|
|
164
165
|
runMacroAutoConvert: runMacroAutoConvert,
|
|
165
166
|
forceAutoSave: forceAutoSave
|
|
@@ -171,16 +172,19 @@ export var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
171
172
|
}) : getToolbarConfig({
|
|
172
173
|
breakoutEnabled: options.breakoutEnabled,
|
|
173
174
|
hoverDecoration: _api === null || _api === void 0 || (_api$decorations = _api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
|
|
174
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$
|
|
175
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel5 = _api.contextPanel) === null || _api$contextPanel5 === void 0 ? void 0 : _api$contextPanel5.actions.applyChange,
|
|
175
176
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
176
177
|
extensionApi: editorExperiment('platform_editor_controls', 'variant1') ? _api : undefined
|
|
177
178
|
}),
|
|
178
|
-
contextPanel:
|
|
179
|
+
contextPanel:
|
|
180
|
+
// if showContextPanel action is not available, or platform_editor_ai_object_sidebar_injection feature flag is off
|
|
181
|
+
// then keep using old context panel.
|
|
182
|
+
!showContextPanel || !fg('platform_editor_ai_object_sidebar_injection') ? getContextPanel(function () {
|
|
179
183
|
var _editorViewRef$curren;
|
|
180
184
|
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
181
185
|
})(_api, featureFlags) : undefined
|
|
182
186
|
},
|
|
183
|
-
usePluginHook: fg('platform_editor_ai_object_sidebar_injection') ? function (_ref6) {
|
|
187
|
+
usePluginHook: showContextPanel && fg('platform_editor_ai_object_sidebar_injection') ? function (_ref6) {
|
|
184
188
|
var editorView = _ref6.editorView;
|
|
185
189
|
useConfigPanelPluginHook({
|
|
186
190
|
editorView: editorView,
|
|
@@ -260,10 +260,15 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
260
260
|
return _ref4.apply(this, arguments);
|
|
261
261
|
};
|
|
262
262
|
}());
|
|
263
|
+
/**
|
|
264
|
+
* Remove renderHeader when when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
265
|
+
* Because header will br rendered separately outside of ConfigPanel.
|
|
266
|
+
* ConfigPanel will be body component of ContextPanel.
|
|
267
|
+
*/
|
|
263
268
|
// memoized to prevent rerender on new parameters
|
|
264
269
|
_defineProperty(_this, "renderHeader", memoizeOne(function (extensionManifest) {
|
|
265
|
-
//
|
|
266
|
-
if (
|
|
270
|
+
// Remove below line when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
271
|
+
if (_this.props.usingObjectSidebarPanel) {
|
|
267
272
|
return null;
|
|
268
273
|
}
|
|
269
274
|
var _this$props2 = _this.props,
|
|
@@ -105,7 +105,8 @@ export default function FieldsLoader(_ref) {
|
|
|
105
105
|
featureFlags = _ref.featureFlags,
|
|
106
106
|
onChange = _ref.onChange,
|
|
107
107
|
onCancel = _ref.onCancel,
|
|
108
|
-
api = _ref.api
|
|
108
|
+
api = _ref.api,
|
|
109
|
+
usingObjectSidebarPanel = _ref.usingObjectSidebarPanel;
|
|
109
110
|
var _useStateFromPromise = useStateFromPromise(function () {
|
|
110
111
|
return extensionProvider.getExtension(extensionType, extensionKey);
|
|
111
112
|
}, [extensionProvider, extensionType, extensionKey]),
|
|
@@ -135,6 +136,9 @@ export default function FieldsLoader(_ref) {
|
|
|
135
136
|
onCancel: onCancel,
|
|
136
137
|
errorMessage: errorMessage,
|
|
137
138
|
featureFlags: featureFlags
|
|
139
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
140
|
+
,
|
|
141
|
+
usingObjectSidebarPanel: usingObjectSidebarPanel
|
|
138
142
|
});
|
|
139
143
|
});
|
|
140
144
|
}
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import React, { useEffect } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
|
|
6
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { Box } from '@atlaskit/primitives';
|
|
8
8
|
import { clearEditingContext, forceAutoSave } from '../editor-commands/commands';
|
|
@@ -43,6 +43,11 @@ export function useConfigPanelPluginHook(_ref) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}, [api, editorState, editorView, extensionState]);
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
return function () {
|
|
48
|
+
hideConfigPanel(api);
|
|
49
|
+
};
|
|
50
|
+
}, [api]);
|
|
46
51
|
}
|
|
47
52
|
export function hideConfigPanel(api) {
|
|
48
53
|
var _api$contextPanel;
|
|
@@ -97,12 +102,15 @@ export function showConfigPanel(_ref2) {
|
|
|
97
102
|
id: CONFIG_PANEL_ID,
|
|
98
103
|
headerComponentElements: {
|
|
99
104
|
HeaderIcon: HeadeIconWrapper,
|
|
100
|
-
headerLabel: configPanelMessages.objectSidebarPanelHeaderLabel,
|
|
101
105
|
HeaderAfterIconElement: HeaderAfterIconElementWrapper
|
|
102
106
|
},
|
|
103
107
|
BodyComponent: BodyComponent,
|
|
104
108
|
closeOptions: {
|
|
105
109
|
canClosePanel: function canClosePanel() {
|
|
110
|
+
// When navigating away from the editor, the editorView is destroyed.
|
|
111
|
+
if (editorView.isDestroyed) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
106
114
|
var extensionState = getPluginState(editorView.state);
|
|
107
115
|
/**
|
|
108
116
|
* If context panel is open, then first update extension plugin state.
|
|
@@ -230,6 +238,10 @@ export var getContextPanelBodyComponent = function getContextPanelBodyComponent(
|
|
|
230
238
|
});
|
|
231
239
|
},
|
|
232
240
|
featureFlags: featureFlags
|
|
241
|
+
// Remove below prop when cleaning platform_editor_ai_object_sidebar_injection FG
|
|
242
|
+
// Becuase it will always be true
|
|
243
|
+
,
|
|
244
|
+
usingObjectSidebarPanel: true
|
|
233
245
|
});
|
|
234
246
|
}));
|
|
235
247
|
};
|
|
@@ -17,5 +17,6 @@ declare const result: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
|
17
17
|
isLoading?: boolean | undefined;
|
|
18
18
|
featureFlags?: FeatureFlags | undefined;
|
|
19
19
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
20
|
+
usingObjectSidebarPanel?: boolean | undefined;
|
|
20
21
|
}, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & React.RefAttributes<any>>;
|
|
21
22
|
export default result;
|
|
@@ -17,5 +17,6 @@ export type PublicProps = {
|
|
|
17
17
|
onChange: (data: Parameters) => void;
|
|
18
18
|
onCancel: () => void;
|
|
19
19
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
20
|
+
usingObjectSidebarPanel?: boolean;
|
|
20
21
|
};
|
|
21
|
-
export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, api, }: PublicProps): React.JSX.Element;
|
|
22
|
+
export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, api, usingObjectSidebarPanel, }: PublicProps): React.JSX.Element;
|
|
@@ -17,5 +17,6 @@ declare const result: React.ForwardRefExoticComponent<Omit<Omit<{
|
|
|
17
17
|
isLoading?: boolean | undefined;
|
|
18
18
|
featureFlags?: FeatureFlags | undefined;
|
|
19
19
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
20
|
+
usingObjectSidebarPanel?: boolean | undefined;
|
|
20
21
|
}, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & React.RefAttributes<any>>;
|
|
21
22
|
export default result;
|
|
@@ -17,5 +17,6 @@ export type PublicProps = {
|
|
|
17
17
|
onChange: (data: Parameters) => void;
|
|
18
18
|
onCancel: () => void;
|
|
19
19
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
20
|
+
usingObjectSidebarPanel?: boolean;
|
|
20
21
|
};
|
|
21
|
-
export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, api, }: PublicProps): React.JSX.Element;
|
|
22
|
+
export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, api, usingObjectSidebarPanel, }: PublicProps): React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-extension",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.8",
|
|
4
4
|
"description": "editor-plugin-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/button": "^21.1.0",
|
|
33
33
|
"@atlaskit/checkbox": "^17.0.0",
|
|
34
34
|
"@atlaskit/datetime-picker": "^16.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^102.
|
|
35
|
+
"@atlaskit/editor-common": "^102.11.0",
|
|
36
36
|
"@atlaskit/editor-json-transformer": "^8.24.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
38
38
|
"@atlaskit/editor-plugin-context-identifier": "^2.0.0",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@atlaskit/heading": "^5.1.0",
|
|
49
49
|
"@atlaskit/icon": "^25.0.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
|
-
"@atlaskit/primitives": "^14.
|
|
51
|
+
"@atlaskit/primitives": "^14.2.0",
|
|
52
52
|
"@atlaskit/radio": "^8.0.0",
|
|
53
|
-
"@atlaskit/section-message": "^8.
|
|
53
|
+
"@atlaskit/section-message": "^8.2.0",
|
|
54
54
|
"@atlaskit/select": "^20.0.0",
|
|
55
55
|
"@atlaskit/smart-user-picker": "^8.0.0",
|
|
56
56
|
"@atlaskit/spinner": "^18.0.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@atlaskit/textarea": "^8.0.0",
|
|
59
59
|
"@atlaskit/textfield": "^8.0.0",
|
|
60
60
|
"@atlaskit/theme": "^18.0.0",
|
|
61
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
61
|
+
"@atlaskit/tmp-editor-statsig": "^4.1.0",
|
|
62
62
|
"@atlaskit/toggle": "^15.0.0",
|
|
63
63
|
"@atlaskit/tokens": "^4.5.0",
|
|
64
64
|
"@atlaskit/tooltip": "^20.0.0",
|