@manuscripts/body-editor 1.11.7-LEAN-1330.0 → 1.11.7

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.
@@ -96,7 +96,7 @@ const createSelection = (nodeType, position, doc) => {
96
96
  }
97
97
  };
98
98
  exports.createSelection = createSelection;
99
- const createBlock = (nodeType, position, state, dispatch) => {
99
+ const createBlock = (nodeType, position, state, dispatch, attrs) => {
100
100
  let node;
101
101
  switch (nodeType) {
102
102
  case state.schema.nodes.table_element:
@@ -117,7 +117,7 @@ const createBlock = (nodeType, position, state, dispatch) => {
117
117
  ]);
118
118
  break;
119
119
  default:
120
- node = nodeType.createAndFill();
120
+ node = nodeType.createAndFill(attrs);
121
121
  }
122
122
  const tr = state.tr.insert(position, node);
123
123
  if (dispatch) {
@@ -397,10 +397,7 @@ const insertSection = (subsection = false) => (state, dispatch) => {
397
397
  return true;
398
398
  };
399
399
  exports.insertSection = insertSection;
400
- const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
401
- transform_1.schema.nodes.ordered_list,
402
- transform_1.schema.nodes.bullet_list,
403
- ]);
400
+ const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([transform_1.schema.nodes.list]);
404
401
  const findRootList = ($pos) => {
405
402
  for (let i = 0; i < $pos.depth; i++) {
406
403
  const node = $pos.node(i);
@@ -467,7 +464,7 @@ const insertList = (type, style) => (state, dispatch, view) => {
467
464
  for (const { node, pos } of nodes) {
468
465
  tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
469
466
  }
470
- dispatch((0, track_changes_plugin_1.skipTracking)(tr));
467
+ dispatch(tr);
471
468
  return true;
472
469
  }
473
470
  else {
@@ -27,16 +27,18 @@ const react_select_1 = __importDefault(require("react-select"));
27
27
  const styled_components_1 = __importDefault(require("styled-components"));
28
28
  const hierarchy_1 = require("../../lib/hierarchy");
29
29
  const node_type_icons_1 = require("../../node-type-icons");
30
- const optionName = (nodeType, depth) => {
30
+ const optionName = (nodeType, depth, listType) => {
31
31
  switch (nodeType) {
32
32
  case nodeType.schema.nodes.section:
33
33
  return (depth > 0 ? 'sub'.repeat(depth - 1) : '') + 'section heading';
34
+ case nodeType.schema.nodes.list:
35
+ return listType === 'order' ? 'Ordered List' : 'Bullet List';
34
36
  default:
35
37
  return transform_1.nodeNames.get(nodeType) || nodeType.name;
36
38
  }
37
39
  };
38
40
  const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
39
- const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType), label: titleCase(optionName(props.nodeType, props.depth)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
41
+ const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
40
42
  const buildOptions = (state, dispatch, view) => {
41
43
  const { doc, selection: { $from, $to }, schema, tr, } = state;
42
44
  const { nodes } = schema;
@@ -189,12 +191,13 @@ const buildOptions = (state, dispatch, view) => {
189
191
  dispatch(tr.scrollIntoView());
190
192
  view && view.focus();
191
193
  };
192
- const convertParagraphToList = (nodeType) => () => {
194
+ const convertParagraphToList = (nodeType, listType) => () => {
193
195
  const paragraph = $from.node($from.depth);
194
196
  const beforeParagraph = $from.before($from.depth);
195
197
  const afterParagraph = $from.after($from.depth);
196
198
  const list = nodeType.create({
197
199
  id: (0, transform_1.generateNodeID)(nodeType),
200
+ listStyleType: listType,
198
201
  }, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
199
202
  tr.replaceWith(beforeParagraph, afterParagraph, list);
200
203
  const anchor = beforeParagraph + 3;
@@ -202,8 +205,8 @@ const buildOptions = (state, dispatch, view) => {
202
205
  dispatch(tr.scrollIntoView());
203
206
  view && view.focus();
204
207
  };
205
- const convertListType = (nodeType, list) => () => {
206
- tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
208
+ const convertListType = (nodeType, list, listType) => () => {
209
+ tr.setNodeMarkup(list.before, nodeType, Object.assign(Object.assign({}, list.node.attrs), { listStyleType: listType }));
207
210
  dispatch(tr.scrollIntoView());
208
211
  view && view.focus();
209
212
  };
@@ -225,16 +228,18 @@ const buildOptions = (state, dispatch, view) => {
225
228
  isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
226
229
  }),
227
230
  buildOption({
228
- nodeType: nodes.ordered_list,
231
+ nodeType: nodes.list,
229
232
  value: -3,
230
233
  depth: 1,
231
234
  isDisabled: true,
235
+ listType: 'order',
232
236
  }),
233
237
  buildOption({
234
- nodeType: nodes.bullet_list,
238
+ nodeType: nodes.list,
235
239
  value: -2,
236
240
  depth: 1,
237
241
  isDisabled: true,
242
+ listType: 'bullet',
238
243
  }),
239
244
  ];
240
245
  const sectionOptions = [];
@@ -291,16 +296,18 @@ const buildOptions = (state, dispatch, view) => {
291
296
  isSelected: true,
292
297
  }),
293
298
  buildOption({
294
- nodeType: nodes.ordered_list,
299
+ nodeType: nodes.list,
295
300
  value: -3,
296
301
  depth: 1,
297
- action: convertParagraphToList(nodes.ordered_list),
302
+ action: convertParagraphToList(nodes.list, 'order'),
303
+ listType: 'order',
298
304
  }),
299
305
  buildOption({
300
- nodeType: nodes.bullet_list,
306
+ nodeType: nodes.list,
301
307
  value: -2,
302
308
  depth: 1,
303
- action: convertParagraphToList(nodes.bullet_list),
309
+ action: convertParagraphToList(nodes.list, 'bullet'),
310
+ listType: 'bullet',
304
311
  }),
305
312
  ];
306
313
  const sectionOptions = [];
@@ -326,7 +333,8 @@ const buildOptions = (state, dispatch, view) => {
326
333
  }));
327
334
  return [{ options: typeOptions }, { options: sectionOptions }];
328
335
  }
329
- case schema.nodes.bullet_list: {
336
+ case schema.nodes.list: {
337
+ const { style } = (0, transform_1.getListType)(parentElement.node.attrs.listStyleType);
330
338
  return [
331
339
  {
332
340
  options: [
@@ -342,35 +350,11 @@ const buildOptions = (state, dispatch, view) => {
342
350
  {
343
351
  options: [
344
352
  buildOption({
345
- nodeType: nodes.ordered_list,
353
+ nodeType: nodes.list,
346
354
  value: -3,
347
355
  depth: 1,
348
- action: convertListType(nodes.ordered_list, parentElement),
349
- }),
350
- ],
351
- },
352
- ];
353
- }
354
- case parentElementType.schema.nodes.ordered_list: {
355
- return [
356
- {
357
- options: [
358
- buildOption({
359
- nodeType: parentElementType,
360
- value: -4,
361
- depth: 1,
362
- isDisabled: true,
363
- isSelected: true,
364
- }),
365
- ],
366
- },
367
- {
368
- options: [
369
- buildOption({
370
- nodeType: nodes.bullet_list,
371
- value: -3,
372
- depth: 1,
373
- action: convertListType(nodes.bullet_list, parentElement),
356
+ action: convertListType(nodes.list, parentElement, style),
357
+ listType: style === 'none' || style === 'disc' ? 'bullet' : 'order',
374
358
  }),
375
359
  ],
376
360
  },
@@ -458,7 +442,7 @@ const LevelSelector = ({ state, dispatch, view }) => {
458
442
  style.opacity = 0.4;
459
443
  }
460
444
  return (react_1.default.createElement(OptionContainer, Object.assign({}, props.innerProps, { ref: null, style: style }),
461
- react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType)),
445
+ react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType, data.listType)),
462
446
  react_1.default.createElement(OptionLabel, null, data.label)));
463
447
  },
464
448
  }, onChange: (value) => {
@@ -29,7 +29,6 @@ const keys_1 = __importDefault(require("../keys"));
29
29
  const affiliations_1 = __importDefault(require("../plugins/affiliations"));
30
30
  const bibliography_1 = __importDefault(require("../plugins/bibliography"));
31
31
  const comments_1 = __importDefault(require("../plugins/comments"));
32
- const doi_1 = __importDefault(require("../plugins/doi"));
33
32
  const editor_props_1 = __importDefault(require("../plugins/editor-props"));
34
33
  const elements_1 = __importDefault(require("../plugins/elements"));
35
34
  const footnotes_1 = __importDefault(require("../plugins/footnotes"));
@@ -72,7 +71,6 @@ exports.default = (props) => {
72
71
  (0, footnotes_1.default)(props),
73
72
  (0, table_footnote_1.default)(),
74
73
  (0, editor_props_1.default)(props),
75
- (0, doi_1.default)(),
76
74
  ];
77
75
  if (props.collabProvider) {
78
76
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const affiliations_1 = __importDefault(require("../views/affiliations"));
22
22
  const bibliography_element_editable_1 = __importDefault(require("../views/bibliography_element_editable"));
23
23
  const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
24
- const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
25
24
  const citation_editable_1 = __importDefault(require("../views/citation_editable"));
26
25
  const contributors_1 = __importDefault(require("../views/contributors"));
27
26
  const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
@@ -37,10 +36,10 @@ const inline_footnote_editable_1 = __importDefault(require("../views/inline_foot
37
36
  const keyword_1 = __importDefault(require("../views/keyword"));
38
37
  const keyword_group_1 = __importDefault(require("../views/keyword_group"));
39
38
  const link_editable_1 = __importDefault(require("../views/link_editable"));
39
+ const list_1 = __importDefault(require("../views/list"));
40
40
  const list_item_1 = __importDefault(require("../views/list_item"));
41
41
  const listing_editable_1 = __importDefault(require("../views/listing_editable"));
42
42
  const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
43
- const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
44
43
  const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
45
44
  const placeholder_1 = __importDefault(require("../views/placeholder"));
46
45
  const placeholder_element_editable_1 = __importDefault(require("../views/placeholder_element_editable"));
@@ -56,7 +55,7 @@ exports.default = (props, dispatch) => {
56
55
  title: (0, title_editable_1.default)(props, dispatch),
57
56
  bibliography_element: (0, bibliography_element_editable_1.default)(props, dispatch),
58
57
  blockquote_element: (0, blockquote_element_editable_1.default)(props),
59
- bullet_list: (0, bullet_list_editable_1.default)(props),
58
+ list: (0, list_1.default)(props),
60
59
  citation: (0, citation_editable_1.default)(props, dispatch),
61
60
  cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
62
61
  contributors: (0, contributors_1.default)(props, dispatch),
@@ -75,7 +74,6 @@ exports.default = (props, dispatch) => {
75
74
  listing: (0, listing_editable_1.default)(props),
76
75
  listing_element: (0, listing_element_editable_1.default)(props),
77
76
  list_item: (0, list_item_1.default)(props),
78
- ordered_list: (0, ordered_list_editable_1.default)(props),
79
77
  paragraph: (0, paragraph_editable_1.default)(props),
80
78
  placeholder: (0, placeholder_1.default)(props),
81
79
  placeholder_element: (0, placeholder_element_editable_1.default)(props),
@@ -15,12 +15,15 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.skipCommandTracking = void 0;
18
+ exports.sinkListItem = exports.skipCommandTracking = void 0;
19
19
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
20
20
  const transform_1 = require("@manuscripts/transform");
21
21
  const prosemirror_commands_1 = require("prosemirror-commands");
22
+ const prosemirror_model_1 = require("prosemirror-model");
22
23
  const prosemirror_schema_list_1 = require("prosemirror-schema-list");
24
+ const prosemirror_transform_1 = require("prosemirror-transform");
23
25
  const prosemirror_utils_1 = require("prosemirror-utils");
26
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
24
27
  const skipCommandTracking = (command) => (state, dispatch) => {
25
28
  return command(state, (tr) => {
26
29
  if (dispatch) {
@@ -56,14 +59,44 @@ const liftToOuterList = (itemType) => {
56
59
  }
57
60
  };
58
61
  };
62
+ function sinkListItem(itemType) {
63
+ return function (state, dispatch) {
64
+ const { $from, $to } = state.selection;
65
+ const range = $from.blockRange($to, (node) => { var _a; return node.childCount > 0 && ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.type) == itemType; });
66
+ if (!range) {
67
+ return false;
68
+ }
69
+ const startIndex = range.startIndex;
70
+ if (startIndex == 0) {
71
+ return false;
72
+ }
73
+ const parent = range.parent, nodeBefore = parent.child(startIndex - 1);
74
+ if (nodeBefore.type != itemType) {
75
+ return false;
76
+ }
77
+ if (dispatch) {
78
+ const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
79
+ const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(parent);
80
+ const listType = actualAttrs.listStyleType;
81
+ const inner = prosemirror_model_1.Fragment.from(nestedBefore ? itemType.create() : null);
82
+ const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(itemType.create(null, prosemirror_model_1.Fragment.from(parent.type.create({ listStyleType: listType }, inner)))), nestedBefore ? 3 : 1, 0);
83
+ const before = range.start, after = range.end;
84
+ dispatch(state.tr
85
+ .step(new prosemirror_transform_1.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true))
86
+ .scrollIntoView());
87
+ }
88
+ return true;
89
+ };
90
+ }
91
+ exports.sinkListItem = sinkListItem;
59
92
  const listKeymap = {
60
93
  Enter: (0, prosemirror_schema_list_1.splitListItem)(transform_1.schema.nodes.list_item),
61
94
  'Mod-[': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
62
- 'Mod-]': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
63
- 'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.ordered_list)),
64
- 'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list)),
95
+ 'Mod-]': (0, exports.skipCommandTracking)(sinkListItem(transform_1.schema.nodes.list_item)),
96
+ 'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'order' })),
97
+ 'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'bullet' })),
65
98
  'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
66
- Tab: (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
99
+ Tab: (0, exports.skipCommandTracking)(sinkListItem(transform_1.schema.nodes.list_item)),
67
100
  Backspace: (0, exports.skipCommandTracking)(listItemBackward),
68
101
  };
69
102
  exports.default = listKeymap;
@@ -29,7 +29,6 @@ const popper_1 = require("./popper");
29
29
  const track_changes_utils_1 = require("./track-changes-utils");
30
30
  const utils_1 = require("./utils");
31
31
  const popper = new popper_1.PopperManager();
32
- const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
33
32
  const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
34
33
  const sectionLevel = (depth) => {
35
34
  switch (depth) {
@@ -56,12 +55,12 @@ class ContextMenu {
56
55
  const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
57
56
  const endPos = $pos.end();
58
57
  const types = this.insertableTypes(after, insertPos, endPos);
59
- const insertNode = (type, pos) => {
58
+ const insertNode = (type, pos, attrs) => {
60
59
  const { state, dispatch } = this.view;
61
60
  if (pos === undefined) {
62
61
  pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
63
62
  }
64
- (0, commands_1.createBlock)(type, pos, state, dispatch);
63
+ (0, commands_1.createBlock)(type, pos, state, dispatch, attrs);
65
64
  };
66
65
  if (hasAny(types, 'section', 'subsection')) {
67
66
  menu.appendChild(this.createMenuSection((section) => {
@@ -88,7 +87,7 @@ class ContextMenu {
88
87
  }
89
88
  }));
90
89
  }
91
- if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
90
+ if (hasAny(types, 'paragraph', 'list')) {
92
91
  menu.appendChild(this.createMenuSection((section) => {
93
92
  if (types.has('paragraph')) {
94
93
  section.appendChild(this.createMenuItem('Paragraph', () => {
@@ -96,15 +95,17 @@ class ContextMenu {
96
95
  popper.destroy();
97
96
  }));
98
97
  }
99
- if (types.has('ordered_list')) {
100
- section.appendChild(this.createMenuItem('Numbered List', () => {
101
- insertNode(transform_1.schema.nodes.ordered_list);
98
+ if (types.has('list')) {
99
+ section.appendChild(this.createMenuItem('Bullet List', () => {
100
+ insertNode(transform_1.schema.nodes.list, undefined, {
101
+ listStyleType: 'bullet',
102
+ });
102
103
  popper.destroy();
103
104
  }));
104
- }
105
- if (types.has('bullet_list')) {
106
- section.appendChild(this.createMenuItem('Bullet List', () => {
107
- insertNode(transform_1.schema.nodes.bullet_list);
105
+ section.appendChild(this.createMenuItem('Ordered List', () => {
106
+ insertNode(transform_1.schema.nodes.list, undefined, {
107
+ listStyleType: 'order',
108
+ });
108
109
  popper.destroy();
109
110
  }));
110
111
  }
@@ -149,17 +150,19 @@ class ContextMenu {
149
150
  menu.className = 'menu';
150
151
  const $pos = this.resolvePos();
151
152
  const type = this.node.type;
152
- if (listTypes.includes(type)) {
153
+ if (type === transform_1.schema.nodes.list) {
153
154
  menu.appendChild(this.createMenuSection((section) => {
154
- if (type === transform_1.schema.nodes.bullet_list) {
155
+ const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
156
+ const listType = (0, transform_1.getListType)(actualAttrs.listStyleType).style;
157
+ if (listType === 'none' || listType === 'disc') {
155
158
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
156
- this.changeNodeType(transform_1.schema.nodes.ordered_list);
159
+ this.changeNodeType(null, 'order');
157
160
  popper.destroy();
158
161
  }));
159
162
  }
160
- if (type === transform_1.schema.nodes.ordered_list) {
163
+ else {
161
164
  section.appendChild(this.createMenuItem('Change to Bullet List', () => {
162
- this.changeNodeType(transform_1.schema.nodes.bullet_list);
165
+ this.changeNodeType(null, 'bullet');
163
166
  popper.destroy();
164
167
  }));
165
168
  }
@@ -319,8 +322,7 @@ class ContextMenu {
319
322
  }
320
323
  checkNode('section', insertPos);
321
324
  checkNode('paragraph');
322
- checkNode('ordered_list');
323
- checkNode('bullet_list');
325
+ checkNode('list');
324
326
  checkNode('figure_element');
325
327
  checkNode('table_element');
326
328
  checkNode('equation_element');
@@ -328,9 +330,10 @@ class ContextMenu {
328
330
  checkNode('pullquote_element');
329
331
  return insertable;
330
332
  };
331
- this.changeNodeType = (nodeType) => {
333
+ this.changeNodeType = (nodeType, listType) => {
332
334
  this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
333
335
  id: this.node.attrs.id,
336
+ listStyleType: listType,
334
337
  }));
335
338
  popper.destroy();
336
339
  };
package/dist/cjs/menus.js CHANGED
@@ -300,15 +300,15 @@ const getEditorMenus = (editor) => {
300
300
  {
301
301
  id: 'insert-bullet-list',
302
302
  label: 'Bullet List',
303
- isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list)),
303
+ isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet')),
304
304
  submenu: [
305
305
  {
306
306
  id: 'bullet-list-context-menu',
307
307
  label: '',
308
308
  isEnabled: true,
309
309
  options: {
310
- bullet: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet')),
311
- simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'simple')),
310
+ bullet: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet')),
311
+ simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'simple')),
312
312
  },
313
313
  },
314
314
  ],
@@ -316,18 +316,18 @@ const getEditorMenus = (editor) => {
316
316
  {
317
317
  id: 'insert-ordered-list',
318
318
  label: 'Ordered List',
319
- isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list)),
319
+ isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.list, 'order')),
320
320
  submenu: [
321
321
  {
322
322
  id: 'ordered-list-context-menu',
323
323
  label: '',
324
324
  isEnabled: true,
325
325
  options: {
326
- order: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order')),
327
- 'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-upper')),
328
- 'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-lower')),
329
- 'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-upper')),
330
- 'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-lower')),
326
+ order: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'order')),
327
+ 'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-upper')),
328
+ 'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-lower')),
329
+ 'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-upper')),
330
+ 'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-lower')),
331
331
  },
332
332
  },
333
333
  ],
@@ -27,10 +27,8 @@ const icons = new Map([
27
27
  [nodes.manuscript, style_guide_1.OutlineManuscriptIcon],
28
28
  [nodes.bibliography_section, style_guide_1.OutlineSectionIcon],
29
29
  [nodes.blockquote_element, style_guide_1.OutlineBlockQuoteIcon],
30
- [nodes.bullet_list, style_guide_1.OutlineUnorderedListIcon],
31
30
  [nodes.equation_element, style_guide_1.OutlineEquationIcon],
32
31
  [nodes.figure_element, style_guide_1.OutlineFigureIcon],
33
- [nodes.ordered_list, style_guide_1.OutlineOrderedListIcon],
34
32
  [nodes.paragraph, style_guide_1.OutlineParagraphIcon],
35
33
  [nodes.pullquote_element, style_guide_1.OutlinePullQuoteIcon],
36
34
  [nodes.section, style_guide_1.OutlineSectionIcon],
@@ -39,7 +37,15 @@ const icons = new Map([
39
37
  [nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
40
38
  [nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
41
39
  ]);
42
- const nodeTypeIcon = (nodeType) => {
40
+ const nodeTypeIcon = (nodeType, listType) => {
41
+ if (nodeType === transform_1.schema.nodes.list) {
42
+ if (listType === 'bullet') {
43
+ return react_1.default.createElement(style_guide_1.OutlineUnorderedListIcon, null);
44
+ }
45
+ else {
46
+ return react_1.default.createElement(style_guide_1.OutlineOrderedListIcon, null);
47
+ }
48
+ }
43
49
  const Icon = icons.get(nodeType);
44
50
  return Icon ? react_1.default.createElement(Icon, null) : null;
45
51
  };
package/dist/cjs/rules.js CHANGED
@@ -35,8 +35,7 @@ exports.default = (0, prosemirror_inputrules_1.inputRules)({
35
35
  ...prosemirror_inputrules_1.smartQuotes,
36
36
  prosemirror_inputrules_1.ellipsis,
37
37
  prosemirror_inputrules_1.emDash,
38
- creatingInputRule(/^\d+[.)]\s$/, transform_1.schema.nodes.ordered_list),
39
- creatingInputRule(/^\s*\*\s$/, transform_1.schema.nodes.bullet_list),
38
+ creatingInputRule(/^(\d+[.)]\s|\s*\*\s)$/, transform_1.schema.nodes.list),
40
39
  creatingInputRule(/^\s*>\s$/, transform_1.schema.nodes.blockquote_element),
41
40
  creatingInputRule(/^```$/, transform_1.schema.nodes.listing_element),
42
41
  creatingInputRule(/^#\s$/, transform_1.schema.nodes.section),
@@ -68,26 +68,26 @@ exports.toolbar = {
68
68
  bullet_list: {
69
69
  title: 'Wrap in bullet list',
70
70
  content: react_1.default.createElement(style_guide_1.ToolbarUnorderedListIcon, null),
71
- isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.bullet_list),
72
- isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
73
- run: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
71
+ isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.list),
72
+ isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
73
+ run: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
74
74
  options: {
75
- bullet: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
76
- simple: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'simple'),
75
+ bullet: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
76
+ simple: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'simple'),
77
77
  },
78
78
  },
79
79
  ordered_list: {
80
80
  title: 'Wrap in ordered list',
81
81
  content: react_1.default.createElement(style_guide_1.ToolbarOrderedListIcon, null),
82
- isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.ordered_list),
83
- isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order'),
84
- run: (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order'),
82
+ isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.list),
83
+ isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
84
+ run: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
85
85
  options: {
86
- order: (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order'),
87
- 'alpha-upper': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-upper'),
88
- 'alpha-lower': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-lower'),
89
- 'roman-upper': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-upper'),
90
- 'roman-lower': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-lower'),
86
+ order: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
87
+ 'alpha-upper': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-upper'),
88
+ 'alpha-lower': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-lower'),
89
+ 'roman-upper': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-upper'),
90
+ 'roman-lower': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-lower'),
91
91
  },
92
92
  },
93
93
  },
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.listCallback = exports.ListView = void 0;
22
+ const transform_1 = require("@manuscripts/transform");
23
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
24
+ const block_view_1 = __importDefault(require("./block_view"));
25
+ const creators_1 = require("./creators");
26
+ const editable_block_1 = require("./editable_block");
27
+ class ListView extends block_view_1.default {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.elementType = 'ul';
31
+ this.updateContents = () => {
32
+ var _a;
33
+ const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
34
+ if (this.contentDOM) {
35
+ const type = actualAttrs.listStyleType;
36
+ this.contentDOM.style.listStyleType = (0, transform_1.getListType)(type).style;
37
+ }
38
+ if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
39
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
40
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
41
+ }
42
+ else {
43
+ this.dom.removeAttribute('data-track-status');
44
+ this.dom.removeAttribute('data-track-type');
45
+ }
46
+ };
47
+ }
48
+ }
49
+ exports.ListView = ListView;
50
+ const listCallback = (node, dom) => {
51
+ dom.classList.add('list');
52
+ const type = node.attrs.listStyleType;
53
+ dom.style.listStyleType = (0, transform_1.getListType)(type).style;
54
+ };
55
+ exports.listCallback = listCallback;
56
+ exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(ListView), 'ul', exports.listCallback);
@@ -88,7 +88,7 @@ export const createSelection = (nodeType, position, doc) => {
88
88
  : TextSelection.near(doc.resolve(position + 1));
89
89
  }
90
90
  };
91
- export const createBlock = (nodeType, position, state, dispatch) => {
91
+ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
92
92
  let node;
93
93
  switch (nodeType) {
94
94
  case state.schema.nodes.table_element:
@@ -109,7 +109,7 @@ export const createBlock = (nodeType, position, state, dispatch) => {
109
109
  ]);
110
110
  break;
111
111
  default:
112
- node = nodeType.createAndFill();
112
+ node = nodeType.createAndFill(attrs);
113
113
  }
114
114
  const tr = state.tr.insert(position, node);
115
115
  if (dispatch) {
@@ -375,10 +375,7 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
375
375
  }
376
376
  return true;
377
377
  };
378
- const findSelectedList = findParentNodeOfType([
379
- schema.nodes.ordered_list,
380
- schema.nodes.bullet_list,
381
- ]);
378
+ const findSelectedList = findParentNodeOfType([schema.nodes.list]);
382
379
  const findRootList = ($pos) => {
383
380
  for (let i = 0; i < $pos.depth; i++) {
384
381
  const node = $pos.node(i);
@@ -445,7 +442,7 @@ export const insertList = (type, style) => (state, dispatch, view) => {
445
442
  for (const { node, pos } of nodes) {
446
443
  tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
447
444
  }
448
- dispatch(skipTracking(tr));
445
+ dispatch(tr);
449
446
  return true;
450
447
  }
451
448
  else {