@atlaskit/editor-core 187.18.0 → 187.18.2

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 (100) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/labs/next/presets/universal.js +2 -1
  3. package/dist/cjs/plugins/help-dialog/ui/index.js +26 -27
  4. package/dist/cjs/plugins/index.js +0 -7
  5. package/dist/cjs/plugins/list/index.js +5 -5
  6. package/dist/cjs/plugins/list/transforms.js +1 -223
  7. package/dist/cjs/plugins/paste/commands.js +224 -2
  8. package/dist/cjs/plugins/paste/pm-plugins/main.js +5 -9
  9. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +3 -3
  10. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -4
  11. package/dist/cjs/utils/clipboard.js +5 -27
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/labs/next/presets/universal.js +2 -1
  15. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -2
  16. package/dist/es2019/plugins/index.js +0 -1
  17. package/dist/es2019/plugins/list/index.js +1 -1
  18. package/dist/es2019/plugins/list/transforms.js +2 -210
  19. package/dist/es2019/plugins/paste/commands.js +210 -2
  20. package/dist/es2019/plugins/paste/pm-plugins/main.js +3 -3
  21. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
  22. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  23. package/dist/es2019/utils/clipboard.js +0 -16
  24. package/dist/es2019/version-wrapper.js +1 -1
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/esm/labs/next/presets/universal.js +2 -1
  27. package/dist/esm/plugins/help-dialog/ui/index.js +1 -2
  28. package/dist/esm/plugins/index.js +0 -1
  29. package/dist/esm/plugins/list/index.js +1 -1
  30. package/dist/esm/plugins/list/transforms.js +2 -219
  31. package/dist/esm/plugins/paste/commands.js +218 -1
  32. package/dist/esm/plugins/paste/pm-plugins/main.js +3 -3
  33. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
  34. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  35. package/dist/esm/utils/clipboard.js +4 -23
  36. package/dist/esm/version-wrapper.js +1 -1
  37. package/dist/esm/version.json +1 -1
  38. package/dist/types/plugins/index.d.ts +0 -1
  39. package/dist/types/plugins/insert-block/index.d.ts +1 -1
  40. package/dist/types/plugins/list/transforms.d.ts +0 -13
  41. package/dist/types/plugins/paste/commands.d.ts +14 -0
  42. package/dist/types/plugins/paste/index.d.ts +2 -0
  43. package/dist/types/utils/clipboard.d.ts +0 -3
  44. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  45. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/list/transforms.d.ts +0 -13
  47. package/dist/types-ts4.5/plugins/paste/commands.d.ts +14 -0
  48. package/dist/types-ts4.5/plugins/paste/index.d.ts +2 -0
  49. package/dist/types-ts4.5/utils/clipboard.d.ts +0 -3
  50. package/package.json +4 -3
  51. package/dist/cjs/plugins/image-upload/index.js +0 -45
  52. package/dist/cjs/plugins/image-upload/pm-plugins/actions.js +0 -19
  53. package/dist/cjs/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -19
  54. package/dist/cjs/plugins/image-upload/pm-plugins/commands.js +0 -40
  55. package/dist/cjs/plugins/image-upload/pm-plugins/input-rule.js +0 -31
  56. package/dist/cjs/plugins/image-upload/pm-plugins/main.js +0 -194
  57. package/dist/cjs/plugins/image-upload/pm-plugins/plugin-key.js +0 -9
  58. package/dist/cjs/plugins/image-upload/types.js +0 -5
  59. package/dist/cjs/plugins/image-upload/utils.js +0 -40
  60. package/dist/cjs/utils/drag-drop.js +0 -19
  61. package/dist/es2019/plugins/image-upload/index.js +0 -34
  62. package/dist/es2019/plugins/image-upload/pm-plugins/actions.js +0 -8
  63. package/dist/es2019/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -12
  64. package/dist/es2019/plugins/image-upload/pm-plugins/commands.js +0 -28
  65. package/dist/es2019/plugins/image-upload/pm-plugins/input-rule.js +0 -25
  66. package/dist/es2019/plugins/image-upload/pm-plugins/main.js +0 -159
  67. package/dist/es2019/plugins/image-upload/pm-plugins/plugin-key.js +0 -2
  68. package/dist/es2019/plugins/image-upload/types.js +0 -1
  69. package/dist/es2019/plugins/image-upload/utils.js +0 -38
  70. package/dist/es2019/utils/drag-drop.js +0 -9
  71. package/dist/esm/plugins/image-upload/index.js +0 -37
  72. package/dist/esm/plugins/image-upload/pm-plugins/actions.js +0 -12
  73. package/dist/esm/plugins/image-upload/pm-plugins/commands-toolbar.js +0 -12
  74. package/dist/esm/plugins/image-upload/pm-plugins/commands.js +0 -32
  75. package/dist/esm/plugins/image-upload/pm-plugins/input-rule.js +0 -23
  76. package/dist/esm/plugins/image-upload/pm-plugins/main.js +0 -186
  77. package/dist/esm/plugins/image-upload/pm-plugins/plugin-key.js +0 -2
  78. package/dist/esm/plugins/image-upload/types.js +0 -1
  79. package/dist/esm/plugins/image-upload/utils.js +0 -31
  80. package/dist/esm/utils/drag-drop.js +0 -11
  81. package/dist/types/plugins/image-upload/index.d.ts +0 -16
  82. package/dist/types/plugins/image-upload/pm-plugins/actions.d.ts +0 -3
  83. package/dist/types/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +0 -3
  84. package/dist/types/plugins/image-upload/pm-plugins/commands.d.ts +0 -5
  85. package/dist/types/plugins/image-upload/pm-plugins/input-rule.d.ts +0 -5
  86. package/dist/types/plugins/image-upload/pm-plugins/main.d.ts +0 -4
  87. package/dist/types/plugins/image-upload/pm-plugins/plugin-key.d.ts +0 -3
  88. package/dist/types/plugins/image-upload/types.d.ts +0 -18
  89. package/dist/types/plugins/image-upload/utils.d.ts +0 -5
  90. package/dist/types/utils/drag-drop.d.ts +0 -2
  91. package/dist/types-ts4.5/plugins/image-upload/index.d.ts +0 -16
  92. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/actions.d.ts +0 -3
  93. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +0 -3
  94. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands.d.ts +0 -5
  95. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/input-rule.d.ts +0 -5
  96. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/main.d.ts +0 -4
  97. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/plugin-key.d.ts +0 -3
  98. package/dist/types-ts4.5/plugins/image-upload/types.d.ts +0 -18
  99. package/dist/types-ts4.5/plugins/image-upload/utils.d.ts +0 -5
  100. package/dist/types-ts4.5/utils/drag-drop.d.ts +0 -2
@@ -1,11 +1,6 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
1
  import { Fragment, NodeRange, Slice } from '@atlaskit/editor-prosemirror/model';
4
- import { EditorState, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
3
  import { liftTarget, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
6
- import { autoJoin } from '@atlaskit/editor-prosemirror/commands';
7
- import { isListNode } from '@atlaskit/editor-common/utils';
8
- import { mapSlice, mapChildren } from '../../utils/slice';
9
4
  import { getListLiftTarget } from './utils/indentation';
10
5
  function liftListItem(selection, tr) {
11
6
  var $from = selection.$from,
@@ -94,216 +89,4 @@ export function liftTextSelectionList(selection, tr) {
94
89
  }
95
90
  }
96
91
  return tr;
97
- }
98
-
99
- // matchers for text lists
100
- var bullets = /^\s*[\*\-\u2022](\s+|\s+$)/;
101
- var numbers = /^\s*\d[\.\)](\s+|$)/;
102
- var getListType = function getListType(node, schema) {
103
- if (!node.text) {
104
- return null;
105
- }
106
- var _schema$nodes = schema.nodes,
107
- bulletList = _schema$nodes.bulletList,
108
- orderedList = _schema$nodes.orderedList;
109
- return [{
110
- node: bulletList,
111
- matcher: bullets
112
- }, {
113
- node: orderedList,
114
- matcher: numbers
115
- }].reduce(function (lastMatch, listType) {
116
- if (lastMatch) {
117
- return lastMatch;
118
- }
119
- var match = node.text.match(listType.matcher);
120
- return match ? [listType.node, match[0].length] : lastMatch;
121
- }, null);
122
- };
123
- var extractListFromParagraph = function extractListFromParagraph(node, parent, schema) {
124
- var _schema$nodes2 = schema.nodes,
125
- hardBreak = _schema$nodes2.hardBreak,
126
- bulletList = _schema$nodes2.bulletList,
127
- orderedList = _schema$nodes2.orderedList;
128
- var content = mapChildren(node.content, function (node) {
129
- return node;
130
- });
131
- var listTypes = [bulletList, orderedList];
132
-
133
- // wrap each line into a listItem and a containing list
134
- var listified = content.map(function (child, index) {
135
- var listMatch = getListType(child, schema);
136
- var prevChild = index > 0 && content[index - 1];
137
-
138
- // only extract list when preceded by a hardbreak
139
- if (prevChild && prevChild.type !== hardBreak) {
140
- return child;
141
- }
142
- if (!listMatch || !child.text) {
143
- return child;
144
- }
145
- var _listMatch = _slicedToArray(listMatch, 2),
146
- nodeType = _listMatch[0],
147
- length = _listMatch[1];
148
-
149
- // convert to list item
150
- var newText = child.text.substr(length);
151
- var listItemNode = schema.nodes.listItem.createAndFill(undefined, schema.nodes.paragraph.createChecked(undefined, newText.length ? schema.text(newText) : undefined));
152
- if (!listItemNode) {
153
- return child;
154
- }
155
- var newList = nodeType.createChecked(undefined, [listItemNode]);
156
- // Check whether our new list is valid content in our current structure,
157
- // otherwise dont convert.
158
- if (parent && !parent.type.validContent(Fragment.from(newList))) {
159
- return child;
160
- }
161
- return newList;
162
- }).filter(function (child, idx, arr) {
163
- // remove hardBreaks that have a list node on either side
164
-
165
- // wasn't hardBreak, leave as-is
166
- if (child.type !== hardBreak) {
167
- return child;
168
- }
169
- if (idx > 0 && listTypes.indexOf(arr[idx - 1].type) > -1) {
170
- // list node on the left
171
- return null;
172
- }
173
- if (idx < arr.length - 1 && listTypes.indexOf(arr[idx + 1].type) > -1) {
174
- // list node on the right
175
- return null;
176
- }
177
- return child;
178
- });
179
-
180
- // try to join
181
- var mockState = EditorState.create({
182
- schema: schema
183
- });
184
- var joinedListsTr;
185
- var mockDispatch = function mockDispatch(tr) {
186
- joinedListsTr = tr;
187
- };
188
- autoJoin(function (state, dispatch) {
189
- if (!dispatch) {
190
- return false;
191
- }
192
-
193
- // Return false to prevent replaceWith from wrapping the text node in a paragraph
194
- // paragraph since that will be done later. If it's done here, it will fail
195
- // the paragraph.validContent check.
196
- // Dont return false if there are lists, as they arent validContent for paragraphs
197
- // and will result in hanging textNodes
198
- var containsList = listified.some(function (node) {
199
- return node.type === bulletList || node.type === orderedList;
200
- });
201
- if (listified.some(function (node) {
202
- return node.isText;
203
- }) && !containsList) {
204
- return false;
205
- }
206
- dispatch(state.tr.replaceWith(0, 2, listified));
207
- return true;
208
- }, function (before, after) {
209
- return isListNode(before) && isListNode(after);
210
- })(mockState, mockDispatch);
211
- var fragment = joinedListsTr ? joinedListsTr.doc.content : Fragment.from(listified);
212
-
213
- // try to re-wrap fragment in paragraph (which is the original node we unwrapped)
214
- var paragraph = schema.nodes.paragraph;
215
- if (paragraph.validContent(fragment)) {
216
- return Fragment.from(paragraph.create(node.attrs, fragment, node.marks));
217
- }
218
-
219
- // fragment now contains other nodes, get Prosemirror to wrap with ContentMatch later
220
- return fragment;
221
- };
222
-
223
- /**
224
- * Walks the slice, creating paragraphs that were previously separated by hardbreaks.
225
- * Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
226
- */
227
- export var splitIntoParagraphs = function splitIntoParagraphs(_ref) {
228
- var fragment = _ref.fragment,
229
- _ref$blockMarks = _ref.blockMarks,
230
- blockMarks = _ref$blockMarks === void 0 ? [] : _ref$blockMarks,
231
- schema = _ref.schema;
232
- var paragraphs = [];
233
- var curChildren = [];
234
- var lastNode = null;
235
- var _schema$nodes3 = schema.nodes,
236
- hardBreak = _schema$nodes3.hardBreak,
237
- paragraph = _schema$nodes3.paragraph;
238
- fragment.forEach(function (node, i) {
239
- var isNodeValidContentForParagraph = schema.nodes.paragraph.validContent(Fragment.from(node));
240
- if (!isNodeValidContentForParagraph) {
241
- paragraphs.push(node);
242
- return;
243
- }
244
- // ED-14725 Fixed the issue that it make duplicated line
245
- // when pasting <br /> from google docs.
246
- if (i === 0 && node.type === hardBreak) {
247
- paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
248
- lastNode = node;
249
- return;
250
- } else if (lastNode && lastNode.type === hardBreak && node.type === hardBreak) {
251
- // double hardbreak
252
-
253
- // backtrack a little; remove the trailing hardbreak we added last loop
254
- curChildren.pop();
255
-
256
- // create a new paragraph
257
- paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
258
- curChildren = [];
259
- return;
260
- }
261
-
262
- // add to this paragraph
263
- curChildren.push(node);
264
- lastNode = node;
265
- });
266
- if (curChildren.length) {
267
- paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
268
- }
269
- return Fragment.from(paragraphs.length ? paragraphs : [paragraph.createAndFill(undefined, undefined, _toConsumableArray(blockMarks))]);
270
- };
271
- export var splitParagraphs = function splitParagraphs(slice, schema) {
272
- // exclude Text nodes with a code mark, since we transform those later
273
- // into a codeblock
274
- var hasCodeMark = false;
275
- slice.content.forEach(function (child) {
276
- hasCodeMark = hasCodeMark || child.marks.some(function (mark) {
277
- return mark.type === schema.marks.code;
278
- });
279
- });
280
-
281
- // slice might just be a raw text string
282
- if (schema.nodes.paragraph.validContent(slice.content) && !hasCodeMark) {
283
- var replSlice = splitIntoParagraphs({
284
- fragment: slice.content,
285
- schema: schema
286
- });
287
- return new Slice(replSlice, slice.openStart + 1, slice.openEnd + 1);
288
- }
289
- return mapSlice(slice, function (node) {
290
- if (node.type === schema.nodes.paragraph) {
291
- return splitIntoParagraphs({
292
- fragment: node.content,
293
- blockMarks: node.marks,
294
- schema: schema
295
- });
296
- }
297
- return node;
298
- });
299
- };
300
-
301
- // above will wrap everything in paragraphs for us
302
- export var upgradeTextToLists = function upgradeTextToLists(slice, schema) {
303
- return mapSlice(slice, function (node, parent) {
304
- if (node.type === schema.nodes.paragraph) {
305
- return extractListFromParagraph(node, parent, schema);
306
- }
307
- return node;
308
- });
309
- };
92
+ }
@@ -1,6 +1,11 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
3
  import { createCommand } from './pm-plugins/plugin-factory';
2
4
  import { PastePluginActionTypes as ActionTypes } from './actions';
3
-
5
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
6
+ import { isListNode, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
7
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
8
+ import { autoJoin } from '@atlaskit/editor-prosemirror/commands';
4
9
  /**
5
10
  * Use this to register macro link positions during a paste operation, that you
6
11
  * want to track in a document over time, through any document changes.
@@ -28,4 +33,216 @@ export var stopTrackingPastedMacroPositions = function stopTrackingPastedMacroPo
28
33
  pastedMacroPositionKeys: pastedMacroPositionKeys
29
34
  };
30
35
  });
36
+ };
37
+
38
+ // matchers for text lists
39
+ var bullets = /^\s*[\*\-\u2022](\s+|\s+$)/;
40
+ var numbers = /^\s*\d[\.\)](\s+|$)/;
41
+ var getListType = function getListType(node, schema) {
42
+ if (!node.text) {
43
+ return null;
44
+ }
45
+ var _schema$nodes = schema.nodes,
46
+ bulletList = _schema$nodes.bulletList,
47
+ orderedList = _schema$nodes.orderedList;
48
+ return [{
49
+ node: bulletList,
50
+ matcher: bullets
51
+ }, {
52
+ node: orderedList,
53
+ matcher: numbers
54
+ }].reduce(function (lastMatch, listType) {
55
+ if (lastMatch) {
56
+ return lastMatch;
57
+ }
58
+ var match = node.text.match(listType.matcher);
59
+ return match ? [listType.node, match[0].length] : lastMatch;
60
+ }, null);
61
+ };
62
+ var extractListFromParagraph = function extractListFromParagraph(node, parent, schema) {
63
+ var _schema$nodes2 = schema.nodes,
64
+ hardBreak = _schema$nodes2.hardBreak,
65
+ bulletList = _schema$nodes2.bulletList,
66
+ orderedList = _schema$nodes2.orderedList;
67
+ var content = mapChildren(node.content, function (node) {
68
+ return node;
69
+ });
70
+ var listTypes = [bulletList, orderedList];
71
+
72
+ // wrap each line into a listItem and a containing list
73
+ var listified = content.map(function (child, index) {
74
+ var listMatch = getListType(child, schema);
75
+ var prevChild = index > 0 && content[index - 1];
76
+
77
+ // only extract list when preceded by a hardbreak
78
+ if (prevChild && prevChild.type !== hardBreak) {
79
+ return child;
80
+ }
81
+ if (!listMatch || !child.text) {
82
+ return child;
83
+ }
84
+ var _listMatch = _slicedToArray(listMatch, 2),
85
+ nodeType = _listMatch[0],
86
+ length = _listMatch[1];
87
+
88
+ // convert to list item
89
+ var newText = child.text.substr(length);
90
+ var listItemNode = schema.nodes.listItem.createAndFill(undefined, schema.nodes.paragraph.createChecked(undefined, newText.length ? schema.text(newText) : undefined));
91
+ if (!listItemNode) {
92
+ return child;
93
+ }
94
+ var newList = nodeType.createChecked(undefined, [listItemNode]);
95
+ // Check whether our new list is valid content in our current structure,
96
+ // otherwise dont convert.
97
+ if (parent && !parent.type.validContent(Fragment.from(newList))) {
98
+ return child;
99
+ }
100
+ return newList;
101
+ }).filter(function (child, idx, arr) {
102
+ // remove hardBreaks that have a list node on either side
103
+
104
+ // wasn't hardBreak, leave as-is
105
+ if (child.type !== hardBreak) {
106
+ return child;
107
+ }
108
+ if (idx > 0 && listTypes.indexOf(arr[idx - 1].type) > -1) {
109
+ // list node on the left
110
+ return null;
111
+ }
112
+ if (idx < arr.length - 1 && listTypes.indexOf(arr[idx + 1].type) > -1) {
113
+ // list node on the right
114
+ return null;
115
+ }
116
+ return child;
117
+ });
118
+
119
+ // try to join
120
+ var mockState = EditorState.create({
121
+ schema: schema
122
+ });
123
+ var joinedListsTr;
124
+ var mockDispatch = function mockDispatch(tr) {
125
+ joinedListsTr = tr;
126
+ };
127
+ autoJoin(function (state, dispatch) {
128
+ if (!dispatch) {
129
+ return false;
130
+ }
131
+
132
+ // Return false to prevent replaceWith from wrapping the text node in a paragraph
133
+ // paragraph since that will be done later. If it's done here, it will fail
134
+ // the paragraph.validContent check.
135
+ // Dont return false if there are lists, as they arent validContent for paragraphs
136
+ // and will result in hanging textNodes
137
+ var containsList = listified.some(function (node) {
138
+ return node.type === bulletList || node.type === orderedList;
139
+ });
140
+ if (listified.some(function (node) {
141
+ return node.isText;
142
+ }) && !containsList) {
143
+ return false;
144
+ }
145
+ dispatch(state.tr.replaceWith(0, 2, listified));
146
+ return true;
147
+ }, function (before, after) {
148
+ return isListNode(before) && isListNode(after);
149
+ })(mockState, mockDispatch);
150
+ var fragment = joinedListsTr ? joinedListsTr.doc.content : Fragment.from(listified);
151
+
152
+ // try to re-wrap fragment in paragraph (which is the original node we unwrapped)
153
+ var paragraph = schema.nodes.paragraph;
154
+ if (paragraph.validContent(fragment)) {
155
+ return Fragment.from(paragraph.create(node.attrs, fragment, node.marks));
156
+ }
157
+
158
+ // fragment now contains other nodes, get Prosemirror to wrap with ContentMatch later
159
+ return fragment;
160
+ };
161
+
162
+ // above will wrap everything in paragraphs for us
163
+ export var upgradeTextToLists = function upgradeTextToLists(slice, schema) {
164
+ return mapSlice(slice, function (node, parent) {
165
+ if (node.type === schema.nodes.paragraph) {
166
+ return extractListFromParagraph(node, parent, schema);
167
+ }
168
+ return node;
169
+ });
170
+ };
171
+ export var splitParagraphs = function splitParagraphs(slice, schema) {
172
+ // exclude Text nodes with a code mark, since we transform those later
173
+ // into a codeblock
174
+ var hasCodeMark = false;
175
+ slice.content.forEach(function (child) {
176
+ hasCodeMark = hasCodeMark || child.marks.some(function (mark) {
177
+ return mark.type === schema.marks.code;
178
+ });
179
+ });
180
+
181
+ // slice might just be a raw text string
182
+ if (schema.nodes.paragraph.validContent(slice.content) && !hasCodeMark) {
183
+ var replSlice = splitIntoParagraphs({
184
+ fragment: slice.content,
185
+ schema: schema
186
+ });
187
+ return new Slice(replSlice, slice.openStart + 1, slice.openEnd + 1);
188
+ }
189
+ return mapSlice(slice, function (node) {
190
+ if (node.type === schema.nodes.paragraph) {
191
+ return splitIntoParagraphs({
192
+ fragment: node.content,
193
+ blockMarks: node.marks,
194
+ schema: schema
195
+ });
196
+ }
197
+ return node;
198
+ });
199
+ };
200
+
201
+ /**
202
+ * Walks the slice, creating paragraphs that were previously separated by hardbreaks.
203
+ * Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
204
+ */
205
+ export var splitIntoParagraphs = function splitIntoParagraphs(_ref) {
206
+ var fragment = _ref.fragment,
207
+ _ref$blockMarks = _ref.blockMarks,
208
+ blockMarks = _ref$blockMarks === void 0 ? [] : _ref$blockMarks,
209
+ schema = _ref.schema;
210
+ var paragraphs = [];
211
+ var curChildren = [];
212
+ var lastNode = null;
213
+ var _schema$nodes3 = schema.nodes,
214
+ hardBreak = _schema$nodes3.hardBreak,
215
+ paragraph = _schema$nodes3.paragraph;
216
+ fragment.forEach(function (node, i) {
217
+ var isNodeValidContentForParagraph = schema.nodes.paragraph.validContent(Fragment.from(node));
218
+ if (!isNodeValidContentForParagraph) {
219
+ paragraphs.push(node);
220
+ return;
221
+ }
222
+ // ED-14725 Fixed the issue that it make duplicated line
223
+ // when pasting <br /> from google docs.
224
+ if (i === 0 && node.type === hardBreak) {
225
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
226
+ lastNode = node;
227
+ return;
228
+ } else if (lastNode && lastNode.type === hardBreak && node.type === hardBreak) {
229
+ // double hardbreak
230
+
231
+ // backtrack a little; remove the trailing hardbreak we added last loop
232
+ curChildren.pop();
233
+
234
+ // create a new paragraph
235
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
236
+ curChildren = [];
237
+ return;
238
+ }
239
+
240
+ // add to this paragraph
241
+ curChildren.push(node);
242
+ lastNode = node;
243
+ });
244
+ if (curChildren.length) {
245
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, _toConsumableArray(blockMarks)));
246
+ }
247
+ return Fragment.from(paragraphs.length ? paragraphs : [paragraph.createAndFill(undefined, undefined, _toConsumableArray(blockMarks))]);
31
248
  };
@@ -7,7 +7,7 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
7
7
  import { addLinkMetadata } from '@atlaskit/editor-common/card';
8
8
  import { mapChildren } from '../../../utils/slice';
9
9
  import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
10
- import * as clipboard from '../../../utils/clipboard';
10
+ import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
11
11
  import { transformSliceForMedia } from '../../media/utils/media-single';
12
12
  import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
13
13
  import { linkifyContent } from '@atlaskit/editor-common/utils';
@@ -19,7 +19,7 @@ import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../anal
19
19
  import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
20
20
  import { measureRender } from '@atlaskit/editor-common/utils';
21
21
  import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
22
- import { upgradeTextToLists, splitParagraphs } from '../../list/transforms';
22
+ import { upgradeTextToLists, splitParagraphs } from '../commands';
23
23
  import { md } from '@atlaskit/editor-common/paste';
24
24
  import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
25
25
  import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
@@ -120,7 +120,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
120
120
  if ((_text = text) !== null && _text !== void 0 && _text.includes('\r')) {
121
121
  text = text.replace(/\r/g, '');
122
122
  }
123
- var isPastedFile = clipboard.isPastedFile(event);
123
+ var isPastedFile = isPastedFileFromEvent(event);
124
124
  var isPlainText = text && !html;
125
125
  var isRichText = !!html;
126
126
 
@@ -7,7 +7,7 @@ import IndentIcon from '@atlaskit/icon/glyph/editor/indent';
7
7
  import OutdentIcon from '@atlaskit/icon/glyph/editor/outdent';
8
8
  import { toggleBulletList as toggleBulletListKeymap, toggleOrderedList as toggleOrderedListKeymap, indent as toggleIndentKeymap, outdent as toggleOutdentKeymap, ToolTipContent, tooltip } from '../../../keymaps';
9
9
  import ToolbarButton, { TOOLBAR_BUTTON } from '../../../ui/ToolbarButton';
10
- import { messages } from '../../list/messages';
10
+ import { listMessages as messages } from '@atlaskit/editor-common/messages';
11
11
  import { messages as indentationMessages } from '../../indentation/messages';
12
12
  import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
13
13
  import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
@@ -10,7 +10,7 @@ import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/ed
10
10
  import ToolbarButton from '../../../ui/ToolbarButton';
11
11
  import { expandIconWrapperStyle, shortcutStyle } from '../../../ui/styles';
12
12
  import { wrapperStyle, separatorStyles } from '@atlaskit/editor-common/styles';
13
- import { messages as listMessages } from '../../list/messages';
13
+ import { listMessages } from '@atlaskit/editor-common/messages';
14
14
  import { messages as indentationMessages } from '../../indentation/messages';
15
15
  export function ToolbarDropdown(props) {
16
16
  var _useIntl = useIntl(),
@@ -2,25 +2,6 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import * as clipboard from 'clipboard-polyfill';
5
- export function checkClipboardTypes(type, item) {
6
- var isDOMStringList = function isDOMStringList(t) {
7
- return !t.indexOf && !!t.contains;
8
- };
9
- return isDOMStringList(type) ? type.contains(item) : type.indexOf(item) > -1;
10
- }
11
-
12
- // Typeguard Function
13
- export var isClipboardEvent = function isClipboardEvent(event) {
14
- return 'clipboardData' in event;
15
- };
16
- export function isPastedFile(rawEvent) {
17
- var _ref = rawEvent,
18
- clipboardData = _ref.clipboardData;
19
- if (!clipboardData) {
20
- return false;
21
- }
22
- return checkClipboardTypes(clipboardData.types, 'Files');
23
- }
24
5
  var isClipboardApiSupported = function isClipboardApiSupported() {
25
6
  return !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
26
7
  };
@@ -28,7 +9,7 @@ var isIEClipboardApiSupported = function isIEClipboardApiSupported() {
28
9
  return window.clipboardData && typeof window.clipboardData.setData === 'function';
29
10
  };
30
11
  export var copyToClipboard = /*#__PURE__*/function () {
31
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(textToCopy) {
12
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(textToCopy) {
32
13
  return _regeneratorRuntime.wrap(function _callee$(_context) {
33
14
  while (1) switch (_context.prev = _context.next) {
34
15
  case 0:
@@ -76,11 +57,11 @@ export var copyToClipboard = /*#__PURE__*/function () {
76
57
  }, _callee, null, [[1, 6], [12, 17]]);
77
58
  }));
78
59
  return function copyToClipboard(_x) {
79
- return _ref2.apply(this, arguments);
60
+ return _ref.apply(this, arguments);
80
61
  };
81
62
  }();
82
63
  export var copyHTMLToClipboard = /*#__PURE__*/function () {
83
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(elementToCopy, plainTextToCopy) {
64
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(elementToCopy, plainTextToCopy) {
84
65
  var data;
85
66
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
86
67
  while (1) switch (_context2.prev = _context2.next) {
@@ -123,7 +104,7 @@ export var copyHTMLToClipboard = /*#__PURE__*/function () {
123
104
  }, _callee2, null, [[1, 7]]);
124
105
  }));
125
106
  return function copyHTMLToClipboard(_x2, _x3) {
126
- return _ref3.apply(this, arguments);
107
+ return _ref2.apply(this, arguments);
127
108
  };
128
109
  }();
129
110
 
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.18.0";
2
+ export var version = "187.18.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.18.0",
3
+ "version": "187.18.2",
4
4
  "sideEffects": false
5
5
  }
@@ -11,7 +11,6 @@ export { default as emojiPlugin } from './emoji';
11
11
  export { default as extensionPlugin } from './extension';
12
12
  export { default as fakeTextCursorPlugin } from './fake-text-cursor';
13
13
  export { default as helpDialogPlugin } from './help-dialog';
14
- export { default as imageUploadPlugin } from './image-upload';
15
14
  export { default as insertBlockPlugin } from './insert-block';
16
15
  export { default as jiraIssuePlugin } from './jira-issue';
17
16
  export { default as layoutPlugin } from './layout';
@@ -1,5 +1,5 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import type { ImageUploadPlugin } from '../image-upload';
2
+ import type { ImageUploadPlugin } from '@atlaskit/editor-plugin-image-upload';
3
3
  import type datePlugin from '../date';
4
4
  import type { tablesPlugin } from '@atlaskit/editor-plugin-table';
5
5
  import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
@@ -1,17 +1,4 @@
1
- import type { Schema, Mark } from '@atlaskit/editor-prosemirror/model';
2
- import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
1
  import type { Transaction, Selection } from '@atlaskit/editor-prosemirror/state';
4
2
  export declare function liftFollowingList(from: number, to: number, rootListDepth: number, tr: Transaction): Transaction;
5
3
  export declare function liftNodeSelectionList(selection: Selection, tr: Transaction): Transaction;
6
4
  export declare function liftTextSelectionList(selection: Selection, tr: Transaction): Transaction;
7
- /**
8
- * Walks the slice, creating paragraphs that were previously separated by hardbreaks.
9
- * Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
10
- */
11
- export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
12
- fragment: Fragment;
13
- blockMarks?: readonly Mark[] | undefined;
14
- schema: Schema;
15
- }) => Fragment;
16
- export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
17
- export declare const upgradeTextToLists: (slice: Slice, schema: Schema) => Slice;
@@ -1,3 +1,6 @@
1
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
1
4
  /**
2
5
  * Use this to register macro link positions during a paste operation, that you
3
6
  * want to track in a document over time, through any document changes.
@@ -14,3 +17,14 @@ export declare const startTrackingPastedMacroPositions: (pastedMacroPositions: {
14
17
  [key: string]: number;
15
18
  }) => import("@atlaskit/editor-common/types").Command;
16
19
  export declare const stopTrackingPastedMacroPositions: (pastedMacroPositionKeys: string[]) => import("@atlaskit/editor-common/types").Command;
20
+ export declare const upgradeTextToLists: (slice: Slice, schema: Schema) => Slice;
21
+ export declare const splitParagraphs: (slice: Slice, schema: Schema) => Slice;
22
+ /**
23
+ * Walks the slice, creating paragraphs that were previously separated by hardbreaks.
24
+ * Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
25
+ */
26
+ export declare const splitIntoParagraphs: ({ fragment, blockMarks, schema, }: {
27
+ fragment: Fragment;
28
+ blockMarks?: readonly Mark[] | undefined;
29
+ schema: Schema;
30
+ }) => Fragment;
@@ -3,6 +3,7 @@ import type { CardOptions } from '@atlaskit/editor-common/card';
3
3
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
4
4
  import type { cardPlugin } from '@atlaskit/editor-plugin-card';
5
5
  import type betterTypeHistoryPlugin from '../better-type-history';
6
+ import type listPlugin from '../list';
6
7
  export type PastePluginOptions = {
7
8
  cardOptions?: CardOptions;
8
9
  sanitizePrivateContent?: boolean;
@@ -11,6 +12,7 @@ declare const pastePlugin: NextEditorPlugin<'paste', {
11
12
  pluginConfiguration: PastePluginOptions;
12
13
  dependencies: [
13
14
  typeof featureFlagsPlugin,
15
+ OptionalPlugin<typeof listPlugin>,
14
16
  typeof betterTypeHistoryPlugin,
15
17
  OptionalPlugin<typeof cardPlugin>
16
18
  ];
@@ -1,6 +1,3 @@
1
- export declare function checkClipboardTypes(type: DOMStringList | ReadonlyArray<string>, item: string): boolean;
2
- export declare const isClipboardEvent: (event: Event) => event is ClipboardEvent;
3
- export declare function isPastedFile(rawEvent: Event): boolean;
4
1
  export declare const copyToClipboard: (textToCopy: string) => Promise<void>;
5
2
  export declare const copyHTMLToClipboard: (elementToCopy: HTMLElement, plainTextToCopy?: string) => Promise<void>;
6
3
  export declare const copyHTMLToClipboardPolyfill: (elementToCopy: HTMLElement, plainTextToCopy?: string) => void;
@@ -11,7 +11,6 @@ export { default as emojiPlugin } from './emoji';
11
11
  export { default as extensionPlugin } from './extension';
12
12
  export { default as fakeTextCursorPlugin } from './fake-text-cursor';
13
13
  export { default as helpDialogPlugin } from './help-dialog';
14
- export { default as imageUploadPlugin } from './image-upload';
15
14
  export { default as insertBlockPlugin } from './insert-block';
16
15
  export { default as jiraIssuePlugin } from './jira-issue';
17
16
  export { default as layoutPlugin } from './layout';