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