@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 188.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41895](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41895) [`96066a06792`](https://bitbucket.org/atlassian/atlassian-frontend/commits/96066a06792) - ED-20524: Adding shared state for paste plugin which will be used by new paste options toolbar plugin
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 188.12.3
14
+
15
+ ### Patch Changes
16
+
17
+ - [#41923](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41923) [`0120da635b9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0120da635b9) - [ED-20519] Decoupling more paste plugin from editor-core moving common functions to editor-common
18
+ - Updated dependencies
19
+
3
20
  ## 188.12.2
4
21
 
5
22
  ### Patch Changes
@@ -1,25 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.sortByOrder = sortByOrder;
8
- exports.sortByOrderWithTypeName = sortByOrderWithTypeName;
9
- var _rank = _interopRequireDefault(require("../plugins/rank"));
10
- function sortByOrder(item) {
11
- return function (a, b) {
12
- return _rank.default[item].indexOf(a.name) - _rank.default[item].indexOf(b.name);
13
- };
14
- }
15
-
16
- // while functionally the same, in order to avoid potentially rewriting the ~10
17
- // existing implementations of the above function I decided creating a separate
18
- // function avoided that whole mess. If someone can think of a better way to implement
19
- // the above and below into a single function please do so
20
-
21
- function sortByOrderWithTypeName(item) {
22
- return function (a, b) {
23
- return _rank.default[item].indexOf(a.type.name) - _rank.default[item].indexOf(b.type.name);
24
- };
25
- }
6
+ Object.defineProperty(exports, "sortByOrder", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _legacyRankPlugins.sortByOrder;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "sortByOrderWithTypeName", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _legacyRankPlugins.sortByOrderWithTypeName;
16
+ }
17
+ });
18
+ var _legacyRankPlugins = require("@atlaskit/editor-common/legacy-rank-plugins");
@@ -5,10 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.addDraftDecoration = void 0;
7
7
  exports.annotationExists = annotationExists;
8
- exports.containsAnyAnnotations = containsAnyAnnotations;
8
+ Object.defineProperty(exports, "containsAnyAnnotations", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _utils.containsAnyAnnotations;
12
+ }
13
+ });
9
14
  exports.getPluginState = exports.getDraftCommandAnalyticsPayload = exports.getAnnotationViewKey = exports.getAllAnnotations = exports.findAnnotationsInSelection = void 0;
10
15
  exports.getSelectionPositions = getSelectionPositions;
11
- exports.hasAnnotationMark = hasAnnotationMark;
16
+ Object.defineProperty(exports, "hasAnnotationMark", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _utils.hasAnnotationMark;
20
+ }
21
+ });
12
22
  exports.hasInvalidNodes = void 0;
13
23
  exports.hasInvalidWhitespaceNode = hasInvalidWhitespaceNode;
14
24
  exports.isSelectionValid = exports.inlineCommentPluginKey = void 0;
@@ -20,8 +30,12 @@ var _styles = require("@atlaskit/editor-common/styles");
20
30
  var _utils = require("@atlaskit/editor-common/utils");
21
31
  var _adfSchema = require("@atlaskit/adf-schema");
22
32
  var _types = require("./types");
23
- var _utils2 = require("../../utils");
24
- var _analytics = require("../analytics");
33
+ var _analytics = require("@atlaskit/editor-common/analytics");
34
+ function sum(arr, f) {
35
+ return arr.reduce(function (val, x) {
36
+ return val + f(x);
37
+ }, 0);
38
+ }
25
39
  /**
26
40
  * Finds the marks in the nodes to the left and right.
27
41
  * @param $pos Position to center search around
@@ -63,9 +77,9 @@ var filterAnnotationIds = function filterAnnotationIds(marks) {
63
77
  var reorderAnnotations = function reorderAnnotations(annotations, $from) {
64
78
  var idSet = surroundingMarks($from).map(filterAnnotationIds);
65
79
  annotations.sort(function (a, b) {
66
- return (0, _utils2.sum)(idSet, function (ids) {
80
+ return sum(idSet, function (ids) {
67
81
  return ids.indexOf(a.id);
68
- }) - (0, _utils2.sum)(idSet, function (ids) {
82
+ }) - sum(idSet, function (ids) {
69
83
  return ids.indexOf(b.id);
70
84
  });
71
85
  });
@@ -278,7 +292,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
278
292
  var foundInvalidWhitespace = false;
279
293
  var content = selection.content().content;
280
294
  content.descendants(function (node) {
281
- if ((0, _utils2.isText)(node, schema)) {
295
+ if ((0, _utils.isText)(node, schema)) {
282
296
  return false;
283
297
  }
284
298
  if (node.textContent.trim() === '') {
@@ -291,7 +305,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
291
305
  // and there are multiple nodes
292
306
  !node.eq(content.firstChild) &&
293
307
  // and it is a paragraph node
294
- (0, _utils2.isParagraph)(node, schema);
308
+ (0, _utils.isParagraph)(node, schema);
295
309
  if (!nodeIsTrailingNewLine) {
296
310
  foundInvalidWhitespace = true;
297
311
  }
@@ -301,14 +315,6 @@ function hasInvalidWhitespaceNode(selection, schema) {
301
315
  return foundInvalidWhitespace;
302
316
  }
303
317
 
304
- /*
305
- * verifies if node contains annotation mark
306
- */
307
- function hasAnnotationMark(node, state) {
308
- var annotationMark = state.schema.marks.annotation;
309
- return !!(annotationMark && node && node.marks.length && annotationMark.isInSet(node.marks));
310
- }
311
-
312
318
  /*
313
319
  * verifies that the annotation exists by the given id
314
320
  */
@@ -317,32 +323,6 @@ function annotationExists(annotationId, state) {
317
323
  return !!(commentsPluginState !== null && commentsPluginState !== void 0 && commentsPluginState.annotations) && Object.keys(commentsPluginState.annotations).includes(annotationId);
318
324
  }
319
325
 
320
- /*
321
- * verifies that slice contains any annotations
322
- */
323
- function containsAnyAnnotations(slice, state) {
324
- if (!slice.content.size) {
325
- return false;
326
- }
327
- var hasAnnotation = false;
328
- slice.content.forEach(function (node) {
329
- hasAnnotation = hasAnnotation || hasAnnotationMark(node, state);
330
- // return early if annotation found already
331
- if (hasAnnotation) {
332
- return true;
333
- }
334
- // check annotations in descendants
335
- node.descendants(function (node) {
336
- if (hasAnnotationMark(node, state)) {
337
- hasAnnotation = true;
338
- return false;
339
- }
340
- return true;
341
- });
342
- });
343
- return hasAnnotation;
344
- }
345
-
346
326
  /*
347
327
  * remove annotations that dont exsist in plugin state from slice
348
328
  */
@@ -364,7 +344,7 @@ function stripNonExistingAnnotations(slice, state) {
364
344
  * from node
365
345
  */
366
346
  function stripNonExistingAnnotationsFromNode(node, state) {
367
- if (hasAnnotationMark(node, state)) {
347
+ if ((0, _utils.hasAnnotationMark)(node, state)) {
368
348
  node.marks = node.marks.filter(function (mark) {
369
349
  if (mark.type.name === 'annotation') {
370
350
  return annotationExists(mark.attrs.id, state);
@@ -3,47 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.transformSingleLineCodeBlockToCodeMark = exports.findCodeBlock = void 0;
7
- exports.transformSliceToJoinAdjacentCodeBlocks = transformSliceToJoinAdjacentCodeBlocks;
8
- var _model = require("@atlaskit/editor-prosemirror/model");
9
- var _slice = require("../../utils/slice");
10
- var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- function joinCodeBlocks(left, right) {
12
- var textContext = "".concat(left.textContent, "\n").concat(right.textContent);
13
- return left.type.create(left.attrs, left.type.schema.text(textContext));
14
- }
15
- function mergeAdjacentCodeBlocks(fragment) {
16
- var children = [];
17
- fragment.forEach(function (maybeCodeBlock) {
18
- if (maybeCodeBlock.type === maybeCodeBlock.type.schema.nodes.codeBlock) {
19
- var peekAtPrevious = children[children.length - 1];
20
- if (peekAtPrevious && peekAtPrevious.type === maybeCodeBlock.type) {
21
- return children.push(joinCodeBlocks(children.pop(), maybeCodeBlock));
22
- }
23
- }
24
- return children.push(maybeCodeBlock);
25
- });
26
- return _model.Fragment.from(children);
27
- }
28
- function transformSliceToJoinAdjacentCodeBlocks(slice) {
29
- slice = (0, _slice.mapSlice)(slice, function (node) {
30
- return node.isBlock && !node.isTextblock ? node.copy(mergeAdjacentCodeBlocks(node.content)) : node;
31
- });
32
- // mapSlice won't be able to merge adjacent top-level code-blocks
33
- return new _model.Slice(mergeAdjacentCodeBlocks(slice.content), slice.openStart, slice.openEnd);
34
- }
35
- var transformSingleLineCodeBlockToCodeMark = exports.transformSingleLineCodeBlockToCodeMark = function transformSingleLineCodeBlockToCodeMark(slice, schema) {
36
- if (slice.content.childCount === 1 && (slice.openStart || slice.openEnd)) {
37
- var maybeCodeBlock = slice.content.firstChild;
38
- if (maybeCodeBlock && maybeCodeBlock.type === schema.nodes.codeBlock) {
39
- if (maybeCodeBlock.textContent && maybeCodeBlock.textContent.indexOf('\n') === -1) {
40
- return new _model.Slice(_model.Fragment.from(schema.text(maybeCodeBlock.textContent, [schema.marks.code.create()])), 0, 0);
41
- }
42
- }
6
+ Object.defineProperty(exports, "findCodeBlock", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _transforms.findCodeBlock;
43
10
  }
44
- return slice;
45
- };
46
- var findCodeBlock = exports.findCodeBlock = function findCodeBlock(state, selection) {
47
- var codeBlock = state.schema.nodes.codeBlock;
48
- return (0, _utils.findSelectedNodeOfType)(codeBlock)(selection || state.selection) || (0, _utils.findParentNodeOfType)(codeBlock)(selection || state.selection);
49
- };
11
+ });
12
+ Object.defineProperty(exports, "transformSingleLineCodeBlockToCodeMark", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _transforms.transformSingleLineCodeBlockToCodeMark;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "transformSliceToJoinAdjacentCodeBlocks", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _transforms.transformSliceToJoinAdjacentCodeBlocks;
22
+ }
23
+ });
24
+ var _transforms = require("@atlaskit/editor-common/transforms");
@@ -7,5 +7,6 @@ exports.PastePluginActionTypes = void 0;
7
7
  var PastePluginActionTypes = exports.PastePluginActionTypes = /*#__PURE__*/function (PastePluginActionTypes) {
8
8
  PastePluginActionTypes["START_TRACKING_PASTED_MACRO_POSITIONS"] = "START_TRACKING_PASTED_MACRO_POSITIONS";
9
9
  PastePluginActionTypes["STOP_TRACKING_PASTED_MACRO_POSITIONS"] = "STOP_TRACKING_PASTED_MACRO_POSITIONS";
10
+ PastePluginActionTypes["ON_PASTE"] = "ON_PASTE";
10
11
  return PastePluginActionTypes;
11
12
  }({});
@@ -31,13 +31,12 @@ var _state = require("@atlaskit/editor-prosemirror/state");
31
31
  var _utils = require("@atlaskit/editor-prosemirror/utils");
32
32
  var _v = _interopRequireDefault(require("uuid/v4"));
33
33
  var _utils2 = require("@atlaskit/editor-tables/utils");
34
- var _utils3 = require("../../utils");
35
- var _slice = require("../../utils/slice");
34
+ var _utils3 = require("@atlaskit/editor-common/utils");
35
+ var _coreUtils = require("@atlaskit/editor-common/core-utils");
36
36
  var _analytics = require("@atlaskit/editor-common/analytics");
37
37
  var _selection = require("@atlaskit/editor-common/selection");
38
38
  var _macro = require("../macro");
39
39
  var _util = require("./util");
40
- var _utils4 = require("@atlaskit/editor-common/utils");
41
40
  var _edgeCases = require("./edge-cases");
42
41
  var _commands = require("./commands");
43
42
  var _pluginFactory = require("./pm-plugins/plugin-factory");
@@ -46,10 +45,29 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
46
45
  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); }
47
46
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
48
47
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
49
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
48
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // TODO: ED-20519 Needs Macro extraction
49
+ /** Helper type for single arg function */
50
+
51
+ /**
52
+ * Compose 1 to n functions.
53
+ * @param func first function
54
+ * @param funcs additional functions
55
+ */
56
+ function compose(func) {
57
+ for (var _len = arguments.length, funcs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
58
+ funcs[_key - 1] = arguments[_key];
59
+ }
60
+ var allFuncs = [func].concat(funcs);
61
+ return function composed(raw) {
62
+ return allFuncs.reduceRight(function (memo, func) {
63
+ return func(memo);
64
+ }, raw);
65
+ };
66
+ }
67
+
50
68
  // remove text attribute from mention for copy/paste (GDPR)
51
69
  function handleMention(slice, schema) {
52
- return (0, _slice.mapSlice)(slice, function (node) {
70
+ return (0, _utils3.mapSlice)(slice, function (node) {
53
71
  if (node.type.name === schema.nodes.mention.name) {
54
72
  var mention = node.attrs;
55
73
  var newMention = _objectSpread(_objectSpread({}, mention), {}, {
@@ -105,13 +123,13 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
105
123
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
106
124
  return false;
107
125
  }
108
- var filters = [(0, _utils4.linkifyContent)(schema)];
126
+ var filters = [(0, _utils3.linkifyContent)(schema)];
109
127
  var selectionMarks = selection.$head.marks();
110
128
  if (selection instanceof _state.TextSelection && Array.isArray(selectionMarks) && selectionMarks.length > 0 && (0, _util.hasOnlyNodesOfType)(paragraph, text, emoji, mention, hardBreak)(slice) && (!codeMark.isInSet(selectionMarks) || (0, _mark.anyMarkActive)(state, codeMark)) // check if there is a code mark anywhere in the selection
111
129
  ) {
112
130
  filters.push((0, _util.applyTextMarksToSlice)(schema, selection.$head.marks()));
113
131
  }
114
- var transformedSlice = _utils3.compose.apply(null, filters)(slice);
132
+ var transformedSlice = compose.apply(null, filters)(slice);
115
133
  var tr = (0, _history.closeHistory)(state.tr);
116
134
  var transformedSliceIsValidNode = transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskList', 'taskItem', 'panel'].includes(transformedSlice.content.firstChild.type.name) && !(0, _utils3.isInListItem)(state);
117
135
  // If the slice or the selection are valid nodes to handle,
@@ -154,7 +172,7 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
154
172
 
155
173
  // Slice info
156
174
  var sliceContent = slice.content;
157
- var sliceIsListItems = (0, _utils4.isListNode)(sliceContent.firstChild) && (0, _utils4.isListNode)(sliceContent.lastChild);
175
+ var sliceIsListItems = (0, _utils3.isListNode)(sliceContent.firstChild) && (0, _utils3.isListNode)(sliceContent.lastChild);
158
176
 
159
177
  // Find case of slices that can be inserted into a list item
160
178
  // (eg. paragraphs, list items, code blocks, media single)
@@ -181,7 +199,7 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
181
199
  var selectionIsInNestedList = !!grandParentListNode;
182
200
  var selectedListItemHasNestedList = false;
183
201
  selectionParentListItemNode.node.content.forEach(function (child) {
184
- if ((0, _utils4.isListNode)(child)) {
202
+ if ((0, _utils3.isListNode)(child)) {
185
203
  selectedListItemHasNestedList = true;
186
204
  }
187
205
  });
@@ -325,7 +343,7 @@ function handlePasteLinkOnSelectedText(slice) {
325
343
  }
326
344
 
327
345
  // if we have a link, apply it to the selected text if we have any and it's allowed
328
- if (linkMark && selection instanceof _state.TextSelection && !selection.empty && (0, _utils4.canLinkBeCreatedInRange)(from, to)(state)) {
346
+ if (linkMark && selection instanceof _state.TextSelection && !selection.empty && (0, _utils3.canLinkBeCreatedInRange)(from, to)(state)) {
329
347
  tr.addMark(from, to, linkMark);
330
348
  if (dispatch) {
331
349
  dispatch(tr);
@@ -574,7 +592,7 @@ function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
574
592
  var _insertMediaAsMediaSi;
575
593
  return (_insertMediaAsMediaSi = insertMediaAsMediaSingle === null || insertMediaAsMediaSingle === void 0 ? void 0 : insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod)) !== null && _insertMediaAsMediaSi !== void 0 ? _insertMediaAsMediaSi : false;
576
594
  }
577
- if ((0, _utils3.insideTable)(state) && isOnlyMediaSingle(state, slice)) {
595
+ if ((0, _coreUtils.insideTable)(state) && isOnlyMediaSingle(state, slice)) {
578
596
  var tr = state.tr.replaceSelection(slice);
579
597
  var nextPos = tr.doc.resolve(tr.mapping.map(state.selection.$from.pos));
580
598
  if (dispatch) {
@@ -600,7 +618,7 @@ function handleExpandPasteInTable(slice) {
600
618
  return function (state, dispatch) {
601
619
  // Do not handle expand if it's not being pasted into a table
602
620
  // OR if it's nested within another node when being pasted into a table
603
- if (!(0, _utils3.insideTable)(state) || !checkExpand(slice)) {
621
+ if (!(0, _coreUtils.insideTable)(state) || !checkExpand(slice)) {
604
622
  return false;
605
623
  }
606
624
  var _state$schema$nodes2 = state.schema.nodes,
@@ -608,7 +626,7 @@ function handleExpandPasteInTable(slice) {
608
626
  nestedExpand = _state$schema$nodes2.nestedExpand;
609
627
  var tr = state.tr;
610
628
  var hasExpand = false;
611
- var newSlice = (0, _slice.mapSlice)(slice, function (maybeNode) {
629
+ var newSlice = (0, _utils3.mapSlice)(slice, function (maybeNode) {
612
630
  if (maybeNode.type === expand) {
613
631
  hasExpand = true;
614
632
  try {
@@ -668,7 +686,7 @@ function hasInlineCode(state, slice) {
668
686
  }
669
687
  function rollupLeafListItems(list, leafListItems) {
670
688
  list.content.forEach(function (child) {
671
- if ((0, _utils4.isListNode)(child) || (0, _utils4.isListItemNode)(child) && (0, _utils4.isListNode)(child.firstChild)) {
689
+ if ((0, _utils3.isListNode)(child) || (0, _utils3.isListItemNode)(child) && (0, _utils3.isListNode)(child.firstChild)) {
672
690
  rollupLeafListItems(child, leafListItems);
673
691
  } else {
674
692
  leafListItems.push(child);
@@ -677,7 +695,7 @@ function rollupLeafListItems(list, leafListItems) {
677
695
  }
678
696
  function shouldFlattenList(state, slice) {
679
697
  var node = slice.content.firstChild;
680
- return node && (0, _utils3.insideTable)(state) && (0, _utils4.isListNode)(node) && slice.openStart > slice.openEnd;
698
+ return node && (0, _coreUtils.insideTable)(state) && (0, _utils3.isListNode)(node) && slice.openStart > slice.openEnd;
681
699
  }
682
700
  function sliceHasTopLevelMarks(slice) {
683
701
  var hasTopLevelMarks = false;
@@ -751,7 +769,7 @@ function handleParagraphBlockMarks(state, slice) {
751
769
 
752
770
  // If the paragraph contains marks forbidden by the parent node (e.g. alignment/indentation),
753
771
  // drop those marks from the slice
754
- return (0, _slice.mapSlice)(slice, function (node) {
772
+ return (0, _utils3.mapSlice)(slice, function (node) {
755
773
  if (node.type === schema.nodes.paragraph) {
756
774
  return schema.nodes.paragraph.createChecked(undefined, node.content, node.marks.filter(function (mark) {
757
775
  return !forbiddenMarkTypes.includes(mark.type);
@@ -821,8 +839,8 @@ function handleRichText(slice, queueCardsFromChangedTr) {
821
839
  slice = flattenNestedListInSlice(slice);
822
840
  }
823
841
  (0, _history.closeHistory)(tr);
824
- var isFirstChildListNode = (0, _utils4.isListNode)(firstChildOfSlice);
825
- var isLastChildListNode = (0, _utils4.isListNode)(lastChildOfSlice);
842
+ var isFirstChildListNode = (0, _utils3.isListNode)(firstChildOfSlice);
843
+ var isLastChildListNode = (0, _utils3.isListNode)(lastChildOfSlice);
826
844
  var isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
827
845
  var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'taskList';
828
846
  var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'taskList';
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.pastePlugin = void 0;
7
7
  var _main = require("./pm-plugins/main");
8
+ var _pluginFactory = require("./pm-plugins/plugin-factory");
8
9
  var pastePlugin = exports.pastePlugin = function pastePlugin(_ref) {
9
10
  var _api$featureFlags;
10
11
  var config = _ref.config,
@@ -26,6 +27,17 @@ var pastePlugin = exports.pastePlugin = function pastePlugin(_ref) {
26
27
  return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
27
28
  }
28
29
  }];
30
+ },
31
+ getSharedState: function getSharedState(editorState) {
32
+ if (!editorState) {
33
+ return {
34
+ lastContentPasted: null
35
+ };
36
+ }
37
+ var pluginState = _pluginFactory.pluginKey.getState(editorState);
38
+ return {
39
+ lastContentPasted: pluginState.lastContentPasted
40
+ };
29
41
  }
30
42
  };
31
43
  };
@@ -13,11 +13,11 @@ exports.handleSelectedTableWithAnalytics = exports.handleRichTextWithAnalytics =
13
13
  exports.sendPasteAnalyticsEvent = sendPasteAnalyticsEvent;
14
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _analytics = require("../../analytics");
16
+ var _analytics = require("@atlaskit/editor-common/analytics");
17
+ var _analytics2 = require("../../analytics");
17
18
  var _util = require("../util");
18
19
  var _handlers = require("../handlers");
19
20
  var _utils = require("@atlaskit/editor-prosemirror/utils");
20
- var _slice = require("../../../utils/slice");
21
21
  var _utils2 = require("@atlaskit/editor-common/utils");
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -101,7 +101,7 @@ function getContent(_ref) {
101
101
  }
102
102
  function getMediaTraceId(slice) {
103
103
  var traceId;
104
- (0, _slice.mapSlice)(slice, function (node) {
104
+ (0, _utils2.mapSlice)(slice, function (node) {
105
105
  if (node.type.name === 'media' || node.type.name === 'mediaInline') {
106
106
  traceId = node.attrs.__mediaTraceId;
107
107
  }
@@ -176,7 +176,7 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext) {
176
176
  // If we have a link among the pasted content, grab the
177
177
  // domain and send it up with the analytics event
178
178
  if (content === _analytics.PasteContents.url || content === _analytics.PasteContents.mixed) {
179
- (0, _slice.mapSlice)(slice, function (node) {
179
+ (0, _utils2.mapSlice)(slice, function (node) {
180
180
  var linkMark = node.marks.find(function (mark) {
181
181
  return mark.type.name === 'link';
182
182
  });
@@ -223,7 +223,7 @@ function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
223
223
  // so pasteCommandWithAnalytics is useless in this case.
224
224
  function sendPasteAnalyticsEvent(view, event, slice, pasteContext) {
225
225
  var payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
226
- view.dispatch((0, _analytics.addAnalytics)(view.state, view.state.tr, payload));
226
+ view.dispatch((0, _analytics2.addAnalytics)(view.state, view.state.tr, payload));
227
227
  }
228
228
  var handlePasteAsPlainTextWithAnalytics = exports.handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainTextWithAnalytics(view, event, slice) {
229
229
  return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
@@ -284,7 +284,7 @@ function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
284
284
  if (dispatch && originalTransaction.docChanged) {
285
285
  // it needs to know the selection before the changes
286
286
  var payload = createPayloadByTransaction(state.selection);
287
- (0, _analytics.addAnalytics)(state, originalTransaction, payload);
287
+ (0, _analytics2.addAnalytics)(state, originalTransaction, payload);
288
288
  dispatch(originalTransaction);
289
289
  }
290
290
  return true;