@atlaskit/editor-core 187.18.0 → 187.18.1

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 (35) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/help-dialog/ui/index.js +26 -27
  3. package/dist/cjs/plugins/list/index.js +5 -5
  4. package/dist/cjs/plugins/list/transforms.js +1 -223
  5. package/dist/cjs/plugins/paste/commands.js +224 -2
  6. package/dist/cjs/plugins/paste/pm-plugins/main.js +3 -3
  7. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +3 -3
  8. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -4
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -2
  12. package/dist/es2019/plugins/list/index.js +1 -1
  13. package/dist/es2019/plugins/list/transforms.js +2 -210
  14. package/dist/es2019/plugins/paste/commands.js +210 -2
  15. package/dist/es2019/plugins/paste/pm-plugins/main.js +1 -1
  16. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
  17. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  18. package/dist/es2019/version-wrapper.js +1 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/plugins/help-dialog/ui/index.js +1 -2
  21. package/dist/esm/plugins/list/index.js +1 -1
  22. package/dist/esm/plugins/list/transforms.js +2 -219
  23. package/dist/esm/plugins/paste/commands.js +218 -1
  24. package/dist/esm/plugins/paste/pm-plugins/main.js +1 -1
  25. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +1 -1
  26. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +1 -1
  27. package/dist/esm/version-wrapper.js +1 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/plugins/list/transforms.d.ts +0 -13
  30. package/dist/types/plugins/paste/commands.d.ts +14 -0
  31. package/dist/types/plugins/paste/index.d.ts +2 -0
  32. package/dist/types-ts4.5/plugins/list/transforms.d.ts +0 -13
  33. package/dist/types-ts4.5/plugins/paste/commands.d.ts +14 -0
  34. package/dist/types-ts4.5/plugins/paste/index.d.ts +2 -0
  35. package/package.json +2 -2
@@ -1,6 +1,9 @@
1
1
  import { createCommand } from './pm-plugins/plugin-factory';
2
2
  import { PastePluginActionTypes as ActionTypes } from './actions';
3
-
3
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
+ import { isListNode, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
5
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
6
+ import { autoJoin } from '@atlaskit/editor-prosemirror/commands';
4
7
  /**
5
8
  * Use this to register macro link positions during a paste operation, that you
6
9
  * want to track in a document over time, through any document changes.
@@ -24,4 +27,209 @@ export const stopTrackingPastedMacroPositions = pastedMacroPositionKeys => creat
24
27
  type: ActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS,
25
28
  pastedMacroPositionKeys
26
29
  };
27
- });
30
+ });
31
+
32
+ // matchers for text lists
33
+ const bullets = /^\s*[\*\-\u2022](\s+|\s+$)/;
34
+ const numbers = /^\s*\d[\.\)](\s+|$)/;
35
+ const getListType = (node, schema) => {
36
+ if (!node.text) {
37
+ return null;
38
+ }
39
+ const {
40
+ bulletList,
41
+ orderedList
42
+ } = schema.nodes;
43
+ return [{
44
+ node: bulletList,
45
+ matcher: bullets
46
+ }, {
47
+ node: orderedList,
48
+ matcher: numbers
49
+ }].reduce((lastMatch, listType) => {
50
+ if (lastMatch) {
51
+ return lastMatch;
52
+ }
53
+ const match = node.text.match(listType.matcher);
54
+ return match ? [listType.node, match[0].length] : lastMatch;
55
+ }, null);
56
+ };
57
+ const extractListFromParagraph = (node, parent, schema) => {
58
+ const {
59
+ hardBreak,
60
+ bulletList,
61
+ orderedList
62
+ } = schema.nodes;
63
+ const content = mapChildren(node.content, node => node);
64
+ const listTypes = [bulletList, orderedList];
65
+
66
+ // wrap each line into a listItem and a containing list
67
+ const listified = content.map((child, index) => {
68
+ const listMatch = getListType(child, schema);
69
+ const prevChild = index > 0 && content[index - 1];
70
+
71
+ // only extract list when preceded by a hardbreak
72
+ if (prevChild && prevChild.type !== hardBreak) {
73
+ return child;
74
+ }
75
+ if (!listMatch || !child.text) {
76
+ return child;
77
+ }
78
+ const [nodeType, length] = listMatch;
79
+
80
+ // convert to list item
81
+ const newText = child.text.substr(length);
82
+ const listItemNode = schema.nodes.listItem.createAndFill(undefined, schema.nodes.paragraph.createChecked(undefined, newText.length ? schema.text(newText) : undefined));
83
+ if (!listItemNode) {
84
+ return child;
85
+ }
86
+ const newList = nodeType.createChecked(undefined, [listItemNode]);
87
+ // Check whether our new list is valid content in our current structure,
88
+ // otherwise dont convert.
89
+ if (parent && !parent.type.validContent(Fragment.from(newList))) {
90
+ return child;
91
+ }
92
+ return newList;
93
+ }).filter((child, idx, arr) => {
94
+ // remove hardBreaks that have a list node on either side
95
+
96
+ // wasn't hardBreak, leave as-is
97
+ if (child.type !== hardBreak) {
98
+ return child;
99
+ }
100
+ if (idx > 0 && listTypes.indexOf(arr[idx - 1].type) > -1) {
101
+ // list node on the left
102
+ return null;
103
+ }
104
+ if (idx < arr.length - 1 && listTypes.indexOf(arr[idx + 1].type) > -1) {
105
+ // list node on the right
106
+ return null;
107
+ }
108
+ return child;
109
+ });
110
+
111
+ // try to join
112
+ const mockState = EditorState.create({
113
+ schema
114
+ });
115
+ let joinedListsTr;
116
+ const mockDispatch = tr => {
117
+ joinedListsTr = tr;
118
+ };
119
+ autoJoin((state, dispatch) => {
120
+ if (!dispatch) {
121
+ return false;
122
+ }
123
+
124
+ // Return false to prevent replaceWith from wrapping the text node in a paragraph
125
+ // paragraph since that will be done later. If it's done here, it will fail
126
+ // the paragraph.validContent check.
127
+ // Dont return false if there are lists, as they arent validContent for paragraphs
128
+ // and will result in hanging textNodes
129
+ const containsList = listified.some(node => node.type === bulletList || node.type === orderedList);
130
+ if (listified.some(node => node.isText) && !containsList) {
131
+ return false;
132
+ }
133
+ dispatch(state.tr.replaceWith(0, 2, listified));
134
+ return true;
135
+ }, (before, after) => isListNode(before) && isListNode(after))(mockState, mockDispatch);
136
+ const fragment = joinedListsTr ? joinedListsTr.doc.content : Fragment.from(listified);
137
+
138
+ // try to re-wrap fragment in paragraph (which is the original node we unwrapped)
139
+ const {
140
+ paragraph
141
+ } = schema.nodes;
142
+ if (paragraph.validContent(fragment)) {
143
+ return Fragment.from(paragraph.create(node.attrs, fragment, node.marks));
144
+ }
145
+
146
+ // fragment now contains other nodes, get Prosemirror to wrap with ContentMatch later
147
+ return fragment;
148
+ };
149
+
150
+ // above will wrap everything in paragraphs for us
151
+ export const upgradeTextToLists = (slice, schema) => {
152
+ return mapSlice(slice, (node, parent) => {
153
+ if (node.type === schema.nodes.paragraph) {
154
+ return extractListFromParagraph(node, parent, schema);
155
+ }
156
+ return node;
157
+ });
158
+ };
159
+ export const splitParagraphs = (slice, schema) => {
160
+ // exclude Text nodes with a code mark, since we transform those later
161
+ // into a codeblock
162
+ let hasCodeMark = false;
163
+ slice.content.forEach(child => {
164
+ hasCodeMark = hasCodeMark || child.marks.some(mark => mark.type === schema.marks.code);
165
+ });
166
+
167
+ // slice might just be a raw text string
168
+ if (schema.nodes.paragraph.validContent(slice.content) && !hasCodeMark) {
169
+ const replSlice = splitIntoParagraphs({
170
+ fragment: slice.content,
171
+ schema
172
+ });
173
+ return new Slice(replSlice, slice.openStart + 1, slice.openEnd + 1);
174
+ }
175
+ return mapSlice(slice, node => {
176
+ if (node.type === schema.nodes.paragraph) {
177
+ return splitIntoParagraphs({
178
+ fragment: node.content,
179
+ blockMarks: node.marks,
180
+ schema
181
+ });
182
+ }
183
+ return node;
184
+ });
185
+ };
186
+
187
+ /**
188
+ * Walks the slice, creating paragraphs that were previously separated by hardbreaks.
189
+ * Returns the original paragraph node (as a fragment), or a fragment containing multiple nodes.
190
+ */
191
+ export const splitIntoParagraphs = ({
192
+ fragment,
193
+ blockMarks = [],
194
+ schema
195
+ }) => {
196
+ const paragraphs = [];
197
+ let curChildren = [];
198
+ let lastNode = null;
199
+ const {
200
+ hardBreak,
201
+ paragraph
202
+ } = schema.nodes;
203
+ fragment.forEach((node, i) => {
204
+ const isNodeValidContentForParagraph = schema.nodes.paragraph.validContent(Fragment.from(node));
205
+ if (!isNodeValidContentForParagraph) {
206
+ paragraphs.push(node);
207
+ return;
208
+ }
209
+ // ED-14725 Fixed the issue that it make duplicated line
210
+ // when pasting <br /> from google docs.
211
+ if (i === 0 && node.type === hardBreak) {
212
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, [...blockMarks]));
213
+ lastNode = node;
214
+ return;
215
+ } else if (lastNode && lastNode.type === hardBreak && node.type === hardBreak) {
216
+ // double hardbreak
217
+
218
+ // backtrack a little; remove the trailing hardbreak we added last loop
219
+ curChildren.pop();
220
+
221
+ // create a new paragraph
222
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, [...blockMarks]));
223
+ curChildren = [];
224
+ return;
225
+ }
226
+
227
+ // add to this paragraph
228
+ curChildren.push(node);
229
+ lastNode = node;
230
+ });
231
+ if (curChildren.length) {
232
+ paragraphs.push(paragraph.createChecked(undefined, curChildren, [...blockMarks]));
233
+ }
234
+ return Fragment.from(paragraphs.length ? paragraphs : [paragraph.createAndFill(undefined, undefined, [...blockMarks])]);
235
+ };
@@ -17,7 +17,7 @@ import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../anal
17
17
  import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
18
18
  import { measureRender } from '@atlaskit/editor-common/utils';
19
19
  import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
20
- import { upgradeTextToLists, splitParagraphs } from '../../list/transforms';
20
+ import { upgradeTextToLists, splitParagraphs } from '../commands';
21
21
  import { md } from '@atlaskit/editor-common/paste';
22
22
  import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
23
23
  import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
@@ -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';
@@ -9,7 +9,7 @@ import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/ed
9
9
  import ToolbarButton from '../../../ui/ToolbarButton';
10
10
  import { expandIconWrapperStyle, shortcutStyle } from '../../../ui/styles';
11
11
  import { wrapperStyle, separatorStyles } from '@atlaskit/editor-common/styles';
12
- import { messages as listMessages } from '../../list/messages';
12
+ import { listMessages } from '@atlaskit/editor-common/messages';
13
13
  import { messages as indentationMessages } from '../../indentation/messages';
14
14
  export function ToolbarDropdown(props) {
15
15
  const {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.18.0";
2
+ export const version = "187.18.1";
3
3
  export const 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.1",
4
4
  "sideEffects": false
5
5
  }
@@ -19,8 +19,7 @@ import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog
19
19
  import { header, footer, contentWrapper, line, content, row, codeSm, codeMd, codeLg, title, column, dialogHeader } from './styles';
20
20
  import * as keymaps from '../../../keymaps';
21
21
  import ToolbarButton from '../../../ui/ToolbarButton';
22
- import { toolbarMessages } from '@atlaskit/editor-common/messages';
23
- import { messages as listMessages } from '../../list/messages';
22
+ import { toolbarMessages, listMessages } from '@atlaskit/editor-common/messages';
24
23
  import { messages as insertBlockMessages } from '../../insert-block/ui/ToolbarInsertBlock/messages';
25
24
  import { messages as blockTypeMessages } from '../../block-type/messages';
26
25
  import { messages as undoRedoMessages } from '../../undo-redo/messages';
@@ -3,7 +3,7 @@ import { orderedList, orderedListWithOrder, bulletList, listItem } from '@atlask
3
3
  import { createPlugin } from './pm-plugins/main';
4
4
  import inputRulePlugin from './pm-plugins/input-rules';
5
5
  import keymapPlugin from './pm-plugins/keymap';
6
- import { messages } from './messages';
6
+ import { listMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { ACTION, EVENT_TYPE, INPUT_METHOD, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
8
8
  import { tooltip, toggleBulletList, toggleOrderedList } from '../../keymaps';
9
9
  import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
@@ -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
+ }