@atlaskit/editor-core 188.12.1 → 188.12.3

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 (57) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/create-editor/sort-by-order.js +13 -20
  3. package/dist/cjs/plugins/annotation/utils.js +23 -43
  4. package/dist/cjs/plugins/code-block/utils.js +18 -43
  5. package/dist/cjs/plugins/paste/handlers.js +36 -18
  6. package/dist/cjs/plugins/paste/plugins/media.js +50 -24
  7. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +6 -6
  8. package/dist/cjs/plugins/paste/pm-plugins/main.js +53 -51
  9. package/dist/cjs/plugins/paste/util/index.js +2 -2
  10. package/dist/cjs/plugins/rank.js +2 -27
  11. package/dist/cjs/plugins/tasks-and-decisions/utils.js +8 -12
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/es2019/create-editor/sort-by-order.js +1 -17
  14. package/dist/es2019/plugins/annotation/utils.js +6 -43
  15. package/dist/es2019/plugins/code-block/utils.js +1 -44
  16. package/dist/es2019/plugins/paste/handlers.js +18 -3
  17. package/dist/es2019/plugins/paste/plugins/media.js +53 -25
  18. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +3 -3
  19. package/dist/es2019/plugins/paste/pm-plugins/main.js +11 -13
  20. package/dist/es2019/plugins/paste/util/index.js +1 -1
  21. package/dist/es2019/plugins/rank.js +2 -27
  22. package/dist/es2019/plugins/tasks-and-decisions/utils.js +2 -12
  23. package/dist/es2019/version-wrapper.js +1 -1
  24. package/dist/esm/create-editor/sort-by-order.js +1 -17
  25. package/dist/esm/plugins/annotation/utils.js +8 -37
  26. package/dist/esm/plugins/code-block/utils.js +1 -42
  27. package/dist/esm/plugins/paste/handlers.js +23 -3
  28. package/dist/esm/plugins/paste/plugins/media.js +50 -23
  29. package/dist/esm/plugins/paste/pm-plugins/analytics.js +3 -3
  30. package/dist/esm/plugins/paste/pm-plugins/main.js +11 -13
  31. package/dist/esm/plugins/paste/util/index.js +1 -1
  32. package/dist/esm/plugins/rank.js +2 -27
  33. package/dist/esm/plugins/tasks-and-decisions/utils.js +2 -12
  34. package/dist/esm/version-wrapper.js +1 -1
  35. package/dist/types/create-editor/sort-by-order.d.ts +1 -14
  36. package/dist/types/plugins/annotation/utils.d.ts +3 -3
  37. package/dist/types/plugins/code-block/utils.d.ts +1 -6
  38. package/dist/types/plugins/paste/handlers.d.ts +2 -2
  39. package/dist/types/plugins/paste/plugins/media.d.ts +11 -0
  40. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +1 -1
  41. package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -2
  42. package/dist/types/plugins/rank.d.ts +2 -6
  43. package/dist/types/plugins/tasks-and-decisions/utils.d.ts +2 -3
  44. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  45. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  46. package/dist/types-ts4.5/create-editor/sort-by-order.d.ts +1 -14
  47. package/dist/types-ts4.5/plugins/annotation/utils.d.ts +3 -3
  48. package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -6
  49. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -2
  50. package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +11 -0
  51. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +1 -1
  52. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -2
  53. package/dist/types-ts4.5/plugins/rank.d.ts +2 -6
  54. package/dist/types-ts4.5/plugins/tasks-and-decisions/utils.d.ts +2 -3
  55. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  56. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  57. package/package.json +2 -2
@@ -18,27 +18,28 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
18
18
  var _uuid = _interopRequireDefault(require("uuid"));
19
19
  var _editorMarkdownTransformer = require("@atlaskit/editor-markdown-transformer");
20
20
  var _card = require("@atlaskit/editor-common/card");
21
- var _slice = require("../../../utils/slice");
21
+ var _utils = require("@atlaskit/editor-common/utils");
22
+ var _utils2 = require("@atlaskit/editor-tables/utils");
22
23
  var _extensions = require("@atlaskit/editor-common/extensions");
24
+ var _analytics = require("@atlaskit/editor-common/analytics");
23
25
  var _paste = require("@atlaskit/editor-common/paste");
24
26
  var _media = require("../plugins/media");
25
27
  var _util = require("../util");
26
- var _utils = require("@atlaskit/editor-common/utils");
27
- var _utils2 = require("../../expand/utils");
28
+ var _transforms = require("@atlaskit/editor-common/transforms");
28
29
  var _handlers = require("../handlers");
29
- var _utils3 = require("../../code-block/utils");
30
- var _analytics = require("./analytics");
31
- var _analytics2 = require("../../analytics");
32
- var _utils4 = require("../../../utils");
30
+ var _analytics2 = require("./analytics");
31
+ var _analytics3 = require("../../analytics");
32
+ var _utils3 = require("../../../utils");
33
33
  var _commands = require("../commands");
34
- var _utils5 = require("../../tasks-and-decisions/utils");
35
- var _utils6 = require("../../annotation/utils");
34
+ var _utils4 = require("../../annotation/utils");
36
35
  var _clipboardTextSerializer = require("./clipboard-text-serializer");
37
36
  var _tinyMCE = require("../util/tinyMCE");
38
- var _utils7 = require("@atlaskit/editor-tables/utils");
39
- var _step = require("../../../utils/step");
40
37
  var _pluginFactory = require("./plugin-factory");
41
- var _utils8 = require("@atlaskit/editor-prosemirror/utils");
38
+ var _utils5 = require("@atlaskit/editor-prosemirror/utils");
39
+ // TODO: ED-20519 It requires full analytics extraction to use the plugin injection API
40
+
41
+ // TODO: ED-20519 It requires annotation extraction to use the plugin injection API
42
+
42
43
  function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
43
44
  var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _paste.md);
44
45
  function getMarkdownSlice(text, openStart, openEnd) {
@@ -157,16 +158,16 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
157
158
  event.stopPropagation();
158
159
  }
159
160
  var state = view.state;
160
- var analyticsPlugin = _analytics2.analyticsPluginKey.getState(state);
161
+ var analyticsPlugin = _analytics3.analyticsPluginKey.getState(state);
161
162
  var pasteTrackingEnabled = analyticsPlugin === null || analyticsPlugin === void 0 || (_analyticsPlugin$perf = analyticsPlugin.performanceTracking) === null || _analyticsPlugin$perf === void 0 || (_analyticsPlugin$perf = _analyticsPlugin$perf.pasteTracking) === null || _analyticsPlugin$perf === void 0 ? void 0 : _analyticsPlugin$perf.enabled;
162
163
  if (pasteTrackingEnabled) {
163
- var content = (0, _analytics.getContentNodeTypes)(slice.content);
164
+ var content = (0, _analytics2.getContentNodeTypes)(slice.content);
164
165
  var pasteId = (0, _uuid.default)();
165
- var measureName = "".concat(_utils4.measurements.PASTE, "_").concat(pasteId);
166
+ var measureName = "".concat(_utils3.measurements.PASTE, "_").concat(pasteId);
166
167
  (0, _utils.measureRender)(measureName, function (_ref) {
167
168
  var duration = _ref.duration,
168
169
  distortedDuration = _ref.distortedDuration;
169
- var payload = (0, _analytics.createPasteMeasurePayload)({
170
+ var payload = (0, _analytics2.createPasteMeasurePayload)({
170
171
  view: view,
171
172
  duration: duration,
172
173
  content: content,
@@ -189,7 +190,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
189
190
  // Don't add closeHistory if we're pasting over layout columns, as we will appendTransaction
190
191
  // to cleanup the layout's structure and we want to keep the paste and re-structuring as
191
192
  // one event.
192
- var isPastingOverLayoutColumns = (0, _utils8.hasParentNodeOfType)(state.schema.nodes.layoutColumn)(state.selection);
193
+ var isPastingOverLayoutColumns = (0, _utils5.hasParentNodeOfType)(state.schema.nodes.layoutColumn)(state.selection);
193
194
 
194
195
  // don't add closeHistory call if we're pasting a table, as some tables may involve additional
195
196
  // appendedTransactions to repair them (if they're partial or incomplete) and we don't want
@@ -197,7 +198,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
197
198
  // "done" stack
198
199
  var isPastingTable = tr.steps.some(function (step) {
199
200
  var _slice$content;
200
- var slice = (0, _step.extractSliceFromStep)(step);
201
+ var slice = (0, _utils.extractSliceFromStep)(step);
201
202
  var tableExists = false;
202
203
  slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 || _slice$content.forEach(function (node) {
203
204
  if (node.type === state.schema.nodes.table) {
@@ -211,14 +212,14 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
211
212
  tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
212
213
  }
213
214
  (0, _card.addLinkMetadata)(view.state.selection, tr, {
214
- action: isPlainText ? _analytics2.ACTION.PASTED_AS_PLAIN : _analytics2.ACTION.PASTED,
215
- inputMethod: _analytics2.INPUT_METHOD.CLIPBOARD
215
+ action: isPlainText ? _analytics.ACTION.PASTED_AS_PLAIN : _analytics.ACTION.PASTED,
216
+ inputMethod: _analytics.INPUT_METHOD.CLIPBOARD
216
217
  });
217
218
  view.dispatch(tr);
218
219
  };
219
220
  slice = (0, _handlers.handleParagraphBlockMarks)(state, slice);
220
221
  var plainTextPasteSlice = (0, _utils.linkifyContent)(state.schema)(slice);
221
- if ((0, _analytics.handlePasteAsPlainTextWithAnalytics)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
222
+ if ((0, _analytics2.handlePasteAsPlainTextWithAnalytics)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
222
223
  return true;
223
224
  }
224
225
 
@@ -238,15 +239,15 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
238
239
  if (markdownSlice) {
239
240
  var _pluginInjectionApi$c;
240
241
  // linkify text prior to converting to macro
241
- if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, markdownSlice, _analytics2.PasteTypes.markdown)(state, dispatch)) {
242
+ if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, markdownSlice, _analytics.PasteTypes.markdown)(state, dispatch)) {
242
243
  return true;
243
244
  }
244
245
 
245
246
  // run macro autoconvert prior to other conversions
246
247
  if ((0, _handlers.handleMacroAutoConvert)(text, markdownSlice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
247
248
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
248
- (0, _analytics.sendPasteAnalyticsEvent)(view, event, markdownSlice, {
249
- type: _analytics2.PasteTypes.markdown
249
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, markdownSlice, {
250
+ type: _analytics.PasteTypes.markdown
250
251
  });
251
252
  return true;
252
253
  }
@@ -267,34 +268,34 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
267
268
  // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
268
269
  slice.openStart = 1;
269
270
  }
270
- if ((0, _analytics.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics2.PasteTypes.plain : _analytics2.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
271
+ if ((0, _analytics2.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics.PasteTypes.plain : _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
271
272
  return true;
272
273
  }
273
274
 
274
275
  // If we're in a code block, append the text contents of clipboard inside it
275
- if ((0, _analytics.handleCodeBlockWithAnalytics)(view, event, slice, text)(state, dispatch)) {
276
+ if ((0, _analytics2.handleCodeBlockWithAnalytics)(view, event, slice, text)(state, dispatch)) {
276
277
  return true;
277
278
  }
278
- if ((0, _analytics.handleMediaSingleWithAnalytics)(view, event, slice, isPastedFile ? _analytics2.PasteTypes.binary : _analytics2.PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.actions.insertMediaAsMediaSingle)(state, dispatch, view)) {
279
+ if ((0, _analytics2.handleMediaSingleWithAnalytics)(view, event, slice, isPastedFile ? _analytics.PasteTypes.binary : _analytics.PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.actions.insertMediaAsMediaSingle)(state, dispatch, view)) {
279
280
  return true;
280
281
  }
281
- if ((0, _analytics.handleSelectedTableWithAnalytics)(view, event, slice)(state, dispatch)) {
282
+ if ((0, _analytics2.handleSelectedTableWithAnalytics)(view, event, slice)(state, dispatch)) {
282
283
  return true;
283
284
  }
284
285
 
285
286
  // If the clipboard only contains plain text, attempt to parse it as Markdown
286
287
  if (isPlainText && markdownSlice) {
287
- if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _analytics2.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
288
+ if ((0, _analytics2.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _analytics.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
288
289
  return true;
289
290
  }
290
- return (0, _analytics.handleMarkdownWithAnalytics)(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
291
+ return (0, _analytics2.handleMarkdownWithAnalytics)(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
291
292
  }
292
- if (isRichText && (0, _utils4.isInsideBlockQuote)(state)) {
293
+ if (isRichText && (0, _utils3.isInsideBlockQuote)(state)) {
293
294
  //If pasting inside blockquote
294
295
  //Skip the blockquote node and keep remaining nodes as they are
295
296
  var blockquote = schema.nodes.blockquote;
296
297
  var children = [];
297
- (0, _slice.mapChildren)(slice.content, function (node) {
298
+ (0, _utils.mapChildren)(slice.content, function (node) {
298
299
  if (node.type === blockquote) {
299
300
  for (var i = 0; i < node.childCount; i++) {
300
301
  children.push(node.child(i));
@@ -311,36 +312,36 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
311
312
  var _pluginInjectionApi$c2, _pluginInjectionApi$l;
312
313
  // linkify the text where possible
313
314
  slice = (0, _utils.linkifyContent)(state.schema)(slice);
314
- if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText)(state, dispatch)) {
315
+ if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
315
316
  return true;
316
317
  }
317
318
 
318
319
  // run macro autoconvert prior to other conversions
319
320
  if ((0, _handlers.handleMacroAutoConvert)(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
320
321
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
321
- (0, _analytics.sendPasteAnalyticsEvent)(view, event, slice, {
322
- type: _analytics2.PasteTypes.richText
322
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, slice, {
323
+ type: _analytics.PasteTypes.richText
323
324
  });
324
325
  return true;
325
326
  }
326
327
 
327
328
  // get editor-tables to handle pasting tables if it can
328
329
  // otherwise, just the replace the selection with the content
329
- if ((0, _utils7.handlePaste)(view, null, slice)) {
330
- (0, _analytics.sendPasteAnalyticsEvent)(view, event, slice, {
331
- type: _analytics2.PasteTypes.richText
330
+ if ((0, _utils2.handlePaste)(view, null, slice)) {
331
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, slice, {
332
+ type: _analytics.PasteTypes.richText
332
333
  });
333
334
  return true;
334
335
  }
335
336
 
336
337
  // remove annotation marks from the pasted data if they are not present in the document
337
338
  // for the cases when they are pasted from external pages
338
- if (slice.content.size && (0, _utils6.containsAnyAnnotations)(slice, state)) {
339
- (0, _utils6.stripNonExistingAnnotations)(slice, state);
339
+ if (slice.content.size && (0, _utils.containsAnyAnnotations)(slice, state)) {
340
+ (0, _utils4.stripNonExistingAnnotations)(slice, state);
340
341
  }
341
342
 
342
343
  // ED-4732
343
- if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
344
+ if ((0, _analytics2.handlePastePreservingMarksWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
344
345
  return true;
345
346
  }
346
347
 
@@ -360,26 +361,26 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
360
361
  });
361
362
  slice = sliceCopy;
362
363
  }
363
- if ((0, _analytics.handleExpandWithAnalytics)(view, event, slice)(state, dispatch)) {
364
+ if ((0, _analytics2.handleExpandWithAnalytics)(view, event, slice)(state, dispatch)) {
364
365
  return true;
365
366
  }
366
- if (!(0, _utils4.insideTable)(state)) {
367
- slice = (0, _utils2.transformSliceNestedExpandToExpand)(slice, state.schema);
367
+ if (!(0, _utils3.insideTable)(state)) {
368
+ slice = (0, _transforms.transformSliceNestedExpandToExpand)(slice, state.schema);
368
369
  }
369
370
 
370
371
  // Create a custom handler to avoid handling with handleRichText method
371
372
  // As SafeInsert is used inside handleRichText which caused some bad UX like this:
372
373
  // https://product-fabric.atlassian.net/browse/MEX-1520
373
- if ((0, _analytics.handlePasteIntoCaptionWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText)(state, dispatch)) {
374
+ if ((0, _analytics2.handlePasteIntoCaptionWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
374
375
  return true;
375
376
  }
376
- if ((0, _analytics.handlePastePanelOrDecisionIntoListWithAnalytics)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
377
+ if ((0, _analytics2.handlePastePanelOrDecisionIntoListWithAnalytics)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
377
378
  return true;
378
379
  }
379
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && (0, _analytics.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(view, event, slice)(state, dispatch)) {
380
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && (0, _analytics2.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(view, event, slice)(state, dispatch)) {
380
381
  return true;
381
382
  }
382
- return (0, _analytics.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
383
+ return (0, _analytics2.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
383
384
  }
384
385
  return false;
385
386
  },
@@ -391,11 +392,12 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
391
392
  /* Bitbucket copies diffs as multiple adjacent code blocks
392
393
  * so we merge ALL adjacent code blocks to support paste here */
393
394
  if (pastedFromBitBucket) {
394
- slice = (0, _utils3.transformSliceToJoinAdjacentCodeBlocks)(slice);
395
+ slice = (0, _transforms.transformSliceToJoinAdjacentCodeBlocks)(slice);
395
396
  }
396
- slice = (0, _utils3.transformSingleLineCodeBlockToCodeMark)(slice, schema);
397
+ slice = (0, _transforms.transformSingleLineCodeBlockToCodeMark)(slice, schema);
397
398
  slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
398
- slice = (0, _utils5.transformSliceToDecisionList)(slice, schema);
399
+ slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema);
400
+ slice = (0, _transforms.transformSliceToDecisionList)(slice, schema);
399
401
 
400
402
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
401
403
  slice = (0, _commands.splitParagraphs)(slice, schema);
@@ -25,7 +25,7 @@ var _analytics = require("../../analytics");
25
25
  var _state = require("@atlaskit/editor-prosemirror/state");
26
26
  var _utils = require("@atlaskit/editor-prosemirror/utils");
27
27
  var _utils2 = require("@atlaskit/editor-tables/utils");
28
- var _sortByOrder = require("../../../create-editor/sort-by-order");
28
+ var _legacyRankPlugins = require("@atlaskit/editor-common/legacy-rank-plugins");
29
29
  var _utils3 = require("@atlaskit/editor-common/utils");
30
30
  function isPastedFromWord(html) {
31
31
  return !!html && html.indexOf('urn:schemas-microsoft-com:office:word') >= 0;
@@ -114,7 +114,7 @@ function applyTextMarksToSlice(schema, marks) {
114
114
  return allowedMarksToPaste.includes(mark.type);
115
115
  }) || []), (0, _toConsumableArray2.default)(parent.type.allowedMarks(marks).filter(function (mark) {
116
116
  return mark.type !== linkMark;
117
- }))).sort((0, _sortByOrder.sortByOrderWithTypeName)('marks'));
117
+ }))).sort((0, _legacyRankPlugins.sortByOrderWithTypeName)('marks'));
118
118
  return false;
119
119
  }
120
120
  return true;
@@ -4,30 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = {
8
- plugins: ['featureFlagsContextPlugin', 'compositionPlugin', 'inlineCursorTargetPlugin', 'typeAhead', 'typeAheadInsertItem', 'focusHandlerPlugin', 'frozenEditor', 'submitEditor', 'saveOnEnter', 'customAutoformatting', 'newlinePreserveMarksPlugin', 'imageUpload', 'imageUploadInputRule', 'clipboard', 'paste', 'pasteKeymap', 'mention', 'mentionInputRule', 'mentionKeymap', 'emoji', 'placeholderText', 'emojiInputRule', 'emojiKeymap', 'emojiAsciiInputRule', 'blockType', 'quickInsert', 'tasksAndDecisions', 'blockTypeInputRule', 'tasksAndDecisionsInputRule', 'list', 'typeAheadKeymap', 'typeAheadInputRule', 'date',
9
- // Needs to be before indentation to handle tab into input field
10
- 'dateKeymap',
11
- // This should be always after `typeAheadKeymap` & `emojiKeymap`
12
- 'indentationKeymap', 'textColor', 'alignmentPlugin', 'listInputRule', 'listKeymap', 'codeBlock', 'codeBlockIDEKeyBindings', 'codeBlockKeyMap', 'textFormatting', 'textFormattingCursor', 'textFormattingInputRule', 'textFormattingSmartRule', 'textFormattingClear', 'textFormattingKeymap',
13
- // task/decisions keymap needs to be above table keymap so can indent actions in a table
14
- 'tasksAndDecisionsKeyMap',
15
- // expand and table keymaps need to be above selection keymap to add their custom selection behaviour:
16
- // https://product-fabric.atlassian.net/wiki/spaces/E/pages/1113098008/Selection+Guide#Special-Cases
17
- 'expandKeymap', 'tableSelectionKeymap', 'tableKeymap', 'captionKeymap',
18
- // media keymap above selection keymap to allow navigating past the mediaSingle node
19
- 'mediaKeymap',
20
- // selection keymap needs to be above gap cursor keymap so it can set node selections from
21
- // left/right arrows
22
- 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'selectionToolbar', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
23
- nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'rule', 'panel', 'mention', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'unsupportedBlock', 'unsupportedInline', 'confluenceJiraIssue', 'hardBreak', 'emoji', 'placeholder', 'mediaSingle', 'mediaGroup', 'table', 'expand', 'nestedExpand', 'media', 'tableHeader', 'decisionList', 'tableRow', 'decisionItem', 'tableCell', 'taskList', 'taskItem', 'extension', 'bodiedExtension', 'inlineExtension', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard'],
24
- marks: [
25
- // Fragment mark is both for inline and block elements
26
- 'fragment',
27
- // Inline marks
28
- 'link', 'em', 'strong', 'textColor', 'strike', 'subsup', 'underline', 'code', 'typeAheadQuery',
29
- // Block marks
30
- 'alignment', 'breakout', 'indentation', 'annotation', 'dataConsumer', 'border',
31
- // Unsupported mark
32
- 'unsupportedMark', 'unsupportedNodeAttribute']
33
- };
7
+ var _legacyRankPlugins = require("@atlaskit/editor-common/legacy-rank-plugins");
8
+ var _default = exports.default = _legacyRankPlugins.rankEditorPlugins;
@@ -3,19 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.transformSliceToDecisionList = exports.normalizeTaskItemsSelection = void 0;
7
- var _model = require("@atlaskit/editor-prosemirror/model");
8
- var _state = require("@atlaskit/editor-prosemirror/state");
9
- // If slice is decisionItem, wrap it inside a decisionList. This prevents an
10
- // additional newline from being pasted along with the selected decision item.
11
- var transformSliceToDecisionList = exports.transformSliceToDecisionList = function transformSliceToDecisionList(slice, schema) {
12
- var node = slice.content.firstChild;
13
- if (slice.content.childCount === 1 && node && node.type.name === 'decisionItem') {
14
- var decisionListWrapperNode = schema.nodes.decisionList.create({}, node);
15
- return new _model.Slice(_model.Fragment.from(decisionListWrapperNode), slice.openStart, slice.openEnd);
6
+ exports.normalizeTaskItemsSelection = void 0;
7
+ Object.defineProperty(exports, "transformSliceToDecisionList", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _transforms.transformSliceToDecisionList;
16
11
  }
17
- return slice;
18
- };
12
+ });
13
+ var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _transforms = require("@atlaskit/editor-common/transforms");
19
15
  function isTaskListNode(node) {
20
16
  return Boolean(node && node.type && 'taskList' === node.type.name);
21
17
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "188.12.1";
8
+ var version = exports.version = "188.12.3";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -1,17 +1 @@
1
- import Ranks from '../plugins/rank';
2
- export function sortByOrder(item) {
3
- return function (a, b) {
4
- return Ranks[item].indexOf(a.name) - Ranks[item].indexOf(b.name);
5
- };
6
- }
7
-
8
- // while functionally the same, in order to avoid potentially rewriting the ~10
9
- // existing implementations of the above function I decided creating a separate
10
- // function avoided that whole mess. If someone can think of a better way to implement
11
- // the above and below into a single function please do so
12
-
13
- export function sortByOrderWithTypeName(item) {
14
- return function (a, b) {
15
- return Ranks[item].indexOf(a.type.name) - Ranks[item].indexOf(b.type.name);
16
- };
17
- }
1
+ export { sortByOrder, sortByOrderWithTypeName } from '@atlaskit/editor-common/legacy-rank-plugins';
@@ -1,11 +1,14 @@
1
1
  import { PluginKey, TextSelection, AllSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
4
- import { canApplyAnnotationOnRange, getAnnotationIdsFromRange } from '@atlaskit/editor-common/utils';
4
+ import { canApplyAnnotationOnRange, getAnnotationIdsFromRange, isText, isParagraph, hasAnnotationMark, containsAnyAnnotations } from '@atlaskit/editor-common/utils';
5
5
  import { AnnotationTypes } from '@atlaskit/adf-schema';
6
6
  import { AnnotationSelectionType } from './types';
7
- import { isText, isParagraph, sum } from '../../utils';
8
- import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, ACTION } from '../analytics';
7
+ import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, ACTION } from '@atlaskit/editor-common/analytics';
8
+ export { hasAnnotationMark, containsAnyAnnotations };
9
+ function sum(arr, f) {
10
+ return arr.reduce((val, x) => val + f(x), 0);
11
+ }
9
12
  /**
10
13
  * Finds the marks in the nodes to the left and right.
11
14
  * @param $pos Position to center search around
@@ -280,20 +283,6 @@ export function hasInvalidWhitespaceNode(selection, schema) {
280
283
  return foundInvalidWhitespace;
281
284
  }
282
285
 
283
- /*
284
- * verifies if node contains annotation mark
285
- */
286
- export function hasAnnotationMark(node, state) {
287
- const {
288
- schema: {
289
- marks: {
290
- annotation: annotationMark
291
- }
292
- }
293
- } = state;
294
- return !!(annotationMark && node && node.marks.length && annotationMark.isInSet(node.marks));
295
- }
296
-
297
286
  /*
298
287
  * verifies that the annotation exists by the given id
299
288
  */
@@ -302,32 +291,6 @@ export function annotationExists(annotationId, state) {
302
291
  return !!(commentsPluginState !== null && commentsPluginState !== void 0 && commentsPluginState.annotations) && Object.keys(commentsPluginState.annotations).includes(annotationId);
303
292
  }
304
293
 
305
- /*
306
- * verifies that slice contains any annotations
307
- */
308
- export function containsAnyAnnotations(slice, state) {
309
- if (!slice.content.size) {
310
- return false;
311
- }
312
- let hasAnnotation = false;
313
- slice.content.forEach(node => {
314
- hasAnnotation = hasAnnotation || hasAnnotationMark(node, state);
315
- // return early if annotation found already
316
- if (hasAnnotation) {
317
- return true;
318
- }
319
- // check annotations in descendants
320
- node.descendants(node => {
321
- if (hasAnnotationMark(node, state)) {
322
- hasAnnotation = true;
323
- return false;
324
- }
325
- return true;
326
- });
327
- });
328
- return hasAnnotation;
329
- }
330
-
331
294
  /*
332
295
  * remove annotations that dont exsist in plugin state from slice
333
296
  */
@@ -1,44 +1 @@
1
- import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import { mapSlice } from '../../utils/slice';
3
- import { findSelectedNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
- function joinCodeBlocks(left, right) {
5
- const textContext = `${left.textContent}\n${right.textContent}`;
6
- return left.type.create(left.attrs, left.type.schema.text(textContext));
7
- }
8
- function mergeAdjacentCodeBlocks(fragment) {
9
- const children = [];
10
- fragment.forEach(maybeCodeBlock => {
11
- if (maybeCodeBlock.type === maybeCodeBlock.type.schema.nodes.codeBlock) {
12
- const peekAtPrevious = children[children.length - 1];
13
- if (peekAtPrevious && peekAtPrevious.type === maybeCodeBlock.type) {
14
- return children.push(joinCodeBlocks(children.pop(), maybeCodeBlock));
15
- }
16
- }
17
- return children.push(maybeCodeBlock);
18
- });
19
- return Fragment.from(children);
20
- }
21
- export function transformSliceToJoinAdjacentCodeBlocks(slice) {
22
- slice = mapSlice(slice, node => {
23
- return node.isBlock && !node.isTextblock ? node.copy(mergeAdjacentCodeBlocks(node.content)) : node;
24
- });
25
- // mapSlice won't be able to merge adjacent top-level code-blocks
26
- return new Slice(mergeAdjacentCodeBlocks(slice.content), slice.openStart, slice.openEnd);
27
- }
28
- export const transformSingleLineCodeBlockToCodeMark = (slice, schema) => {
29
- if (slice.content.childCount === 1 && (slice.openStart || slice.openEnd)) {
30
- const maybeCodeBlock = slice.content.firstChild;
31
- if (maybeCodeBlock && maybeCodeBlock.type === schema.nodes.codeBlock) {
32
- if (maybeCodeBlock.textContent && maybeCodeBlock.textContent.indexOf('\n') === -1) {
33
- return new Slice(Fragment.from(schema.text(maybeCodeBlock.textContent, [schema.marks.code.create()])), 0, 0);
34
- }
35
- }
36
- }
37
- return slice;
38
- };
39
- export const findCodeBlock = (state, selection) => {
40
- const {
41
- codeBlock
42
- } = state.schema.nodes;
43
- return findSelectedNodeOfType(codeBlock)(selection || state.selection) || findParentNodeOfType(codeBlock)(selection || state.selection);
44
- };
1
+ export { findCodeBlock, transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '@atlaskit/editor-common/transforms';
@@ -4,17 +4,32 @@ import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state
4
4
  import { canInsert, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
5
  import uuid from 'uuid/v4';
6
6
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
7
- import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
8
- import { mapSlice } from '../../utils/slice';
7
+ import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
8
+ import { insideTable } from '@atlaskit/editor-common/core-utils';
9
9
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
10
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
11
+ // TODO: ED-20519 Needs Macro extraction
11
12
  import { runMacroAutoConvert } from '../macro';
12
13
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
13
- import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
14
14
  import { insertSliceForLists } from './edge-cases';
15
15
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
16
16
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
17
17
  import { anyMarkActive } from '@atlaskit/editor-common/mark';
18
+
19
+ /** Helper type for single arg function */
20
+
21
+ /**
22
+ * Compose 1 to n functions.
23
+ * @param func first function
24
+ * @param funcs additional functions
25
+ */
26
+ function compose(func, ...funcs) {
27
+ const allFuncs = [func, ...funcs];
28
+ return function composed(raw) {
29
+ return allFuncs.reduceRight((memo, func) => func(memo), raw);
30
+ };
31
+ }
32
+
18
33
  // remove text attribute from mention for copy/paste (GDPR)
19
34
  export function handleMention(slice, schema) {
20
35
  return mapSlice(slice, node => {
@@ -2,6 +2,13 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { mapSlice, unwrap, removeNestedEmptyEls, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
3
3
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
4
  import { getRandomHex } from '@atlaskit/media-common';
5
+ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
6
+
7
+ /**
8
+ * Ensure correct layout in nested mode
9
+ *
10
+ * TODO: this func is only used in handlePaste, so layout update won't work for drop event
11
+ */
5
12
  export function transformSliceForMedia(slice, schema) {
6
13
  const {
7
14
  mediaSingle,
@@ -9,8 +16,6 @@ export function transformSliceForMedia(slice, schema) {
9
16
  table,
10
17
  bulletList,
11
18
  orderedList,
12
- media,
13
- mediaInline,
14
19
  expand,
15
20
  nestedExpand
16
21
  } = schema.nodes;
@@ -41,29 +46,6 @@ export function transformSliceForMedia(slice, schema) {
41
46
  return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
42
47
  });
43
48
  }
44
- const __mediaTraceId = getRandomHex(8);
45
- newSlice = mapSlice(newSlice, node => {
46
- // This logic is duplicated in editor-plugin-ai where external images can be inserted
47
- // from external sources through the use of AI. The editor-plugin-ai package is avoiding
48
- // sharing dependencies with editor-core to support products using it with various versions
49
- // of editor packages.
50
- // The duplication is in the following file:
51
- // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
52
- if (node.type.name === 'media') {
53
- return media.createChecked({
54
- ...node.attrs,
55
- __external: node.attrs.type === 'external',
56
- __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
57
- }, node.content, node.marks);
58
- }
59
- if (node.type.name === 'mediaInline') {
60
- return mediaInline.createChecked({
61
- ...node.attrs,
62
- __mediaTraceId
63
- }, node.content, node.marks);
64
- }
65
- return node;
66
- });
67
49
  return newSlice;
68
50
  };
69
51
  }
@@ -90,6 +72,52 @@ export const transformSliceToCorrectMediaWrapper = (slice, schema) => {
90
72
  });
91
73
  };
92
74
 
75
+ /**
76
+ * This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
77
+ * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
78
+ *
79
+ */
80
+ export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
81
+ const {
82
+ mediaInline,
83
+ mediaSingle,
84
+ media
85
+ } = schema.nodes;
86
+ const newSlice = mapSlice(slice, node => {
87
+ // This logic is duplicated in editor-plugin-ai where external images can be inserted
88
+ // from external sources through the use of AI. The editor-plugin-ai package is avoiding
89
+ // sharing dependencies with editor-core to support products using it with various versions
90
+ // of editor packages.
91
+ // The duplication is in the following file:
92
+ // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
93
+ if (node.type === mediaSingle) {
94
+ return getBooleanFF('platform.editor.media.extended-resize-experience') ? mediaSingle.createChecked({
95
+ width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
96
+ widthType: node.attrs.widthType || 'pixel',
97
+ layout: node.attrs.layout
98
+ }, node.content, node.marks) : node;
99
+ }
100
+ return node;
101
+ });
102
+ return mapSlice(newSlice, node => {
103
+ const __mediaTraceId = getRandomHex(8);
104
+ if (node.type === media) {
105
+ return media.createChecked({
106
+ ...node.attrs,
107
+ __external: node.attrs.type === 'external',
108
+ __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
109
+ }, node.content, node.marks);
110
+ }
111
+ if (node.type.name === 'mediaInline') {
112
+ return mediaInline.createChecked({
113
+ ...node.attrs,
114
+ __mediaTraceId
115
+ }, node.content, node.marks);
116
+ }
117
+ return node;
118
+ });
119
+ };
120
+
93
121
  /**
94
122
  * Check base styles to see if an element will be invisible when rendered in a document.
95
123
  * @param element