@atlaskit/editor-core 187.10.0 → 187.10.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 (83) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +7 -0
  3. package/dist/cjs/labs/next/presets/default.js +2 -2
  4. package/dist/cjs/plugins/floating-toolbar/index.js +154 -132
  5. package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +11 -10
  6. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
  7. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +6 -1
  8. package/dist/cjs/plugins/index.js +0 -7
  9. package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
  10. package/dist/cjs/plugins/media/toolbar/alt-text.js +6 -6
  11. package/dist/cjs/plugins/media/toolbar/linking.js +4 -1
  12. package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +2 -2
  13. package/dist/cjs/ui/ColorPickerButton/index.js +3 -3
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/cjs/version.json +1 -1
  16. package/dist/es2019/labs/next/presets/default.js +1 -1
  17. package/dist/es2019/plugins/floating-toolbar/index.js +152 -128
  18. package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +12 -8
  19. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +5 -4
  20. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +12 -1
  21. package/dist/es2019/plugins/index.js +0 -1
  22. package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +3 -1
  23. package/dist/es2019/plugins/media/toolbar/alt-text.js +10 -6
  24. package/dist/es2019/plugins/media/toolbar/linking.js +8 -1
  25. package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +5 -3
  26. package/dist/es2019/ui/ColorPickerButton/index.js +2 -2
  27. package/dist/es2019/version-wrapper.js +1 -1
  28. package/dist/es2019/version.json +1 -1
  29. package/dist/esm/labs/next/presets/default.js +1 -1
  30. package/dist/esm/plugins/floating-toolbar/index.js +153 -131
  31. package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +9 -7
  32. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
  33. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +6 -1
  34. package/dist/esm/plugins/index.js +0 -1
  35. package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
  36. package/dist/esm/plugins/media/toolbar/alt-text.js +6 -6
  37. package/dist/esm/plugins/media/toolbar/linking.js +4 -1
  38. package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +2 -2
  39. package/dist/esm/ui/ColorPickerButton/index.js +3 -3
  40. package/dist/esm/version-wrapper.js +1 -1
  41. package/dist/esm/version.json +1 -1
  42. package/dist/types/labs/next/presets/default.d.ts +40 -8
  43. package/dist/types/plugins/date/index.d.ts +2 -2
  44. package/dist/types/plugins/floating-toolbar/index.d.ts +1 -7
  45. package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
  46. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
  47. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
  48. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  49. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
  50. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
  51. package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
  52. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  53. package/dist/types/plugins/index.d.ts +0 -1
  54. package/dist/types/plugins/media/index.d.ts +2 -2
  55. package/dist/types/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
  56. package/dist/types/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
  57. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  58. package/dist/types/ui/ColorPickerButton/index.d.ts +2 -2
  59. package/dist/types-ts4.5/labs/next/presets/default.d.ts +44 -8
  60. package/dist/types-ts4.5/plugins/date/index.d.ts +2 -2
  61. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +1 -7
  62. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
  63. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
  64. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
  65. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  66. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
  67. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
  68. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
  69. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  70. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  71. package/dist/types-ts4.5/plugins/media/index.d.ts +2 -2
  72. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
  73. package/dist/types-ts4.5/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
  74. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  75. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +2 -2
  76. package/package.json +3 -2
  77. package/report.api.md +3 -21
  78. package/tmp/api-report-tmp.d.ts +3 -18
  79. package/dist/cjs/plugins/editor-disabled/index.js +0 -75
  80. package/dist/es2019/plugins/editor-disabled/index.js +0 -62
  81. package/dist/esm/plugins/editor-disabled/index.js +0 -66
  82. package/dist/types/plugins/editor-disabled/index.d.ts +0 -13
  83. package/dist/types-ts4.5/plugins/editor-disabled/index.d.ts +0 -13
@@ -8,7 +8,7 @@ import textFormattingPlugin from '../../../plugins/text-formatting';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import unsupportedContentPlugin from '../../../plugins/unsupported-content';
10
10
  import basePlugin from '../../../plugins/base';
11
- import editorDisabledPlugin from '../../../plugins/editor-disabled';
11
+ import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
12
12
  import typeAheadPlugin from '../../../plugins/type-ahead';
13
13
  import submitEditorPlugin from '../../../plugins/submit-editor';
14
14
  import fakeTextCursorPlugin from '../../../plugins/fake-text-cursor';
@@ -6,11 +6,9 @@ import camelCase from 'lodash/camelCase';
6
6
  import { Popup } from '@atlaskit/editor-common/ui';
7
7
  // AFP-2532 TODO: Fix automatic suppressions below
8
8
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
9
- import WithPluginState from '../../ui/WithPluginState';
9
+ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
10
10
  import { CONTENT_COMPONENT } from '../analytics/types';
11
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
12
- import { pluginKey as extensionsPluginKey } from '../extension/plugin-key';
13
- import { pluginKey as editorDisabledPluginKey } from '../editor-disabled';
14
12
  import { pluginKey as dataPluginKey } from './pm-plugins/toolbar-data/plugin-key';
15
13
  import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
16
14
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
@@ -112,8 +110,6 @@ function filterUndefined(x) {
112
110
  return !!x;
113
111
  }
114
112
  const floatingToolbarPlugin = (_, api) => {
115
- var _api$dependencies, _api$dependencies$fea;
116
- const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
117
113
  return {
118
114
  name: 'floatingToolbar',
119
115
  pmPlugins(floatingToolbarHandlers = []) {
@@ -143,6 +139,17 @@ const floatingToolbarPlugin = (_, api) => {
143
139
  actions: {
144
140
  forceFocusSelector
145
141
  },
142
+ getSharedState(editorState) {
143
+ var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
144
+ if (!editorState) {
145
+ return undefined;
146
+ }
147
+ const configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
148
+ return {
149
+ configWithNodeInfo,
150
+ floatingToolbarData: dataPluginKey.getState(editorState)
151
+ };
152
+ },
146
153
  contentComponent({
147
154
  popupsMountPoint,
148
155
  popupsBoundariesElement,
@@ -151,131 +158,150 @@ const floatingToolbarPlugin = (_, api) => {
151
158
  providerFactory,
152
159
  dispatchAnalyticsEvent
153
160
  }) {
154
- return /*#__PURE__*/React.createElement(WithPluginState, {
155
- plugins: {
156
- floatingToolbarState: pluginKey,
157
- floatingToolbarData: dataPluginKey,
158
- editorDisabledPlugin: editorDisabledPluginKey,
159
- extensionsState: extensionsPluginKey
160
- },
161
- render: ({
162
- editorDisabledPlugin,
163
- floatingToolbarState,
164
- floatingToolbarData,
165
- extensionsState
166
- }) => {
167
- var _configWithNodeInfo$c, _configWithNodeInfo$c2;
168
- const configWithNodeInfo = floatingToolbarState === null || floatingToolbarState === void 0 ? void 0 : floatingToolbarState.getConfigWithNodeInfo(editorView.state);
169
- if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
170
- return null;
171
- }
172
- const {
173
- config,
174
- node
175
- } = configWithNodeInfo;
176
- const {
177
- title,
178
- getDomRef = getDomRefFromSelection,
179
- items,
180
- align = 'center',
181
- className = '',
182
- height,
183
- width,
184
- zIndex,
185
- offset = [0, 12],
186
- forcePlacement,
187
- preventPopupOverflow,
188
- onPositionCalculated,
189
- focusTrap
190
- } = config;
191
- const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
192
- if (!targetRef || editorDisabledPlugin && editorDisabledPlugin.editorDisabled) {
193
- return null;
194
- }
195
- let customPositionCalculation;
196
- const toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration);
197
- if (onPositionCalculated) {
198
- customPositionCalculation = nextPos => {
199
- return onPositionCalculated(editorView, nextPos);
200
- };
201
- }
202
- const dispatchCommand = fn => fn && fn(editorView.state, editorView.dispatch, editorView);
203
-
204
- // Confirm dialog
205
- const {
206
- confirmDialogForItem
207
- } = floatingToolbarData || {};
208
- const confirmButtonItem = confirmDialogForItem ? toolbarItems[confirmDialogForItem] : undefined;
209
- const scrollable = featureFlags.floatingToolbarCopyButton && config.scrollable;
210
- const confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
211
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
212
- component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
213
- componentId: camelCase(title),
214
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
215
- fallbackComponent: null
216
- }, /*#__PURE__*/React.createElement(Popup, {
217
- ariaLabel: title,
218
- offset: offset,
219
- target: targetRef,
220
- alignY: "bottom",
221
- forcePlacement: forcePlacement,
222
- fitHeight: height,
223
- fitWidth: width,
224
- alignX: align,
225
- stick: true,
226
- zIndex: zIndex,
227
- mountTo: popupsMountPoint,
228
- boundariesElement: popupsBoundariesElement,
229
- scrollableElement: popupsScrollableElement,
230
- onPositionCalculated: customPositionCalculation,
231
- style: scrollable ? {
232
- maxWidth: '100%'
233
- } : {},
234
- focusTrap: focusTrap,
235
- preventOverflow: preventPopupOverflow
236
- }, /*#__PURE__*/React.createElement(ToolbarLoader, {
237
- target: targetRef,
238
- items: toolbarItems,
239
- node: node,
240
- dispatchCommand: dispatchCommand,
241
- editorView: editorView,
242
- className: className,
243
- focusEditor: () => editorView.focus(),
244
- providerFactory: providerFactory,
245
- popupsMountPoint: popupsMountPoint,
246
- popupsBoundariesElement: popupsBoundariesElement,
247
- popupsScrollableElement: popupsScrollableElement,
248
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
249
- extensionsProvider: extensionsState === null || extensionsState === void 0 ? void 0 : extensionsState.extensionProvider,
250
- scrollable: scrollable,
251
- featureFlags: featureFlags,
252
- api: api
253
- })), /*#__PURE__*/React.createElement(ConfirmationModal, {
254
- testId: "ak-floating-toolbar-confirmation-modal",
255
- options: confirmDialogOptions,
256
- onConfirm: (isChecked = false) => {
257
- if (!!confirmDialogOptions.onConfirm) {
258
- dispatchCommand(confirmDialogOptions.onConfirm(isChecked));
259
- } else {
260
- dispatchCommand(confirmButtonItem.onClick);
261
- }
262
- },
263
- onClose: () => {
264
- dispatchCommand(hideConfirmDialog());
265
- // Need to set focus to Editor here,
266
- // As when the Confirmation dialog pop up, and user interacts with the dialog, Editor loses focus.
267
- // So when Confirmation dialog is closed, Editor does not have the focus, then cursor goes to the position 1 of the doc,
268
- // instead of the cursor position before the dialog pop up.
269
- if (!editorView.hasFocus()) {
270
- editorView.focus();
271
- }
272
- }
273
- }));
274
- }
161
+ return /*#__PURE__*/React.createElement(ContentComponent, {
162
+ editorView: editorView,
163
+ pluginInjectionApi: api,
164
+ popupsMountPoint: popupsMountPoint,
165
+ popupsBoundariesElement: popupsBoundariesElement,
166
+ popupsScrollableElement: popupsScrollableElement,
167
+ providerFactory: providerFactory,
168
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent
275
169
  });
276
170
  }
277
171
  };
278
172
  };
173
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
174
+ function ContentComponent({
175
+ pluginInjectionApi,
176
+ editorView,
177
+ popupsMountPoint,
178
+ popupsBoundariesElement,
179
+ popupsScrollableElement,
180
+ providerFactory,
181
+ dispatchAnalyticsEvent
182
+ }) {
183
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2, _configWithNodeInfo$c, _configWithNodeInfo$c2;
184
+ const featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.featureFlags) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState()) || {};
185
+ const {
186
+ floatingToolbarState,
187
+ editorDisabledState
188
+ } = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled']);
189
+ const {
190
+ configWithNodeInfo,
191
+ floatingToolbarData
192
+ } = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {};
193
+ if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
194
+ return null;
195
+ }
196
+ const {
197
+ config,
198
+ node
199
+ } = configWithNodeInfo;
200
+ const {
201
+ title,
202
+ getDomRef = getDomRefFromSelection,
203
+ items,
204
+ align = 'center',
205
+ className = '',
206
+ height,
207
+ width,
208
+ zIndex,
209
+ offset = [0, 12],
210
+ forcePlacement,
211
+ preventPopupOverflow,
212
+ onPositionCalculated,
213
+ focusTrap
214
+ } = config;
215
+ const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
216
+ if (!targetRef || editorDisabledState && editorDisabledState.editorDisabled) {
217
+ return null;
218
+ }
219
+ let customPositionCalculation;
220
+ const toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions.hoverDecoration);
221
+ if (onPositionCalculated) {
222
+ customPositionCalculation = nextPos => {
223
+ return onPositionCalculated(editorView, nextPos);
224
+ };
225
+ }
226
+ const dispatchCommand = fn => fn && fn(editorView.state, editorView.dispatch, editorView);
227
+
228
+ // Confirm dialog
229
+ const {
230
+ confirmDialogForItem
231
+ } = floatingToolbarData || {};
232
+ const confirmButtonItem = confirmDialogForItem ? toolbarItems[confirmDialogForItem] : undefined;
233
+ const scrollable = featureFlags.floatingToolbarCopyButton && config.scrollable;
234
+ const confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
235
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
236
+ component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
237
+ componentId: camelCase(title),
238
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
239
+ fallbackComponent: null
240
+ }, /*#__PURE__*/React.createElement(Popup, {
241
+ ariaLabel: title,
242
+ offset: offset,
243
+ target: targetRef,
244
+ alignY: "bottom",
245
+ forcePlacement: forcePlacement,
246
+ fitHeight: height,
247
+ fitWidth: width,
248
+ alignX: align,
249
+ stick: true,
250
+ zIndex: zIndex,
251
+ mountTo: popupsMountPoint,
252
+ boundariesElement: popupsBoundariesElement,
253
+ scrollableElement: popupsScrollableElement,
254
+ onPositionCalculated: customPositionCalculation,
255
+ style: scrollable ? {
256
+ maxWidth: '100%'
257
+ } : {},
258
+ focusTrap: focusTrap,
259
+ preventOverflow: preventPopupOverflow
260
+ }, /*#__PURE__*/React.createElement(WithProviders, {
261
+ providerFactory: providerFactory,
262
+ providers: ['extensionProvider'],
263
+ renderNode: providers => {
264
+ return /*#__PURE__*/React.createElement(ToolbarLoader, {
265
+ target: targetRef,
266
+ items: toolbarItems,
267
+ node: node,
268
+ dispatchCommand: dispatchCommand,
269
+ editorView: editorView,
270
+ className: className,
271
+ focusEditor: () => editorView.focus(),
272
+ providerFactory: providerFactory,
273
+ popupsMountPoint: popupsMountPoint,
274
+ popupsBoundariesElement: popupsBoundariesElement,
275
+ popupsScrollableElement: popupsScrollableElement,
276
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
277
+ extensionsProvider: providers.extensionProvider,
278
+ scrollable: scrollable,
279
+ featureFlags: featureFlags,
280
+ api: pluginInjectionApi
281
+ });
282
+ }
283
+ })), /*#__PURE__*/React.createElement(ConfirmationModal, {
284
+ testId: "ak-floating-toolbar-confirmation-modal",
285
+ options: confirmDialogOptions,
286
+ onConfirm: (isChecked = false) => {
287
+ if (!!confirmDialogOptions.onConfirm) {
288
+ dispatchCommand(confirmDialogOptions.onConfirm(isChecked));
289
+ } else {
290
+ dispatchCommand(confirmButtonItem.onClick);
291
+ }
292
+ },
293
+ onClose: () => {
294
+ dispatchCommand(hideConfirmDialog());
295
+ // Need to set focus to Editor here,
296
+ // As when the Confirmation dialog pop up, and user interacts with the dialog, Editor loses focus.
297
+ // So when Confirmation dialog is closed, Editor does not have the focus, then cursor goes to the position 1 of the doc,
298
+ // instead of the cursor position before the dialog pop up.
299
+ if (!editorView.hasFocus()) {
300
+ editorView.focus();
301
+ }
302
+ }
303
+ }));
304
+ }
279
305
  export default floatingToolbarPlugin;
280
306
 
281
307
  /**
@@ -303,7 +329,6 @@ function sanitizeFloatingToolbarConfig(config) {
303
329
  function floatingToolbarPluginFactory(options) {
304
330
  const {
305
331
  floatingToolbarHandlers,
306
- dispatch,
307
332
  providerFactory,
308
333
  getIntl
309
334
  } = options;
@@ -317,7 +342,6 @@ function floatingToolbarPluginFactory(options) {
317
342
  const newPluginState = {
318
343
  ...pluginState
319
344
  };
320
- dispatch(pluginKey, newPluginState);
321
345
  return newPluginState;
322
346
  };
323
347
  return new SafePlugin({
@@ -26,13 +26,11 @@ export default (() => new SafePlugin({
26
26
  /**
27
27
  * The provided selector should be the floating toolbar button that needs focus.
28
28
  */
29
- export function forceFocusSelector(selector, view) {
30
- if (view) {
31
- return view.dispatch(view.state.tr.setMeta(forceFocusStateKey, {
32
- selector
33
- }));
34
- }
35
- }
29
+ export const forceFocusSelector = selector => tr => {
30
+ return tr.setMeta(forceFocusStateKey, {
31
+ selector
32
+ });
33
+ };
36
34
 
37
35
  /**
38
36
  * If a selector is set and the element exists, focus it.
@@ -52,7 +50,13 @@ export function checkShouldForceFocusAndApply(view) {
52
50
  inline: 'nearest'
53
51
  });
54
52
  focusableElement.focus();
55
- forceFocusSelector(null, view);
53
+ const {
54
+ state: {
55
+ tr
56
+ },
57
+ dispatch
58
+ } = view;
59
+ dispatch(forceFocusSelector(null)(tr));
56
60
  }
57
61
  }
58
62
  }
@@ -60,11 +60,12 @@ export const ExtensionsPlaceholder = props => {
60
60
  } = props;
61
61
  const [extensions, setExtensions] = useState([]);
62
62
  useEffect(() => {
63
- if (extensionProvider) {
64
- getExtensions();
65
- }
63
+ getExtensions();
66
64
  async function getExtensions() {
67
- setExtensions(await extensionProvider.getExtensions());
65
+ const provider = await extensionProvider;
66
+ if (provider) {
67
+ setExtensions(await provider.getExtensions());
68
+ }
68
69
  }
69
70
  // leaving dependencies array empty so that this effect runs just once on component mount
70
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -405,7 +405,18 @@ class Toolbar extends Component {
405
405
  }
406
406
  }
407
407
  componentWillUnmount() {
408
- forceFocusSelector(null, this.props.editorView);
408
+ const {
409
+ editorView
410
+ } = this.props;
411
+ if (editorView) {
412
+ const {
413
+ state: {
414
+ tr
415
+ },
416
+ dispatch
417
+ } = editorView;
418
+ dispatch(forceFocusSelector(null)(tr));
419
+ }
409
420
  this.resetStyling({
410
421
  table: this.props.node.type.name === 'table'
411
422
  });
@@ -37,7 +37,6 @@ export { default as statusPlugin } from './status';
37
37
  export { default as breakoutPlugin } from './breakout';
38
38
  export { default as alignmentPlugin } from './alignment';
39
39
  export { default as dataConsumerMarkPlugin } from './data-consumer';
40
- export { default as editorDisabledPlugin } from './editor-disabled';
41
40
  export { default as fragmentMarkPlugin } from './fragment';
42
41
  export { default as indentationPlugin } from './indentation';
43
42
  export { default as annotationPlugin } from './annotation';
@@ -75,13 +75,15 @@ export class AltTextEditComponent extends React.Component {
75
75
  });
76
76
  _defineProperty(this, "dispatchCancelEvent", event => {
77
77
  const {
78
- view
78
+ view,
79
+ onEscape
79
80
  } = this.props;
80
81
 
81
82
  // We need to pass down the ESCAPE keymap
82
83
  // because when we focus on the Toolbar, Prosemirror blur,
83
84
  // making all keyboard shortcuts not working
84
85
  view.someProp('handleKeyDown', fn => fn(view, event));
86
+ onEscape === null || onEscape === void 0 ? void 0 : onEscape();
85
87
  });
86
88
  _defineProperty(this, "updateAltText", newAltText => {
87
89
  const {
@@ -6,7 +6,6 @@ import AltTextEdit from '../pm-plugins/alt-text/ui/AltTextEdit';
6
6
  import { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/AltTextEdit';
7
7
  import { getMediaNodeFromSelection } from '../utils/media-common';
8
8
  import { ClassNames } from '../pm-plugins/alt-text/style';
9
- import { withOuterListeners } from '@atlaskit/editor-common/ui';
10
9
  import { forceFocusSelector } from '../../floating-toolbar/pm-plugins/force-focus';
11
10
  const testId = 'alt-text-edit-button';
12
11
  export const altTextButton = (intl, state) => {
@@ -26,7 +25,6 @@ export const altTextButton = (intl, state) => {
26
25
  })
27
26
  };
28
27
  };
29
- const AltTextEditWithListeners = withOuterListeners(AltTextEdit);
30
28
  export const altTextEditComponent = options => {
31
29
  return {
32
30
  type: 'custom',
@@ -43,15 +41,21 @@ export const altTextEditComponent = options => {
43
41
  /** Focus should move to the 'Alt text' button when the toolbar closes
44
42
  * and not close the floating toolbar.
45
43
  */
46
- const handleEsc = e => {
47
- forceFocusSelector(`[data-testid="${testId}"]`, view);
44
+ const handleEsc = () => {
45
+ const {
46
+ state: {
47
+ tr
48
+ },
49
+ dispatch
50
+ } = view;
51
+ dispatch(forceFocusSelector(`[data-testid="${testId}"]`)(tr));
48
52
  };
49
- return /*#__PURE__*/React.createElement(AltTextEditWithListeners, {
53
+ return /*#__PURE__*/React.createElement(AltTextEdit, {
50
54
  view: view,
51
55
  key: idx,
52
56
  value: mediaNode.attrs.alt,
53
57
  altTextValidator: options && options.altTextValidator,
54
- handleEscapeKeydown: handleEsc
58
+ onEscape: handleEsc
55
59
  });
56
60
  }
57
61
  };
@@ -68,7 +68,14 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
68
68
  /** Focus should move to the 'Add link' button when the toolbar closes
69
69
  * and not close the floating toolbar.
70
70
  */
71
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.forceFocusSelector(FORCE_FOCUS_SELECTOR, view);
71
+ const {
72
+ state: {
73
+ tr
74
+ },
75
+ dispatch
76
+ } = view;
77
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
78
+ dispatch(tr);
72
79
  },
73
80
  onSubmit: (href, meta) => {
74
81
  setUrlToMedia(href, meta.inputMethod)(view.state, view.dispatch, view);
@@ -18,15 +18,17 @@ import { INPUT_METHOD } from '../../analytics/types/enums';
18
18
  import { mediaLinkToolbarMessages } from './media-linking-toolbar-messages';
19
19
  const validationWrapper = css`
20
20
  line-height: 0;
21
- padding: 12px 24px 12px 0;
22
- margin: 0 4px 0 32px;
21
+ padding: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-300, 24px)"}
22
+ ${"var(--ds-space-150, 12px)"} 0;
23
+ margin: 0 ${"var(--ds-space-050, 4px)"} 0 ${"var(--ds-space-400, 32px)"};
23
24
  border-top: 1px solid ${`var(--ds-border-danger, ${R400})`};
24
25
  align-items: start;
25
26
  display: flex;
26
27
  flex-direction: column;
27
28
  `;
28
29
  const buttonWrapper = css`
29
- padding: 4px 8px 4px 0px;
30
+ padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}
31
+ ${"var(--ds-space-050, 4px)"} 0px;
30
32
  `;
31
33
  export class LinkAddToolbar extends React.PureComponent {
32
34
  constructor(...args) {
@@ -38,6 +38,7 @@ const colorPickerWrapper = theme => css`
38
38
  `;
39
39
  /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
40
40
 
41
+ const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
41
42
  const ColorPickerButton = props => {
42
43
  const buttonRef = React.useRef(null);
43
44
  const [isPopupOpen, setIsPopupOpen] = React.useState(false);
@@ -70,7 +71,6 @@ const ColorPickerButton = props => {
70
71
  setIsPopupPositioned(true);
71
72
  return position;
72
73
  }, []);
73
- const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
74
74
  const {
75
75
  onChange,
76
76
  createAnalyticsEvent,
@@ -174,7 +174,7 @@ const ColorPickerButton = props => {
174
174
  width: ${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px'};
175
175
  height: ${((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px'};
176
176
  padding: 0;
177
- margin: 0px 2px;
177
+ margin: 0px ${"var(--ds-space-025, 2px)"};
178
178
  }
179
179
  &:hover {
180
180
  background: ${themed({
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.10.0";
2
+ export const version = "187.10.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.10.0",
3
+ "version": "187.10.1",
4
4
  "sideEffects": false
5
5
  }
@@ -8,7 +8,7 @@ import textFormattingPlugin from '../../../plugins/text-formatting';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import unsupportedContentPlugin from '../../../plugins/unsupported-content';
10
10
  import basePlugin from '../../../plugins/base';
11
- import editorDisabledPlugin from '../../../plugins/editor-disabled';
11
+ import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
12
12
  import typeAheadPlugin from '../../../plugins/type-ahead';
13
13
  import submitEditorPlugin from '../../../plugins/submit-editor';
14
14
  import fakeTextCursorPlugin from '../../../plugins/fake-text-cursor';