@atlaskit/editor-core 172.3.1 → 173.0.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 (189) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/cjs/index.js +0 -6
  3. package/dist/cjs/plugins/base/index.js +8 -0
  4. package/dist/cjs/plugins/base/pm-plugins/composition.js +60 -0
  5. package/dist/cjs/plugins/breakout/index.js +5 -4
  6. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +1 -3
  7. package/dist/cjs/plugins/card/pm-plugins/doc.js +8 -1
  8. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +2 -36
  9. package/dist/cjs/plugins/collab-edit/plugin-state.js +16 -9
  10. package/dist/cjs/plugins/collab-edit/utils.js +16 -2
  11. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  12. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  13. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  14. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  15. package/dist/cjs/plugins/paste/actions.js +13 -0
  16. package/dist/cjs/plugins/paste/commands.js +44 -0
  17. package/dist/cjs/plugins/paste/handlers.js +48 -7
  18. package/dist/cjs/plugins/paste/index.js +3 -2
  19. package/dist/cjs/plugins/paste/pm-plugins/main.js +34 -9
  20. package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +62 -0
  21. package/dist/cjs/plugins/paste/reducer.js +47 -0
  22. package/dist/cjs/plugins/paste/types.js +5 -0
  23. package/dist/cjs/plugins/placeholder/index.js +3 -1
  24. package/dist/cjs/plugins/placeholder-text/index.js +9 -3
  25. package/dist/cjs/plugins/status/ui/statusPicker.js +4 -1
  26. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -52
  27. package/dist/cjs/plugins/table/index.js +53 -36
  28. package/dist/cjs/plugins/table/toolbar.js +136 -20
  29. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  30. package/dist/cjs/plugins/tasks-and-decisions/commands.js +1 -16
  31. package/dist/cjs/plugins/type-ahead/constants.js +3 -1
  32. package/dist/cjs/plugins/type-ahead/messages.js +16 -1
  33. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +1 -1
  34. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  35. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +143 -0
  36. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +59 -11
  37. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +156 -31
  38. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +55 -29
  39. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  40. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  41. package/dist/cjs/plugins/type-ahead/utils.js +1 -1
  42. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +8 -0
  43. package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +2 -6
  44. package/dist/cjs/ui/PortalProvider/index.js +26 -32
  45. package/dist/cjs/utils/index.js +8 -1
  46. package/dist/cjs/version-wrapper.js +1 -1
  47. package/dist/cjs/version.json +1 -1
  48. package/dist/es2019/index.js +1 -1
  49. package/dist/es2019/plugins/base/index.js +5 -0
  50. package/dist/es2019/plugins/base/pm-plugins/composition.js +45 -0
  51. package/dist/es2019/plugins/breakout/index.js +5 -4
  52. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -3
  53. package/dist/es2019/plugins/card/pm-plugins/doc.js +10 -1
  54. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +3 -40
  55. package/dist/es2019/plugins/collab-edit/plugin-state.js +9 -3
  56. package/dist/es2019/plugins/collab-edit/utils.js +17 -3
  57. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  58. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +15 -7
  59. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +9 -5
  60. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  61. package/dist/es2019/plugins/paste/actions.js +6 -0
  62. package/dist/es2019/plugins/paste/commands.js +27 -0
  63. package/dist/es2019/plugins/paste/handlers.js +50 -8
  64. package/dist/es2019/plugins/paste/index.js +3 -2
  65. package/dist/es2019/plugins/paste/pm-plugins/main.js +29 -6
  66. package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +33 -0
  67. package/dist/es2019/plugins/paste/reducer.js +24 -0
  68. package/dist/es2019/plugins/paste/types.js +1 -0
  69. package/dist/es2019/plugins/placeholder/index.js +2 -1
  70. package/dist/es2019/plugins/placeholder-text/index.js +13 -3
  71. package/dist/es2019/plugins/status/ui/statusPicker.js +5 -1
  72. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -3
  73. package/dist/es2019/plugins/table/index.js +22 -4
  74. package/dist/es2019/plugins/table/toolbar.js +118 -14
  75. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  76. package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -9
  77. package/dist/es2019/plugins/type-ahead/constants.js +1 -0
  78. package/dist/es2019/plugins/type-ahead/messages.js +16 -1
  79. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
  80. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  81. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +95 -0
  82. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +49 -12
  83. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +143 -29
  84. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +64 -31
  85. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  86. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  87. package/dist/es2019/plugins/type-ahead/utils.js +1 -1
  88. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +17 -0
  89. package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  90. package/dist/es2019/ui/PortalProvider/index.js +5 -8
  91. package/dist/es2019/utils/index.js +6 -0
  92. package/dist/es2019/version-wrapper.js +1 -1
  93. package/dist/es2019/version.json +1 -1
  94. package/dist/esm/index.js +1 -1
  95. package/dist/esm/plugins/base/index.js +7 -0
  96. package/dist/esm/plugins/base/pm-plugins/composition.js +45 -0
  97. package/dist/esm/plugins/breakout/index.js +5 -4
  98. package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -3
  99. package/dist/esm/plugins/card/pm-plugins/doc.js +8 -1
  100. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +3 -37
  101. package/dist/esm/plugins/collab-edit/plugin-state.js +9 -3
  102. package/dist/esm/plugins/collab-edit/utils.js +17 -3
  103. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  104. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  105. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  106. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  107. package/dist/esm/plugins/paste/actions.js +6 -0
  108. package/dist/esm/plugins/paste/commands.js +31 -0
  109. package/dist/esm/plugins/paste/handlers.js +46 -8
  110. package/dist/esm/plugins/paste/index.js +3 -2
  111. package/dist/esm/plugins/paste/pm-plugins/main.js +27 -6
  112. package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +46 -0
  113. package/dist/esm/plugins/paste/reducer.js +34 -0
  114. package/dist/esm/plugins/paste/types.js +1 -0
  115. package/dist/esm/plugins/placeholder/index.js +2 -1
  116. package/dist/esm/plugins/placeholder-text/index.js +9 -3
  117. package/dist/esm/plugins/status/ui/statusPicker.js +4 -1
  118. package/dist/esm/plugins/table/commands-with-analytics.js +56 -49
  119. package/dist/esm/plugins/table/index.js +54 -37
  120. package/dist/esm/plugins/table/toolbar.js +124 -15
  121. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  122. package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -12
  123. package/dist/esm/plugins/type-ahead/constants.js +1 -0
  124. package/dist/esm/plugins/type-ahead/messages.js +16 -1
  125. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
  126. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  127. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +129 -0
  128. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +56 -12
  129. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +151 -32
  130. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +54 -31
  131. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  132. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  133. package/dist/esm/plugins/type-ahead/utils.js +1 -1
  134. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +7 -0
  135. package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  136. package/dist/esm/ui/PortalProvider/index.js +26 -35
  137. package/dist/esm/utils/index.js +4 -0
  138. package/dist/esm/version-wrapper.js +1 -1
  139. package/dist/esm/version.json +1 -1
  140. package/dist/types/index.d.ts +1 -1
  141. package/dist/types/plugins/base/pm-plugins/composition.d.ts +8 -0
  142. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  143. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  144. package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  145. package/dist/types/plugins/paste/actions.d.ts +15 -0
  146. package/dist/types/plugins/paste/commands.d.ts +16 -0
  147. package/dist/types/plugins/paste/handlers.d.ts +1 -1
  148. package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -3
  149. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  150. package/dist/types/plugins/paste/reducer.d.ts +3 -0
  151. package/dist/types/plugins/paste/types.d.ts +6 -0
  152. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  153. package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -2
  154. package/dist/types/plugins/type-ahead/constants.d.ts +1 -0
  155. package/dist/types/plugins/type-ahead/messages.d.ts +15 -0
  156. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  157. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  158. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  159. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  160. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  161. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  162. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  163. package/dist/types/utils/index.d.ts +1 -0
  164. package/dist/types-ts4.0/index.d.ts +1 -1
  165. package/dist/types-ts4.0/plugins/base/pm-plugins/composition.d.ts +8 -0
  166. package/dist/types-ts4.0/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  167. package/dist/types-ts4.0/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  168. package/dist/types-ts4.0/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  169. package/dist/types-ts4.0/plugins/paste/actions.d.ts +15 -0
  170. package/dist/types-ts4.0/plugins/paste/commands.d.ts +16 -0
  171. package/dist/types-ts4.0/plugins/paste/handlers.d.ts +1 -1
  172. package/dist/types-ts4.0/plugins/paste/pm-plugins/main.d.ts +3 -3
  173. package/dist/types-ts4.0/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  174. package/dist/types-ts4.0/plugins/paste/reducer.d.ts +3 -0
  175. package/dist/types-ts4.0/plugins/paste/types.d.ts +6 -0
  176. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  177. package/dist/types-ts4.0/plugins/tasks-and-decisions/commands.d.ts +0 -2
  178. package/dist/types-ts4.0/plugins/type-ahead/constants.d.ts +1 -0
  179. package/dist/types-ts4.0/plugins/type-ahead/messages.d.ts +15 -0
  180. package/dist/types-ts4.0/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  181. package/dist/types-ts4.0/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  182. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  183. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  184. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  185. package/dist/types-ts4.0/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  186. package/dist/types-ts4.0/ui/ContentStyles/index.d.ts +2 -2
  187. package/dist/types-ts4.0/utils/index.d.ts +1 -0
  188. package/package.json +31 -32
  189. package/report.api.md +161 -49
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stopTrackingPastedMacroPositions = exports.startTrackingPastedMacroPositions = void 0;
7
+
8
+ var _pluginFactory = require("./pm-plugins/plugin-factory");
9
+
10
+ var _actions = require("./actions");
11
+
12
+ /**
13
+ * Use this to register macro link positions during a paste operation, that you
14
+ * want to track in a document over time, through any document changes.
15
+ *
16
+ * @param positions a map of string keys (custom position references) and position values e.g. { ['my-key-1']: 11 }
17
+ *
18
+ * **Context**: This is neccessary if there is an async process or an unknown period of time
19
+ * between obtaining an original position, and wanting to know about what its final eventual
20
+ * value. In that scenario, positions will need to be actively tracked and mapped in plugin
21
+ * state so that they can be mapped through any other independent document change transactions being
22
+ * dispatched to the editor that could affect their value.
23
+ */
24
+ var startTrackingPastedMacroPositions = function startTrackingPastedMacroPositions(pastedMacroPositions) {
25
+ return (0, _pluginFactory.createCommand)(function () {
26
+ return {
27
+ type: _actions.PastePluginActionTypes.START_TRACKING_PASTED_MACRO_POSITIONS,
28
+ pastedMacroPositions: pastedMacroPositions
29
+ };
30
+ });
31
+ };
32
+
33
+ exports.startTrackingPastedMacroPositions = startTrackingPastedMacroPositions;
34
+
35
+ var stopTrackingPastedMacroPositions = function stopTrackingPastedMacroPositions(pastedMacroPositionKeys) {
36
+ return (0, _pluginFactory.createCommand)(function () {
37
+ return {
38
+ type: _actions.PastePluginActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS,
39
+ pastedMacroPositionKeys: pastedMacroPositionKeys
40
+ };
41
+ });
42
+ };
43
+
44
+ exports.stopTrackingPastedMacroPositions = stopTrackingPastedMacroPositions;
@@ -37,6 +37,8 @@ var _prosemirrorState = require("prosemirror-state");
37
37
 
38
38
  var _prosemirrorUtils = require("prosemirror-utils");
39
39
 
40
+ var _v = _interopRequireDefault(require("uuid/v4"));
41
+
40
42
  var _utils = require("@atlaskit/editor-tables/utils");
41
43
 
42
44
  var _utils2 = require("../../utils");
@@ -65,6 +67,10 @@ var _main2 = require("../hyperlink/pm-plugins/main");
65
67
 
66
68
  var _edgeCases = require("./edge-cases");
67
69
 
70
+ var _commands = require("./commands");
71
+
72
+ var _pluginFactory = require("./pm-plugins/plugin-factory");
73
+
68
74
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
69
75
 
70
76
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -376,12 +382,21 @@ function _getSmartLinkAdf() {
376
382
  return _getSmartLinkAdf.apply(this, arguments);
377
383
  }
378
384
 
379
- function insertAutoMacro(slice, macro, view) {
385
+ function insertAutoMacro(slice, macro, view, from, to) {
380
386
  if (view) {
381
387
  // insert the text or linkified/md-converted clipboard data
382
388
  var selection = view.state.tr.selection;
383
- var tr = view.state.tr.replaceSelection(slice);
384
- var before = tr.mapping.map(selection.from, -1);
389
+ var tr;
390
+ var before;
391
+
392
+ if (typeof from === 'number' && typeof to === 'number') {
393
+ tr = view.state.tr.replaceRange(from, to, slice);
394
+ before = tr.mapping.map(from, -1);
395
+ } else {
396
+ tr = view.state.tr.replaceSelection(slice);
397
+ before = tr.mapping.map(selection.from, -1);
398
+ }
399
+
385
400
  view.dispatch(tr); // replace the text with the macro as a separate transaction
386
401
  // so the autoconversion generates 2 undo steps
387
402
 
@@ -414,16 +429,36 @@ function handleMacroAutoConvert(text, slice, cardsOptions, extensionAutoConverte
414
429
  * if FF enabled, run through smart links and check for result
415
430
  */
416
431
  if (cardsOptions && cardsOptions.resolveBeforeMacros && cardsOptions.resolveBeforeMacros.length) {
432
+ var _startTrackingPastedM;
433
+
417
434
  if (cardsOptions.resolveBeforeMacros.indexOf(macro.attrs.extensionKey) < 0) {
418
435
  return insertAutoMacro(slice, macro, view);
419
436
  }
420
437
 
438
+ if (!view) {
439
+ throw new Error('View is missing');
440
+ }
441
+
442
+ var trackingId = (0, _v.default)();
443
+ var trackingFrom = "handleMacroAutoConvert-from-".concat(trackingId);
444
+ var trackingTo = "handleMacroAutoConvert-to-".concat(trackingId);
445
+ (0, _commands.startTrackingPastedMacroPositions)((_startTrackingPastedM = {}, (0, _defineProperty2.default)(_startTrackingPastedM, trackingFrom, state.selection.from), (0, _defineProperty2.default)(_startTrackingPastedM, trackingTo, state.selection.to), _startTrackingPastedM))(state, dispatch);
421
446
  getSmartLinkAdf(text, 'inline', cardsOptions).then(function () {
447
+ // we use view.state rather than state because state becomes a stale
448
+ // state reference after getSmartLinkAdf's async work
449
+ var _getPastePluginState = (0, _pluginFactory.getPluginState)(view.state),
450
+ pastedMacroPositions = _getPastePluginState.pastedMacroPositions;
451
+
422
452
  if (dispatch) {
423
- handleMarkdown(slice)(state, dispatch);
453
+ handleMarkdown(slice, pastedMacroPositions[trackingFrom], pastedMacroPositions[trackingTo])(view.state, dispatch);
424
454
  }
425
455
  }).catch(function () {
426
- return insertAutoMacro(slice, macro, view);
456
+ var _getPastePluginState2 = (0, _pluginFactory.getPluginState)(view.state),
457
+ pastedMacroPositions = _getPastePluginState2.pastedMacroPositions;
458
+
459
+ insertAutoMacro(slice, macro, view, pastedMacroPositions[trackingFrom], pastedMacroPositions[trackingTo]);
460
+ }).finally(function () {
461
+ (0, _commands.stopTrackingPastedMacroPositions)([trackingFrom, trackingTo])(view.state, dispatch);
427
462
  });
428
463
  return true;
429
464
  }
@@ -545,10 +580,16 @@ function handleExpandPasteInTable(slice) {
545
580
  };
546
581
  }
547
582
 
548
- function handleMarkdown(markdownSlice) {
583
+ function handleMarkdown(markdownSlice, from, to) {
549
584
  return function (state, dispatch) {
550
585
  var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
551
- tr.replaceSelection(markdownSlice);
586
+
587
+ if (typeof from === 'number' && typeof to === 'number') {
588
+ tr.replaceRange(from, to, markdownSlice);
589
+ } else {
590
+ tr.replaceSelection(markdownSlice);
591
+ }
592
+
552
593
  (0, _doc.queueCardsFromChangedTr)(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
553
594
 
554
595
  if (dispatch) {
@@ -19,8 +19,9 @@ var pastePlugin = function pastePlugin(_ref) {
19
19
  plugin: function plugin(_ref2) {
20
20
  var schema = _ref2.schema,
21
21
  providerFactory = _ref2.providerFactory,
22
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
23
- return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory);
22
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
23
+ dispatch = _ref2.dispatch;
24
+ return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, dispatch, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory);
24
25
  }
25
26
  }];
26
27
  }
@@ -14,7 +14,12 @@ Object.defineProperty(exports, "md", {
14
14
  return _md.md;
15
15
  }
16
16
  });
17
- exports.stateKey = void 0;
17
+ Object.defineProperty(exports, "stateKey", {
18
+ enumerable: true,
19
+ get: function get() {
20
+ return _pluginFactory.pluginKey;
21
+ }
22
+ });
18
23
 
19
24
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
20
25
 
@@ -24,12 +29,12 @@ var _prosemirrorModel = require("prosemirror-model");
24
29
 
25
30
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
26
31
 
27
- var _prosemirrorState = require("prosemirror-state");
28
-
29
32
  var _uuid = _interopRequireDefault(require("uuid"));
30
33
 
31
34
  var _editorMarkdownTransformer = require("@atlaskit/editor-markdown-transformer");
32
35
 
36
+ var _slice = require("../../../utils/slice");
37
+
33
38
  var _extensions = require("@atlaskit/editor-common/extensions");
34
39
 
35
40
  var clipboard = _interopRequireWildcard(require("../../../utils/clipboard"));
@@ -76,22 +81,22 @@ var _utils9 = require("@atlaskit/editor-tables/utils");
76
81
 
77
82
  var _step = require("../../../utils/step");
78
83
 
84
+ var _pluginFactory = require("./plugin-factory");
85
+
79
86
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
80
87
 
81
88
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
82
89
 
83
90
  _analytics.sendPasteAnalyticsEvent;
84
- var stateKey = new _prosemirrorState.PluginKey('pastePlugin');
85
- exports.stateKey = stateKey;
86
91
 
87
- function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory) {
92
+ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory) {
88
93
  var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _md.md);
89
94
 
90
95
  function getMarkdownSlice(text, openStart, openEnd) {
91
96
  var textInput = text;
92
97
 
93
- if (textInput.includes(':\\\\')) {
94
- textInput = textInput.replace(/:\\\\/g, ':\\\\\\\\');
98
+ if (textInput.includes('\\')) {
99
+ textInput = textInput.replace(/\\/g, '\\\\');
95
100
  }
96
101
 
97
102
  var doc = atlassianMarkDownParser.parse((0, _util.escapeLinks)(textInput));
@@ -155,7 +160,10 @@ function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinkificatio
155
160
  var mostRecentPasteEvent;
156
161
  var pastedFromBitBucket = false;
157
162
  return new _safePlugin.SafePlugin({
158
- key: stateKey,
163
+ key: _pluginFactory.pluginKey,
164
+ state: (0, _pluginFactory.createPluginState)(dispatch, {
165
+ pastedMacroPositions: {}
166
+ }),
159
167
  props: {
160
168
  // For serialising to plain text
161
169
  clipboardTextSerializer: _clipboardTextSerializer.clipboardTextSerializer,
@@ -350,6 +358,23 @@ function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinkificatio
350
358
  }
351
359
 
352
360
  return (0, _analytics.handleMarkdownWithAnalytics)(view, event, markdownSlice)(state, dispatch);
361
+ }
362
+
363
+ if (isRichText && (0, _utils4.isInsideBlockQuote)(state)) {
364
+ //If pasting inside blockquote
365
+ //Skip the blockquote node and keep remaining nodes as they are
366
+ var blockquote = schema.nodes.blockquote;
367
+ var children = [];
368
+ (0, _slice.mapChildren)(slice.content, function (node) {
369
+ if (node.type === blockquote) {
370
+ for (var i = 0; i < node.childCount; i++) {
371
+ children.push(node.child(i));
372
+ }
373
+ } else {
374
+ children.push(node);
375
+ }
376
+ });
377
+ slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.fromArray(children), slice.openStart, slice.openEnd);
353
378
  } // finally, handle rich-text copy-paste
354
379
 
355
380
 
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.pluginKey = exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _prosemirrorState = require("prosemirror-state");
15
+
16
+ var _pluginStateFactory = require("../../../utils/plugin-state-factory");
17
+
18
+ var _reducer = require("../reducer");
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ var pluginKey = new _prosemirrorState.PluginKey('pastePlugin');
25
+ exports.pluginKey = pluginKey;
26
+
27
+ var _pluginFactory = (0, _pluginStateFactory.pluginFactory)(pluginKey, _reducer.reducer, {
28
+ mapping: function mapping(tr, pluginState) {
29
+ if (tr.docChanged) {
30
+ var atLeastOnePositionChanged = false;
31
+ var positionsMappedThroughChanges = Object.entries(pluginState.pastedMacroPositions).reduce(function (acc, _ref) {
32
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
33
+ key = _ref2[0],
34
+ position = _ref2[1];
35
+
36
+ var mappedPosition = tr.mapping.map(position);
37
+
38
+ if (position !== mappedPosition) {
39
+ atLeastOnePositionChanged = true;
40
+ }
41
+
42
+ acc[key] = tr.mapping.map(position);
43
+ return acc;
44
+ }, {});
45
+
46
+ if (atLeastOnePositionChanged) {
47
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
48
+ pastedMacroPositions: positionsMappedThroughChanges
49
+ });
50
+ }
51
+ }
52
+
53
+ return pluginState;
54
+ }
55
+ }),
56
+ createPluginState = _pluginFactory.createPluginState,
57
+ createCommand = _pluginFactory.createCommand,
58
+ getPluginState = _pluginFactory.getPluginState;
59
+
60
+ exports.getPluginState = getPluginState;
61
+ exports.createCommand = createCommand;
62
+ exports.createPluginState = createPluginState;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.reducer = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _actions = require("./actions");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
20
+ var reducer = function reducer(state, action) {
21
+ switch (action.type) {
22
+ case _actions.PastePluginActionTypes.START_TRACKING_PASTED_MACRO_POSITIONS:
23
+ {
24
+ return _objectSpread(_objectSpread({}, state), {}, {
25
+ pastedMacroPositions: _objectSpread(_objectSpread({}, state.pastedMacroPositions), action.pastedMacroPositions)
26
+ });
27
+ }
28
+
29
+ case _actions.PastePluginActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS:
30
+ {
31
+ var filteredMacroPositions = Object.fromEntries(Object.entries(state.pastedMacroPositions).filter(function (_ref) {
32
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 1),
33
+ key = _ref2[0];
34
+
35
+ return !action.pastedMacroPositionKeys.includes(key);
36
+ }));
37
+ return _objectSpread(_objectSpread({}, state), {}, {
38
+ pastedMacroPositions: filteredMacroPositions
39
+ });
40
+ }
41
+
42
+ default:
43
+ return state;
44
+ }
45
+ };
46
+
47
+ exports.reducer = reducer;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -25,6 +25,8 @@ var _focusHandler = require("../base/pm-plugins/focus-handler");
25
25
 
26
26
  var _utils2 = require("../type-ahead/utils");
27
27
 
28
+ var _composition = require("../base/pm-plugins/composition");
29
+
28
30
  var pluginKey = new _prosemirrorState.PluginKey('placeholderPlugin');
29
31
  exports.pluginKey = pluginKey;
30
32
 
@@ -154,7 +156,7 @@ function createPlugin(defaultPlaceholderText, placeholderHints, bracketPlacehold
154
156
  placeholderText = _getPlaceholderState.placeholderText,
155
157
  pos = _getPlaceholderState.pos;
156
158
 
157
- if (hasPlaceholder && placeholderText && pos !== undefined) {
159
+ if (hasPlaceholder && placeholderText && pos !== undefined && !(0, _composition.isComposing)(editorState)) {
158
160
  return createPlaceholderDecoration(editorState, placeholderText, pos);
159
161
  }
160
162
 
@@ -97,10 +97,16 @@ function createPlugin(dispatch, options) {
97
97
  var placeholderNodeType = newState.schema.nodes.placeholder;
98
98
 
99
99
  if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
100
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
101
- var wasContentAdded = oldState.selection.$head.pos < newState.selection.$head.pos && !(0, _utils.isNodeEmpty)(newState.selection.$head.nodeBefore);
100
+ var _$newHead$nodeBefore;
102
101
 
103
- if (wasContentAdded) {
102
+ var $newHead = newState.selection.$head;
103
+ var $oldHead = oldState.selection.$head; // Check that cursor has moved forward in the document **and** that there is content before the cursor
104
+
105
+ var cursorMoved = $oldHead.pos < $newHead.pos;
106
+ var nodeBeforeHasContent = !(0, _utils.isNodeEmpty)($newHead.nodeBefore);
107
+ var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
108
+
109
+ if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
104
110
  var _NodeSelection$create = _prosemirrorState.NodeSelection.create(newState.doc, adjacentNodePos),
105
111
  $from = _NodeSelection$create.$from,
106
112
  $to = _NodeSelection$create.$to;
@@ -78,8 +78,11 @@ var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component) {
78
78
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClickOutside", function (event) {
79
79
  event.preventDefault();
80
80
  _this.inputMethod = InputMethod.blur;
81
+ var selectedText = window.getSelection();
81
82
 
82
- _this.props.closeStatusPicker();
83
+ if (!selectedText) {
84
+ _this.props.closeStatusPicker();
85
+ }
83
86
  });
84
87
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEscapeKeydown", function (event) {
85
88
  event.preventDefault();
@@ -84,77 +84,83 @@ var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(e
84
84
  exports.emptyMultipleCellsWithAnalytics = emptyMultipleCellsWithAnalytics;
85
85
 
86
86
  var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAPI) {
87
- return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref2) {
88
- var selection = _ref2.selection;
89
-
90
- var _getSelectedCellInfo2 = (0, _utils2.getSelectedCellInfo)(selection),
91
- horizontalCells = _getSelectedCellInfo2.horizontalCells,
92
- verticalCells = _getSelectedCellInfo2.verticalCells,
93
- totalCells = _getSelectedCellInfo2.totalCells,
94
- totalRowCount = _getSelectedCellInfo2.totalRowCount,
95
- totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
96
-
97
- return {
98
- action: _analytics.TABLE_ACTION.MERGED,
99
- actionSubject: _analytics.ACTION_SUBJECT.TABLE,
100
- actionSubjectId: null,
101
- attributes: {
102
- horizontalCells: horizontalCells,
103
- verticalCells: verticalCells,
104
- totalCells: totalCells,
105
- totalRowCount: totalRowCount,
106
- totalColumnCount: totalColumnCount
107
- },
108
- eventType: _analytics.EVENT_TYPE.TRACK
109
- };
110
- })(editorAnalyticsAPI)(function (state, dispatch) {
111
- if (dispatch) {
112
- dispatch((0, _transforms.mergeCells)(state.tr));
113
- }
114
-
115
- return true;
116
- });
117
- };
118
-
119
- exports.mergeCellsWithAnalytics = mergeCellsWithAnalytics;
120
-
121
- var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
122
- return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref3) {
123
- var selection = _ref3.selection;
124
-
125
- var _getSelectedCellInfo3 = (0, _utils2.getSelectedCellInfo)(selection),
126
- totalRowCount = _getSelectedCellInfo3.totalRowCount,
127
- totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
87
+ return function (inputMethod) {
88
+ return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref2) {
89
+ var selection = _ref2.selection;
128
90
 
129
- var cell = (0, _utils.findCellClosestToPos)(selection.$anchor);
91
+ var _getSelectedCellInfo2 = (0, _utils2.getSelectedCellInfo)(selection),
92
+ horizontalCells = _getSelectedCellInfo2.horizontalCells,
93
+ verticalCells = _getSelectedCellInfo2.verticalCells,
94
+ totalCells = _getSelectedCellInfo2.totalCells,
95
+ totalRowCount = _getSelectedCellInfo2.totalRowCount,
96
+ totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
130
97
 
131
- if (cell) {
132
- var _cell$node$attrs = cell.node.attrs,
133
- verticalCells = _cell$node$attrs.rowspan,
134
- horizontalCells = _cell$node$attrs.colspan;
135
98
  return {
136
- action: _analytics.TABLE_ACTION.SPLIT,
99
+ action: _analytics.TABLE_ACTION.MERGED,
137
100
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
138
101
  actionSubjectId: null,
139
102
  attributes: {
103
+ inputMethod: inputMethod,
140
104
  horizontalCells: horizontalCells,
141
105
  verticalCells: verticalCells,
142
- totalCells: horizontalCells * verticalCells,
106
+ totalCells: totalCells,
143
107
  totalRowCount: totalRowCount,
144
108
  totalColumnCount: totalColumnCount
145
109
  },
146
110
  eventType: _analytics.EVENT_TYPE.TRACK
147
111
  };
148
- }
112
+ })(editorAnalyticsAPI)(function (state, dispatch) {
113
+ if (dispatch) {
114
+ dispatch((0, _transforms.mergeCells)(state.tr));
115
+ }
149
116
 
150
- return;
151
- })(editorAnalyticsAPI)(_splitCell.splitCell);
117
+ return true;
118
+ });
119
+ };
120
+ };
121
+
122
+ exports.mergeCellsWithAnalytics = mergeCellsWithAnalytics;
123
+
124
+ var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
125
+ return function (inputMethod) {
126
+ return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref3) {
127
+ var selection = _ref3.selection;
128
+
129
+ var _getSelectedCellInfo3 = (0, _utils2.getSelectedCellInfo)(selection),
130
+ totalRowCount = _getSelectedCellInfo3.totalRowCount,
131
+ totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
132
+
133
+ var cell = (0, _utils.findCellClosestToPos)(selection.$anchor);
134
+
135
+ if (cell) {
136
+ var _cell$node$attrs = cell.node.attrs,
137
+ verticalCells = _cell$node$attrs.rowspan,
138
+ horizontalCells = _cell$node$attrs.colspan;
139
+ return {
140
+ action: _analytics.TABLE_ACTION.SPLIT,
141
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
142
+ actionSubjectId: null,
143
+ attributes: {
144
+ inputMethod: inputMethod,
145
+ horizontalCells: horizontalCells,
146
+ verticalCells: verticalCells,
147
+ totalCells: horizontalCells * verticalCells,
148
+ totalRowCount: totalRowCount,
149
+ totalColumnCount: totalColumnCount
150
+ },
151
+ eventType: _analytics.EVENT_TYPE.TRACK
152
+ };
153
+ }
154
+
155
+ return;
156
+ })(editorAnalyticsAPI)(_splitCell.splitCell);
157
+ };
152
158
  };
153
159
 
154
160
  exports.splitCellWithAnalytics = splitCellWithAnalytics;
155
161
 
156
162
  var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
157
- return function (cellColor, targetCellPosition) {
163
+ return function (inputMethod, cellColor, targetCellPosition) {
158
164
  return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref4) {
159
165
  var selection = _ref4.selection;
160
166
 
@@ -170,6 +176,7 @@ var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
170
176
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
171
177
  actionSubjectId: null,
172
178
  attributes: {
179
+ inputMethod: inputMethod,
173
180
  cellColor: (_adfSchema.tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
174
181
  horizontalCells: horizontalCells,
175
182
  verticalCells: verticalCells,