@atlaskit/editor-core 188.12.2 → 188.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +17 -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/actions.js +1 -0
  6. package/dist/cjs/plugins/paste/handlers.js +36 -18
  7. package/dist/cjs/plugins/paste/plugin.js +12 -0
  8. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +6 -6
  9. package/dist/cjs/plugins/paste/pm-plugins/main.js +72 -53
  10. package/dist/cjs/plugins/paste/reducer.js +6 -0
  11. package/dist/cjs/plugins/paste/util/index.js +2 -2
  12. package/dist/cjs/plugins/rank.js +2 -27
  13. package/dist/cjs/plugins/tasks-and-decisions/utils.js +8 -12
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/es2019/create-editor/sort-by-order.js +1 -17
  16. package/dist/es2019/plugins/annotation/utils.js +6 -43
  17. package/dist/es2019/plugins/code-block/utils.js +1 -44
  18. package/dist/es2019/plugins/paste/actions.js +1 -0
  19. package/dist/es2019/plugins/paste/handlers.js +18 -3
  20. package/dist/es2019/plugins/paste/plugin.js +12 -0
  21. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +3 -3
  22. package/dist/es2019/plugins/paste/pm-plugins/main.js +30 -13
  23. package/dist/es2019/plugins/paste/reducer.js +7 -0
  24. package/dist/es2019/plugins/paste/util/index.js +1 -1
  25. package/dist/es2019/plugins/rank.js +2 -27
  26. package/dist/es2019/plugins/tasks-and-decisions/utils.js +2 -12
  27. package/dist/es2019/version-wrapper.js +1 -1
  28. package/dist/esm/create-editor/sort-by-order.js +1 -17
  29. package/dist/esm/plugins/annotation/utils.js +8 -37
  30. package/dist/esm/plugins/code-block/utils.js +1 -42
  31. package/dist/esm/plugins/paste/actions.js +1 -0
  32. package/dist/esm/plugins/paste/handlers.js +23 -3
  33. package/dist/esm/plugins/paste/plugin.js +12 -0
  34. package/dist/esm/plugins/paste/pm-plugins/analytics.js +3 -3
  35. package/dist/esm/plugins/paste/pm-plugins/main.js +30 -13
  36. package/dist/esm/plugins/paste/reducer.js +6 -0
  37. package/dist/esm/plugins/paste/util/index.js +1 -1
  38. package/dist/esm/plugins/rank.js +2 -27
  39. package/dist/esm/plugins/tasks-and-decisions/utils.js +2 -12
  40. package/dist/esm/version-wrapper.js +1 -1
  41. package/dist/types/create-editor/sort-by-order.d.ts +1 -14
  42. package/dist/types/plugins/annotation/utils.d.ts +3 -3
  43. package/dist/types/plugins/code-block/utils.d.ts +1 -6
  44. package/dist/types/plugins/paste/actions.d.ts +8 -2
  45. package/dist/types/plugins/paste/handlers.d.ts +2 -2
  46. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +1 -1
  47. package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -2
  48. package/dist/types/plugins/paste/reducer.d.ts +2 -2
  49. package/dist/types/plugins/rank.d.ts +2 -6
  50. package/dist/types/plugins/tasks-and-decisions/utils.d.ts +2 -3
  51. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  52. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  53. package/dist/types-ts4.5/create-editor/sort-by-order.d.ts +1 -14
  54. package/dist/types-ts4.5/plugins/annotation/utils.d.ts +3 -3
  55. package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -6
  56. package/dist/types-ts4.5/plugins/paste/actions.d.ts +8 -2
  57. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -2
  58. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +1 -1
  59. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -2
  60. package/dist/types-ts4.5/plugins/paste/reducer.d.ts +2 -2
  61. package/dist/types-ts4.5/plugins/rank.d.ts +2 -6
  62. package/dist/types-ts4.5/plugins/tasks-and-decisions/utils.d.ts +2 -3
  63. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  64. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  65. package/package.json +3 -3
@@ -18,27 +18,29 @@ 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
+ var _actions = require("../actions");
40
+ // TODO: ED-20519 It requires full analytics extraction to use the plugin injection API
41
+
42
+ // TODO: ED-20519 It requires annotation extraction to use the plugin injection API
43
+
42
44
  function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
43
45
  var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _paste.md);
44
46
  function getMarkdownSlice(text, openStart, openEnd) {
@@ -99,7 +101,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
99
101
  return new _safePlugin.SafePlugin({
100
102
  key: _pluginFactory.pluginKey,
101
103
  state: (0, _pluginFactory.createPluginState)(dispatch, {
102
- pastedMacroPositions: {}
104
+ pastedMacroPositions: {},
105
+ lastContentPasted: null
103
106
  }),
104
107
  props: {
105
108
  // For serialising to plain text
@@ -157,16 +160,16 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
157
160
  event.stopPropagation();
158
161
  }
159
162
  var state = view.state;
160
- var analyticsPlugin = _analytics2.analyticsPluginKey.getState(state);
163
+ var analyticsPlugin = _analytics3.analyticsPluginKey.getState(state);
161
164
  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
165
  if (pasteTrackingEnabled) {
163
- var content = (0, _analytics.getContentNodeTypes)(slice.content);
166
+ var content = (0, _analytics2.getContentNodeTypes)(slice.content);
164
167
  var pasteId = (0, _uuid.default)();
165
- var measureName = "".concat(_utils4.measurements.PASTE, "_").concat(pasteId);
168
+ var measureName = "".concat(_utils3.measurements.PASTE, "_").concat(pasteId);
166
169
  (0, _utils.measureRender)(measureName, function (_ref) {
167
170
  var duration = _ref.duration,
168
171
  distortedDuration = _ref.distortedDuration;
169
- var payload = (0, _analytics.createPasteMeasurePayload)({
172
+ var payload = (0, _analytics2.createPasteMeasurePayload)({
170
173
  view: view,
171
174
  duration: duration,
172
175
  content: content,
@@ -179,7 +182,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
179
182
  }
180
183
  // creating a custom dispatch because we want to add a meta whenever we do a paste.
181
184
  var dispatch = function dispatch(tr) {
182
- var _state$doc$resolve$no;
185
+ var _state$doc$resolve$no, _input;
183
186
  // https://product-fabric.atlassian.net/browse/ED-12633
184
187
  // don't add closeHistory call if we're pasting a text inside placeholder text as we want the whole action
185
188
  // to be atomic
@@ -189,7 +192,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
189
192
  // Don't add closeHistory if we're pasting over layout columns, as we will appendTransaction
190
193
  // to cleanup the layout's structure and we want to keep the paste and re-structuring as
191
194
  // one event.
192
- var isPastingOverLayoutColumns = (0, _utils8.hasParentNodeOfType)(state.schema.nodes.layoutColumn)(state.selection);
195
+ var isPastingOverLayoutColumns = (0, _utils5.hasParentNodeOfType)(state.schema.nodes.layoutColumn)(state.selection);
193
196
 
194
197
  // don't add closeHistory call if we're pasting a table, as some tables may involve additional
195
198
  // appendedTransactions to repair them (if they're partial or incomplete) and we don't want
@@ -197,7 +200,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
197
200
  // "done" stack
198
201
  var isPastingTable = tr.steps.some(function (step) {
199
202
  var _slice$content;
200
- var slice = (0, _step.extractSliceFromStep)(step);
203
+ var slice = (0, _utils.extractSliceFromStep)(step);
201
204
  var tableExists = false;
202
205
  slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 || _slice$content.forEach(function (node) {
203
206
  if (node.type === state.schema.nodes.table) {
@@ -211,14 +214,30 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
211
214
  tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
212
215
  }
213
216
  (0, _card.addLinkMetadata)(view.state.selection, tr, {
214
- action: isPlainText ? _analytics2.ACTION.PASTED_AS_PLAIN : _analytics2.ACTION.PASTED,
215
- inputMethod: _analytics2.INPUT_METHOD.CLIPBOARD
217
+ action: isPlainText ? _analytics.ACTION.PASTED_AS_PLAIN : _analytics.ACTION.PASTED,
218
+ inputMethod: _analytics.INPUT_METHOD.CLIPBOARD
219
+ });
220
+ var pasteStartPos = Math.min(state.selection.anchor, state.selection.head);
221
+ var pasteEndPos = tr.selection.to;
222
+ var contentPasted = {
223
+ pasteStartPos: pasteStartPos,
224
+ pasteEndPos: pasteEndPos,
225
+ text: text,
226
+ isShiftPressed: Boolean(view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey)),
227
+ isPlainText: Boolean(isPlainText),
228
+ pastedSlice: tr.doc.slice(pasteStartPos, pasteEndPos),
229
+ pastedAt: Date.now(),
230
+ pasteSource: (0, _util.getPasteSource)(event)
231
+ };
232
+ tr.setMeta(_pluginFactory.pluginKey, {
233
+ type: _actions.PastePluginActionTypes.ON_PASTE,
234
+ contentPasted: contentPasted
216
235
  });
217
236
  view.dispatch(tr);
218
237
  };
219
238
  slice = (0, _handlers.handleParagraphBlockMarks)(state, slice);
220
239
  var plainTextPasteSlice = (0, _utils.linkifyContent)(state.schema)(slice);
221
- if ((0, _analytics.handlePasteAsPlainTextWithAnalytics)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
240
+ if ((0, _analytics2.handlePasteAsPlainTextWithAnalytics)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
222
241
  return true;
223
242
  }
224
243
 
@@ -238,15 +257,15 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
238
257
  if (markdownSlice) {
239
258
  var _pluginInjectionApi$c;
240
259
  // linkify text prior to converting to macro
241
- if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, markdownSlice, _analytics2.PasteTypes.markdown)(state, dispatch)) {
260
+ if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, markdownSlice, _analytics.PasteTypes.markdown)(state, dispatch)) {
242
261
  return true;
243
262
  }
244
263
 
245
264
  // run macro autoconvert prior to other conversions
246
265
  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
266
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
248
- (0, _analytics.sendPasteAnalyticsEvent)(view, event, markdownSlice, {
249
- type: _analytics2.PasteTypes.markdown
267
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, markdownSlice, {
268
+ type: _analytics.PasteTypes.markdown
250
269
  });
251
270
  return true;
252
271
  }
@@ -267,34 +286,34 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
267
286
  // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
268
287
  slice.openStart = 1;
269
288
  }
270
- if ((0, _analytics.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics2.PasteTypes.plain : _analytics2.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
289
+ if ((0, _analytics2.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _analytics.PasteTypes.plain : _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
271
290
  return true;
272
291
  }
273
292
 
274
293
  // 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)) {
294
+ if ((0, _analytics2.handleCodeBlockWithAnalytics)(view, event, slice, text)(state, dispatch)) {
276
295
  return true;
277
296
  }
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)) {
297
+ 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
298
  return true;
280
299
  }
281
- if ((0, _analytics.handleSelectedTableWithAnalytics)(view, event, slice)(state, dispatch)) {
300
+ if ((0, _analytics2.handleSelectedTableWithAnalytics)(view, event, slice)(state, dispatch)) {
282
301
  return true;
283
302
  }
284
303
 
285
304
  // If the clipboard only contains plain text, attempt to parse it as Markdown
286
305
  if (isPlainText && markdownSlice) {
287
- if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _analytics2.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
306
+ if ((0, _analytics2.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _analytics.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
288
307
  return true;
289
308
  }
290
- return (0, _analytics.handleMarkdownWithAnalytics)(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
309
+ return (0, _analytics2.handleMarkdownWithAnalytics)(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
291
310
  }
292
- if (isRichText && (0, _utils4.isInsideBlockQuote)(state)) {
311
+ if (isRichText && (0, _utils3.isInsideBlockQuote)(state)) {
293
312
  //If pasting inside blockquote
294
313
  //Skip the blockquote node and keep remaining nodes as they are
295
314
  var blockquote = schema.nodes.blockquote;
296
315
  var children = [];
297
- (0, _slice.mapChildren)(slice.content, function (node) {
316
+ (0, _utils.mapChildren)(slice.content, function (node) {
298
317
  if (node.type === blockquote) {
299
318
  for (var i = 0; i < node.childCount; i++) {
300
319
  children.push(node.child(i));
@@ -311,36 +330,36 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
311
330
  var _pluginInjectionApi$c2, _pluginInjectionApi$l;
312
331
  // linkify the text where possible
313
332
  slice = (0, _utils.linkifyContent)(state.schema)(slice);
314
- if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText)(state, dispatch)) {
333
+ if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
315
334
  return true;
316
335
  }
317
336
 
318
337
  // run macro autoconvert prior to other conversions
319
338
  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
339
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
321
- (0, _analytics.sendPasteAnalyticsEvent)(view, event, slice, {
322
- type: _analytics2.PasteTypes.richText
340
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, slice, {
341
+ type: _analytics.PasteTypes.richText
323
342
  });
324
343
  return true;
325
344
  }
326
345
 
327
346
  // get editor-tables to handle pasting tables if it can
328
347
  // 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
348
+ if ((0, _utils2.handlePaste)(view, null, slice)) {
349
+ (0, _analytics2.sendPasteAnalyticsEvent)(view, event, slice, {
350
+ type: _analytics.PasteTypes.richText
332
351
  });
333
352
  return true;
334
353
  }
335
354
 
336
355
  // remove annotation marks from the pasted data if they are not present in the document
337
356
  // 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);
357
+ if (slice.content.size && (0, _utils.containsAnyAnnotations)(slice, state)) {
358
+ (0, _utils4.stripNonExistingAnnotations)(slice, state);
340
359
  }
341
360
 
342
361
  // ED-4732
343
- if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
362
+ if ((0, _analytics2.handlePastePreservingMarksWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
344
363
  return true;
345
364
  }
346
365
 
@@ -360,26 +379,26 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
360
379
  });
361
380
  slice = sliceCopy;
362
381
  }
363
- if ((0, _analytics.handleExpandWithAnalytics)(view, event, slice)(state, dispatch)) {
382
+ if ((0, _analytics2.handleExpandWithAnalytics)(view, event, slice)(state, dispatch)) {
364
383
  return true;
365
384
  }
366
- if (!(0, _utils4.insideTable)(state)) {
367
- slice = (0, _utils2.transformSliceNestedExpandToExpand)(slice, state.schema);
385
+ if (!(0, _utils3.insideTable)(state)) {
386
+ slice = (0, _transforms.transformSliceNestedExpandToExpand)(slice, state.schema);
368
387
  }
369
388
 
370
389
  // Create a custom handler to avoid handling with handleRichText method
371
390
  // As SafeInsert is used inside handleRichText which caused some bad UX like this:
372
391
  // https://product-fabric.atlassian.net/browse/MEX-1520
373
- if ((0, _analytics.handlePasteIntoCaptionWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText)(state, dispatch)) {
392
+ if ((0, _analytics2.handlePasteIntoCaptionWithAnalytics)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
374
393
  return true;
375
394
  }
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)) {
395
+ 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
396
  return true;
378
397
  }
379
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && (0, _analytics.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(view, event, slice)(state, dispatch)) {
398
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && (0, _analytics2.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(view, event, slice)(state, dispatch)) {
380
399
  return true;
381
400
  }
382
- return (0, _analytics.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
401
+ return (0, _analytics2.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
383
402
  }
384
403
  return false;
385
404
  },
@@ -391,12 +410,12 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
391
410
  /* Bitbucket copies diffs as multiple adjacent code blocks
392
411
  * so we merge ALL adjacent code blocks to support paste here */
393
412
  if (pastedFromBitBucket) {
394
- slice = (0, _utils3.transformSliceToJoinAdjacentCodeBlocks)(slice);
413
+ slice = (0, _transforms.transformSliceToJoinAdjacentCodeBlocks)(slice);
395
414
  }
396
- slice = (0, _utils3.transformSingleLineCodeBlockToCodeMark)(slice, schema);
415
+ slice = (0, _transforms.transformSingleLineCodeBlockToCodeMark)(slice, schema);
397
416
  slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
398
417
  slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema);
399
- slice = (0, _utils5.transformSliceToDecisionList)(slice, schema);
418
+ slice = (0, _transforms.transformSliceToDecisionList)(slice, schema);
400
419
 
401
420
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
402
421
  slice = (0, _commands.splitParagraphs)(slice, schema);
@@ -29,6 +29,12 @@ var reducer = exports.reducer = function reducer(state, action) {
29
29
  pastedMacroPositions: filteredMacroPositions
30
30
  });
31
31
  }
32
+ case _actions.PastePluginActionTypes.ON_PASTE:
33
+ {
34
+ return _objectSpread(_objectSpread({}, state), {}, {
35
+ lastContentPasted: action.contentPasted
36
+ });
37
+ }
32
38
  default:
33
39
  return state;
34
40
  }
@@ -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.2";
8
+ var version = exports.version = "188.13.0";
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';
@@ -1,5 +1,6 @@
1
1
  export let PastePluginActionTypes = /*#__PURE__*/function (PastePluginActionTypes) {
2
2
  PastePluginActionTypes["START_TRACKING_PASTED_MACRO_POSITIONS"] = "START_TRACKING_PASTED_MACRO_POSITIONS";
3
3
  PastePluginActionTypes["STOP_TRACKING_PASTED_MACRO_POSITIONS"] = "STOP_TRACKING_PASTED_MACRO_POSITIONS";
4
+ PastePluginActionTypes["ON_PASTE"] = "ON_PASTE";
4
5
  return PastePluginActionTypes;
5
6
  }({});
@@ -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 => {
@@ -1,4 +1,5 @@
1
1
  import { createPlugin } from './pm-plugins/main';
2
+ import { pluginKey } from './pm-plugins/plugin-factory';
2
3
  export const pastePlugin = ({
3
4
  config,
4
5
  api
@@ -21,6 +22,17 @@ export const pastePlugin = ({
21
22
  dispatch
22
23
  }) => createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory)
23
24
  }];
25
+ },
26
+ getSharedState: editorState => {
27
+ if (!editorState) {
28
+ return {
29
+ lastContentPasted: null
30
+ };
31
+ }
32
+ const pluginState = pluginKey.getState(editorState);
33
+ return {
34
+ lastContentPasted: pluginState.lastContentPasted
35
+ };
24
36
  }
25
37
  };
26
38
  };
@@ -1,9 +1,9 @@
1
- import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, PasteTypes, PasteContents } from '../../analytics';
1
+ import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, PasteTypes, PasteContents } from '@atlaskit/editor-common/analytics';
2
+ import { addAnalytics } from '../../analytics';
2
3
  import { getPasteSource } from '../util';
3
4
  import { handlePasteAsPlainText, handlePasteIntoTaskOrDecisionOrPanel, handleCodeBlock, handleMediaSingle, handlePastePreservingMarks, handleMarkdown, handleRichText, handleExpandPasteInTable, handleSelectedTable, handlePasteLinkOnSelectedText, handlePasteIntoCaption, handlePastePanelOrDecisionContentIntoList, handlePasteNonNestableBlockNodesIntoList } from '../handlers';
4
5
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
5
- import { mapSlice } from '../../../utils/slice';
6
- import { getLinkDomain } from '@atlaskit/editor-common/utils';
6
+ import { getLinkDomain, mapSlice } from '@atlaskit/editor-common/utils';
7
7
  const contentToPasteContent = {
8
8
  url: PasteContents.url,
9
9
  paragraph: PasteContents.text,