@manuscripts/body-editor 1.10.8 → 1.10.10-LEAN-3608.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.
@@ -95,7 +95,7 @@ const createSelection = (nodeType, position, doc) => {
95
95
  }
96
96
  };
97
97
  exports.createSelection = createSelection;
98
- const createBlock = (nodeType, position, state, dispatch) => {
98
+ const createBlock = (nodeType, position, state, dispatch, attrs) => {
99
99
  let node;
100
100
  switch (nodeType) {
101
101
  case state.schema.nodes.table_element:
@@ -116,7 +116,7 @@ const createBlock = (nodeType, position, state, dispatch) => {
116
116
  ]);
117
117
  break;
118
118
  default:
119
- node = nodeType.createAndFill();
119
+ node = nodeType.createAndFill(attrs);
120
120
  }
121
121
  const tr = state.tr.insert(position, node);
122
122
  if (dispatch) {
@@ -393,10 +393,7 @@ const insertSection = (subsection = false) => (state, dispatch) => {
393
393
  return true;
394
394
  };
395
395
  exports.insertSection = insertSection;
396
- const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
397
- transform_1.schema.nodes.ordered_list,
398
- transform_1.schema.nodes.bullet_list,
399
- ]);
396
+ const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([transform_1.schema.nodes.list]);
400
397
  const findRootList = ($pos) => {
401
398
  for (let i = 0; i < $pos.depth; i++) {
402
399
  const node = $pos.node(i);
@@ -463,7 +460,7 @@ const insertList = (type, style) => (state, dispatch, view) => {
463
460
  for (const { node, pos } of nodes) {
464
461
  tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
465
462
  }
466
- dispatch((0, track_changes_plugin_1.skipTracking)(tr));
463
+ dispatch(tr);
467
464
  return true;
468
465
  }
469
466
  else {
@@ -36,7 +36,7 @@ const optionName = (nodeType, depth) => {
36
36
  }
37
37
  };
38
38
  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) }));
39
+ 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)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
40
40
  const buildOptions = (state, dispatch, view) => {
41
41
  const { doc, selection: { $from, $to }, schema, tr, } = state;
42
42
  const { nodes } = schema;
@@ -189,12 +189,13 @@ const buildOptions = (state, dispatch, view) => {
189
189
  dispatch(tr.scrollIntoView());
190
190
  view && view.focus();
191
191
  };
192
- const convertParagraphToList = (nodeType) => () => {
192
+ const convertParagraphToList = (nodeType, listType) => () => {
193
193
  const paragraph = $from.node($from.depth);
194
194
  const beforeParagraph = $from.before($from.depth);
195
195
  const afterParagraph = $from.after($from.depth);
196
196
  const list = nodeType.create({
197
197
  id: (0, transform_1.generateNodeID)(nodeType),
198
+ listStyleType: listType,
198
199
  }, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
199
200
  tr.replaceWith(beforeParagraph, afterParagraph, list);
200
201
  const anchor = beforeParagraph + 3;
@@ -202,8 +203,8 @@ const buildOptions = (state, dispatch, view) => {
202
203
  dispatch(tr.scrollIntoView());
203
204
  view && view.focus();
204
205
  };
205
- const convertListType = (nodeType, list) => () => {
206
- tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
206
+ const convertListType = (nodeType, list, listType) => () => {
207
+ tr.setNodeMarkup(list.before, nodeType, Object.assign(Object.assign({}, list.node.attrs), { listStyleType: listType }));
207
208
  dispatch(tr.scrollIntoView());
208
209
  view && view.focus();
209
210
  };
@@ -225,16 +226,18 @@ const buildOptions = (state, dispatch, view) => {
225
226
  isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
226
227
  }),
227
228
  buildOption({
228
- nodeType: nodes.ordered_list,
229
+ nodeType: nodes.list,
229
230
  value: -3,
230
231
  depth: 1,
231
232
  isDisabled: true,
233
+ listType: 'order',
232
234
  }),
233
235
  buildOption({
234
- nodeType: nodes.bullet_list,
236
+ nodeType: nodes.list,
235
237
  value: -2,
236
238
  depth: 1,
237
239
  isDisabled: true,
240
+ listType: 'bullet',
238
241
  }),
239
242
  ];
240
243
  const sectionOptions = [];
@@ -291,16 +294,18 @@ const buildOptions = (state, dispatch, view) => {
291
294
  isSelected: true,
292
295
  }),
293
296
  buildOption({
294
- nodeType: nodes.ordered_list,
297
+ nodeType: nodes.list,
295
298
  value: -3,
296
299
  depth: 1,
297
- action: convertParagraphToList(nodes.ordered_list),
300
+ action: convertParagraphToList(nodes.list, 'order'),
301
+ listType: 'order',
298
302
  }),
299
303
  buildOption({
300
- nodeType: nodes.bullet_list,
304
+ nodeType: nodes.list,
301
305
  value: -2,
302
306
  depth: 1,
303
- action: convertParagraphToList(nodes.bullet_list),
307
+ action: convertParagraphToList(nodes.list, 'bullet'),
308
+ listType: 'bullet',
304
309
  }),
305
310
  ];
306
311
  const sectionOptions = [];
@@ -326,7 +331,8 @@ const buildOptions = (state, dispatch, view) => {
326
331
  }));
327
332
  return [{ options: typeOptions }, { options: sectionOptions }];
328
333
  }
329
- case schema.nodes.bullet_list: {
334
+ case schema.nodes.list: {
335
+ const { style, type } = (0, transform_1.getListType)(parentElement.node.attrs.listStyleType);
330
336
  return [
331
337
  {
332
338
  options: [
@@ -342,35 +348,11 @@ const buildOptions = (state, dispatch, view) => {
342
348
  {
343
349
  options: [
344
350
  buildOption({
345
- nodeType: nodes.ordered_list,
351
+ nodeType: nodes.list,
346
352
  value: -3,
347
353
  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),
354
+ action: convertListType(nodes.list, parentElement, style),
355
+ listType: type === 'ol' ? 'order' : 'bullet',
374
356
  }),
375
357
  ],
376
358
  },
@@ -458,7 +440,7 @@ const LevelSelector = ({ state, dispatch, view }) => {
458
440
  style.opacity = 0.4;
459
441
  }
460
442
  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)),
443
+ react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType, data.listType)),
462
444
  react_1.default.createElement(OptionLabel, null, data.label)));
463
445
  },
464
446
  }, onChange: (value) => {
@@ -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),
@@ -60,8 +60,8 @@ const listKeymap = {
60
60
  Enter: (0, prosemirror_schema_list_1.splitListItem)(transform_1.schema.nodes.list_item),
61
61
  'Mod-[': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
62
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)),
63
+ 'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'order' })),
64
+ 'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'bullet' })),
65
65
  'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
66
66
  Tab: (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
67
67
  Backspace: (0, exports.skipCommandTracking)(listItemBackward),
@@ -28,7 +28,6 @@ const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
28
28
  const popper_1 = require("./popper");
29
29
  const track_changes_utils_1 = require("./track-changes-utils");
30
30
  const popper = new popper_1.PopperManager();
31
- const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
32
31
  const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
33
32
  const sectionLevel = (depth) => {
34
33
  switch (depth) {
@@ -55,12 +54,12 @@ class ContextMenu {
55
54
  const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
56
55
  const endPos = $pos.end();
57
56
  const types = this.insertableTypes(after, insertPos, endPos);
58
- const insertNode = (type, pos) => {
57
+ const insertNode = (type, pos, attrs) => {
59
58
  const { state, dispatch } = this.view;
60
59
  if (pos === undefined) {
61
60
  pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
62
61
  }
63
- (0, commands_1.createBlock)(type, pos, state, dispatch);
62
+ (0, commands_1.createBlock)(type, pos, state, dispatch, attrs);
64
63
  };
65
64
  if (hasAny(types, 'section', 'subsection')) {
66
65
  menu.appendChild(this.createMenuSection((section) => {
@@ -87,7 +86,7 @@ class ContextMenu {
87
86
  }
88
87
  }));
89
88
  }
90
- if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
89
+ if (hasAny(types, 'paragraph', 'list')) {
91
90
  menu.appendChild(this.createMenuSection((section) => {
92
91
  if (types.has('paragraph')) {
93
92
  section.appendChild(this.createMenuItem('Paragraph', () => {
@@ -95,15 +94,17 @@ class ContextMenu {
95
94
  popper.destroy();
96
95
  }));
97
96
  }
98
- if (types.has('ordered_list')) {
99
- section.appendChild(this.createMenuItem('Numbered List', () => {
100
- insertNode(transform_1.schema.nodes.ordered_list);
97
+ if (types.has('list')) {
98
+ section.appendChild(this.createMenuItem('Bullet List', () => {
99
+ insertNode(transform_1.schema.nodes.list, undefined, {
100
+ listStyleType: 'bullet',
101
+ });
101
102
  popper.destroy();
102
103
  }));
103
- }
104
- if (types.has('bullet_list')) {
105
- section.appendChild(this.createMenuItem('Bullet List', () => {
106
- insertNode(transform_1.schema.nodes.bullet_list);
104
+ section.appendChild(this.createMenuItem('Ordered List', () => {
105
+ insertNode(transform_1.schema.nodes.list, undefined, {
106
+ listStyleType: 'order',
107
+ });
107
108
  popper.destroy();
108
109
  }));
109
110
  }
@@ -148,17 +149,18 @@ class ContextMenu {
148
149
  menu.className = 'menu';
149
150
  const $pos = this.resolvePos();
150
151
  const type = this.node.type;
151
- if (listTypes.includes(type)) {
152
+ if (type === transform_1.schema.nodes.list) {
152
153
  menu.appendChild(this.createMenuSection((section) => {
153
- if (type === transform_1.schema.nodes.bullet_list) {
154
+ const listType = (0, transform_1.getListType)(this.node.attrs.listStyleType).type;
155
+ if (listType === 'ul') {
154
156
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
155
- this.changeNodeType(transform_1.schema.nodes.ordered_list);
157
+ this.changeNodeType(transform_1.schema.nodes.list, 'order');
156
158
  popper.destroy();
157
159
  }));
158
160
  }
159
- if (type === transform_1.schema.nodes.ordered_list) {
161
+ if (listType === 'ol') {
160
162
  section.appendChild(this.createMenuItem('Change to Bullet List', () => {
161
- this.changeNodeType(transform_1.schema.nodes.bullet_list);
163
+ this.changeNodeType(transform_1.schema.nodes.list, 'bullet');
162
164
  popper.destroy();
163
165
  }));
164
166
  }
@@ -318,8 +320,7 @@ class ContextMenu {
318
320
  }
319
321
  checkNode('section', insertPos);
320
322
  checkNode('paragraph');
321
- checkNode('ordered_list');
322
- checkNode('bullet_list');
323
+ checkNode('list');
323
324
  checkNode('figure_element');
324
325
  checkNode('table_element');
325
326
  checkNode('equation_element');
@@ -327,9 +328,10 @@ class ContextMenu {
327
328
  checkNode('pullquote_element');
328
329
  return insertable;
329
330
  };
330
- this.changeNodeType = (nodeType) => {
331
+ this.changeNodeType = (nodeType, listType) => {
331
332
  this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
332
333
  id: this.node.attrs.id,
334
+ listStyleType: listType,
333
335
  }));
334
336
  popper.destroy();
335
337
  };
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);
@@ -87,7 +87,7 @@ export const createSelection = (nodeType, position, doc) => {
87
87
  : TextSelection.near(doc.resolve(position + 1));
88
88
  }
89
89
  };
90
- export const createBlock = (nodeType, position, state, dispatch) => {
90
+ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
91
91
  let node;
92
92
  switch (nodeType) {
93
93
  case state.schema.nodes.table_element:
@@ -108,7 +108,7 @@ export const createBlock = (nodeType, position, state, dispatch) => {
108
108
  ]);
109
109
  break;
110
110
  default:
111
- node = nodeType.createAndFill();
111
+ node = nodeType.createAndFill(attrs);
112
112
  }
113
113
  const tr = state.tr.insert(position, node);
114
114
  if (dispatch) {
@@ -371,10 +371,7 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
371
371
  }
372
372
  return true;
373
373
  };
374
- const findSelectedList = findParentNodeOfType([
375
- schema.nodes.ordered_list,
376
- schema.nodes.bullet_list,
377
- ]);
374
+ const findSelectedList = findParentNodeOfType([schema.nodes.list]);
378
375
  const findRootList = ($pos) => {
379
376
  for (let i = 0; i < $pos.depth; i++) {
380
377
  const node = $pos.node(i);
@@ -441,7 +438,7 @@ export const insertList = (type, style) => (state, dispatch, view) => {
441
438
  for (const { node, pos } of nodes) {
442
439
  tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
443
440
  }
444
- dispatch(skipTracking(tr));
441
+ dispatch(tr);
445
442
  return true;
446
443
  }
447
444
  else {
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { generateNodeID, isSectionNodeType, nodeNames, } from '@manuscripts/transform';
16
+ import { generateNodeID, getListType, isSectionNodeType, nodeNames, } from '@manuscripts/transform';
17
17
  import { Fragment } from 'prosemirror-model';
18
18
  import { TextSelection } from 'prosemirror-state';
19
19
  import React from 'react';
@@ -30,7 +30,7 @@ const optionName = (nodeType, depth) => {
30
30
  }
31
31
  };
32
32
  const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
33
- const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType), label: titleCase(optionName(props.nodeType, props.depth)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
33
+ const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
34
34
  const buildOptions = (state, dispatch, view) => {
35
35
  const { doc, selection: { $from, $to }, schema, tr, } = state;
36
36
  const { nodes } = schema;
@@ -183,12 +183,13 @@ const buildOptions = (state, dispatch, view) => {
183
183
  dispatch(tr.scrollIntoView());
184
184
  view && view.focus();
185
185
  };
186
- const convertParagraphToList = (nodeType) => () => {
186
+ const convertParagraphToList = (nodeType, listType) => () => {
187
187
  const paragraph = $from.node($from.depth);
188
188
  const beforeParagraph = $from.before($from.depth);
189
189
  const afterParagraph = $from.after($from.depth);
190
190
  const list = nodeType.create({
191
191
  id: generateNodeID(nodeType),
192
+ listStyleType: listType,
192
193
  }, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
193
194
  tr.replaceWith(beforeParagraph, afterParagraph, list);
194
195
  const anchor = beforeParagraph + 3;
@@ -196,8 +197,8 @@ const buildOptions = (state, dispatch, view) => {
196
197
  dispatch(tr.scrollIntoView());
197
198
  view && view.focus();
198
199
  };
199
- const convertListType = (nodeType, list) => () => {
200
- tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
200
+ const convertListType = (nodeType, list, listType) => () => {
201
+ tr.setNodeMarkup(list.before, nodeType, Object.assign(Object.assign({}, list.node.attrs), { listStyleType: listType }));
201
202
  dispatch(tr.scrollIntoView());
202
203
  view && view.focus();
203
204
  };
@@ -219,16 +220,18 @@ const buildOptions = (state, dispatch, view) => {
219
220
  isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
220
221
  }),
221
222
  buildOption({
222
- nodeType: nodes.ordered_list,
223
+ nodeType: nodes.list,
223
224
  value: -3,
224
225
  depth: 1,
225
226
  isDisabled: true,
227
+ listType: 'order',
226
228
  }),
227
229
  buildOption({
228
- nodeType: nodes.bullet_list,
230
+ nodeType: nodes.list,
229
231
  value: -2,
230
232
  depth: 1,
231
233
  isDisabled: true,
234
+ listType: 'bullet',
232
235
  }),
233
236
  ];
234
237
  const sectionOptions = [];
@@ -285,16 +288,18 @@ const buildOptions = (state, dispatch, view) => {
285
288
  isSelected: true,
286
289
  }),
287
290
  buildOption({
288
- nodeType: nodes.ordered_list,
291
+ nodeType: nodes.list,
289
292
  value: -3,
290
293
  depth: 1,
291
- action: convertParagraphToList(nodes.ordered_list),
294
+ action: convertParagraphToList(nodes.list, 'order'),
295
+ listType: 'order',
292
296
  }),
293
297
  buildOption({
294
- nodeType: nodes.bullet_list,
298
+ nodeType: nodes.list,
295
299
  value: -2,
296
300
  depth: 1,
297
- action: convertParagraphToList(nodes.bullet_list),
301
+ action: convertParagraphToList(nodes.list, 'bullet'),
302
+ listType: 'bullet',
298
303
  }),
299
304
  ];
300
305
  const sectionOptions = [];
@@ -320,7 +325,8 @@ const buildOptions = (state, dispatch, view) => {
320
325
  }));
321
326
  return [{ options: typeOptions }, { options: sectionOptions }];
322
327
  }
323
- case schema.nodes.bullet_list: {
328
+ case schema.nodes.list: {
329
+ const { style, type } = getListType(parentElement.node.attrs.listStyleType);
324
330
  return [
325
331
  {
326
332
  options: [
@@ -336,35 +342,11 @@ const buildOptions = (state, dispatch, view) => {
336
342
  {
337
343
  options: [
338
344
  buildOption({
339
- nodeType: nodes.ordered_list,
345
+ nodeType: nodes.list,
340
346
  value: -3,
341
347
  depth: 1,
342
- action: convertListType(nodes.ordered_list, parentElement),
343
- }),
344
- ],
345
- },
346
- ];
347
- }
348
- case parentElementType.schema.nodes.ordered_list: {
349
- return [
350
- {
351
- options: [
352
- buildOption({
353
- nodeType: parentElementType,
354
- value: -4,
355
- depth: 1,
356
- isDisabled: true,
357
- isSelected: true,
358
- }),
359
- ],
360
- },
361
- {
362
- options: [
363
- buildOption({
364
- nodeType: nodes.bullet_list,
365
- value: -3,
366
- depth: 1,
367
- action: convertListType(nodes.bullet_list, parentElement),
348
+ action: convertListType(nodes.list, parentElement, style),
349
+ listType: type === 'ol' ? 'order' : 'bullet',
368
350
  }),
369
351
  ],
370
352
  },
@@ -452,7 +434,7 @@ export const LevelSelector = ({ state, dispatch, view }) => {
452
434
  style.opacity = 0.4;
453
435
  }
454
436
  return (React.createElement(OptionContainer, Object.assign({}, props.innerProps, { ref: null, style: style }),
455
- React.createElement(OptionIcon, null, nodeTypeIcon(data.nodeType)),
437
+ React.createElement(OptionIcon, null, nodeTypeIcon(data.nodeType, data.listType)),
456
438
  React.createElement(OptionLabel, null, data.label)));
457
439
  },
458
440
  }, onChange: (value) => {
@@ -16,7 +16,6 @@
16
16
  import affiliations from '../views/affiliations';
17
17
  import bibliographyElement from '../views/bibliography_element_editable';
18
18
  import blockquoteElement from '../views/blockquote_element_editable';
19
- import bulletList from '../views/bullet_list_editable';
20
19
  import citation from '../views/citation_editable';
21
20
  import contributors from '../views/contributors';
22
21
  import crossReference from '../views/cross_reference_editable';
@@ -32,10 +31,10 @@ import inlineFootnote from '../views/inline_footnote_editable';
32
31
  import keyword from '../views/keyword';
33
32
  import keywordGroup from '../views/keyword_group';
34
33
  import link from '../views/link_editable';
34
+ import list from '../views/list';
35
35
  import list_item from '../views/list_item';
36
36
  import listing from '../views/listing_editable';
37
37
  import listingElement from '../views/listing_element_editable';
38
- import orderedList from '../views/ordered_list_editable';
39
38
  import paragraph from '../views/paragraph_editable';
40
39
  import placeholder from '../views/placeholder';
41
40
  import placeholderElement from '../views/placeholder_element_editable';
@@ -51,7 +50,7 @@ export default (props, dispatch) => {
51
50
  title: title(props, dispatch),
52
51
  bibliography_element: bibliographyElement(props, dispatch),
53
52
  blockquote_element: blockquoteElement(props),
54
- bullet_list: bulletList(props),
53
+ list: list(props),
55
54
  citation: citation(props, dispatch),
56
55
  cross_reference: crossReference(props, dispatch),
57
56
  contributors: contributors(props, dispatch),
@@ -70,7 +69,6 @@ export default (props, dispatch) => {
70
69
  listing: listing(props),
71
70
  listing_element: listingElement(props),
72
71
  list_item: list_item(props),
73
- ordered_list: orderedList(props),
74
72
  paragraph: paragraph(props),
75
73
  placeholder: placeholder(props),
76
74
  placeholder_element: placeholderElement(props),
@@ -56,8 +56,8 @@ const listKeymap = {
56
56
  Enter: splitListItem(schema.nodes.list_item),
57
57
  'Mod-[': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
58
58
  'Mod-]': skipCommandTracking(sinkListItem(schema.nodes.list_item)),
59
- 'Mod-Alt-o': skipCommandTracking(wrapInList(schema.nodes.ordered_list)),
60
- 'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.bullet_list)),
59
+ 'Mod-Alt-o': skipCommandTracking(wrapInList(schema.nodes.list, { listStyleType: 'order' })),
60
+ 'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.list, { listStyleType: 'bullet' })),
61
61
  'Shift-Tab': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
62
62
  Tab: skipCommandTracking(sinkListItem(schema.nodes.list_item)),
63
63
  Backspace: skipCommandTracking(listItemBackward),
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { TableFootnotesSelector, } from '@manuscripts/style-guide';
17
- import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
17
+ import { getListType, isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
18
18
  import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
19
19
  import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
20
20
  import { buildTableFootnoteLabels } from '../plugins/footnotes/footnotes-utils';
@@ -22,7 +22,6 @@ import ReactSubView from '../views/ReactSubView';
22
22
  import { PopperManager } from './popper';
23
23
  import { isDeleted, isRejectedInsert } from './track-changes-utils';
24
24
  const popper = new PopperManager();
25
- const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
26
25
  const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
27
26
  export const sectionLevel = (depth) => {
28
27
  switch (depth) {
@@ -48,12 +47,12 @@ export class ContextMenu {
48
47
  const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
49
48
  const endPos = $pos.end();
50
49
  const types = this.insertableTypes(after, insertPos, endPos);
51
- const insertNode = (type, pos) => {
50
+ const insertNode = (type, pos, attrs) => {
52
51
  const { state, dispatch } = this.view;
53
52
  if (pos === undefined) {
54
53
  pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
55
54
  }
56
- createBlock(type, pos, state, dispatch);
55
+ createBlock(type, pos, state, dispatch, attrs);
57
56
  };
58
57
  if (hasAny(types, 'section', 'subsection')) {
59
58
  menu.appendChild(this.createMenuSection((section) => {
@@ -80,7 +79,7 @@ export class ContextMenu {
80
79
  }
81
80
  }));
82
81
  }
83
- if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
82
+ if (hasAny(types, 'paragraph', 'list')) {
84
83
  menu.appendChild(this.createMenuSection((section) => {
85
84
  if (types.has('paragraph')) {
86
85
  section.appendChild(this.createMenuItem('Paragraph', () => {
@@ -88,15 +87,17 @@ export class ContextMenu {
88
87
  popper.destroy();
89
88
  }));
90
89
  }
91
- if (types.has('ordered_list')) {
92
- section.appendChild(this.createMenuItem('Numbered List', () => {
93
- insertNode(schema.nodes.ordered_list);
90
+ if (types.has('list')) {
91
+ section.appendChild(this.createMenuItem('Bullet List', () => {
92
+ insertNode(schema.nodes.list, undefined, {
93
+ listStyleType: 'bullet',
94
+ });
94
95
  popper.destroy();
95
96
  }));
96
- }
97
- if (types.has('bullet_list')) {
98
- section.appendChild(this.createMenuItem('Bullet List', () => {
99
- insertNode(schema.nodes.bullet_list);
97
+ section.appendChild(this.createMenuItem('Ordered List', () => {
98
+ insertNode(schema.nodes.list, undefined, {
99
+ listStyleType: 'order',
100
+ });
100
101
  popper.destroy();
101
102
  }));
102
103
  }
@@ -141,17 +142,18 @@ export class ContextMenu {
141
142
  menu.className = 'menu';
142
143
  const $pos = this.resolvePos();
143
144
  const type = this.node.type;
144
- if (listTypes.includes(type)) {
145
+ if (type === schema.nodes.list) {
145
146
  menu.appendChild(this.createMenuSection((section) => {
146
- if (type === schema.nodes.bullet_list) {
147
+ const listType = getListType(this.node.attrs.listStyleType).type;
148
+ if (listType === 'ul') {
147
149
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
148
- this.changeNodeType(schema.nodes.ordered_list);
150
+ this.changeNodeType(schema.nodes.list, 'order');
149
151
  popper.destroy();
150
152
  }));
151
153
  }
152
- if (type === schema.nodes.ordered_list) {
154
+ if (listType === 'ol') {
153
155
  section.appendChild(this.createMenuItem('Change to Bullet List', () => {
154
- this.changeNodeType(schema.nodes.bullet_list);
156
+ this.changeNodeType(schema.nodes.list, 'bullet');
155
157
  popper.destroy();
156
158
  }));
157
159
  }
@@ -311,8 +313,7 @@ export class ContextMenu {
311
313
  }
312
314
  checkNode('section', insertPos);
313
315
  checkNode('paragraph');
314
- checkNode('ordered_list');
315
- checkNode('bullet_list');
316
+ checkNode('list');
316
317
  checkNode('figure_element');
317
318
  checkNode('table_element');
318
319
  checkNode('equation_element');
@@ -320,9 +321,10 @@ export class ContextMenu {
320
321
  checkNode('pullquote_element');
321
322
  return insertable;
322
323
  };
323
- this.changeNodeType = (nodeType) => {
324
+ this.changeNodeType = (nodeType, listType) => {
324
325
  this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
325
326
  id: this.node.attrs.id,
327
+ listStyleType: listType,
326
328
  }));
327
329
  popper.destroy();
328
330
  };
package/dist/es/menus.js CHANGED
@@ -297,15 +297,15 @@ export const getEditorMenus = (editor) => {
297
297
  {
298
298
  id: 'insert-bullet-list',
299
299
  label: 'Bullet List',
300
- isEnabled: isCommandValid(insertList(schema.nodes.bullet_list)),
300
+ isEnabled: isCommandValid(insertList(schema.nodes.list, 'bullet')),
301
301
  submenu: [
302
302
  {
303
303
  id: 'bullet-list-context-menu',
304
304
  label: '',
305
305
  isEnabled: true,
306
306
  options: {
307
- bullet: doCommand(insertList(schema.nodes.bullet_list, 'bullet')),
308
- simple: doCommand(insertList(schema.nodes.bullet_list, 'simple')),
307
+ bullet: doCommand(insertList(schema.nodes.list, 'bullet')),
308
+ simple: doCommand(insertList(schema.nodes.list, 'simple')),
309
309
  },
310
310
  },
311
311
  ],
@@ -313,18 +313,18 @@ export const getEditorMenus = (editor) => {
313
313
  {
314
314
  id: 'insert-ordered-list',
315
315
  label: 'Ordered List',
316
- isEnabled: isCommandValid(insertList(schema.nodes.ordered_list)),
316
+ isEnabled: isCommandValid(insertList(schema.nodes.list, 'order')),
317
317
  submenu: [
318
318
  {
319
319
  id: 'ordered-list-context-menu',
320
320
  label: '',
321
321
  isEnabled: true,
322
322
  options: {
323
- order: doCommand(insertList(schema.nodes.ordered_list, 'order')),
324
- 'alpha-upper': doCommand(insertList(schema.nodes.ordered_list, 'alpha-upper')),
325
- 'alpha-lower': doCommand(insertList(schema.nodes.ordered_list, 'alpha-lower')),
326
- 'roman-upper': doCommand(insertList(schema.nodes.ordered_list, 'roman-upper')),
327
- 'roman-lower': doCommand(insertList(schema.nodes.ordered_list, 'roman-lower')),
323
+ order: doCommand(insertList(schema.nodes.list, 'order')),
324
+ 'alpha-upper': doCommand(insertList(schema.nodes.list, 'alpha-upper')),
325
+ 'alpha-lower': doCommand(insertList(schema.nodes.list, 'alpha-lower')),
326
+ 'roman-upper': doCommand(insertList(schema.nodes.list, 'roman-upper')),
327
+ 'roman-lower': doCommand(insertList(schema.nodes.list, 'roman-lower')),
328
328
  },
329
329
  },
330
330
  ],
@@ -21,10 +21,8 @@ const icons = new Map([
21
21
  [nodes.manuscript, OutlineManuscriptIcon],
22
22
  [nodes.bibliography_section, OutlineSectionIcon],
23
23
  [nodes.blockquote_element, OutlineBlockQuoteIcon],
24
- [nodes.bullet_list, OutlineUnorderedListIcon],
25
24
  [nodes.equation_element, OutlineEquationIcon],
26
25
  [nodes.figure_element, OutlineFigureIcon],
27
- [nodes.ordered_list, OutlineOrderedListIcon],
28
26
  [nodes.paragraph, OutlineParagraphIcon],
29
27
  [nodes.pullquote_element, OutlinePullQuoteIcon],
30
28
  [nodes.section, OutlineSectionIcon],
@@ -33,7 +31,15 @@ const icons = new Map([
33
31
  [nodes.graphical_abstract_section, OutlineSectionIcon],
34
32
  [nodes.footnotes_section, OutlineSectionIcon],
35
33
  ]);
36
- export const nodeTypeIcon = (nodeType) => {
34
+ export const nodeTypeIcon = (nodeType, listType) => {
35
+ if (nodeType === schema.nodes.list) {
36
+ if (listType === 'bullet') {
37
+ return React.createElement(OutlineUnorderedListIcon, null);
38
+ }
39
+ else {
40
+ return React.createElement(OutlineOrderedListIcon, null);
41
+ }
42
+ }
37
43
  const Icon = icons.get(nodeType);
38
44
  return Icon ? React.createElement(Icon, null) : null;
39
45
  };
package/dist/es/rules.js CHANGED
@@ -33,8 +33,7 @@ export default inputRules({
33
33
  ...smartQuotes,
34
34
  ellipsis,
35
35
  emDash,
36
- creatingInputRule(/^\d+[.)]\s$/, schema.nodes.ordered_list),
37
- creatingInputRule(/^\s*\*\s$/, schema.nodes.bullet_list),
36
+ creatingInputRule(/^(\d+[.)]\s|\s*\*\s)$/, schema.nodes.list),
38
37
  creatingInputRule(/^\s*>\s$/, schema.nodes.blockquote_element),
39
38
  creatingInputRule(/^```$/, schema.nodes.listing_element),
40
39
  creatingInputRule(/^#\s$/, schema.nodes.section),
@@ -62,26 +62,26 @@ export const toolbar = {
62
62
  bullet_list: {
63
63
  title: 'Wrap in bullet list',
64
64
  content: React.createElement(ToolbarUnorderedListIcon, null),
65
- isActive: blockActive(schema.nodes.bullet_list),
66
- isEnabled: insertList(schema.nodes.bullet_list, 'bullet'),
67
- run: insertList(schema.nodes.bullet_list, 'bullet'),
65
+ isActive: blockActive(schema.nodes.list),
66
+ isEnabled: insertList(schema.nodes.list, 'bullet'),
67
+ run: insertList(schema.nodes.list, 'bullet'),
68
68
  options: {
69
- bullet: insertList(schema.nodes.bullet_list, 'bullet'),
70
- simple: insertList(schema.nodes.bullet_list, 'simple'),
69
+ bullet: insertList(schema.nodes.list, 'bullet'),
70
+ simple: insertList(schema.nodes.list, 'simple'),
71
71
  },
72
72
  },
73
73
  ordered_list: {
74
74
  title: 'Wrap in ordered list',
75
75
  content: React.createElement(ToolbarOrderedListIcon, null),
76
- isActive: blockActive(schema.nodes.ordered_list),
77
- isEnabled: insertList(schema.nodes.ordered_list, 'order'),
78
- run: insertList(schema.nodes.ordered_list, 'order'),
76
+ isActive: blockActive(schema.nodes.list),
77
+ isEnabled: insertList(schema.nodes.list, 'order'),
78
+ run: insertList(schema.nodes.list, 'order'),
79
79
  options: {
80
- order: insertList(schema.nodes.ordered_list, 'order'),
81
- 'alpha-upper': insertList(schema.nodes.ordered_list, 'alpha-upper'),
82
- 'alpha-lower': insertList(schema.nodes.ordered_list, 'alpha-lower'),
83
- 'roman-upper': insertList(schema.nodes.ordered_list, 'roman-upper'),
84
- 'roman-lower': insertList(schema.nodes.ordered_list, 'roman-lower'),
80
+ order: insertList(schema.nodes.list, 'order'),
81
+ 'alpha-upper': insertList(schema.nodes.list, 'alpha-upper'),
82
+ 'alpha-lower': insertList(schema.nodes.list, 'alpha-lower'),
83
+ 'roman-upper': insertList(schema.nodes.list, 'roman-upper'),
84
+ 'roman-lower': insertList(schema.nodes.list, 'roman-lower'),
85
85
  },
86
86
  },
87
87
  },
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { getListType, } from '@manuscripts/transform';
17
+ import { getActualAttrs } from '../lib/track-changes-utils';
18
+ import BlockView from './block_view';
19
+ import { createNodeOrElementView } from './creators';
20
+ import { EditableBlock } from './editable_block';
21
+ export class ListView extends BlockView {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.elementType = 'ul';
25
+ this.updateContents = () => {
26
+ var _a;
27
+ const actualAttrs = getActualAttrs(this.node);
28
+ if (this.contentDOM) {
29
+ const type = actualAttrs.listStyleType;
30
+ this.contentDOM.style.listStyleType = getListType(type).style;
31
+ }
32
+ if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
33
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
34
+ this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
35
+ }
36
+ else {
37
+ this.dom.removeAttribute('data-track-status');
38
+ this.dom.removeAttribute('data-track-type');
39
+ }
40
+ };
41
+ }
42
+ }
43
+ export const listCallback = (node, dom) => {
44
+ dom.classList.add('list');
45
+ const type = node.attrs.listStyleType;
46
+ dom.style.listStyleType = getListType(type).style;
47
+ };
48
+ export default createNodeOrElementView(EditableBlock(ListView), 'ul', listCallback);
@@ -16,7 +16,7 @@
16
16
  import { CommentAnnotation } from '@manuscripts/json-schema';
17
17
  import { FileAttachment } from '@manuscripts/style-guide';
18
18
  import { InlineFootnoteNode, ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
19
- import { ResolvedPos } from 'prosemirror-model';
19
+ import { Attrs, ResolvedPos } from 'prosemirror-model';
20
20
  import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
21
21
  import { NodeWithPos } from 'prosemirror-utils';
22
22
  import { EditorView } from 'prosemirror-view';
@@ -27,7 +27,7 @@ export declare const isNodeSelection: (selection: Selection) => selection is Nod
27
27
  export declare const blockActive: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
28
28
  export declare const canInsert: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
29
29
  export declare const createSelection: (nodeType: ManuscriptNodeType, position: number, doc: ManuscriptNode) => Selection;
30
- export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch) => void;
30
+ export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch, attrs?: Attrs) => void;
31
31
  export declare const insertGeneralFootnote: (tableNode: ManuscriptNode, position: number, view: ManuscriptEditorView, tableElementFooter?: NodeWithPos[]) => void;
32
32
  export declare const insertFileAsFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
33
33
  export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
@@ -92,7 +92,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
92
92
  destroy: () => void;
93
93
  handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
94
94
  } & import("../views/blockquote_element").BlockquoteElementView<any>>;
95
- bullet_list: import("../types").NodeViewCreator<{
95
+ list: import("../types").NodeViewCreator<{
96
96
  gutterButtons: () => HTMLElement[];
97
97
  actionGutterButtons: () => HTMLElement[];
98
98
  createAddButton: () => HTMLElement | null;
@@ -126,7 +126,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
126
126
  deselectNode: () => void;
127
127
  destroy: () => void;
128
128
  handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
129
- } & import("../views/bullet_list").BulletListView<any>>;
129
+ } & import("../views/list").ListView<any>>;
130
130
  citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
131
131
  cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
132
132
  contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView>;
@@ -281,41 +281,6 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
281
281
  handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
282
282
  } & import("../views/listing_element").ListingElementView<any>>;
283
283
  list_item: import("../types").NodeViewCreator<import("../views/list_item").ListItemView<any>>;
284
- ordered_list: import("../types").NodeViewCreator<{
285
- gutterButtons: () => HTMLElement[];
286
- actionGutterButtons: () => HTMLElement[];
287
- createAddButton: () => HTMLElement | null;
288
- createEditButton: () => HTMLElement | null;
289
- createMenu: () => import("../lib/context-menu").ContextMenu;
290
- viewAttributes: {
291
- id: string;
292
- placeholder: string;
293
- paragraphStyle: string;
294
- };
295
- initialise: () => void;
296
- updateContents: () => void;
297
- onUpdateContent(): void;
298
- updateClasses: () => void;
299
- updateAttributes: () => void;
300
- createElement: () => void;
301
- createDOM: () => void;
302
- createGutter: (className: string, buttons: HTMLElement[]) => void;
303
- dom: HTMLElement;
304
- contentDOM?: HTMLElement | undefined;
305
- syncErrors: import("../types").SyncError[];
306
- elementType: string;
307
- readonly props: EditableBlockProps;
308
- node: import("prosemirror-model").Node;
309
- readonly view: import("prosemirror-view").EditorView;
310
- readonly getPos: () => number;
311
- decorations: readonly import("prosemirror-view").Decoration[];
312
- update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
313
- setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
314
- selectNode: () => void;
315
- deselectNode: () => void;
316
- destroy: () => void;
317
- handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
318
- } & import("../views/ordered_list").OrderedListView<any>>;
319
284
  paragraph: import("../types").NodeViewCreator<{
320
285
  gutterButtons: () => HTMLElement[];
321
286
  actionGutterButtons: () => HTMLElement[];
@@ -15,4 +15,4 @@
15
15
  */
16
16
  import { NodeType } from 'prosemirror-model';
17
17
  import React from 'react';
18
- export declare const nodeTypeIcon: (nodeType: NodeType) => React.JSX.Element | null;
18
+ export declare const nodeTypeIcon: (nodeType: NodeType, listType?: string) => React.JSX.Element | null;
@@ -0,0 +1,59 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { ManuscriptNode } from '@manuscripts/transform';
17
+ import { BaseNodeProps } from './base_node_view';
18
+ import BlockView from './block_view';
19
+ export declare class ListView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
20
+ elementType: string;
21
+ updateContents: () => void;
22
+ }
23
+ export declare const listCallback: (node: ManuscriptNode, dom: HTMLElement) => void;
24
+ declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<{
25
+ gutterButtons: () => HTMLElement[];
26
+ actionGutterButtons: () => HTMLElement[];
27
+ createAddButton: () => HTMLElement | null;
28
+ createEditButton: () => HTMLElement | null;
29
+ createMenu: () => import("../lib/context-menu").ContextMenu;
30
+ viewAttributes: {
31
+ id: string;
32
+ placeholder: string;
33
+ paragraphStyle: string;
34
+ };
35
+ initialise: () => void;
36
+ updateContents: () => void;
37
+ onUpdateContent(): void;
38
+ updateClasses: () => void;
39
+ updateAttributes: () => void;
40
+ createElement: () => void;
41
+ createDOM: () => void;
42
+ createGutter: (className: string, buttons: HTMLElement[]) => void;
43
+ dom: HTMLElement;
44
+ contentDOM?: HTMLElement | undefined;
45
+ syncErrors: import("../types").SyncError[];
46
+ elementType: string;
47
+ readonly props: import("./editable_block").EditableBlockProps;
48
+ node: import("prosemirror-model").Node;
49
+ readonly view: import("prosemirror-view").EditorView;
50
+ readonly getPos: () => number;
51
+ decorations: readonly import("prosemirror-view").Decoration[];
52
+ update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
53
+ setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
54
+ selectNode: () => void;
55
+ deselectNode: () => void;
56
+ destroy: () => void;
57
+ handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
58
+ } & ListView<any>>;
59
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "1.10.8",
4
+ "version": "1.10.10-LEAN-3608.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,9 +30,9 @@
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/json-schema": "2.2.8",
32
32
  "@manuscripts/library": "1.3.7",
33
- "@manuscripts/style-guide": "1.12.10",
33
+ "@manuscripts/style-guide": "1.12.11-LEAN-3608.0",
34
34
  "@manuscripts/track-changes-plugin": "1.7.12",
35
- "@manuscripts/transform": "2.3.5",
35
+ "@manuscripts/transform": "2.3.7-LEAN-3608.1",
36
36
  "astrocite-eutils": "^0.16.4",
37
37
  "mathjax-full": "^3.2.2",
38
38
  "codemirror": "^5.58.1",
@@ -110,4 +110,4 @@
110
110
  "@types/react": "^17.0.2",
111
111
  "prosemirror-tables": "^1.3.5"
112
112
  }
113
- }
113
+ }