@atlaskit/editor-plugin-extension 0.6.2 → 0.7.0

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 (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/actions.js +7 -22
  3. package/dist/cjs/context-panel.js +4 -1
  4. package/dist/cjs/plugin.js +5 -4
  5. package/dist/cjs/pm-plugins/main.js +11 -54
  6. package/dist/cjs/toolbar.js +5 -1
  7. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +55 -29
  8. package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
  9. package/dist/es2019/actions.js +3 -19
  10. package/dist/es2019/context-panel.js +4 -1
  11. package/dist/es2019/plugin.js +5 -4
  12. package/dist/es2019/pm-plugins/main.js +4 -23
  13. package/dist/es2019/toolbar.js +5 -1
  14. package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +58 -28
  15. package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
  16. package/dist/esm/actions.js +6 -21
  17. package/dist/esm/context-panel.js +4 -1
  18. package/dist/esm/plugin.js +5 -4
  19. package/dist/esm/pm-plugins/main.js +10 -53
  20. package/dist/esm/toolbar.js +5 -1
  21. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +55 -29
  22. package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
  23. package/dist/types/actions.d.ts +2 -5
  24. package/dist/types/context-panel.d.ts +3 -3
  25. package/dist/types/pm-plugins/main.d.ts +1 -2
  26. package/dist/types/types.d.ts +4 -4
  27. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
  28. package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +4 -3
  29. package/dist/types-ts4.5/actions.d.ts +2 -5
  30. package/dist/types-ts4.5/context-panel.d.ts +3 -3
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -2
  32. package/dist/types-ts4.5/types.d.ts +4 -4
  33. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
  34. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +4 -3
  35. package/example-utils/config-panel/ConfigPanelWithProviders.tsx +2 -1
  36. package/example-utils/config-panel/FieldTypePicker.tsx +1 -1
  37. package/package.json +6 -5
@@ -10,9 +10,8 @@ import ButtonGroup from '@atlaskit/button/button-group';
10
10
  import Button from '@atlaskit/button/custom-theme-button';
11
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
12
12
  import { isTabGroup } from '@atlaskit/editor-common/extensions';
13
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
13
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
14
14
  import Form, { FormFooter } from '@atlaskit/form';
15
- import { pluginKey as extensionPluginKey } from '../../plugin-key';
16
15
  import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
17
16
  import ErrorMessage from './ErrorMessage';
18
17
  import FormContent from './FormContent';
@@ -352,7 +351,8 @@ class ConfigPanel extends React.Component {
352
351
  errorMessage,
353
352
  fields,
354
353
  isLoading,
355
- onCancel
354
+ onCancel,
355
+ api
356
356
  } = this.props;
357
357
  const {
358
358
  currentParameters,
@@ -380,36 +380,66 @@ class ConfigPanel extends React.Component {
380
380
  noValidate: true,
381
381
  onKeyDown: handleKeyDown,
382
382
  "data-testid": "extension-config-panel"
383
- }), this.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(WithPluginState, {
384
- plugins: {
385
- extension: extensionPluginKey
386
- },
387
- render: ({
388
- extension
389
- }) => /*#__PURE__*/React.createElement(FormErrorBoundary, {
390
- contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
391
- extensionKey: extensionManifest.key,
392
- fields: fields || []
393
- }, /*#__PURE__*/React.createElement(ConfigFormIntl, {
394
- canSave: !autoSave,
395
- errorMessage: errorMessage,
396
- extensionManifest: extensionManifest,
397
- fields: fields,
398
- firstVisibleFieldName: firstVisibleFieldName,
399
- hasParsedParameters: hasParsedParameters,
400
- isLoading: isLoading || false,
401
- onCancel: onCancel,
402
- onFieldChange: onFieldChange,
403
- parameters: currentParameters,
404
- submitting: submitting,
405
- contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
406
- featureFlags: featureFlags
407
- }))
383
+ }), this.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(ConfigFormIntlWithBoundary, {
384
+ api: api,
385
+ canSave: !autoSave,
386
+ errorMessage: errorMessage,
387
+ extensionManifest: extensionManifest,
388
+ fields: fields !== null && fields !== void 0 ? fields : [],
389
+ firstVisibleFieldName: firstVisibleFieldName,
390
+ hasParsedParameters: hasParsedParameters,
391
+ isLoading: isLoading || false,
392
+ onCancel: onCancel,
393
+ onFieldChange: onFieldChange,
394
+ parameters: currentParameters,
395
+ submitting: submitting,
396
+ featureFlags: featureFlags
408
397
  }));
409
398
  });
410
399
  });
411
400
  }
412
401
  }
402
+ function ConfigFormIntlWithBoundary({
403
+ api,
404
+ fields,
405
+ submitting,
406
+ parameters,
407
+ featureFlags,
408
+ canSave,
409
+ extensionManifest,
410
+ onFieldChange,
411
+ onCancel,
412
+ isLoading,
413
+ hasParsedParameters,
414
+ firstVisibleFieldName,
415
+ errorMessage
416
+ }) {
417
+ const {
418
+ contextIdentifierState
419
+ } = useSharedPluginState(api, ['contextIdentifier']);
420
+ const {
421
+ contextIdentifierProvider
422
+ } = contextIdentifierState !== null && contextIdentifierState !== void 0 ? contextIdentifierState : {};
423
+ return /*#__PURE__*/React.createElement(FormErrorBoundary, {
424
+ contextIdentifierProvider: contextIdentifierProvider,
425
+ extensionKey: extensionManifest.key,
426
+ fields: fields
427
+ }, /*#__PURE__*/React.createElement(ConfigFormIntl, {
428
+ canSave: canSave,
429
+ errorMessage: errorMessage,
430
+ extensionManifest: extensionManifest,
431
+ fields: fields,
432
+ firstVisibleFieldName: firstVisibleFieldName,
433
+ hasParsedParameters: hasParsedParameters,
434
+ isLoading: isLoading || false,
435
+ onCancel: onCancel,
436
+ onFieldChange: onFieldChange,
437
+ parameters: parameters,
438
+ submitting: submitting,
439
+ contextIdentifierProvider: contextIdentifierProvider,
440
+ featureFlags: featureFlags
441
+ }));
442
+ }
413
443
  export default withAnalyticsContext({
414
444
  source: 'ConfigPanel'
415
445
  })(withAnalyticsEvents()(ConfigPanel));
@@ -73,7 +73,8 @@ export default function FieldsLoader({
73
73
  showHeader,
74
74
  featureFlags,
75
75
  onChange,
76
- onCancel
76
+ onCancel,
77
+ api
77
78
  }) {
78
79
  const [extensionManifest] = useStateFromPromise(() => extensionProvider.getExtension(extensionType, extensionKey), [extensionProvider, extensionType, extensionKey]);
79
80
  const [errorMessage, setErrorMessage] = useState(null);
@@ -83,6 +84,7 @@ export default function FieldsLoader({
83
84
  nodeKey: nodeKey,
84
85
  extensionParameters: extensionParameters
85
86
  }, fields => /*#__PURE__*/React.createElement(ConfigPanel, {
87
+ api: api,
86
88
  extensionManifest: extensionManifest,
87
89
  isLoading: !extensionManifest || errorMessage === null && !fields,
88
90
  fields: fields,
@@ -153,28 +153,13 @@ var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
153
153
  }();
154
154
  };
155
155
  };
156
-
157
- // This is to decouple extensions from editor core
158
- // Ideally in the future we completely deprecate `EditorActions`
159
- export var editSelectedExtension = function editSelectedExtension(editorActions) {
160
- var editorView = editorActions._privateGetEditorView();
161
- var _getPluginState = getPluginState(editorView.state),
162
- updateExtension = _getPluginState.updateExtension,
163
- applyChangeToContextPanel = _getPluginState.applyChangeToContextPanel;
164
- // The analytics API cannot be accessed in this case because
165
- // we do not have access to the plugin injection API. Rather
166
- // than change the way this works - we just won't use analytics
167
- // here for now.
168
- var editorAnalyticsAPI = undefined;
169
- return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
170
- };
171
156
  export var editExtension = function editExtension(macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) {
172
157
  return function (state, dispatch, view) {
173
158
  if (!view) {
174
159
  return false;
175
160
  }
176
- var _getPluginState2 = getPluginState(state),
177
- localId = _getPluginState2.localId;
161
+ var _getPluginState = getPluginState(state),
162
+ localId = _getPluginState.localId;
178
163
  var nodeWithPos = findExtensionWithLocalId(state, localId);
179
164
  if (!nodeWithPos) {
180
165
  return false;
@@ -212,15 +197,15 @@ export var editExtension = function editExtension(macroProvider, applyChangeToCo
212
197
  };
213
198
  export var createEditSelectedExtensionAction = function createEditSelectedExtensionAction(_ref2) {
214
199
  var editorViewRef = _ref2.editorViewRef,
215
- editorAnalyticsAPI = _ref2.editorAnalyticsAPI;
200
+ editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
201
+ applyChangeToContextPanel = _ref2.applyChangeToContextPanel;
216
202
  return function () {
217
203
  var view = editorViewRef.current;
218
204
  if (!view) {
219
205
  return false;
220
206
  }
221
- var _getPluginState3 = getPluginState(view.state),
222
- updateExtension = _getPluginState3.updateExtension,
223
- applyChangeToContextPanel = _getPluginState3.applyChangeToContextPanel;
207
+ var _getPluginState2 = getPluginState(view.state),
208
+ updateExtension = _getPluginState2.updateExtension;
224
209
  return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(view.state, view.dispatch, view);
225
210
  };
226
211
  };
@@ -38,9 +38,11 @@ export var duplicateSelection = function duplicateSelection(selectionToDuplicate
38
38
  }
39
39
  };
40
40
  export var getContextPanel = function getContextPanel(getEditorView) {
41
- return function (allowAutoSave, featureFlags, applyChange) {
41
+ return function (api, allowAutoSave, featureFlags) {
42
42
  return function (state) {
43
+ var _api$contextPanel;
43
44
  var nodeWithPos = getSelectedExtension(state, true);
45
+ var applyChange = api === null || api === void 0 || (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange;
44
46
 
45
47
  // Adding checks to bail out early
46
48
  if (!nodeWithPos) {
@@ -74,6 +76,7 @@ export var getContextPanel = function getContextPanel(getEditorView) {
74
76
  return null;
75
77
  }
76
78
  return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
79
+ api: api,
77
80
  showHeader: true,
78
81
  closeOnEsc: true,
79
82
  extensionType: extensionType,
@@ -12,7 +12,7 @@ import { createPlugin, pluginKey } from './pm-plugins/main';
12
12
  import { createPlugin as createUniqueIdPlugin } from './pm-plugins/unique-id';
13
13
  import { getToolbarConfig } from './toolbar';
14
14
  export var extensionPlugin = function extensionPlugin(_ref) {
15
- var _api$featureFlags, _api$analytics2, _api$analytics3, _api$decorations, _api$contextPanel3, _api$analytics4, _api$contextPanel4;
15
+ var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$decorations, _api$contextPanel4, _api$analytics4;
16
16
  var _ref$config = _ref.config,
17
17
  options = _ref$config === void 0 ? {} : _ref$config,
18
18
  _api = _ref.api;
@@ -119,7 +119,8 @@ export var extensionPlugin = function extensionPlugin(_ref) {
119
119
  insertMacroFromMacroBrowser: insertMacroFromMacroBrowser(_api === null || _api === void 0 || (_api$analytics2 = _api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
120
120
  editSelectedExtension: createEditSelectedExtensionAction({
121
121
  editorViewRef: editorViewRef,
122
- editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
122
+ editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
123
+ applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange
123
124
  }),
124
125
  runMacroAutoConvert: runMacroAutoConvert,
125
126
  forceAutoSave: forceAutoSave
@@ -128,13 +129,13 @@ export var extensionPlugin = function extensionPlugin(_ref) {
128
129
  floatingToolbar: getToolbarConfig({
129
130
  breakoutEnabled: options.breakoutEnabled,
130
131
  hoverDecoration: _api === null || _api === void 0 || (_api$decorations = _api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
131
- applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
132
+ applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange,
132
133
  editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions
133
134
  }),
134
135
  contextPanel: getContextPanel(function () {
135
136
  var _editorViewRef$curren;
136
137
  return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
137
- })(options.allowAutoSave, featureFlags, _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
138
+ })(_api, options.allowAutoSave, featureFlags)
138
139
  }
139
140
  };
140
141
  };
@@ -97,50 +97,12 @@ export var createExtensionProviderHandler = function createExtensionProviderHand
97
97
  };
98
98
  }();
99
99
  };
100
- export var createContextIdentifierProviderHandler = function createContextIdentifierProviderHandler(view) {
101
- return /*#__PURE__*/function () {
102
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(name, provider) {
103
- var contextIdentifierProvider;
104
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
105
- while (1) switch (_context3.prev = _context3.next) {
106
- case 0:
107
- if (!(name === 'contextIdentifierProvider' && provider)) {
108
- _context3.next = 11;
109
- break;
110
- }
111
- _context3.prev = 1;
112
- _context3.next = 4;
113
- return provider;
114
- case 4:
115
- contextIdentifierProvider = _context3.sent;
116
- updateState({
117
- contextIdentifierProvider: contextIdentifierProvider
118
- })(view.state, view.dispatch);
119
- _context3.next = 11;
120
- break;
121
- case 8:
122
- _context3.prev = 8;
123
- _context3.t0 = _context3["catch"](1);
124
- updateState({
125
- contextIdentifierProvider: undefined
126
- })(view.state, view.dispatch);
127
- case 11:
128
- case "end":
129
- return _context3.stop();
130
- }
131
- }, _callee3, null, [[1, 8]]);
132
- }));
133
- return function (_x6, _x7) {
134
- return _ref3.apply(this, arguments);
135
- };
136
- }();
137
- };
138
- export var handleUpdate = function handleUpdate(_ref4) {
139
- var view = _ref4.view,
140
- prevState = _ref4.prevState,
141
- domAtPos = _ref4.domAtPos,
142
- extensionHandlers = _ref4.extensionHandlers,
143
- applyChange = _ref4.applyChange;
100
+ export var handleUpdate = function handleUpdate(_ref3) {
101
+ var view = _ref3.view,
102
+ prevState = _ref3.prevState,
103
+ domAtPos = _ref3.domAtPos,
104
+ extensionHandlers = _ref3.extensionHandlers,
105
+ applyChange = _ref3.applyChange;
144
106
  var state = view.state,
145
107
  dispatch = view.dispatch;
146
108
  var _getPluginState = getPluginState(state),
@@ -198,13 +160,11 @@ export var handleUpdate = function handleUpdate(_ref4) {
198
160
  return true;
199
161
  };
200
162
  var createPlugin = function createPlugin(dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, pluginInjectionApi) {
201
- var _pluginInjectionApi$c;
202
163
  var useLongPressSelection = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
203
164
  var options = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : {};
204
165
  var state = createPluginState(dispatch, {
205
166
  showEditButton: false,
206
- showContextPanel: false,
207
- applyChangeToContextPanel: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.applyChange
167
+ showContextPanel: false
208
168
  });
209
169
  var extensionNodeViewOptions = {
210
170
  appearance: options.appearance
@@ -214,23 +174,20 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
214
174
  view: function view(editorView) {
215
175
  var domAtPos = editorView.domAtPos.bind(editorView);
216
176
  var extensionProviderHandler = createExtensionProviderHandler(editorView);
217
- var contextIdentificationProviderHandler = createContextIdentifierProviderHandler(editorView);
218
177
  providerFactory.subscribe('extensionProvider', extensionProviderHandler);
219
- providerFactory.subscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
220
178
  return {
221
179
  update: function update(view, prevState) {
222
- var _pluginInjectionApi$c2;
180
+ var _pluginInjectionApi$c;
223
181
  handleUpdate({
224
182
  view: view,
225
183
  prevState: prevState,
226
184
  domAtPos: domAtPos,
227
185
  extensionHandlers: extensionHandlers,
228
- applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.applyChange
186
+ applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.applyChange
229
187
  });
230
188
  },
231
189
  destroy: function destroy() {
232
190
  providerFactory.unsubscribe('extensionProvider', extensionProviderHandler);
233
- providerFactory.unsubscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
234
191
  }
235
192
  };
236
193
  },
@@ -287,7 +244,7 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
287
244
  inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
288
245
  multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
289
246
  },
290
- handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], function (target) {
247
+ handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension', 'multiBodiedExtension'], function (target) {
291
248
  return !target.closest('.extension-content');
292
249
  }, {
293
250
  useLongPressSelection: useLongPressSelection
@@ -179,8 +179,12 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
179
179
  *
180
180
  */
181
181
  var frameheight = mbeFrameRect.height > 0 ? mbeFrameRect.height : 102;
182
+ // MBE wrapper header height includes, top margin 8px + bottom margin 8px + Line height of 16px + padding top 8px
183
+ // Ref: platform/packages/editor/editor-common/src/extensibility/MultiBodiedExtension/styles.ts
184
+ var wrapperHeaderHeight = 40;
185
+ var toolbarTopPos = mbeNodeRect.top + frameheight + wrapperHeaderHeight + scrollWrapper.scrollTop;
182
186
  return {
183
- top: mbeNodeRect.top + frameheight + scrollWrapper.scrollTop,
187
+ top: toolbarTopPos,
184
188
  left: nextPos.left
185
189
  };
186
190
  },
@@ -22,9 +22,8 @@ import ButtonGroup from '@atlaskit/button/button-group';
22
22
  import Button from '@atlaskit/button/custom-theme-button';
23
23
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
24
24
  import { isTabGroup } from '@atlaskit/editor-common/extensions';
25
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
25
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
26
26
  import Form, { FormFooter } from '@atlaskit/form';
27
- import { pluginKey as extensionPluginKey } from '../../plugin-key';
28
27
  import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
29
28
  import ErrorMessage from './ErrorMessage';
30
29
  import FormContent from './FormContent';
@@ -404,7 +403,8 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
404
403
  errorMessage = _this$props7.errorMessage,
405
404
  fields = _this$props7.fields,
406
405
  isLoading = _this$props7.isLoading,
407
- onCancel = _this$props7.onCancel;
406
+ onCancel = _this$props7.onCancel,
407
+ api = _this$props7.api;
408
408
  var _this$state = this.state,
409
409
  currentParameters = _this$state.currentParameters,
410
410
  hasParsedParameters = _this$state.hasParsedParameters,
@@ -427,32 +427,20 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
427
427
  noValidate: true,
428
428
  onKeyDown: handleKeyDown,
429
429
  "data-testid": "extension-config-panel"
430
- }), _this2.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(WithPluginState, {
431
- plugins: {
432
- extension: extensionPluginKey
433
- },
434
- render: function render(_ref6) {
435
- var extension = _ref6.extension;
436
- return /*#__PURE__*/React.createElement(FormErrorBoundary, {
437
- contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
438
- extensionKey: extensionManifest.key,
439
- fields: fields || []
440
- }, /*#__PURE__*/React.createElement(ConfigFormIntl, {
441
- canSave: !autoSave,
442
- errorMessage: errorMessage,
443
- extensionManifest: extensionManifest,
444
- fields: fields,
445
- firstVisibleFieldName: firstVisibleFieldName,
446
- hasParsedParameters: hasParsedParameters,
447
- isLoading: isLoading || false,
448
- onCancel: onCancel,
449
- onFieldChange: onFieldChange,
450
- parameters: currentParameters,
451
- submitting: submitting,
452
- contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
453
- featureFlags: featureFlags
454
- }));
455
- }
430
+ }), _this2.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(ConfigFormIntlWithBoundary, {
431
+ api: api,
432
+ canSave: !autoSave,
433
+ errorMessage: errorMessage,
434
+ extensionManifest: extensionManifest,
435
+ fields: fields !== null && fields !== void 0 ? fields : [],
436
+ firstVisibleFieldName: firstVisibleFieldName,
437
+ hasParsedParameters: hasParsedParameters,
438
+ isLoading: isLoading || false,
439
+ onCancel: onCancel,
440
+ onFieldChange: onFieldChange,
441
+ parameters: currentParameters,
442
+ submitting: submitting,
443
+ featureFlags: featureFlags
456
444
  }));
457
445
  });
458
446
  });
@@ -460,6 +448,44 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
460
448
  }]);
461
449
  return ConfigPanel;
462
450
  }(React.Component);
451
+ function ConfigFormIntlWithBoundary(_ref6) {
452
+ var api = _ref6.api,
453
+ fields = _ref6.fields,
454
+ submitting = _ref6.submitting,
455
+ parameters = _ref6.parameters,
456
+ featureFlags = _ref6.featureFlags,
457
+ canSave = _ref6.canSave,
458
+ extensionManifest = _ref6.extensionManifest,
459
+ onFieldChange = _ref6.onFieldChange,
460
+ onCancel = _ref6.onCancel,
461
+ isLoading = _ref6.isLoading,
462
+ hasParsedParameters = _ref6.hasParsedParameters,
463
+ firstVisibleFieldName = _ref6.firstVisibleFieldName,
464
+ errorMessage = _ref6.errorMessage;
465
+ var _useSharedPluginState = useSharedPluginState(api, ['contextIdentifier']),
466
+ contextIdentifierState = _useSharedPluginState.contextIdentifierState;
467
+ var _ref7 = contextIdentifierState !== null && contextIdentifierState !== void 0 ? contextIdentifierState : {},
468
+ contextIdentifierProvider = _ref7.contextIdentifierProvider;
469
+ return /*#__PURE__*/React.createElement(FormErrorBoundary, {
470
+ contextIdentifierProvider: contextIdentifierProvider,
471
+ extensionKey: extensionManifest.key,
472
+ fields: fields
473
+ }, /*#__PURE__*/React.createElement(ConfigFormIntl, {
474
+ canSave: canSave,
475
+ errorMessage: errorMessage,
476
+ extensionManifest: extensionManifest,
477
+ fields: fields,
478
+ firstVisibleFieldName: firstVisibleFieldName,
479
+ hasParsedParameters: hasParsedParameters,
480
+ isLoading: isLoading || false,
481
+ onCancel: onCancel,
482
+ onFieldChange: onFieldChange,
483
+ parameters: parameters,
484
+ submitting: submitting,
485
+ contextIdentifierProvider: contextIdentifierProvider,
486
+ featureFlags: featureFlags
487
+ }));
488
+ }
463
489
  export default withAnalyticsContext({
464
490
  source: 'ConfigPanel'
465
491
  })(withAnalyticsEvents()(ConfigPanel));
@@ -77,7 +77,8 @@ export default function FieldsLoader(_ref) {
77
77
  showHeader = _ref.showHeader,
78
78
  featureFlags = _ref.featureFlags,
79
79
  onChange = _ref.onChange,
80
- onCancel = _ref.onCancel;
80
+ onCancel = _ref.onCancel,
81
+ api = _ref.api;
81
82
  var _useStateFromPromise = useStateFromPromise(function () {
82
83
  return extensionProvider.getExtension(extensionType, extensionKey);
83
84
  }, [extensionProvider, extensionType, extensionKey]),
@@ -94,6 +95,7 @@ export default function FieldsLoader(_ref) {
94
95
  extensionParameters: extensionParameters
95
96
  }, function (fields) {
96
97
  return /*#__PURE__*/React.createElement(ConfigPanel, {
98
+ api: api,
97
99
  extensionManifest: extensionManifest,
98
100
  isLoading: !extensionManifest || errorMessage === null && !fields,
99
101
  fields: fields,
@@ -8,13 +8,10 @@ import type { Fragment, Mark, Node as PmNode, Schema } from '@atlaskit/editor-pr
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
9
  export declare const buildExtensionNode: <S extends Schema<any, any>>(type: 'inlineExtension' | 'extension' | 'bodiedExtension' | 'multiBodiedExtension', schema: S, attrs: object, content?: Fragment, marks?: readonly Mark[]) => PmNode;
10
10
  export declare const performNodeUpdate: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (type: 'inlineExtension' | 'extension' | 'bodiedExtension' | 'multiBodiedExtension', newAttrs: object, content: Fragment, marks: readonly Mark[], shouldScrollIntoView: boolean) => Command;
11
- interface EditorActions {
12
- _privateGetEditorView: () => EditorView | undefined;
13
- }
14
- export declare const editSelectedExtension: (editorActions: EditorActions) => boolean;
15
11
  export declare const editExtension: (macroProvider: MacroProvider | null | undefined, applyChangeToContextPanel: ApplyChangeHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, updateExtension?: Promise<UpdateExtension<object> | void>) => Command;
16
12
  type Props = {
17
13
  editorViewRef: Record<'current', EditorView | null>;
18
14
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
15
+ applyChangeToContextPanel: ApplyChangeHandler | undefined;
19
16
  };
20
- export declare const createEditSelectedExtensionAction: ({ editorViewRef, editorAnalyticsAPI }: Props) => () => boolean;
17
+ export declare const createEditSelectedExtensionAction: ({ editorViewRef, editorAnalyticsAPI, applyChangeToContextPanel }: Props) => () => boolean;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { FeatureFlags } from '@atlaskit/editor-common/types';
3
- import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
2
+ import type { ExtractInjectionAPI, FeatureFlags } from '@atlaskit/editor-common/types';
4
3
  import type { Node } from '@atlaskit/editor-prosemirror/model';
5
4
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
6
5
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { ExtensionPlugin } from './types';
8
8
  export declare const duplicateSelection: (selectionToDuplicate: Selection, doc: Node) => Selection | undefined;
9
- export declare const getContextPanel: (getEditorView?: () => EditorView | undefined) => (allowAutoSave?: boolean, featureFlags?: FeatureFlags, applyChange?: ApplyChangeHandler) => (state: EditorState) => JSX.Element | undefined;
9
+ export declare const getContextPanel: (getEditorView?: () => EditorView | undefined) => (api: ExtractInjectionAPI<ExtensionPlugin> | undefined, allowAutoSave?: boolean, featureFlags?: FeatureFlags) => (state: EditorState) => JSX.Element | undefined;
10
10
  export declare function onChangeAction(editorView: EditorView, updatedParameters: object | undefined, oldParameters: object | undefined, nodeWithPos: ContentNodeWithPos, onSaving?: () => void): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
2
  import type { ExtensionHandlers, ExtensionProvider } from '@atlaskit/editor-common/extensions';
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
- import type { ContextIdentifierProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
7
  import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
@@ -11,7 +11,6 @@ import { createCommand, getPluginState } from '../plugin-factory';
11
11
  import { pluginKey } from '../plugin-key';
12
12
  import type { ExtensionPlugin } from '../types';
13
13
  export declare const createExtensionProviderHandler: (view: EditorView) => (name: string, provider?: Promise<ExtensionProvider>) => Promise<void>;
14
- export declare const createContextIdentifierProviderHandler: (view: EditorView) => (name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
15
14
  export declare const handleUpdate: ({ view, prevState, domAtPos, extensionHandlers, applyChange, }: {
16
15
  view: EditorView;
17
16
  prevState: EditorState;
@@ -1,8 +1,9 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { ExtensionAPI, ExtensionHandlers, ExtensionProvider, Parameters, TransformAfter, TransformBefore, UpdateExtension } from '@atlaskit/editor-common/extensions';
3
- import type { ContextIdentifierProvider, MacroProvider } from '@atlaskit/editor-common/provider-factory';
3
+ import type { MacroProvider } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { EditorAppearance, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
5
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
+ import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
6
7
  import type { ApplyChangeHandler, ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
7
8
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
8
9
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -21,11 +22,9 @@ export type ExtensionState<T extends Parameters = Parameters> = {
21
22
  updateExtension?: Promise<UpdateExtension<T> | void>;
22
23
  element?: HTMLElement;
23
24
  extensionProvider?: ExtensionProvider<T>;
24
- contextIdentifierProvider?: ContextIdentifierProvider;
25
25
  processParametersBefore?: TransformBefore<T>;
26
26
  processParametersAfter?: TransformAfter<T>;
27
27
  positions?: Record<number, number>;
28
- applyChangeToContextPanel: ApplyChangeHandler | undefined;
29
28
  };
30
29
  export type ExtensionAction<T extends Parameters = Parameters> = {
31
30
  type: 'UPDATE_STATE';
@@ -53,7 +52,8 @@ export type ExtensionPlugin = NextEditorPlugin<'extension', {
53
52
  OptionalPlugin<FeatureFlagsPlugin>,
54
53
  WidthPlugin,
55
54
  DecorationsPlugin,
56
- OptionalPlugin<ContextPanelPlugin>
55
+ OptionalPlugin<ContextPanelPlugin>,
56
+ OptionalPlugin<ContextIdentifierPlugin>
57
57
  ];
58
58
  sharedState: {
59
59
  showContextPanel: boolean | undefined;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
3
3
  import type { ExtensionManifest, FieldDefinition, OnSaveCallback, Parameters } from '@atlaskit/editor-common/extensions';
4
- import type { FeatureFlags } from '@atlaskit/editor-common/types';
5
- import type { RejectSave } from '../../types';
4
+ import type { ExtractInjectionAPI, FeatureFlags } from '@atlaskit/editor-common/types';
5
+ import type { ExtensionPlugin, RejectSave } from '../../types';
6
6
  type Props = {
7
7
  extensionManifest?: ExtensionManifest;
8
8
  fields?: FieldDefinition[];
@@ -17,6 +17,7 @@ type Props = {
17
17
  errorMessage: string | null;
18
18
  isLoading?: boolean;
19
19
  featureFlags?: FeatureFlags;
20
+ api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
20
21
  } & WithAnalyticsEventsProps;
21
- declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "autoSaveReject" | "key" | "parameters" | "autoSave" | "onChange" | "errorMessage" | "analyticsContext" | "fields" | "extensionManifest" | "isLoading" | "onCancel" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
22
+ declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "api" | "autoSaveReject" | "key" | "parameters" | "autoSave" | "onChange" | "errorMessage" | "analyticsContext" | "fields" | "extensionManifest" | "isLoading" | "onCancel" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
22
23
  export default _default;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { ExtensionKey, ExtensionProvider, ExtensionType, Parameters } from '@atlaskit/editor-common/extensions';
3
- import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
- import type { RejectSave } from '../../types';
3
+ import type { ExtractInjectionAPI, FeatureFlags } from '@atlaskit/editor-common/types';
4
+ import type { ExtensionPlugin, RejectSave } from '../../types';
5
5
  export type PublicProps = {
6
6
  extensionProvider: ExtensionProvider;
7
7
  extensionType: ExtensionType;
@@ -17,5 +17,6 @@ export type PublicProps = {
17
17
  featureFlags?: FeatureFlags;
18
18
  onChange: (data: Parameters) => void;
19
19
  onCancel: () => void;
20
+ api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
20
21
  };
21
- export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSave, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, }: PublicProps): JSX.Element;
22
+ export default function FieldsLoader({ extensionType, extensionKey, nodeKey, extensionProvider, extensionParameters, parameters, autoSave, autoSaveTrigger, autoSaveReject, closeOnEsc, showHeader, featureFlags, onChange, onCancel, api, }: PublicProps): JSX.Element;
@@ -8,13 +8,10 @@ import type { Fragment, Mark, Node as PmNode, Schema } from '@atlaskit/editor-pr
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
9
  export declare const buildExtensionNode: <S extends Schema<any, any>>(type: 'inlineExtension' | 'extension' | 'bodiedExtension' | 'multiBodiedExtension', schema: S, attrs: object, content?: Fragment, marks?: readonly Mark[]) => PmNode;
10
10
  export declare const performNodeUpdate: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (type: 'inlineExtension' | 'extension' | 'bodiedExtension' | 'multiBodiedExtension', newAttrs: object, content: Fragment, marks: readonly Mark[], shouldScrollIntoView: boolean) => Command;
11
- interface EditorActions {
12
- _privateGetEditorView: () => EditorView | undefined;
13
- }
14
- export declare const editSelectedExtension: (editorActions: EditorActions) => boolean;
15
11
  export declare const editExtension: (macroProvider: MacroProvider | null | undefined, applyChangeToContextPanel: ApplyChangeHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, updateExtension?: Promise<UpdateExtension<object> | void>) => Command;
16
12
  type Props = {
17
13
  editorViewRef: Record<'current', EditorView | null>;
18
14
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
15
+ applyChangeToContextPanel: ApplyChangeHandler | undefined;
19
16
  };
20
- export declare const createEditSelectedExtensionAction: ({ editorViewRef, editorAnalyticsAPI }: Props) => () => boolean;
17
+ export declare const createEditSelectedExtensionAction: ({ editorViewRef, editorAnalyticsAPI, applyChangeToContextPanel }: Props) => () => boolean;