@atlaskit/editor-plugin-extension 4.1.2 → 5.0.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/extensionPlugin.js +19 -5
  3. package/dist/cjs/pm-plugins/toolbar.js +25 -24
  4. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +9 -1
  5. package/dist/cjs/ui/ConfigPanel/DescriptionSummary.js +50 -0
  6. package/dist/cjs/ui/ConfigPanel/Header/HeaderAfterIconElement.js +50 -0
  7. package/dist/cjs/ui/ConfigPanel/Header/HeaderIcon.js +49 -0
  8. package/dist/cjs/ui/ConfigPanel/Header.js +3 -12
  9. package/dist/cjs/ui/ConfigPanel/HelpLink.js +22 -0
  10. package/dist/cjs/ui/ConfigPanel/constants.js +4 -2
  11. package/dist/cjs/ui/ConfigPanel/withExtensionManifest.js +33 -0
  12. package/dist/cjs/ui/useConfigPanelPluginHook.js +250 -0
  13. package/dist/es2019/extensionPlugin.js +19 -5
  14. package/dist/es2019/pm-plugins/toolbar.js +25 -24
  15. package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +9 -1
  16. package/dist/es2019/ui/ConfigPanel/DescriptionSummary.js +45 -0
  17. package/dist/es2019/ui/ConfigPanel/Header/HeaderAfterIconElement.js +44 -0
  18. package/dist/es2019/ui/ConfigPanel/Header/HeaderIcon.js +39 -0
  19. package/dist/es2019/ui/ConfigPanel/Header.js +1 -11
  20. package/dist/es2019/ui/ConfigPanel/HelpLink.js +16 -0
  21. package/dist/es2019/ui/ConfigPanel/constants.js +3 -1
  22. package/dist/es2019/ui/ConfigPanel/withExtensionManifest.js +21 -0
  23. package/dist/es2019/ui/useConfigPanelPluginHook.js +201 -0
  24. package/dist/esm/extensionPlugin.js +18 -5
  25. package/dist/esm/pm-plugins/toolbar.js +25 -24
  26. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +9 -1
  27. package/dist/esm/ui/ConfigPanel/DescriptionSummary.js +41 -0
  28. package/dist/esm/ui/ConfigPanel/Header/HeaderAfterIconElement.js +43 -0
  29. package/dist/esm/ui/ConfigPanel/Header/HeaderIcon.js +40 -0
  30. package/dist/esm/ui/ConfigPanel/Header.js +1 -10
  31. package/dist/esm/ui/ConfigPanel/HelpLink.js +15 -0
  32. package/dist/esm/ui/ConfigPanel/constants.js +3 -1
  33. package/dist/esm/ui/ConfigPanel/withExtensionManifest.js +26 -0
  34. package/dist/esm/ui/useConfigPanelPluginHook.js +236 -0
  35. package/dist/types/extensionPluginType.d.ts +2 -0
  36. package/dist/types/ui/ConfigPanel/DescriptionSummary.d.ts +7 -0
  37. package/dist/types/ui/ConfigPanel/Header/HeaderAfterIconElement.d.ts +7 -0
  38. package/dist/types/ui/ConfigPanel/Header/HeaderIcon.d.ts +7 -0
  39. package/dist/types/ui/ConfigPanel/HelpLink.d.ts +7 -0
  40. package/dist/types/ui/ConfigPanel/constants.d.ts +2 -0
  41. package/dist/types/ui/ConfigPanel/withExtensionManifest.d.ts +9 -0
  42. package/dist/types/ui/useConfigPanelPluginHook.d.ts +27 -0
  43. package/dist/types-ts4.5/extensionPluginType.d.ts +2 -0
  44. package/dist/types-ts4.5/ui/ConfigPanel/DescriptionSummary.d.ts +7 -0
  45. package/dist/types-ts4.5/ui/ConfigPanel/Header/HeaderAfterIconElement.d.ts +7 -0
  46. package/dist/types-ts4.5/ui/ConfigPanel/Header/HeaderIcon.d.ts +7 -0
  47. package/dist/types-ts4.5/ui/ConfigPanel/HelpLink.d.ts +7 -0
  48. package/dist/types-ts4.5/ui/ConfigPanel/constants.d.ts +2 -0
  49. package/dist/types-ts4.5/ui/ConfigPanel/withExtensionManifest.d.ts +9 -0
  50. package/dist/types-ts4.5/ui/useConfigPanelPluginHook.d.ts +27 -0
  51. package/package.json +7 -4
@@ -0,0 +1,201 @@
1
+ import React, { useEffect } from 'react';
2
+ import { configPanelMessages, getExtensionKeyAndNodeKey } from '@atlaskit/editor-common/extensions';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { Box } from '@atlaskit/primitives';
5
+ import { clearEditingContext, forceAutoSave } from '../editor-commands/commands';
6
+ import { getPluginState } from '../pm-plugins/plugin-factory';
7
+ import { getSelectedExtension } from '../pm-plugins/utils';
8
+ import ConfigPanelLoader from './ConfigPanel/ConfigPanelLoader';
9
+ import { CONFIG_PANEL_ID, CONFIG_PANEL_WIDTH } from './ConfigPanel/constants';
10
+ import HeaderAfterIconElement from './ConfigPanel/Header/HeaderAfterIconElement';
11
+ import HeaderIcon from './ConfigPanel/Header/HeaderIcon';
12
+ import { onChangeAction } from './context-panel';
13
+ import { SaveIndicator } from './SaveIndicator/SaveIndicator';
14
+ export function useConfigPanelPluginHook({
15
+ editorView,
16
+ api
17
+ }) {
18
+ const editorState = editorView.state;
19
+ const {
20
+ extensionState
21
+ } = useSharedPluginState(api, ['extension']);
22
+ useEffect(() => {
23
+ const nodeWithPos = getSelectedExtension(editorState, true);
24
+ // Adding checks to bail out early
25
+ if (!nodeWithPos || !extensionState) {
26
+ hideConfigPanel(api);
27
+ return;
28
+ }
29
+ if (extensionState) {
30
+ const {
31
+ showContextPanel,
32
+ extensionProvider,
33
+ processParametersAfter
34
+ } = extensionState;
35
+ if (showContextPanel && extensionProvider && processParametersAfter) {
36
+ showConfigPanel({
37
+ api,
38
+ editorView,
39
+ extensionProvider,
40
+ nodeWithPos
41
+ });
42
+ } else {
43
+ hideConfigPanel(api);
44
+ }
45
+ }
46
+ }, [api, editorState, editorView, extensionState]);
47
+ }
48
+ export function hideConfigPanel(api) {
49
+ var _api$contextPanel, _api$contextPanel$act;
50
+ const closePanelById = 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.closePanelById;
51
+ if (closePanelById) {
52
+ closePanelById(CONFIG_PANEL_ID);
53
+ }
54
+ }
55
+ export function showConfigPanel({
56
+ api,
57
+ editorView,
58
+ extensionProvider,
59
+ nodeWithPos
60
+ }) {
61
+ var _api$contextPanel2, _api$contextPanel2$ac;
62
+ const showContextPanel = api === null || api === void 0 ? void 0 : (_api$contextPanel2 = api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : (_api$contextPanel2$ac = _api$contextPanel2.actions) === null || _api$contextPanel2$ac === void 0 ? void 0 : _api$contextPanel2$ac.showPanel;
63
+ if (showContextPanel) {
64
+ const nodeAttrs = nodeWithPos === null || nodeWithPos === void 0 ? void 0 : nodeWithPos.node.attrs;
65
+ const extensionType = nodeAttrs === null || nodeAttrs === void 0 ? void 0 : nodeAttrs.extensionType;
66
+ const extensionKey = nodeAttrs === null || nodeAttrs === void 0 ? void 0 : nodeAttrs.extensionKey;
67
+
68
+ /**
69
+ * Loading extension manifest fails when using
70
+ * extensionKey directly from nodeAttrs.
71
+ * Always get extensionKey from getExtensionKeyAndNodeKey to load
72
+ * extension manifest successfully.
73
+ */
74
+ const [extKey, _] = getExtensionKeyAndNodeKey(extensionKey, extensionType);
75
+ const HeadeIconWrapper = () => {
76
+ return /*#__PURE__*/React.createElement(HeaderIcon, {
77
+ extensionProvider: extensionProvider,
78
+ extensionKey: extKey,
79
+ extensionType: extensionType
80
+ });
81
+ };
82
+ const HeaderAfterIconElementWrapper = () => {
83
+ return /*#__PURE__*/React.createElement(HeaderAfterIconElement, {
84
+ extensionProvider: extensionProvider,
85
+ extensionKey: extKey,
86
+ extensionType: extensionType
87
+ });
88
+ };
89
+ const BodyComponent = getContextPanelBodyComponent({
90
+ api,
91
+ editorView,
92
+ extensionProvider,
93
+ nodeWithPos
94
+ });
95
+ showContextPanel({
96
+ id: CONFIG_PANEL_ID,
97
+ headerComponentElements: {
98
+ HeaderIcon: HeadeIconWrapper,
99
+ headerLabel: configPanelMessages.objectSidebarPanelHeaderLabel,
100
+ HeaderAfterIconElement: HeaderAfterIconElementWrapper
101
+ },
102
+ BodyComponent,
103
+ closeOptions: {
104
+ canClosePanel: () => {
105
+ const extensionState = getPluginState(editorView.state);
106
+ /**
107
+ * If context panel is open, then first update extension plugin state.
108
+ * Updating extension plugin state will trigger useEffect in useConfigPanelPluginHook,
109
+ * which will call hideConfigPanel.
110
+ */
111
+ if (extensionState !== null && extensionState !== void 0 && extensionState.showContextPanel) {
112
+ startClosingConfigPanel({
113
+ api,
114
+ editorView
115
+ });
116
+ return false;
117
+ }
118
+
119
+ // Return true if extension plugin state has been updated and hideConfigPanel has been called.
120
+ return true;
121
+ }
122
+ }
123
+ }, 'push', CONFIG_PANEL_WIDTH);
124
+ }
125
+ }
126
+ export async function startClosingConfigPanel({
127
+ api,
128
+ editorView
129
+ }) {
130
+ var _api$contextPanel3;
131
+ const applyChange = api === null || api === void 0 ? void 0 : (_api$contextPanel3 = api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange;
132
+ // Even if the save failed, we should proceed with closing the panel
133
+ clearEditingContext(applyChange)(editorView.state, editorView.dispatch);
134
+ try {
135
+ await new Promise((resolve, reject) => {
136
+ forceAutoSave(applyChange)(resolve, reject)(editorView.state, editorView.dispatch);
137
+ });
138
+ } catch (e) {
139
+ // Even if the save failed, we should proceed with closing the panel
140
+ // eslint-disable-next-line no-console
141
+ console.error(`Autosave failed with error`, e);
142
+ }
143
+ }
144
+ export const getContextPanelBodyComponent = ({
145
+ api,
146
+ editorView,
147
+ extensionProvider,
148
+ nodeWithPos
149
+ }) => {
150
+ var _api$featureFlags;
151
+ const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
152
+ const editorState = editorView.state;
153
+ const extensionState = getPluginState(editorState);
154
+ const {
155
+ autoSaveResolve,
156
+ autoSaveReject,
157
+ processParametersBefore
158
+ } = extensionState;
159
+ const {
160
+ extensionType,
161
+ extensionKey,
162
+ parameters
163
+ } = nodeWithPos.node.attrs;
164
+ const [extKey, nodeKey] = getExtensionKeyAndNodeKey(extensionKey, extensionType);
165
+ const configParams = processParametersBefore ? processParametersBefore(parameters || {}) : parameters;
166
+ return () => /*#__PURE__*/React.createElement(Box, {
167
+ padding: "space.200"
168
+ }, /*#__PURE__*/React.createElement(SaveIndicator, {
169
+ duration: 5000,
170
+ visible: true
171
+ }, ({
172
+ onSaveStarted,
173
+ onSaveEnded
174
+ }) => {
175
+ return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
176
+ api: api,
177
+ showHeader: true,
178
+ closeOnEsc: true,
179
+ extensionType: extensionType,
180
+ extensionKey: extKey,
181
+ nodeKey: nodeKey,
182
+ extensionParameters: parameters,
183
+ parameters: configParams,
184
+ extensionProvider: extensionProvider,
185
+ autoSaveTrigger: autoSaveResolve,
186
+ autoSaveReject: autoSaveReject,
187
+ onChange: async updatedParameters => {
188
+ await onChangeAction(editorView, updatedParameters, parameters, nodeWithPos, onSaveStarted);
189
+ onSaveEnded();
190
+ if (autoSaveResolve) {
191
+ autoSaveResolve();
192
+ }
193
+ },
194
+ onCancel: () => startClosingConfigPanel({
195
+ api,
196
+ editorView
197
+ }),
198
+ featureFlags: featureFlags
199
+ });
200
+ }));
201
+ };
@@ -1,6 +1,7 @@
1
1
  import { extension, extensionFrame, inlineExtension, multiBodiedExtension } from '@atlaskit/adf-schema';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { createEditSelectedExtensionAction, insertOrReplaceBodiedExtension as _insertOrReplaceBodiedExtension, insertOrReplaceExtension as _insertOrReplaceExtension } from './editor-actions/actions';
5
6
  import { forceAutoSave } from './editor-commands/commands';
6
7
  import { createExtensionAPI } from './pm-plugins/extension-api';
@@ -12,7 +13,9 @@ import { pluginKey } from './pm-plugins/plugin-key';
12
13
  import { bodiedExtensionSpecWithFixedToDOM } from './pm-plugins/toDOM-fixes/bodiedExtension';
13
14
  import { getToolbarConfig } from './pm-plugins/toolbar';
14
15
  import { createPlugin as createUniqueIdPlugin } from './pm-plugins/unique-id';
16
+ // Remove below line when cleaning up platform_editor_ai_object_sidebar_injection feature flag
15
17
  import { getContextPanel } from './ui/context-panel';
18
+ import { useConfigPanelPluginHook } from './ui/useConfigPanelPluginHook';
16
19
  export var extensionPlugin = function extensionPlugin(_ref) {
17
20
  var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$decorations, _api$contextPanel4, _api$analytics4;
18
21
  var _ref$config = _ref.config,
@@ -51,7 +54,9 @@ export var extensionPlugin = function extensionPlugin(_ref) {
51
54
  }
52
55
  var pluginState = pluginKey.getState(state);
53
56
  return {
54
- showContextPanel: pluginState === null || pluginState === void 0 ? void 0 : pluginState.showContextPanel
57
+ showContextPanel: pluginState === null || pluginState === void 0 ? void 0 : pluginState.showContextPanel,
58
+ extensionProvider: pluginState === null || pluginState === void 0 ? void 0 : pluginState.extensionProvider,
59
+ processParametersAfter: pluginState === null || pluginState === void 0 ? void 0 : pluginState.processParametersAfter
55
60
  };
56
61
  },
57
62
  pmPlugins: function pmPlugins() {
@@ -167,12 +172,20 @@ export var extensionPlugin = function extensionPlugin(_ref) {
167
172
  breakoutEnabled: options.breakoutEnabled,
168
173
  hoverDecoration: _api === null || _api === void 0 || (_api$decorations = _api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
169
174
  applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange,
170
- editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions
175
+ editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
176
+ extensionApi: editorExperiment('platform_editor_controls', 'variant1') ? _api : undefined
171
177
  }),
172
- contextPanel: getContextPanel(function () {
178
+ contextPanel: !fg('platform_editor_ai_object_sidebar_injection') ? getContextPanel(function () {
173
179
  var _editorViewRef$curren;
174
180
  return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
175
- })(_api, featureFlags)
176
- }
181
+ })(_api, featureFlags) : undefined
182
+ },
183
+ usePluginHook: fg('platform_editor_ai_object_sidebar_injection') ? function (_ref6) {
184
+ var editorView = _ref6.editorView;
185
+ useConfigPanelPluginHook({
186
+ editorView: editorView,
187
+ api: _api
188
+ });
189
+ } : undefined
177
190
  };
178
191
  };
@@ -1,4 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import React from 'react';
2
3
  import { messages } from '@atlaskit/editor-common/extensions';
3
4
  import commonMessages from '@atlaskit/editor-common/messages';
4
5
  import { BODIED_EXT_MBE_MARGIN_TOP } from '@atlaskit/editor-common/styles';
@@ -6,6 +7,7 @@ import { getChildrenInfo as _getChildrenInfo, getNodeName, isReferencedSource }
6
7
  import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
8
  import ContentWidthNarrowIcon from '@atlaskit/icon/core/content-width-narrow';
8
9
  import ContentWidthWideIcon from '@atlaskit/icon/core/content-width-wide';
10
+ import CopyIcon from '@atlaskit/icon/core/copy';
9
11
  import DeleteIcon from '@atlaskit/icon/core/delete';
10
12
  import EditIcon from '@atlaskit/icon/core/edit';
11
13
  import ExpandHorizontalIcon from '@atlaskit/icon/core/expand-horizontal';
@@ -132,7 +134,7 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
132
134
  editorAnalyticsAPI = extensionApi === null || extensionApi === void 0 || (_extensionApi$analyti = extensionApi.analytics) === null || _extensionApi$analyti === void 0 ? void 0 : _extensionApi$analyti.actions;
133
135
  }
134
136
  if (extensionState && !extensionState.showContextPanel && extensionState.element) {
135
- var _hoverDecoration, _hoverDecoration2, _hoverDecoration3, _hoverDecoration4, _hoverDecoration5, _hoverDecoration6, _hoverDecoration7, _hoverDecoration8;
137
+ var _hoverDecoration, _hoverDecoration2, _hoverDecoration3, _hoverDecoration4;
136
138
  var nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension, state.schema.nodes.multiBodiedExtension];
137
139
  var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI);
138
140
  var breakoutButtonArray = breakoutOptions(state, formatMessage, extensionState, breakoutEnabled, editorAnalyticsAPI);
@@ -208,13 +210,13 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
208
210
  left: nextPos.left
209
211
  };
210
212
  },
211
- items: [].concat(_toConsumableArray(editButtonArray), _toConsumableArray(breakoutButtonArray), [{
213
+ items: [].concat(_toConsumableArray(editButtonArray), _toConsumableArray(breakoutButtonArray), _toConsumableArray(editorExperiment('platform_editor_controls', 'control') ? [{
212
214
  type: 'separator',
213
215
  hidden: editButtonArray.length === 0 && breakoutButtonArray.length === 0
214
216
  }, {
215
217
  type: 'extensions-placeholder',
216
218
  separator: 'end'
217
- }], _toConsumableArray(editorExperiment('platform_editor_controls', 'control') ? [{
219
+ }, {
218
220
  type: 'copy-button',
219
221
  items: [{
220
222
  state: state,
@@ -239,28 +241,27 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
239
241
  tabIndex: null,
240
242
  confirmDialog: confirmDialog
241
243
  }] : [{
242
- id: 'editor.extension.delete',
243
- type: 'button',
244
- icon: DeleteIcon,
245
- iconFallback: RemoveIcon,
246
- appearance: 'danger',
247
- onClick: removeExtension(editorAnalyticsAPI),
248
- onMouseEnter: (_hoverDecoration5 = hoverDecoration) === null || _hoverDecoration5 === void 0 ? void 0 : _hoverDecoration5(nodeType, true),
249
- onMouseLeave: (_hoverDecoration6 = hoverDecoration) === null || _hoverDecoration6 === void 0 ? void 0 : _hoverDecoration6(nodeType, false),
250
- onFocus: (_hoverDecoration7 = hoverDecoration) === null || _hoverDecoration7 === void 0 ? void 0 : _hoverDecoration7(nodeType, true),
251
- onBlur: (_hoverDecoration8 = hoverDecoration) === null || _hoverDecoration8 === void 0 ? void 0 : _hoverDecoration8(nodeType, false),
252
- focusEditoronEnter: true,
253
- title: formatMessage(commonMessages.remove),
254
- tabIndex: null,
255
- confirmDialog: confirmDialog
256
- }, {
257
- type: 'separator'
244
+ type: 'separator',
245
+ fullHeight: true
258
246
  }, {
259
- type: 'copy-button',
260
- items: [{
261
- state: state,
262
- formatMessage: intl.formatMessage,
263
- nodeType: nodeType
247
+ type: 'overflow-dropdown',
248
+ options: [{
249
+ title: 'Copy',
250
+ onClick: function onClick() {
251
+ var _extensionApi$core, _extensionApi$floatin;
252
+ extensionApi === null || extensionApi === void 0 || (_extensionApi$core = extensionApi.core) === null || _extensionApi$core === void 0 || _extensionApi$core.actions.execute( // @ts-ignore
253
+ extensionApi === null || extensionApi === void 0 || (_extensionApi$floatin = extensionApi.floatingToolbar) === null || _extensionApi$floatin === void 0 ? void 0 : _extensionApi$floatin.commands.copyNode(nodeType));
254
+ return true;
255
+ },
256
+ icon: /*#__PURE__*/React.createElement(CopyIcon, {
257
+ label: "Copy"
258
+ })
259
+ }, {
260
+ title: 'Delete',
261
+ onClick: removeExtension(editorAnalyticsAPI),
262
+ icon: /*#__PURE__*/React.createElement(DeleteIcon, {
263
+ label: "Delete"
264
+ })
264
265
  }]
265
266
  }])),
266
267
  scrollable: true
@@ -23,7 +23,9 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaski
23
23
  import { isTabGroup, configPanelMessages as messages } from '@atlaskit/editor-common/extensions';
24
24
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
25
25
  import Form, { FormFooter } from '@atlaskit/form';
26
+ import { fg } from '@atlaskit/platform-feature-flags';
26
27
  import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
28
+ import { DescriptionSummary } from './DescriptionSummary';
27
29
  import ErrorMessage from './ErrorMessage';
28
30
  import FormContent from './FormContent';
29
31
  import { FormErrorBoundary } from './FormErrorBoundary';
@@ -260,6 +262,10 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
260
262
  }());
261
263
  // memoized to prevent rerender on new parameters
262
264
  _defineProperty(_this, "renderHeader", memoizeOne(function (extensionManifest) {
265
+ // If below FG is true then Header will be rendered separately
266
+ if (fg('platform_editor_ai_object_sidebar_injection')) {
267
+ return null;
268
+ }
263
269
  var _this$props2 = _this.props,
264
270
  onCancel = _this$props2.onCancel,
265
271
  showHeader = _this$props2.showHeader;
@@ -426,7 +432,9 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
426
432
  noValidate: true,
427
433
  onKeyDown: handleKeyDown,
428
434
  "data-testid": "extension-config-panel"
429
- }), _this2.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(ConfigFormIntlWithBoundary, {
435
+ }), _this2.renderHeader(extensionManifest), fg('platform_editor_ai_object_sidebar_injection') && /*#__PURE__*/React.createElement(DescriptionSummary, {
436
+ extensionManifest: extensionManifest
437
+ }), /*#__PURE__*/React.createElement(ConfigFormIntlWithBoundary, {
430
438
  api: api,
431
439
  canSave: false,
432
440
  errorMessage: errorMessage,
@@ -0,0 +1,41 @@
1
+ import React, { Fragment } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { configPanelMessages as messages } from '@atlaskit/editor-common/extensions';
4
+ import { Box, Text, xcss } from '@atlaskit/primitives';
5
+ import { HelpLink } from './HelpLink';
6
+ var descriptionStyles = xcss({
7
+ marginBottom: 'space.300'
8
+ });
9
+ var helpLinkStyles = xcss({
10
+ paddingTop: 'space.150'
11
+ });
12
+ export function DescriptionSummary(_ref) {
13
+ var extensionManifest = _ref.extensionManifest;
14
+ var _useIntl = useIntl(),
15
+ formatMessage = _useIntl.formatMessage;
16
+ var description = extensionManifest.description,
17
+ documentationUrl = extensionManifest.documentationUrl;
18
+ // Use a temporary allowlist of top 3 macros to test out a new "Documentation" CTA ("Need help?")
19
+ // This will be removed when Top 5 Modernized Macros updates are rolled out
20
+ var modernizedMacrosList = ['children', 'recently-updated', 'excerpt'];
21
+ var enableHelpCTA = modernizedMacrosList.includes(extensionManifest.key);
22
+ return /*#__PURE__*/React.createElement(Fragment, null, (description || documentationUrl) && /*#__PURE__*/React.createElement(Box, {
23
+ xcss: descriptionStyles
24
+ }, /*#__PURE__*/React.createElement(Text, {
25
+ as: "p",
26
+ testId: "config-panel-header-description"
27
+ }, description && /*#__PURE__*/React.createElement(Fragment, null,
28
+ // Ignored via go/ees005
29
+ // eslint-disable-next-line require-unicode-regexp
30
+ description.replace(/([^.])$/, '$1.'), ' '), documentationUrl && (enableHelpCTA ? /*#__PURE__*/React.createElement(Box, {
31
+ xcss: helpLinkStyles
32
+ }, /*#__PURE__*/React.createElement(Text, {
33
+ as: "p"
34
+ }, /*#__PURE__*/React.createElement(HelpLink, {
35
+ documentationUrl: documentationUrl,
36
+ label: formatMessage(messages.help)
37
+ }))) : /*#__PURE__*/React.createElement(HelpLink, {
38
+ documentationUrl: documentationUrl,
39
+ label: formatMessage(messages.documentation)
40
+ })))));
41
+ }
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Box, Flex, xcss } from '@atlaskit/primitives';
3
+ import { withExtensionManifest } from '../withExtensionManifest';
4
+ var itemBodyStyles = xcss({
5
+ display: 'flex',
6
+ flexDirection: 'row',
7
+ flexWrap: 'nowrap',
8
+ justifyContent: 'space-between',
9
+ margin: 'space.200',
10
+ flexGrow: 3
11
+ });
12
+ var itemTextStyles = xcss({
13
+ maxWidth: '100%',
14
+ whiteSpace: 'initial'
15
+ });
16
+ var summaryStyles = xcss({
17
+ font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
18
+ color: 'color.text.subtlest',
19
+ marginTop: 'space.050',
20
+ whiteSpace: 'nowrap',
21
+ overflow: 'hidden',
22
+ textOverflow: 'ellipsis'
23
+ });
24
+ function HeaderAfterIconElement(_ref) {
25
+ var extensionManifest = _ref.extensionManifest;
26
+ var title = extensionManifest.title;
27
+ var summary = extensionManifest.summary;
28
+ return /*#__PURE__*/React.createElement(Box, {
29
+ xcss: itemBodyStyles
30
+ }, summary ? /*#__PURE__*/React.createElement(Box, {
31
+ xcss: itemTextStyles
32
+ }, /*#__PURE__*/React.createElement("div", {
33
+ id: "context-panel-title",
34
+ "data-testid": "context-panel-title"
35
+ }, title), /*#__PURE__*/React.createElement(Box, {
36
+ xcss: summaryStyles
37
+ }, summary)) : /*#__PURE__*/React.createElement(Flex, {
38
+ direction: "column",
39
+ alignItems: "center",
40
+ testId: "context-panel-title"
41
+ }, title));
42
+ }
43
+ export default withExtensionManifest(HeaderAfterIconElement);
@@ -0,0 +1,40 @@
1
+ import React, { Suspense, lazy, useMemo } from 'react';
2
+ import { Box, xcss } from '@atlaskit/primitives';
3
+ import { withExtensionManifest } from '../withExtensionManifest';
4
+ var iconWidth = '40px';
5
+ var itemIconStyles = xcss({
6
+ width: iconWidth,
7
+ height: iconWidth,
8
+ overflow: 'hidden',
9
+ border: "1px solid ".concat("var(--ds-border, rgba(223, 225, 229, 0.5))"),
10
+ borderRadius: "var(--ds-border-radius, 3px)",
11
+ boxSizing: 'border-box',
12
+ display: 'flex',
13
+ justifyContent: 'center',
14
+ alignItems: 'center'
15
+ });
16
+ function HeaderIcon(_ref) {
17
+ var extensionManifest = _ref.extensionManifest;
18
+ var icon = extensionManifest.icons['48'];
19
+ var title = extensionManifest.title;
20
+ var ResolvedIcon = useMemo(function () {
21
+ return /*#__PURE__*/lazy(function () {
22
+ return icon().then(function (Cmp) {
23
+ if ('default' in Cmp) {
24
+ return Cmp;
25
+ }
26
+ return {
27
+ default: Cmp
28
+ };
29
+ });
30
+ });
31
+ }, [icon]);
32
+ return /*#__PURE__*/React.createElement(Box, {
33
+ xcss: itemIconStyles
34
+ }, /*#__PURE__*/React.createElement(Suspense, {
35
+ fallback: null
36
+ }, /*#__PURE__*/React.createElement(ResolvedIcon, {
37
+ label: title
38
+ })));
39
+ }
40
+ export default withExtensionManifest(HeaderIcon);
@@ -14,6 +14,7 @@ import CrossIcon from '@atlaskit/icon/core/migration/close--cross';
14
14
  import { Box, Text, xcss } from '@atlaskit/primitives';
15
15
  import { N200 } from '@atlaskit/theme/colors';
16
16
  import { borderRadius } from '@atlaskit/theme/constants';
17
+ import { HelpLink } from './HelpLink';
17
18
  var iconWidth = 40;
18
19
  var buttonWidth = 40;
19
20
  var margin = 16;
@@ -152,14 +153,4 @@ var Header = function Header(_ref) {
152
153
  label: intl.formatMessage(messages.documentation)
153
154
  })))));
154
155
  };
155
- var HelpLink = function HelpLink(_ref2) {
156
- var documentationUrl = _ref2.documentationUrl,
157
- label = _ref2.label;
158
- return jsx("a", {
159
- target: "_blank",
160
- rel: "noopener noreferrer",
161
- href: documentationUrl,
162
- "data-testid": "config-panel-header-documentation-link"
163
- }, label);
164
- };
165
156
  export default injectIntl(Header);
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ export var HelpLink = function HelpLink(_ref) {
3
+ var documentationUrl = _ref.documentationUrl,
4
+ label = _ref.label;
5
+ return (
6
+ /*#__PURE__*/
7
+ // eslint-disable-next-line @atlaskit/design-system/no-html-anchor
8
+ React.createElement("a", {
9
+ target: "_blank",
10
+ rel: "noopener noreferrer",
11
+ href: documentationUrl,
12
+ "data-testid": "config-panel-header-documentation-link"
13
+ }, label)
14
+ );
15
+ };
@@ -4,4 +4,6 @@ export var ALLOWED_LOGGED_MACRO_PARAMS = {
4
4
  'recently-updated': ['width', 'types', 'max', 'theme', 'showProfilePic', 'hideHeading'],
5
5
  excerpt: ['hidden']
6
6
  };
7
- export var ALLOWED_PARAM_TYPES = ['enum', 'number', 'boolean'];
7
+ export var ALLOWED_PARAM_TYPES = ['enum', 'number', 'boolean'];
8
+ export var CONFIG_PANEL_WIDTH = 320;
9
+ export var CONFIG_PANEL_ID = 'extensions-panel';
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["extensionKey", "extensionProvider", "extensionType"];
5
+ import React from 'react';
6
+ import { useStateFromPromise } from './use-state-from-promise';
7
+ export function withExtensionManifest(WrappedComponent) {
8
+ return function WithExtensionManifest(props) {
9
+ var extensionKey = props.extensionKey,
10
+ extensionProvider = props.extensionProvider,
11
+ extensionType = props.extensionType,
12
+ restProps = _objectWithoutProperties(props, _excluded);
13
+ var _useStateFromPromise = useStateFromPromise(function () {
14
+ return extensionProvider.getExtension(extensionType, extensionKey);
15
+ }, [extensionProvider, extensionType, extensionKey]),
16
+ _useStateFromPromise2 = _slicedToArray(_useStateFromPromise, 1),
17
+ extensionManifest = _useStateFromPromise2[0];
18
+ return extensionManifest ?
19
+ /*#__PURE__*/
20
+ // Ignored via go/ees005
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, react/jsx-props-no-spreading
22
+ React.createElement(WrappedComponent, _extends({
23
+ extensionManifest: extensionManifest
24
+ }, restProps)) : null;
25
+ };
26
+ }