@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
@@ -1,11 +1,7 @@
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';
1
+ import createUniversalPreset from '../labs/next/presets/universal';
4
2
  import { GUTTER_SIZE_MOBILE_IN_PX } from '../plugins/base/pm-plugins/scroll-gutter';
5
- import { createFeatureFlagsFromProps } from '../plugins/feature-flags-context/feature-flags-from-props';
6
- import { getMediaFeatureFlag } from '@atlaskit/media-common';
7
- import { createDefaultPreset } from '../labs/next/presets/default';
8
- import { shouldForceTracking } from '@atlaskit/editor-common/utils';
3
+ import { isFullPage as fullPageCheck } from '../utils/is-full-page';
4
+ import { createFeatureFlagsFromProps } from './feature-flags-from-props';
9
5
  const isCodeBlockAllowed = options => {
10
6
  const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
11
7
  return exclude.indexOf('codeBlock') === -1;
@@ -39,6 +35,7 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
39
35
  const inputTracking = (_props$performanceTra = props.performanceTracking) === null || _props$performanceTra === void 0 ? void 0 : _props$performanceTra.inputTracking;
40
36
  const cardOptions = ((_props$linking = props.linking) === null || _props$linking === void 0 ? void 0 : _props$linking.smartLinks) || props.smartLinks || props.UNSAFE_cards;
41
37
  return {
38
+ ...props,
42
39
  createAnalyticsEvent,
43
40
  typeAhead: {
44
41
  createAnalyticsEvent,
@@ -103,292 +100,7 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
103
100
  * their placement in the editor toolbar
104
101
  */
105
102
  export default function createPluginsList(props, prevProps, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI, getEditorContainerWidth) {
106
- var _props$linking3;
107
- const appearance = props.appearance;
108
- const isMobile = appearance === 'mobile';
109
- const isComment = appearance === 'comment';
110
- const isFullPage = fullPageCheck(appearance);
111
- const preset = createDefaultPreset(getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent));
112
- const featureFlags = createFeatureFlagsFromProps(props);
113
- const getEditorFeatureFlags = () => featureFlags;
114
- if (props.allowAnalyticsGASV3) {
115
- const {
116
- performanceTracking
117
- } = props;
118
- preset.add([analyticsPlugin, {
119
- createAnalyticsEvent,
120
- performanceTracking
121
- }]);
122
- }
123
- if (props.allowBreakout && isFullPage) {
124
- preset.add([breakoutPlugin, {
125
- allowBreakoutButton: props.appearance === 'full-page'
126
- }]);
127
- }
128
- if (props.allowTextAlignment) {
129
- preset.add(alignmentPlugin);
130
- }
131
- preset.add(dataConsumerMarkPlugin);
132
- if (props.allowTextColor) {
133
- preset.add([textColorPlugin, props.allowTextColor]);
134
- }
135
-
136
- // Needs to be after allowTextColor as order of buttons in toolbar depends on it
137
- preset.add([listPlugin, {
138
- restartNumberedLists: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.restartNumberedLists,
139
- restartNumberedListsToolbar: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.restartNumberedListsToolbar,
140
- listNumberContinuity: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.listNumberContinuity
141
- }]);
142
- if (props.allowRule) {
143
- preset.add(rulePlugin);
144
- }
145
- if (props.allowExpand) {
146
- preset.add([expandPlugin, {
147
- allowInsertion: isExpandInsertionEnabled(props),
148
- useLongPressSelection: false,
149
- appearance: props.appearance
150
- }]);
151
- }
152
- if (props.media) {
153
- preset.add([gridPlugin, {
154
- shouldCalcBreakoutGridLines: isFullPage
155
- }]);
156
- const alignLeftOnInsert = typeof props.media.alignLeftOnInsert !== 'undefined' ? props.media.alignLeftOnInsert : isComment;
157
- const showMediaLayoutOptions = typeof props.media.allowAdvancedToolBarOptions !== 'undefined' ? props.media.allowAdvancedToolBarOptions : isFullPage || isComment;
158
- preset.add([mediaPlugin, {
159
- ...props.media,
160
- allowLazyLoading: !isMobile,
161
- allowBreakoutSnapPoints: isFullPage,
162
- allowAdvancedToolBarOptions: showMediaLayoutOptions,
163
- allowDropzoneDropLine: isFullPage,
164
- allowMediaSingleEditable: !isMobile,
165
- allowRemoteDimensionsFetch: !isMobile,
166
- editorSelectionAPI,
167
- // This is a wild one. I didnt quite understand what the code was doing
168
- // so a bit of guess for now.
169
- allowMarkingUploadsAsIncomplete: isMobile,
170
- fullWidthEnabled: props.appearance === 'full-width',
171
- uploadErrorHandler: props.uploadErrorHandler,
172
- waitForMediaUpload: props.waitForMediaUpload,
173
- isCopyPasteEnabled: !isMobile,
174
- alignLeftOnInsert
175
- }]);
176
-
177
- // EDM-799: inside caption plugin we do the feature flag in enabling the plugin
178
- if (getMediaFeatureFlag('captions', props.media.featureFlags)) {
179
- preset.add(captionPlugin);
180
- }
181
- }
182
- if (props.mentionProvider) {
183
- var _props$mention$insert, _props$mention, _props$mention2;
184
- preset.add([mentionsPlugin, {
185
- createAnalyticsEvent,
186
- sanitizePrivateContent: props.sanitizePrivateContent,
187
- 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,
188
- allowZeroWidthSpaceAfter: !isMobile,
189
- HighlightComponent: (_props$mention2 = props.mention) === null || _props$mention2 === void 0 ? void 0 : _props$mention2.HighlightComponent
190
- }]);
191
- }
192
- if (props.emojiProvider) {
193
- preset.add([emojiPlugin, {
194
- createAnalyticsEvent
195
- }]);
196
- }
197
- if (props.allowTables) {
198
- const tableOptions = !props.allowTables || typeof props.allowTables === 'boolean' ? {} : props.allowTables;
199
- preset.add([tablesPlugin, {
200
- tableOptions,
201
- breakoutEnabled: props.appearance === 'full-page',
202
- allowContextualMenu: !isMobile,
203
- fullWidthEnabled: props.appearance === 'full-width',
204
- wasFullWidthEnabled: prevProps && prevProps.appearance === 'full-width',
205
- editorAnalyticsAPI,
206
- editorSelectionAPI,
207
- getEditorFeatureFlags
208
- }]);
209
- }
210
- if (props.allowTasksAndDecisions || props.taskDecisionProvider) {
211
- preset.add([tasksAndDecisionsPlugin, {
212
- allowNestedTasks: props.allowNestedTasks,
213
- consumeTabs: isFullPage,
214
- useLongPressSelection: false
215
- }]);
216
- }
217
- if (props.feedbackInfo) {
218
- preset.add([feedbackDialogPlugin, props.feedbackInfo]);
219
- }
220
- if (props.allowHelpDialog) {
221
- preset.add([helpDialogPlugin, !!props.legacyImageUploadProvider]);
222
- }
223
- if (props.saveOnEnter && props.onSave) {
224
- preset.add([saveOnEnterPlugin, props.onSave]);
225
- }
226
- if (props.legacyImageUploadProvider) {
227
- preset.add(imageUploadPlugin);
228
- if (!props.media) {
229
- preset.add([mediaPlugin, {
230
- allowMediaSingle: {
231
- disableLayout: true
232
- },
233
- allowMediaGroup: false,
234
- isCopyPasteEnabled: true,
235
- editorSelectionAPI
236
- }]);
237
- }
238
- }
239
- if (props.collabEdit || props.collabEditProvider) {
240
- var _collabEditOptions$EX;
241
- let collabEditOptions = {
242
- sanitizePrivateContent: props.sanitizePrivateContent,
243
- createAnalyticsEvent
244
- };
245
- if (props.collabEdit) {
246
- collabEditOptions = {
247
- ...props.collabEdit,
248
- ...collabEditOptions
249
- };
250
- }
251
- preset.add([collabEditPlugin, {
252
- ...collabEditOptions,
253
- EXPERIMENTAL_allowInternalErrorAnalytics: (_collabEditOptions$EX = collabEditOptions.EXPERIMENTAL_allowInternalErrorAnalytics) !== null && _collabEditOptions$EX !== void 0 ? _collabEditOptions$EX : shouldForceTracking()
254
- }]);
255
- }
256
- if (props.maxContentSize) {
257
- preset.add([maxContentSizePlugin, props.maxContentSize]);
258
- }
259
- if (props.allowJiraIssue) {
260
- preset.add(jiraIssuePlugin);
261
- }
262
- if (props.allowPanel) {
263
- preset.add([panelPlugin, {
264
- useLongPressSelection: false,
265
- allowCustomPanel: props.allowPanel.allowCustomPanel,
266
- allowCustomPanelEdit: props.allowPanel.allowCustomPanelEdit
267
- }]);
268
- }
269
- if (props.allowExtension) {
270
- const extensionConfig = typeof props.allowExtension === 'object' ? props.allowExtension : {};
271
- preset.add([extensionPlugin, {
272
- breakoutEnabled: props.appearance === 'full-page' && extensionConfig.allowBreakout !== false,
273
- allowAutoSave: extensionConfig.allowAutoSave,
274
- extensionHandlers: props.extensionHandlers,
275
- useLongPressSelection: false,
276
- appearance
277
- }]);
278
- }
279
- if (props.macroProvider) {
280
- preset.add(macroPlugin);
281
- }
282
-
283
- // See default list for when adding annotations with a provider
284
- if (!props.annotationProviders && props.allowConfluenceInlineComment) {
285
- preset.add([annotationPlugin, undefined]);
286
- }
287
- if (props.allowDate) {
288
- preset.add(datePlugin);
289
- }
290
- if (props.allowTemplatePlaceholders) {
291
- const options = props.allowTemplatePlaceholders !== true ? props.allowTemplatePlaceholders : {};
292
- preset.add([placeholderTextPlugin, options]);
293
- }
294
- if (props.allowLayouts) {
295
- preset.add([layoutPlugin, {
296
- ...(typeof props.allowLayouts === 'boolean' ? {} : props.allowLayouts),
297
- useLongPressSelection: false,
298
- UNSAFE_allowSingleColumnLayout: props.allowLayouts.UNSAFE_allowSingleColumnLayout
299
- }]);
300
- }
301
- if ((_props$linking3 = props.linking) !== null && _props$linking3 !== void 0 && _props$linking3.smartLinks || props.smartLinks || props.UNSAFE_cards) {
302
- var _props$linking4, _props$linking5;
303
- const fullWidthMode = props.appearance === 'full-width';
304
- preset.add([cardPlugin, {
305
- ...props.UNSAFE_cards,
306
- ...props.smartLinks,
307
- ...((_props$linking4 = props.linking) === null || _props$linking4 === void 0 ? void 0 : _props$linking4.smartLinks),
308
- platform: isMobile ? 'mobile' : 'web',
309
- fullWidthMode,
310
- createAnalyticsEvent,
311
- linkPicker: (_props$linking5 = props.linking) === null || _props$linking5 === void 0 ? void 0 : _props$linking5.linkPicker
312
- }]);
313
- }
314
- if (props.autoformattingProvider) {
315
- preset.add(customAutoformatPlugin);
316
- }
317
- let statusMenuDisabled = true;
318
- if (props.allowStatus) {
319
- statusMenuDisabled = typeof props.allowStatus === 'object' ? props.allowStatus.menuDisabled : false;
320
- preset.add([statusPlugin, {
321
- menuDisabled: statusMenuDisabled,
322
- allowZeroWidthSpaceAfter: !isMobile
323
- }]);
324
- }
325
- if (props.allowIndentation) {
326
- preset.add(indentationPlugin);
327
- }
328
- if (isFullPage) {
329
- preset.add(contextPanelPlugin);
330
- }
331
- if (props.autoScrollIntoView !== false) {
332
- preset.add(scrollIntoViewPlugin);
333
- }
334
- if (isMobile || props.allowUndoRedoButtons) {
335
- preset.add(historyPlugin);
336
- }
337
- if (isMobile) {
338
- preset.add(mobileDimensionsPlugin);
339
- preset.add(mobileSelectionPlugin);
340
- }
341
-
342
- // UI only plugins
343
- preset.add([toolbarListsIndentationPlugin, {
344
- showIndentationButtons: !!featureFlags.indentationButtonsInTheToolbar,
345
- allowHeadingAndParagraphIndentation: !!props.allowIndentation
346
- }]);
347
- preset.add([insertBlockPlugin, {
348
- allowTables: !!props.allowTables,
349
- allowExpand: isExpandInsertionEnabled(props),
350
- insertMenuItems: props.insertMenuItems,
351
- horizontalRuleEnabled: props.allowRule,
352
- nativeStatusSupported: !statusMenuDisabled,
353
- showElementBrowserLink: props.elementBrowser && props.elementBrowser.showModal || false,
354
- replacePlusMenuWithElementBrowser: props.elementBrowser && props.elementBrowser.replacePlusMenu || false,
355
- insertNodeAPI
356
- }]);
357
- const hasBeforePrimaryToolbar = components => {
358
- if (components && 'before' in components) {
359
- return !!components.before;
360
- }
361
- return false;
362
- };
363
- if (hasBeforePrimaryToolbar(props.primaryToolbarComponents) && !featureFlags.twoLineEditorToolbar) {
364
- preset.add([beforePrimaryToolbarPlugin, {
365
- beforePrimaryToolbarComponents: props.primaryToolbarComponents.before
366
- }]);
367
- }
368
- if (featureFlags.showAvatarGroupAsPlugin === true && !featureFlags.twoLineEditorToolbar) {
369
- preset.add([avatarGroupPlugin, {
370
- collabEdit: props.collabEdit,
371
- takeFullWidth: !hasBeforePrimaryToolbar(props.primaryToolbarComponents)
372
- }]);
373
- }
374
- if (props.allowFindReplace) {
375
- preset.add([findReplacePlugin, {
376
- takeFullWidth: !!featureFlags.showAvatarGroupAsPlugin === false && !hasBeforePrimaryToolbar(props.primaryToolbarComponents),
377
- twoLineEditorToolbar: !!featureFlags.twoLineEditorToolbar
378
- }]);
379
- }
380
- if (props.allowFragmentMark) {
381
- preset.add(fragmentMarkPlugin);
382
- }
383
- if (featureFlags.enableViewUpdateSubscription) {
384
- preset.add(viewUpdateSubscriptionPlugin);
385
- }
386
- preset.add([codeBidiWarningPlugin, {
387
- appearance: props.appearance
388
- }]);
389
- if (featureFlags.floatingToolbarCopyButton) {
390
- preset.add(copyButtonPlugin);
391
- }
103
+ const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI, getEditorContainerWidth);
392
104
  const excludes = new Set();
393
105
  if (!isCodeBlockAllowed({
394
106
  allowBlockType: props.allowBlockType
@@ -21,10 +21,10 @@ import { PortalProviderWithThemeProviders, PortalRenderer } from './ui/PortalPro
21
21
  import { nextMajorVersion } from './version-wrapper';
22
22
  import { ContextAdapter } from './nodeviews/context-adapter';
23
23
  import measurements from './utils/performance/measure-enum';
24
- import { combineQuickInsertProviders, extensionProviderToQuickInsertProvider } from './utils/extensions';
24
+ import prepareQuickInsertProvider from './utils/prepare-quick-insert-provider';
25
25
  import { fireAnalyticsEvent, EVENT_TYPE, ACTION_SUBJECT, ACTION } from './plugins/analytics';
26
26
  import ErrorBoundary from './create-editor/ErrorBoundary';
27
- import { createFeatureFlagsFromProps } from './plugins/feature-flags-context/feature-flags-from-props';
27
+ import { createFeatureFlagsFromProps } from './create-editor/feature-flags-from-props';
28
28
  import { RenderTracking } from './utils/performance/components/RenderTracking';
29
29
  const fullHeight = css`
30
30
  height: 100%;
@@ -43,9 +43,7 @@ export default class Editor extends React.Component {
43
43
  return combineExtensionProviders(extensionProviders);
44
44
  }));
45
45
  _defineProperty(this, "prepareQuickInsertProvider", (extensionProvider, quickInsert) => {
46
- const quickInsertProvider = quickInsert && typeof quickInsert !== 'boolean' && quickInsert.provider;
47
- const extensionQuickInsertProvider = extensionProvider && extensionProviderToQuickInsertProvider(extensionProvider, this.editorActions, this.createAnalyticsEvent);
48
- return quickInsertProvider && extensionQuickInsertProvider ? combineQuickInsertProviders([quickInsertProvider, extensionQuickInsertProvider]) : quickInsertProvider || extensionQuickInsertProvider;
46
+ return prepareQuickInsertProvider(this.editorActions, extensionProvider, quickInsert, this.createAnalyticsEvent);
49
47
  });
50
48
  _defineProperty(this, "handleSave", view => {
51
49
  if (!this.props.onSave) {
@@ -105,10 +103,10 @@ export default class Editor extends React.Component {
105
103
  }, (_props$performanceTra5 = props.performanceTracking) === null || _props$performanceTra5 === void 0 ? void 0 : (_props$performanceTra6 = _props$performanceTra5.ttiTracking) === null || _props$performanceTra6 === void 0 ? void 0 : _props$performanceTra6.ttiIdleThreshold, (_props$performanceTra7 = props.performanceTracking) === null || _props$performanceTra7 === void 0 ? void 0 : (_props$performanceTra8 = _props$performanceTra7.ttiTracking) === null || _props$performanceTra8 === void 0 ? void 0 : _props$performanceTra8.ttiCancelTimeout);
106
104
  }
107
105
  const _extensionProvider = this.prepareExtensionProvider(props.extensionProviders);
108
- const _quickInsertProvider = this.prepareQuickInsertProvider(_extensionProvider, props.quickInsert);
106
+ const quickInsertProvider = this.prepareQuickInsertProvider(_extensionProvider, props.quickInsert);
109
107
  this.state = {
110
108
  extensionProvider: _extensionProvider,
111
- quickInsertProvider: _quickInsertProvider
109
+ quickInsertProvider
112
110
  };
113
111
  }
114
112
  componentDidMount() {
@@ -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
+ }