@atlaskit/editor-core 179.0.3 → 179.1.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 (107) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/create-editor/ReactEditorView.js +1 -1
  3. package/dist/cjs/create-editor/create-plugins-list.js +6 -287
  4. package/dist/cjs/{plugins/feature-flags-context → create-editor}/feature-flags-from-props.js +0 -0
  5. package/dist/cjs/editor.js +41 -8
  6. package/dist/cjs/labs/next/presets/universal.js +313 -0
  7. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +24 -5
  8. package/dist/cjs/plugins/floating-toolbar/index.js +6 -0
  9. package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +72 -0
  10. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +12 -9
  11. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +3 -1
  12. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +3 -2
  13. package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +40 -1
  14. package/dist/cjs/plugins/list/commands/outdent-list.js +22 -9
  15. package/dist/cjs/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +30 -12
  16. package/dist/cjs/plugins/list/utils/analytics.js +18 -2
  17. package/dist/cjs/plugins/media/commands/linking.js +2 -2
  18. package/dist/cjs/plugins/media/pm-plugins/alt-text/index.js +1 -12
  19. package/dist/cjs/plugins/media/toolbar/alt-text.js +14 -3
  20. package/dist/cjs/plugins/media/toolbar/linking-toolbar-appearance.js +6 -6
  21. package/dist/cjs/plugins/media/toolbar/linking.js +7 -1
  22. package/dist/cjs/plugins/paste/handlers.js +7 -5
  23. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +17 -0
  24. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +13 -13
  25. package/dist/cjs/test-utils.js +13 -1
  26. package/dist/cjs/utils/document.js +3 -2
  27. package/dist/cjs/utils/input-rules.js +3 -2
  28. package/dist/cjs/utils/lists.js +31 -0
  29. package/dist/cjs/utils/prepare-quick-insert-provider.js +22 -0
  30. package/dist/cjs/version-wrapper.js +1 -1
  31. package/dist/cjs/version.json +1 -1
  32. package/dist/es2019/create-editor/ReactEditorView.js +1 -1
  33. package/dist/es2019/create-editor/create-plugins-list.js +5 -293
  34. package/dist/es2019/{plugins/feature-flags-context → create-editor}/feature-flags-from-props.js +0 -0
  35. package/dist/es2019/editor.js +41 -7
  36. package/dist/es2019/labs/next/presets/universal.js +311 -0
  37. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +19 -2
  38. package/dist/es2019/plugins/floating-toolbar/index.js +4 -0
  39. package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +59 -0
  40. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +6 -3
  41. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +3 -1
  42. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +3 -2
  43. package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +41 -1
  44. package/dist/es2019/plugins/list/commands/outdent-list.js +16 -1
  45. package/dist/es2019/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +29 -11
  46. package/dist/es2019/plugins/list/utils/analytics.js +12 -0
  47. package/dist/es2019/plugins/media/commands/linking.js +2 -2
  48. package/dist/es2019/plugins/media/pm-plugins/alt-text/index.js +1 -12
  49. package/dist/es2019/plugins/media/toolbar/alt-text.js +14 -3
  50. package/dist/es2019/plugins/media/toolbar/linking-toolbar-appearance.js +6 -6
  51. package/dist/es2019/plugins/media/toolbar/linking.js +9 -1
  52. package/dist/es2019/plugins/paste/handlers.js +8 -6
  53. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +17 -0
  54. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +13 -13
  55. package/dist/es2019/test-utils.js +11 -1
  56. package/dist/es2019/utils/document.js +3 -2
  57. package/dist/es2019/utils/input-rules.js +3 -2
  58. package/dist/es2019/utils/lists.js +26 -0
  59. package/dist/es2019/utils/prepare-quick-insert-provider.js +17 -0
  60. package/dist/es2019/version-wrapper.js +1 -1
  61. package/dist/es2019/version.json +1 -1
  62. package/dist/esm/create-editor/ReactEditorView.js +1 -1
  63. package/dist/esm/create-editor/create-plugins-list.js +6 -287
  64. package/dist/esm/{plugins/feature-flags-context → create-editor}/feature-flags-from-props.js +0 -0
  65. package/dist/esm/editor.js +41 -8
  66. package/dist/esm/labs/next/presets/universal.js +306 -0
  67. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +24 -5
  68. package/dist/esm/plugins/floating-toolbar/index.js +6 -0
  69. package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +62 -0
  70. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +12 -9
  71. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +3 -1
  72. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +3 -2
  73. package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +40 -1
  74. package/dist/esm/plugins/list/commands/outdent-list.js +15 -2
  75. package/dist/esm/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +30 -12
  76. package/dist/esm/plugins/list/utils/analytics.js +12 -0
  77. package/dist/esm/plugins/media/commands/linking.js +2 -2
  78. package/dist/esm/plugins/media/pm-plugins/alt-text/index.js +1 -12
  79. package/dist/esm/plugins/media/toolbar/alt-text.js +14 -3
  80. package/dist/esm/plugins/media/toolbar/linking-toolbar-appearance.js +6 -6
  81. package/dist/esm/plugins/media/toolbar/linking.js +7 -1
  82. package/dist/esm/plugins/paste/handlers.js +8 -6
  83. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +17 -0
  84. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +13 -13
  85. package/dist/esm/test-utils.js +11 -1
  86. package/dist/esm/utils/document.js +3 -2
  87. package/dist/esm/utils/input-rules.js +3 -2
  88. package/dist/esm/utils/lists.js +24 -0
  89. package/dist/esm/utils/prepare-quick-insert-provider.js +17 -0
  90. package/dist/esm/version-wrapper.js +1 -1
  91. package/dist/esm/version.json +1 -1
  92. package/dist/types/create-editor/create-plugins-list.d.ts +5 -4
  93. package/dist/types/{plugins/feature-flags-context → create-editor}/feature-flags-from-props.d.ts +2 -2
  94. package/dist/types/editor.d.ts +42 -0
  95. package/dist/types/labs/next/presets/universal.d.ts +30 -0
  96. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +4 -0
  97. package/dist/types/plugins/expand/index.d.ts +4 -1
  98. package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +18 -0
  99. package/dist/types/plugins/list/utils/analytics.d.ts +5 -2
  100. package/dist/types/plugins/media/commands/linking.d.ts +1 -1
  101. package/dist/types/test-utils.d.ts +7 -0
  102. package/dist/types/types/editor-props.d.ts +96 -92
  103. package/dist/types/utils/input-rules.d.ts +2 -1
  104. package/dist/types/utils/lists.d.ts +2 -0
  105. package/dist/types/utils/prepare-quick-insert-provider.d.ts +16 -0
  106. package/package.json +8 -8
  107. package/report.api.md +89 -79
@@ -0,0 +1,311 @@
1
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, imageUploadPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, cardPlugin, gridPlugin, statusPlugin, alignmentPlugin, indentationPlugin, analyticsPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, contextPanelPlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, copyButtonPlugin } from '../../../plugins';
2
+ import { tablesPlugin } from '@atlaskit/editor-plugin-table';
3
+ import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
4
+ import { getMediaFeatureFlag } from '@atlaskit/media-common';
5
+ import { createDefaultPreset } from './default';
6
+ import { shouldForceTracking } from '@atlaskit/editor-common/utils';
7
+ /**
8
+ * Creates a preset with all of the available plugins.
9
+ * Basis for create-plugins-list and can be used to migrate from Editor -> EditorNext (Presets project)
10
+ * with minimal friction.
11
+ *
12
+ * @param appearance
13
+ * @param props A subset of full EditorProps for the full feature preset
14
+ * @param featureFlags
15
+ * @param prevAppearance The appearance of the editor in the previous render
16
+ * @param createAnalyticsEvent
17
+ * @param insertNodeAPI
18
+ * @param editorAnalyticsAPI
19
+ * @param editorSelectionAPI
20
+ * @param getEditorContainerWidth
21
+ * @returns a full featured preset configured according to the provided props - basis for create-plugins-list
22
+ */
23
+ export default function createUniversalPreset(appearance, props, featureFlags, prevAppearance, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI, getEditorContainerWidth) {
24
+ var _props$linking;
25
+ const isMobile = appearance === 'mobile';
26
+ const isComment = appearance === 'comment';
27
+ const isFullPage = fullPageCheck(appearance);
28
+ const preset = createDefaultPreset(props);
29
+ const getEditorFeatureFlags = () => featureFlags;
30
+ if (props.allowAnalyticsGASV3) {
31
+ const {
32
+ performanceTracking
33
+ } = props;
34
+ preset.add([analyticsPlugin, {
35
+ createAnalyticsEvent,
36
+ performanceTracking
37
+ }]);
38
+ }
39
+ if (props.allowBreakout && isFullPage) {
40
+ preset.add([breakoutPlugin, {
41
+ allowBreakoutButton: appearance === 'full-page'
42
+ }]);
43
+ }
44
+ if (props.allowTextAlignment) {
45
+ preset.add(alignmentPlugin);
46
+ }
47
+ preset.add(dataConsumerMarkPlugin);
48
+ if (props.allowTextColor) {
49
+ preset.add([textColorPlugin, props.allowTextColor]);
50
+ }
51
+
52
+ // Needs to be after allowTextColor as order of buttons in toolbar depends on it
53
+ preset.add([listPlugin, {
54
+ restartNumberedLists: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.restartNumberedLists,
55
+ restartNumberedListsToolbar: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.restartNumberedListsToolbar,
56
+ listNumberContinuity: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.listNumberContinuity
57
+ }]);
58
+ if (props.allowRule) {
59
+ preset.add(rulePlugin);
60
+ }
61
+ if (props.allowExpand) {
62
+ preset.add([expandPlugin, {
63
+ allowInsertion: isExpandInsertionEnabled(props),
64
+ useLongPressSelection: false,
65
+ appearance: appearance
66
+ }]);
67
+ }
68
+ if (props.media) {
69
+ preset.add([gridPlugin, {
70
+ shouldCalcBreakoutGridLines: isFullPage
71
+ }]);
72
+ const alignLeftOnInsert = typeof props.media.alignLeftOnInsert !== 'undefined' ? props.media.alignLeftOnInsert : isComment;
73
+ const showMediaLayoutOptions = typeof props.media.allowAdvancedToolBarOptions !== 'undefined' ? props.media.allowAdvancedToolBarOptions : isFullPage || isComment;
74
+ preset.add([mediaPlugin, {
75
+ ...props.media,
76
+ allowLazyLoading: !isMobile,
77
+ allowBreakoutSnapPoints: isFullPage,
78
+ allowAdvancedToolBarOptions: showMediaLayoutOptions,
79
+ allowDropzoneDropLine: isFullPage,
80
+ allowMediaSingleEditable: !isMobile,
81
+ allowRemoteDimensionsFetch: !isMobile,
82
+ editorSelectionAPI,
83
+ // This is a wild one. I didnt quite understand what the code was doing
84
+ // so a bit of guess for now.
85
+ allowMarkingUploadsAsIncomplete: isMobile,
86
+ fullWidthEnabled: appearance === 'full-width',
87
+ uploadErrorHandler: props.uploadErrorHandler,
88
+ waitForMediaUpload: props.waitForMediaUpload,
89
+ isCopyPasteEnabled: !isMobile,
90
+ alignLeftOnInsert
91
+ }]);
92
+
93
+ // EDM-799: inside caption plugin we do the feature flag in enabling the plugin
94
+ if (getMediaFeatureFlag('captions', props.media.featureFlags)) {
95
+ preset.add(captionPlugin);
96
+ }
97
+ }
98
+ if (props.mentionProvider) {
99
+ var _props$mention$insert, _props$mention, _props$mention2;
100
+ preset.add([mentionsPlugin, {
101
+ createAnalyticsEvent,
102
+ sanitizePrivateContent: props.sanitizePrivateContent,
103
+ insertDisplayName: (_props$mention$insert = (_props$mention = props.mention) === null || _props$mention === void 0 ? void 0 : _props$mention.insertDisplayName) !== null && _props$mention$insert !== void 0 ? _props$mention$insert : props.mentionInsertDisplayName,
104
+ allowZeroWidthSpaceAfter: !isMobile,
105
+ HighlightComponent: (_props$mention2 = props.mention) === null || _props$mention2 === void 0 ? void 0 : _props$mention2.HighlightComponent
106
+ }]);
107
+ }
108
+ if (props.emojiProvider) {
109
+ preset.add([emojiPlugin, {
110
+ createAnalyticsEvent
111
+ }]);
112
+ }
113
+ if (props.allowTables) {
114
+ const tableOptions = !props.allowTables || typeof props.allowTables === 'boolean' ? {} : props.allowTables;
115
+ preset.add([tablesPlugin, {
116
+ tableOptions,
117
+ breakoutEnabled: appearance === 'full-page',
118
+ allowContextualMenu: !isMobile,
119
+ fullWidthEnabled: appearance === 'full-width',
120
+ wasFullWidthEnabled: prevAppearance && prevAppearance === 'full-width',
121
+ editorAnalyticsAPI,
122
+ editorSelectionAPI,
123
+ getEditorFeatureFlags
124
+ }]);
125
+ }
126
+ if (props.allowTasksAndDecisions || props.taskDecisionProvider) {
127
+ preset.add([tasksAndDecisionsPlugin, {
128
+ allowNestedTasks: props.allowNestedTasks,
129
+ consumeTabs: isFullPage,
130
+ useLongPressSelection: false
131
+ }]);
132
+ }
133
+ if (props.feedbackInfo) {
134
+ preset.add([feedbackDialogPlugin, props.feedbackInfo]);
135
+ }
136
+ if (props.allowHelpDialog) {
137
+ preset.add([helpDialogPlugin, !!props.legacyImageUploadProvider]);
138
+ }
139
+ if (props.saveOnEnter && props.onSave) {
140
+ preset.add([saveOnEnterPlugin, props.onSave]);
141
+ }
142
+ if (props.legacyImageUploadProvider) {
143
+ preset.add(imageUploadPlugin);
144
+ if (!props.media) {
145
+ preset.add([mediaPlugin, {
146
+ allowMediaSingle: {
147
+ disableLayout: true
148
+ },
149
+ allowMediaGroup: false,
150
+ isCopyPasteEnabled: true,
151
+ editorSelectionAPI
152
+ }]);
153
+ }
154
+ }
155
+ if (props.collabEdit || props.collabEditProvider) {
156
+ var _collabEditOptions$EX;
157
+ let collabEditOptions = {
158
+ sanitizePrivateContent: props.sanitizePrivateContent,
159
+ createAnalyticsEvent
160
+ };
161
+ if (props.collabEdit) {
162
+ collabEditOptions = {
163
+ ...props.collabEdit,
164
+ ...collabEditOptions
165
+ };
166
+ }
167
+ preset.add([collabEditPlugin, {
168
+ ...collabEditOptions,
169
+ EXPERIMENTAL_allowInternalErrorAnalytics: (_collabEditOptions$EX = collabEditOptions.EXPERIMENTAL_allowInternalErrorAnalytics) !== null && _collabEditOptions$EX !== void 0 ? _collabEditOptions$EX : shouldForceTracking()
170
+ }]);
171
+ }
172
+ if (props.maxContentSize) {
173
+ preset.add([maxContentSizePlugin, props.maxContentSize]);
174
+ }
175
+ if (props.allowJiraIssue) {
176
+ preset.add(jiraIssuePlugin);
177
+ }
178
+ if (props.allowPanel) {
179
+ const allowPanel = typeof props.allowPanel === 'object' ? props.allowPanel : {};
180
+ preset.add([panelPlugin, {
181
+ useLongPressSelection: false,
182
+ allowCustomPanel: allowPanel.allowCustomPanel,
183
+ allowCustomPanelEdit: allowPanel.allowCustomPanelEdit
184
+ }]);
185
+ }
186
+ if (props.allowExtension) {
187
+ const extensionConfig = typeof props.allowExtension === 'object' ? props.allowExtension : {};
188
+ preset.add([extensionPlugin, {
189
+ breakoutEnabled: appearance === 'full-page' && extensionConfig.allowBreakout !== false,
190
+ allowAutoSave: extensionConfig.allowAutoSave,
191
+ extensionHandlers: props.extensionHandlers,
192
+ useLongPressSelection: false,
193
+ appearance
194
+ }]);
195
+ }
196
+ if (props.macroProvider) {
197
+ preset.add(macroPlugin);
198
+ }
199
+
200
+ // See default list for when adding annotations with a provider
201
+ if (!props.annotationProviders && props.allowConfluenceInlineComment) {
202
+ preset.add([annotationPlugin, undefined]);
203
+ }
204
+ if (props.allowDate) {
205
+ preset.add(datePlugin);
206
+ }
207
+ if (props.allowTemplatePlaceholders) {
208
+ const options = props.allowTemplatePlaceholders !== true ? props.allowTemplatePlaceholders : {};
209
+ preset.add([placeholderTextPlugin, options]);
210
+ }
211
+ if (props.allowLayouts) {
212
+ const layoutOptions = typeof props.allowLayouts === 'object' ? props.allowLayouts : {};
213
+ preset.add([layoutPlugin, {
214
+ ...layoutOptions,
215
+ useLongPressSelection: false,
216
+ UNSAFE_allowSingleColumnLayout: layoutOptions.UNSAFE_allowSingleColumnLayout
217
+ }]);
218
+ }
219
+ if ((_props$linking = props.linking) !== null && _props$linking !== void 0 && _props$linking.smartLinks || props.smartLinks || props.UNSAFE_cards) {
220
+ var _props$linking2, _props$linking3;
221
+ const fullWidthMode = appearance === 'full-width';
222
+ preset.add([cardPlugin, {
223
+ ...props.UNSAFE_cards,
224
+ ...props.smartLinks,
225
+ ...((_props$linking2 = props.linking) === null || _props$linking2 === void 0 ? void 0 : _props$linking2.smartLinks),
226
+ platform: isMobile ? 'mobile' : 'web',
227
+ fullWidthMode,
228
+ createAnalyticsEvent,
229
+ linkPicker: (_props$linking3 = props.linking) === null || _props$linking3 === void 0 ? void 0 : _props$linking3.linkPicker
230
+ }]);
231
+ }
232
+ if (props.autoformattingProvider) {
233
+ preset.add(customAutoformatPlugin);
234
+ }
235
+ let statusMenuDisabled = true;
236
+ if (props.allowStatus) {
237
+ statusMenuDisabled = typeof props.allowStatus === 'object' ? props.allowStatus.menuDisabled : false;
238
+ preset.add([statusPlugin, {
239
+ menuDisabled: statusMenuDisabled,
240
+ allowZeroWidthSpaceAfter: !isMobile
241
+ }]);
242
+ }
243
+ if (props.allowIndentation) {
244
+ preset.add(indentationPlugin);
245
+ }
246
+ if (isFullPage) {
247
+ preset.add(contextPanelPlugin);
248
+ }
249
+ if (props.autoScrollIntoView !== false) {
250
+ preset.add(scrollIntoViewPlugin);
251
+ }
252
+ if (isMobile || props.allowUndoRedoButtons) {
253
+ preset.add(historyPlugin);
254
+ }
255
+ if (isMobile) {
256
+ preset.add(mobileDimensionsPlugin);
257
+ preset.add(mobileSelectionPlugin);
258
+ }
259
+
260
+ // UI only plugins
261
+ preset.add([toolbarListsIndentationPlugin, {
262
+ showIndentationButtons: !!featureFlags.indentationButtonsInTheToolbar,
263
+ allowHeadingAndParagraphIndentation: !!props.allowIndentation
264
+ }]);
265
+ preset.add([insertBlockPlugin, {
266
+ allowTables: !!props.allowTables,
267
+ allowExpand: isExpandInsertionEnabled(props),
268
+ insertMenuItems: props.insertMenuItems,
269
+ horizontalRuleEnabled: props.allowRule,
270
+ nativeStatusSupported: !statusMenuDisabled,
271
+ showElementBrowserLink: props.elementBrowser && props.elementBrowser.showModal || false,
272
+ replacePlusMenuWithElementBrowser: props.elementBrowser && props.elementBrowser.replacePlusMenu || false,
273
+ insertNodeAPI
274
+ }]);
275
+ const hasBeforePrimaryToolbar = components => {
276
+ if (components && 'before' in components) {
277
+ return !!components.before;
278
+ }
279
+ return false;
280
+ };
281
+ if (hasBeforePrimaryToolbar(props.primaryToolbarComponents) && !featureFlags.twoLineEditorToolbar) {
282
+ preset.add([beforePrimaryToolbarPlugin, {
283
+ beforePrimaryToolbarComponents: props.primaryToolbarComponents.before
284
+ }]);
285
+ }
286
+ if (featureFlags.showAvatarGroupAsPlugin === true && !featureFlags.twoLineEditorToolbar) {
287
+ preset.add([avatarGroupPlugin, {
288
+ collabEdit: props.collabEdit,
289
+ takeFullWidth: !hasBeforePrimaryToolbar(props.primaryToolbarComponents)
290
+ }]);
291
+ }
292
+ if (props.allowFindReplace) {
293
+ preset.add([findReplacePlugin, {
294
+ takeFullWidth: !!featureFlags.showAvatarGroupAsPlugin === false && !hasBeforePrimaryToolbar(props.primaryToolbarComponents),
295
+ twoLineEditorToolbar: !!featureFlags.twoLineEditorToolbar
296
+ }]);
297
+ }
298
+ if (props.allowFragmentMark) {
299
+ preset.add(fragmentMarkPlugin);
300
+ }
301
+ if (featureFlags.enableViewUpdateSubscription) {
302
+ preset.add(viewUpdateSubscriptionPlugin);
303
+ }
304
+ preset.add([codeBidiWarningPlugin, {
305
+ appearance
306
+ }]);
307
+ if (featureFlags.floatingToolbarCopyButton) {
308
+ preset.add(copyButtonPlugin);
309
+ }
310
+ return preset;
311
+ }
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import React from 'react';
2
3
  import HyperlinkToolbar from '../../hyperlink/ui/HyperlinkAddToolbar';
3
4
  import { showLinkToolbar, hideLinkToolbar } from '../pm-plugins/actions';
@@ -7,7 +8,17 @@ import { changeSelectedCardToLink, updateCard } from '../pm-plugins/doc';
7
8
  import { findCardInfo, displayInfoForCard } from '../utils';
8
9
  import { NodeSelection } from 'prosemirror-state';
9
10
  import { buildEditLinkPayload } from '../../../utils/linking-utils';
11
+ import { forceFocusSelector } from '../../floating-toolbar/pm-plugins/force-focus';
12
+ import { withOuterListeners } from '@atlaskit/editor-common/ui';
13
+ import { linkToolbarMessages } from '../../../messages';
14
+ const HyperLinkToolbarWithListeners = withOuterListeners(HyperlinkToolbar);
10
15
  export class EditLinkToolbar extends React.Component {
16
+ constructor(...args) {
17
+ super(...args);
18
+ _defineProperty(this, "handleEsc", e => {
19
+ forceFocusSelector(`[aria-label="${linkToolbarMessages.editLink.defaultMessage}"]`, this.props.view);
20
+ });
21
+ }
11
22
  componentDidUpdate(prevProps) {
12
23
  if (prevProps.node !== this.props.node) {
13
24
  this.hideLinkToolbar();
@@ -16,6 +27,11 @@ export class EditLinkToolbar extends React.Component {
16
27
  componentWillUnmount() {
17
28
  this.hideLinkToolbar();
18
29
  }
30
+
31
+ /** Focus should move to the 'Edit link' button when the toolbar closes
32
+ * and not close the floating toolbar.
33
+ */
34
+
19
35
  hideLinkToolbar() {
20
36
  const {
21
37
  view
@@ -31,12 +47,13 @@ export class EditLinkToolbar extends React.Component {
31
47
  view,
32
48
  onSubmit
33
49
  } = this.props;
34
- return /*#__PURE__*/React.createElement(HyperlinkToolbar, {
50
+ return /*#__PURE__*/React.createElement(HyperLinkToolbarWithListeners, {
35
51
  view: view,
36
52
  linkPickerOptions: linkPickerOptions,
37
53
  providerFactory: providerFactory,
38
54
  displayUrl: url,
39
- displayText: text
55
+ displayText: text,
56
+ handleEscapeKeydown: this.handleEsc
40
57
  // Assumes that the smart card link picker can only ever be invoked by clicking "edit"
41
58
  // via the floating toolbar
42
59
  ,
@@ -21,6 +21,7 @@ import { findNode } from './utils';
21
21
  import { ErrorBoundary } from '../../ui/ErrorBoundary';
22
22
  import { getFeatureFlags } from '../feature-flags-context';
23
23
  import { processCopyButtonItems } from '../copy-button/toolbar';
24
+ import forceFocusPlugin from './pm-plugins/force-focus';
24
25
  export const getRelevantConfig = (selection, configs) => {
25
26
  // node selections always take precedence, see if
26
27
  let configPair;
@@ -133,6 +134,9 @@ const floatingToolbarPlugin = () => ({
133
134
  plugin: ({
134
135
  dispatch
135
136
  }) => floatingToolbarDataPluginFactory(dispatch)
137
+ }, {
138
+ name: 'forceFocus',
139
+ plugin: () => forceFocusPlugin()
136
140
  }];
137
141
  },
138
142
  contentComponent({
@@ -0,0 +1,59 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from 'prosemirror-state';
3
+ export const forceFocusStateKey = new PluginKey('forceFocusStatePlugin');
4
+ /**
5
+ * Used in cases where a floating toolbar button opens a submenu which destroys
6
+ * the button, but the user has pressed ESC to close the submenu and focus needs
7
+ * to move back to the button. */
8
+ export default (() => new SafePlugin({
9
+ key: forceFocusStateKey,
10
+ state: {
11
+ init: () => ({
12
+ selector: null
13
+ }),
14
+ apply: (tr, prevState) => {
15
+ const meta = tr.getMeta(forceFocusStateKey);
16
+ if (meta && 'selector' in meta) {
17
+ return {
18
+ selector: meta.selector
19
+ };
20
+ }
21
+ return prevState;
22
+ }
23
+ }
24
+ }));
25
+
26
+ /**
27
+ * The provided selector should be the floating toolbar button that needs focus.
28
+ */
29
+ export function forceFocusSelector(selector, view) {
30
+ if (view) {
31
+ return view.dispatch(view.state.tr.setMeta(forceFocusStateKey, {
32
+ selector
33
+ }));
34
+ }
35
+ }
36
+
37
+ /**
38
+ * If a selector is set and the element exists, focus it.
39
+ */
40
+ export function checkShouldForceFocusAndApply(view) {
41
+ const state = view === null || view === void 0 ? void 0 : view.state;
42
+ if (state) {
43
+ const {
44
+ selector
45
+ } = forceFocusStateKey.getState(state);
46
+ if (selector) {
47
+ const focusableElement = document.querySelector(selector);
48
+ if (focusableElement) {
49
+ focusableElement.scrollIntoView({
50
+ behavior: 'smooth',
51
+ block: 'center',
52
+ inline: 'nearest'
53
+ });
54
+ focusableElement.focus();
55
+ forceFocusSelector(null, view);
56
+ }
57
+ }
58
+ }
59
+ }
@@ -23,8 +23,10 @@ import Announcer from '../../../utils/announcer/announcer';
23
23
  import { injectIntl } from 'react-intl-next';
24
24
  import messages from './messages';
25
25
  import { decorationStateKey, ACTIONS } from '../../base/pm-plugins/decoration';
26
+ import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
26
27
  import ScrollButtons from './ScrollButtons';
27
28
  import { ToolbarArrowKeyNavigationProvider } from '../../../ui/ToolbarArrowKeyNavigationProvider';
29
+ import { checkShouldForceFocusAndApply, forceFocusSelector } from '../pm-plugins/force-focus';
28
30
  const akGridSize = gridSize();
29
31
  const ToolbarItems = /*#__PURE__*/React.memo(({
30
32
  items,
@@ -336,10 +338,8 @@ class Toolbar extends Component {
336
338
  state,
337
339
  dispatch
338
340
  } = this.props.editorView;
339
- // tables use their own decorations
340
- // TODO fix for tables https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-617
341
341
  if (table) {
342
- return null;
342
+ return clearHoverSelection()(state, dispatch);
343
343
  }
344
344
  dispatch(state.tr.setMeta(decorationStateKey, {
345
345
  action: ACTIONS.DECORATION_REMOVE
@@ -366,6 +366,8 @@ class Toolbar extends Component {
366
366
  });
367
367
  }
368
368
  componentDidUpdate(prevProps) {
369
+ var _this$props;
370
+ checkShouldForceFocusAndApply((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.editorView);
369
371
  if (this.props.node !== prevProps.node) {
370
372
  this.resetStyling({
371
373
  table: (prevProps === null || prevProps === void 0 ? void 0 : prevProps.node.type.name) === 'table'
@@ -373,6 +375,7 @@ class Toolbar extends Component {
373
375
  }
374
376
  }
375
377
  componentWillUnmount() {
378
+ forceFocusSelector(null, this.props.editorView);
376
379
  this.resetStyling({
377
380
  table: this.props.node.type.name === 'table'
378
381
  });
@@ -10,7 +10,9 @@ export const BlockInsertElementBrowser = props => {
10
10
  offset: [0, 3],
11
11
  mountTo: props.popupsMountPoint,
12
12
  boundariesElement: props.popupsBoundariesElement,
13
- scrollableElement: props.popupsScrollableElement
13
+ scrollableElement: props.popupsScrollableElement,
14
+ preventOverflow: true,
15
+ alignX: "right"
14
16
  }, /*#__PURE__*/React.createElement(InsertMenu, {
15
17
  editorView: props.editorView,
16
18
  dropdownItems: props.items,
@@ -459,7 +459,8 @@ export class ToolbarInsertBlock extends React.PureComponent {
459
459
  var _this$props$isDisable, _this$props$replacePl;
460
460
  const {
461
461
  buttons,
462
- dropdownItems
462
+ dropdownItems,
463
+ emojiPickerOpen
463
464
  } = this.state;
464
465
  const {
465
466
  isDisabled,
@@ -478,7 +479,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
478
479
  spacing: isReducedSpacing ? 'none' : 'default',
479
480
  disabled: isDisabled || btn.isDisabled,
480
481
  iconBefore: btn.elemBefore,
481
- selected: btn.isActive,
482
+ selected: btn.value.name === 'emoji' && emojiPickerOpen || btn.isActive,
482
483
  title: btn.title,
483
484
  "aria-label": btn['aria-label'],
484
485
  "aria-haspopup": btn['aria-haspopup'],
@@ -7,6 +7,8 @@ import { findFirstParentListItemNode, findRootParentListNode } from '../utils/fi
7
7
  import { normalizeListItemsSelection, createListNodeRange } from '../utils/selection';
8
8
  import { GapCursorSelection } from '../../selection/gap-cursor-selection';
9
9
  import { getFeatureFlags } from '../../feature-flags-context';
10
+ import { storeRestartListsAttributes, getRestartListsAttributes } from '../utils/analytics';
11
+ import { OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
10
12
  export const outdentListItemsSelected = (tr, state) => {
11
13
  const originalSelection = tr.selection;
12
14
  const normalizedSelection = normalizeListItemsSelection({
@@ -199,22 +201,55 @@ const extractListItemsRangeFromList = ({
199
201
  }
200
202
  let nextList = list.copy(Fragment.empty);
201
203
  const featureFlags = getFeatureFlags(state);
204
+ let nextListStartNumber;
202
205
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
203
206
  // if splitting a numbered list, keep the splitted item
204
207
  // counter as the start of the next (second half) list (instead
205
208
  // of reverting back to 1 as a starting number)
206
209
  const order = getOrderFromOrderedListNode(list);
207
210
  if (list.type.name === 'orderedList') {
211
+ nextListStartNumber = range.endIndex - 1 + order;
208
212
  nextList.attrs = {
209
213
  ...nextList.attrs,
210
- order: range.endIndex - 1 + order
214
+ order: nextListStartNumber
211
215
  };
216
+ const {
217
+ splitListStartNumber
218
+ } = getRestartListsAttributes(tr);
219
+ if (typeof splitListStartNumber !== 'number') {
220
+ storeRestartListsAttributes(tr, {
221
+ splitListStartNumber: nextListStartNumber
222
+ });
223
+ }
212
224
  }
213
225
  }
214
226
  const nextListFragment = listItemContent.append(Fragment.from(nextList));
227
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
228
+ // if the split list with nextListStartNumber is below another list
229
+ // with order (e.g due to multi-level indent items being lifted), track the
230
+ // list above's order instead, as it will be the split list's order after sibling joins
231
+ nextListFragment.forEach((node, _offset, index) => {
232
+ var _node$attrs;
233
+ if (node.type.name === 'orderedList' && ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order) === nextListStartNumber) {
234
+ var _prev$attrs;
235
+ const prev = nextListFragment.child(index - 1);
236
+ if ((prev === null || prev === void 0 ? void 0 : (_prev$attrs = prev.attrs) === null || _prev$attrs === void 0 ? void 0 : _prev$attrs.order) >= 0) {
237
+ var _prev$attrs2;
238
+ storeRestartListsAttributes(tr, {
239
+ splitListStartNumber: prev === null || prev === void 0 ? void 0 : (_prev$attrs2 = prev.attrs) === null || _prev$attrs2 === void 0 ? void 0 : _prev$attrs2.order
240
+ });
241
+ }
242
+ }
243
+ });
244
+ }
215
245
  if (isTheEntireList) {
216
246
  const slice = new Slice(listItemContent, 0, 0);
217
247
  const step = new ReplaceStep($start.pos - 1, range.end + 1, slice, false);
248
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
249
+ storeRestartListsAttributes(tr, {
250
+ outdentScenario: undefined
251
+ });
252
+ }
218
253
  tr.step(step);
219
254
  } else if (isAtTop) {
220
255
  const slice = new Slice(nextListFragment, 0, 1);
@@ -225,6 +260,11 @@ const extractListItemsRangeFromList = ({
225
260
  const step = new ReplaceStep($start.pos, listEnd + 1, slice, false);
226
261
  tr.step(step);
227
262
  } else {
263
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
264
+ storeRestartListsAttributes(tr, {
265
+ outdentScenario: OUTDENT_SCENARIOS.SPLIT_LIST
266
+ });
267
+ }
228
268
  const slice = new Slice(nextListFragment, 1, 1);
229
269
  const step = new ReplaceAroundStep($start.pos, listEnd, range.end, listEnd, slice, slice.size, false);
230
270
  tr.step(step);
@@ -1,10 +1,12 @@
1
+ import { OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
1
2
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../analytics';
2
3
  import { isInsideListItem, isInsideTableCell } from '../utils/selection';
3
4
  import { isBulletList } from '../utils/node';
4
5
  import { findFirstParentListNode } from '../utils/find';
5
- import { getCommonListAnalyticsAttributes } from '../utils/analytics';
6
+ import { getCommonListAnalyticsAttributes, getRestartListsAttributes } from '../utils/analytics';
6
7
  import { outdentListItemsSelected as outdentListAction } from '../actions/outdent-list-items-selected';
7
8
  import { closeHistory } from 'prosemirror-history';
9
+ import { getFeatureFlags } from '../../feature-flags-context';
8
10
  export function outdentList(inputMethod = INPUT_METHOD.KEYBOARD) {
9
11
  return function (state, dispatch) {
10
12
  if (!isInsideListItem(state)) {
@@ -29,6 +31,18 @@ export function outdentList(inputMethod = INPUT_METHOD.KEYBOARD) {
29
31
  // If inside table cell and can't outdent list, then let it handle by table keymap
30
32
  return !isInsideTableCell(state);
31
33
  }
34
+ const featureFlags = getFeatureFlags(state);
35
+ const restartListsAttributes = {};
36
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
37
+ const {
38
+ outdentScenario,
39
+ splitListStartNumber
40
+ } = getRestartListsAttributes(customTr);
41
+ if (outdentScenario === OUTDENT_SCENARIOS.SPLIT_LIST) {
42
+ restartListsAttributes.outdentScenario = outdentScenario;
43
+ restartListsAttributes.splitListStartNumber = splitListStartNumber;
44
+ }
45
+ }
32
46
  addAnalytics(state, customTr, {
33
47
  action: ACTION.OUTDENTED,
34
48
  actionSubject: ACTION_SUBJECT.LIST,
@@ -36,6 +50,7 @@ export function outdentList(inputMethod = INPUT_METHOD.KEYBOARD) {
36
50
  eventType: EVENT_TYPE.TRACK,
37
51
  attributes: {
38
52
  ...getCommonListAnalyticsAttributes(state),
53
+ ...restartListsAttributes,
39
54
  inputMethod
40
55
  }
41
56
  });