@manuscripts/body-editor 1.5.16 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/commands.js +53 -132
  2. package/dist/cjs/components/outline/DraggableTree.js +33 -25
  3. package/dist/cjs/components/toolbar/OrderListSelector.js +3 -11
  4. package/dist/cjs/configs/editor-plugins.js +2 -2
  5. package/dist/cjs/configs/editor-views.js +4 -6
  6. package/dist/cjs/lib/context-menu.js +6 -5
  7. package/dist/cjs/node-type-icons.js +0 -1
  8. package/dist/cjs/plugins/bibliography/bibliography-utils.js +60 -47
  9. package/dist/cjs/plugins/bibliography/index.js +48 -63
  10. package/dist/cjs/plugins/comment_annotation.js +2 -2
  11. package/dist/cjs/plugins/footnotes/index.js +19 -10
  12. package/dist/cjs/plugins/persist.js +21 -31
  13. package/dist/cjs/plugins/sections.js +1 -2
  14. package/dist/cjs/plugins/toc.js +28 -23
  15. package/dist/cjs/views/bibliography_element.js +20 -38
  16. package/dist/cjs/views/citation.js +29 -26
  17. package/dist/cjs/views/citation_editable.js +25 -44
  18. package/dist/cjs/views/{contributors_section.js → contributors.js} +4 -4
  19. package/dist/cjs/views/cross_reference.js +7 -36
  20. package/dist/cjs/views/cross_reference_editable.js +6 -14
  21. package/dist/cjs/views/editable_block.js +2 -2
  22. package/dist/cjs/views/{meta_section.js → empty.js} +3 -3
  23. package/dist/cjs/views/section_title.js +1 -16
  24. package/dist/es/commands.js +55 -110
  25. package/dist/es/components/outline/DraggableTree.js +33 -25
  26. package/dist/es/components/toolbar/OrderListSelector.js +4 -12
  27. package/dist/es/configs/editor-plugins.js +2 -2
  28. package/dist/es/configs/editor-views.js +4 -6
  29. package/dist/es/lib/context-menu.js +7 -6
  30. package/dist/es/node-type-icons.js +0 -1
  31. package/dist/es/plugins/bibliography/bibliography-utils.js +56 -45
  32. package/dist/es/plugins/bibliography/index.js +49 -65
  33. package/dist/es/plugins/comment_annotation.js +2 -2
  34. package/dist/es/plugins/footnotes/index.js +20 -11
  35. package/dist/es/plugins/persist.js +22 -32
  36. package/dist/es/plugins/sections.js +2 -3
  37. package/dist/es/plugins/toc.js +29 -24
  38. package/dist/es/views/bibliography_element.js +21 -39
  39. package/dist/es/views/citation.js +31 -28
  40. package/dist/es/views/citation_editable.js +28 -47
  41. package/dist/es/views/{contributors_section.js → contributors.js} +2 -2
  42. package/dist/es/views/cross_reference.js +7 -33
  43. package/dist/es/views/cross_reference_editable.js +6 -14
  44. package/dist/es/views/editable_block.js +3 -3
  45. package/dist/es/views/{meta_section.js → empty.js} +3 -3
  46. package/dist/es/views/section_title.js +0 -14
  47. package/dist/types/commands.d.ts +1 -2
  48. package/dist/types/components/outline/DraggableTree.d.ts +1 -2
  49. package/dist/types/configs/ManuscriptsEditor.d.ts +1 -10
  50. package/dist/types/configs/editor-plugins.d.ts +1 -5
  51. package/dist/types/configs/editor-views.d.ts +5 -6
  52. package/dist/types/lib/context-menu.d.ts +0 -1
  53. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +10 -7
  54. package/dist/types/plugins/bibliography/index.d.ts +21 -3
  55. package/dist/types/views/bibliography_element.d.ts +1 -0
  56. package/dist/types/views/citation.d.ts +3 -4
  57. package/dist/types/views/citation_editable.d.ts +2 -8
  58. package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
  59. package/dist/types/views/cross_reference.d.ts +0 -5
  60. package/dist/types/views/{meta_section.d.ts → empty.d.ts} +2 -2
  61. package/dist/types/views/section_title.d.ts +0 -2
  62. package/package.json +4 -22
  63. package/styles/AdvancedEditor.css +30 -34
  64. package/dist/cjs/plugins/auxiliary_object_order.js +0 -49
  65. package/dist/cjs/plugins/bibliography/types.js +0 -17
  66. package/dist/cjs/plugins/footnotes/footnotes-utils.js +0 -52
  67. package/dist/cjs/views/bibliography_item.js +0 -138
  68. package/dist/cjs/views/bibliography_item_editable.js +0 -20
  69. package/dist/es/plugins/auxiliary_object_order.js +0 -46
  70. package/dist/es/plugins/bibliography/types.js +0 -16
  71. package/dist/es/plugins/footnotes/footnotes-utils.js +0 -46
  72. package/dist/es/views/bibliography_item.js +0 -131
  73. package/dist/es/views/bibliography_item_editable.js +0 -18
  74. package/dist/types/plugins/auxiliary_object_order.d.ts +0 -12
  75. package/dist/types/plugins/bibliography/types.d.ts +0 -40
  76. package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -25
  77. package/dist/types/views/bibliography_item.d.ts +0 -34
  78. package/dist/types/views/bibliography_item_editable.d.ts +0 -18
@@ -14,17 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ObjectTypes } from '@manuscripts/json-schema';
17
- import { buildCitation, buildComment, buildInlineMathFragment, generateID, isElementNodeType, isInAbstractsSection, isInBibliographySection, isSectionNodeType, } from '@manuscripts/transform';
17
+ import { buildComment, buildInlineMathFragment, generateID, isElementNodeType, isInBibliographySection, isSectionNodeType, schema, } from '@manuscripts/transform';
18
18
  import { NodeRange } from 'prosemirror-model';
19
19
  import { NodeSelection, TextSelection, } from 'prosemirror-state';
20
20
  import { findWrapping } from 'prosemirror-transform';
21
- import { findParentNode } from 'prosemirror-utils';
21
+ import { findChildrenByType, findParentNodeOfType } from 'prosemirror-utils';
22
22
  import { isNodeOfType, nearestAncestor } from './lib/helpers';
23
- import { findParentNodeWithId, getChildOfType, getMatchingDescendant, } from './lib/utils';
24
- import { bibliographyKey } from './plugins/bibliography';
23
+ import { findParentNodeWithId, getChildOfType } from './lib/utils';
25
24
  import { commentAnnotation } from './plugins/comment_annotation';
26
- import { footnotesKey } from './plugins/footnotes';
27
- import * as footnotesUtils from './plugins/footnotes/footnotes-utils';
28
25
  import { highlightKey, SET_COMMENT } from './plugins/highlight';
29
26
  export const markActive = (type) => (state) => {
30
27
  const { from, $from, to, empty } = state.selection;
@@ -219,12 +216,11 @@ export const insertLink = (state, dispatch) => {
219
216
  }
220
217
  return true;
221
218
  };
222
- export const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = []) => {
223
- const citation = buildCitation(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
219
+ export const insertInlineCitation = (state, dispatch, view) => {
224
220
  const node = state.schema.nodes.citation.create({
225
- rid: citation._id,
221
+ id: generateID(ObjectTypes.Citation),
222
+ rids: [],
226
223
  selectedText: selectedText(),
227
- embeddedCitationItems: [],
228
224
  });
229
225
  const pos = state.selection.to;
230
226
  const { tr } = state;
@@ -237,7 +233,7 @@ export const insertInlineCitation = (state, dispatch, view, embeddedCitationItem
237
233
  };
238
234
  export const insertCrossReference = (state, dispatch) => {
239
235
  const node = state.schema.nodes.cross_reference.create({
240
- rid: null,
236
+ rids: [],
241
237
  });
242
238
  const pos = state.selection.to;
243
239
  const tr = state.tr.insert(pos, node);
@@ -265,52 +261,47 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
265
261
  kind,
266
262
  });
267
263
  const insertedAt = state.selection.to;
268
- const thisFootnoteNumbering = footnotesUtils.getNewFootnoteNumbering(insertedAt, state);
269
- const inlineFootnote = state.schema.nodes.inline_footnote.create({
270
- rid: footnote.attrs.id,
271
- contents: thisFootnoteNumbering.toString(),
264
+ const node = state.schema.nodes.inline_footnote.create({
265
+ rids: [footnote.attrs.id],
272
266
  });
273
267
  const tr = state.tr;
274
- tr.insert(insertedAt, inlineFootnote);
275
- const footnotesElementAndPos = footnotesUtils.findFootnotesElement(tr.doc);
268
+ tr.insert(insertedAt, node);
269
+ const elements = findChildrenByType(tr.doc, schema.nodes.footnotes_element);
276
270
  let selectionPos;
277
- if (footnotesElementAndPos === undefined) {
278
- const footnotesSection = state.schema.nodes.footnotes_section.create({}, [
271
+ if (!elements.length) {
272
+ const section = state.schema.nodes.footnotes_section.create({}, [
279
273
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
280
274
  state.schema.nodes.footnotes_element.create({}, footnote),
281
275
  ]);
282
- const insideEndPos = tr.doc.content.size;
283
- tr.insert(insideEndPos, footnotesSection);
284
- selectionPos = insideEndPos + footnotesSection.nodeSize;
276
+ const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
277
+ tr.insert(backmatter.pos + 1, section);
278
+ selectionPos = backmatter.pos + section.nodeSize - 3;
285
279
  }
286
280
  else {
287
- const [footnotePos, selectPos] = footnotesUtils.getNewFootnoteElementPos(footnotesElementAndPos, thisFootnoteNumbering);
288
- tr.insert(footnotePos, footnote);
289
- selectionPos = selectPos;
281
+ const element = elements[0];
282
+ const pos = element.pos + element.node.nodeSize - 1;
283
+ tr.insert(pos, footnote);
284
+ selectionPos = pos + 2;
290
285
  }
291
- if (dispatch) {
286
+ if (dispatch && selectionPos) {
292
287
  const selection = TextSelection.create(tr.doc, selectionPos);
293
288
  dispatch(tr.setSelection(selection).scrollIntoView());
294
289
  }
295
290
  return true;
296
291
  };
297
292
  export const insertGraphicalAbstract = (state, dispatch) => {
298
- const pos = findPosAfterParentSection(state.selection.$from);
299
- if (pos === null ||
300
- isInBibliographySection(state.selection.$from) ||
301
- !isInAbstractsSection(state.selection.$from)) {
293
+ if (getChildOfType(state.doc, schema.nodes.graphical_abstract_section)) {
302
294
  return false;
303
295
  }
304
- if (getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
305
- return false;
306
- }
307
- const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
308
- state.schema.nodes.section_title.create({}, state.schema.text('Graphical Abstract')),
296
+ const abstracts = findChildrenByType(state.doc, schema.nodes.abstracts)[0];
297
+ const section = schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
298
+ schema.nodes.section_title.create({}, schema.text('Graphical Abstract')),
309
299
  createAndFillFigureElement(state),
310
300
  ]);
301
+ const pos = abstracts.pos + abstracts.node.nodeSize + 1;
311
302
  const tr = state.tr.insert(pos, section);
312
303
  if (dispatch) {
313
- const selection = TextSelection.create(tr.doc, pos + 2);
304
+ const selection = TextSelection.create(tr.doc, pos + 1);
314
305
  dispatch(tr.setSelection(selection).scrollIntoView());
315
306
  }
316
307
  return true;
@@ -328,56 +319,11 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
328
319
  }
329
320
  return true;
330
321
  };
331
- export const insertFootnotesSection = (state, dispatch) => {
332
- if (getChildOfType(state.doc, state.schema.nodes.footnotes_section)) {
333
- return false;
334
- }
335
- const section = state.schema.nodes.footnotes_section.createAndFill({}, [
336
- state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
337
- state.schema.nodes.footnotes_element.create(),
338
- ]);
339
- const pos = state.tr.doc.content.size;
340
- const tr = state.tr;
341
- tr.insert(pos, section).setMeta(footnotesKey, {
342
- footnotesElementInserted: true,
343
- });
344
- if (dispatch) {
345
- const selection = NodeSelection.create(tr.doc, pos);
346
- dispatch(tr.setSelection(selection).scrollIntoView());
347
- }
348
- return true;
349
- };
350
322
  export const insertBibliographySection = (state, dispatch) => {
351
- if (getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.bibliography_section)) {
352
- return false;
353
- }
354
- const section = state.schema.nodes.bibliography_section.createAndFill({}, [
355
- state.schema.nodes.section_title.create({}, state.schema.text('Bibliography')),
356
- ]);
357
- const pos = state.tr.doc.content.size;
358
- const tr = state.tr;
359
- tr.insert(pos, section).setMeta(bibliographyKey, {
360
- bibliographyInserted: true,
361
- });
362
- if (dispatch) {
363
- const selection = NodeSelection.create(tr.doc, pos);
364
- dispatch(tr.setSelection(selection).scrollIntoView());
365
- }
366
- return true;
323
+ return false;
367
324
  };
368
325
  export const insertTOCSection = (state, dispatch) => {
369
- if (getChildOfType(state.doc, state.schema.nodes.toc_section)) {
370
- return false;
371
- }
372
- const section = state.schema.nodes.toc_section.createAndFill({}, [
373
- state.schema.nodes.section_title.create({}, state.schema.text('Table of Contents')),
374
- ]);
375
- const pos = 0;
376
- const tr = state.tr.insert(pos, section);
377
- if (dispatch) {
378
- dispatch(tr.setSelection(NodeSelection.create(tr.doc, pos)).scrollIntoView());
379
- }
380
- return true;
326
+ return false;
381
327
  };
382
328
  export const ifInTableBody = (command) => (state) => {
383
329
  const $head = state.selection.$head;
@@ -562,11 +508,17 @@ export const deleteHighlightMarkers = (rid) => (state, dispatch) => {
562
508
  };
563
509
  export function addComment(state, dispatch, viewNode, resolvePos) {
564
510
  const { selection } = state;
565
- const isThereTextSelected = selection.content().size > 0;
566
- const selectionNode = getParentNode(selection);
511
+ const hasText = selection.content().size > 0;
512
+ const parent = getParentNode(selection);
513
+ if (!parent) {
514
+ return false;
515
+ }
567
516
  if (viewNode && resolvePos) {
568
517
  const viewNode = getParentNode(TextSelection.near(resolvePos));
569
- if (isThereTextSelected && selectionNode.attrs.id === viewNode.attrs.id) {
518
+ if (!viewNode) {
519
+ return false;
520
+ }
521
+ if (hasText && parent.attrs.id === viewNode.attrs.id) {
570
522
  return addHighlightComment(viewNode, state, dispatch);
571
523
  }
572
524
  else {
@@ -574,41 +526,34 @@ export function addComment(state, dispatch, viewNode, resolvePos) {
574
526
  }
575
527
  }
576
528
  else {
577
- if (isThereTextSelected) {
578
- return addHighlightComment(selectionNode, state, dispatch);
529
+ if (hasText) {
530
+ return addHighlightComment(parent, state, dispatch);
579
531
  }
580
532
  else {
581
- return addBlockComment(selectionNode, state, dispatch);
533
+ return addBlockComment(parent, state, dispatch);
582
534
  }
583
535
  }
584
536
  }
585
537
  const getParentNode = (selection) => {
586
538
  var _a;
587
539
  const parentNode = findParentNodeWithId(selection);
588
- let node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
589
- if (node.type === node.type.schema.nodes.table && parentNode) {
590
- const findTableElement = findParentNode((node) => node.type === node.type.schema.nodes.table_element);
591
- node = (_a = findTableElement(selection)) === null || _a === void 0 ? void 0 : _a.node;
540
+ const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
541
+ if ((node === null || node === void 0 ? void 0 : node.type) === schema.nodes.table) {
542
+ return (_a = findParentNodeOfType(schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
592
543
  }
593
544
  return node;
594
545
  };
595
- const isAllowedType = (type) => type === type.schema.nodes.section ||
596
- type === type.schema.nodes.footnotes_section ||
597
- type === type.schema.nodes.bibliography_section ||
598
- type === type.schema.nodes.keywords_group ||
599
- type === type.schema.nodes.paragraph ||
600
- type === type.schema.nodes.figure_element ||
601
- type === type.schema.nodes.table_element;
546
+ const isAllowedType = (type) => type === schema.nodes.section ||
547
+ type === schema.nodes.footnotes_section ||
548
+ type === schema.nodes.bibliography_section ||
549
+ type === schema.nodes.keyword_group ||
550
+ type === schema.nodes.paragraph ||
551
+ type === schema.nodes.figure_element ||
552
+ type === schema.nodes.table_element;
602
553
  const getNode = (node) => {
603
- if (node.type === node.type.schema.nodes.keywords_section) {
604
- let keywordGroup;
605
- node.descendants((child) => {
606
- if (child.type === node.type.schema.nodes.keywords_group) {
607
- keywordGroup = child;
608
- return false;
609
- }
610
- });
611
- return keywordGroup || node;
554
+ if (node.type === schema.nodes.keywords) {
555
+ const keywordGroups = findChildrenByType(node, schema.nodes.keyword_group, true);
556
+ return keywordGroups.length ? keywordGroups[0].node : node;
612
557
  }
613
558
  return node;
614
559
  };
@@ -627,7 +572,7 @@ const addBlockComment = (node, state, dispatch) => {
627
572
  const addHighlightComment = (node, state, dispatch) => {
628
573
  const { attrs: { id }, type, } = node;
629
574
  const comment = buildComment(id);
630
- if (type === state.schema.nodes.paragraph) {
575
+ if (type === schema.nodes.paragraph) {
631
576
  const { $anchor, $head } = state.selection;
632
577
  const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
633
578
  $anchor.textOffset === $head.textOffset;
@@ -6,16 +6,15 @@ import { findDOMNode } from 'react-dom';
6
6
  import { ContextMenu } from '../../lib/context-menu';
7
7
  import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
8
8
  import { nodeTypeIcon } from '../../node-type-icons';
9
- import { isSpecialSection } from '../../views/section_title';
10
9
  import { Outline, OutlineDropPreview, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, StyledTriangleCollapsed, StyledTriangleExpanded, } from './Outline';
11
10
  const excludedTypes = [
12
11
  schema.nodes.table,
13
12
  schema.nodes.figure,
14
13
  schema.nodes.footnotes_element,
15
14
  schema.nodes.bibliography_element,
16
- schema.nodes.keywords_section,
17
- schema.nodes.affiliations_section,
18
- schema.nodes.contributors_section,
15
+ schema.nodes.keywords,
16
+ schema.nodes.affiliations,
17
+ schema.nodes.contributors,
19
18
  schema.nodes.title,
20
19
  ];
21
20
  const childrenExcludedTypes = [
@@ -28,6 +27,9 @@ const isExcluded = (nodeType) => {
28
27
  const isChildrenExcluded = (nodeType) => {
29
28
  return childrenExcludedTypes.includes(nodeType);
30
29
  };
30
+ const isManuscriptNode = (node) => {
31
+ return (node === null || node === void 0 ? void 0 : node.type) === schema.nodes.manuscript;
32
+ };
31
33
  export const buildTree = ({ node, pos, index, selected, parent, }) => {
32
34
  const items = [];
33
35
  const startPos = pos + 1;
@@ -35,9 +37,12 @@ export const buildTree = ({ node, pos, index, selected, parent, }) => {
35
37
  const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
36
38
  if (!isChildrenExcluded(node.type)) {
37
39
  node.forEach((childNode, offset, childIndex) => {
38
- if ((!childNode.isAtom || isElementNodeType(childNode.type)) &&
39
- childNode.attrs.id &&
40
- !isExcluded(childNode.type)) {
40
+ if (isExcluded(childNode.type)) {
41
+ return;
42
+ }
43
+ if (isManuscriptNode(node) ||
44
+ ((!childNode.isAtom || isElementNodeType(childNode.type)) &&
45
+ childNode.attrs.id)) {
41
46
  items.push(buildTree({
42
47
  node: childNode,
43
48
  pos: startPos + offset,
@@ -104,29 +109,32 @@ class Tree extends React.Component {
104
109
  render() {
105
110
  const { depth = 0, tree, canDrop, connectDragSource, connectDragPreview, connectDropTarget, isDragging, isOverCurrent, item, view, } = this.props;
106
111
  const { open, dragPosition } = this.state;
107
- const { node, items, isSelected } = tree;
112
+ const { node, items, isSelected, parent } = tree;
108
113
  const isDeletedItem = isDeleted(node);
109
114
  const isRejectedItem = isRejectedInsert(node);
110
115
  const mightDrop = item && isOverCurrent && canDrop;
111
- if (isRejectedItem || node.attrs.id === 'META_SECTION') {
116
+ const isTop = isManuscriptNode(parent);
117
+ if (isRejectedItem) {
112
118
  return null;
113
119
  }
114
- return connectDropTarget(React.createElement("div", null, node.type.name !== 'titles' && (React.createElement(Outline, { style: this.outlineStyles(isDragging) },
115
- React.createElement(OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
116
- !isSpecialSection(node) && (React.createElement(React.Fragment, null, connectDragSource(React.createElement("div", null,
117
- React.createElement(OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
118
- items.length ? (React.createElement(OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(StyledTriangleExpanded, null)) : (React.createElement(StyledTriangleCollapsed, null)))) : (React.createElement(OutlineItemNoArrow, null)),
119
- React.createElement(OutlineItemLink, { to: `#${node.attrs.id || ''}` },
120
- connectDragPreview(React.createElement("span", { style: {
121
- display: 'inline-flex',
122
- alignItems: 'center',
123
- } },
124
- React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)))),
125
- React.createElement(OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))))),
126
- items.length ? (React.createElement("div", { style: {
127
- display: open || isSpecialSection(node) ? '' : 'none',
128
- } }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isSpecialSection(node) ? depth : depth + 1 })))))) : null,
129
- React.createElement(OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) })))));
120
+ return connectDropTarget(React.createElement("div", null,
121
+ React.createElement(Outline, { style: this.outlineStyles(isDragging) },
122
+ React.createElement(OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
123
+ !isTop &&
124
+ connectDragSource(React.createElement("div", null,
125
+ React.createElement(OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
126
+ items.length ? (React.createElement(OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(StyledTriangleExpanded, null)) : (React.createElement(StyledTriangleCollapsed, null)))) : (React.createElement(OutlineItemNoArrow, null)),
127
+ React.createElement(OutlineItemLink, { to: `#${node.attrs.id || ''}` },
128
+ connectDragPreview(React.createElement("span", { style: {
129
+ display: 'inline-flex',
130
+ alignItems: 'center',
131
+ } },
132
+ React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)))),
133
+ React.createElement(OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))),
134
+ items.length ? (React.createElement("div", { style: {
135
+ display: open || isTop ? '' : 'none',
136
+ } }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isTop ? depth : depth + 1 })))))) : (''),
137
+ React.createElement(OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
130
138
  }
131
139
  }
132
140
  const dragSource = DragSource('outline', {
@@ -3,20 +3,12 @@ import { skipTracking } from '@manuscripts/track-changes-plugin';
3
3
  import { schema, } from '@manuscripts/transform';
4
4
  import { wrapInList } from 'prosemirror-schema-list';
5
5
  import { Selection } from 'prosemirror-state';
6
- import React, { useCallback, useMemo } from 'react';
6
+ import React, { useCallback } from 'react';
7
7
  import { skipTrackingChanges } from '../../keys/list';
8
8
  import { ListButton, ListStyleSelector } from './ListStyleSelector';
9
9
  import { ToolbarItem } from './ManuscriptToolbar';
10
10
  export const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }) => {
11
- const disabled = useMemo(() => enable && !enable(state), [state.selection]);
12
- const dropDownDisabled = useMemo(() => {
13
- const { $from, $to } = state.selection;
14
- const range = $from.blockRange($to);
15
- return !!(enable &&
16
- !enable(state) &&
17
- range &&
18
- !schema.nodes.ordered_list.compatibleContent($from.node(range.depth - 1).type));
19
- }, [state.selection]);
11
+ const isEnabled = !enable || enable(state);
20
12
  const onClickListType = useCallback((type) => {
21
13
  if (!dispatch) {
22
14
  return;
@@ -34,13 +26,13 @@ export const OrderListSelector = ({ state, dispatch, view, title, active, run, e
34
26
  }
35
27
  }, [dispatch, state, view]);
36
28
  return (React.createElement(ToolbarItem, null,
37
- React.createElement(ListButton, { title: title, "data-active": active && active(state), disabled: disabled, onMouseDown: (event) => {
29
+ React.createElement(ListButton, { title: title, "data-active": active && active(state), disabled: !isEnabled, onMouseDown: (event) => {
38
30
  event.preventDefault();
39
31
  run(state, dispatch);
40
32
  view && view.focus();
41
33
  } },
42
34
  React.createElement(OrderedList, null)),
43
- React.createElement(ListStyleSelector, { disabled: dropDownDisabled, onClickListType: onClickListType, list: [
35
+ React.createElement(ListStyleSelector, { disabled: !isEnabled, onClickListType: onClickListType, list: [
44
36
  { items: ['1.', '2.', '3.'], type: 'order' },
45
37
  { items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
46
38
  { items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
@@ -19,10 +19,10 @@ import { dropCursor } from 'prosemirror-dropcursor';
19
19
  import { history } from 'prosemirror-history';
20
20
  import { tableEditing } from 'prosemirror-tables';
21
21
  import keys from '../keys';
22
- import auxiliary_object_order from '../plugins/auxiliary_object_order';
23
22
  import bibliography from '../plugins/bibliography';
24
23
  import comment_annotation from '../plugins/comment_annotation';
25
24
  import elements from '../plugins/elements';
25
+ import footnotes from '../plugins/footnotes';
26
26
  import highlights from '../plugins/highlight';
27
27
  import keywords from '../plugins/keywords';
28
28
  import objects from '../plugins/objects';
@@ -51,7 +51,6 @@ export default (props) => {
51
51
  keywords(props),
52
52
  bibliography(props),
53
53
  objects(props),
54
- auxiliary_object_order(props),
55
54
  comment_annotation(props),
56
55
  paragraphs(),
57
56
  placeholder(),
@@ -59,6 +58,7 @@ export default (props) => {
59
58
  highlights(props),
60
59
  track_changes_ui(props),
61
60
  tracking_mark(),
61
+ footnotes(),
62
62
  ];
63
63
  };
64
64
  document.execCommand('enableObjectResizing', false, 'false');
@@ -14,12 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import bibliographyElement from '../views/bibliography_element_editable';
17
- import bibliographyItem from '../views/bibliography_item_editable';
18
17
  import blockquoteElement from '../views/blockquote_element_editable';
19
18
  import bulletList from '../views/bullet_list_editable';
20
19
  import citation from '../views/citation_editable';
21
- import contributorsSection from '../views/contributors_section';
20
+ import contributorsSection from '../views/contributors';
22
21
  import crossReference from '../views/cross_reference_editable';
22
+ import empty from '../views/empty';
23
23
  import equation from '../views/equation_editable';
24
24
  import equationElement from '../views/equation_element_editable';
25
25
  import figure from '../views/figure_editable';
@@ -33,7 +33,6 @@ import keywordsElement from '../views/keywords_element';
33
33
  import link from '../views/link_editable';
34
34
  import listing from '../views/listing_editable';
35
35
  import listingElement from '../views/listing_element_editable';
36
- import metaSection from '../views/meta_section';
37
36
  import orderedList from '../views/ordered_list_editable';
38
37
  import paragraph from '../views/paragraph_editable';
39
38
  import placeholder from '../views/placeholder';
@@ -47,13 +46,12 @@ import tocElement from '../views/toc_element_editable';
47
46
  export default (props, dispatch) => {
48
47
  return {
49
48
  title: title(props, dispatch),
50
- bibliography_item: bibliographyItem(props),
51
49
  bibliography_element: bibliographyElement(props),
52
50
  blockquote_element: blockquoteElement(props),
53
51
  bullet_list: bulletList(props),
54
52
  citation: citation(props),
55
53
  cross_reference: crossReference(props),
56
- contributors_section: contributorsSection(props, dispatch),
54
+ contributors: contributorsSection(props, dispatch),
57
55
  equation: equation(props),
58
56
  equation_element: equationElement(props),
59
57
  figure: figure(props, dispatch),
@@ -76,6 +74,6 @@ export default (props, dispatch) => {
76
74
  section_label: sectionLabel(props),
77
75
  table_element: tableElement(props),
78
76
  toc_element: tocElement(props),
79
- meta_section: metaSection,
77
+ comments: empty('comments'),
80
78
  };
81
79
  };
@@ -13,11 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { isInBibliographySection, nodeNames, } from '@manuscripts/transform';
16
+ import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
17
17
  import { Fragment, Slice } from 'prosemirror-model';
18
18
  import { addComment, createBlock } from '../commands';
19
19
  import { PopperManager } from './popper';
20
20
  const popper = new PopperManager();
21
+ const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
22
+ const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
21
23
  export const sectionLevel = (depth) => {
22
24
  switch (depth) {
23
25
  case 1:
@@ -155,8 +157,8 @@ export class ContextMenu {
155
157
  menu.className = 'menu';
156
158
  const $pos = this.resolvePos();
157
159
  const nodeType = this.node.type;
158
- const { nodes } = this.view.state.schema;
159
- if (this.isListType(nodeType.name)) {
160
+ const nodes = schema.nodes;
161
+ if (listTypes.includes(nodeType)) {
160
162
  menu.appendChild(this.createMenuSection((section) => {
161
163
  if (nodeType === nodes.bullet_list) {
162
164
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
@@ -204,8 +206,8 @@ export class ContextMenu {
204
206
  }));
205
207
  }));
206
208
  }
207
- if (nodeType !== nodes.bibliography_element &&
208
- $pos.parent.type !== nodes.keywords_section) {
209
+ if (!readonlyTypes.includes(nodeType) &&
210
+ !readonlyTypes.includes($pos.parent.type)) {
209
211
  menu.appendChild(this.createMenuSection((section) => {
210
212
  const nodeName = nodeNames.get(nodeType) || '';
211
213
  section.appendChild(this.createMenuItem(`Delete ${nodeName}`, () => {
@@ -313,7 +315,6 @@ export class ContextMenu {
313
315
  const { getPos, attr, attrs } = option;
314
316
  this.view.dispatch(this.view.state.tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, attrs), { [attr]: !attrs[attr] })));
315
317
  };
316
- this.isListType = (type) => ['bullet_list', 'ordered_list'].includes(type);
317
318
  this.buildSuppressOptions = () => {
318
319
  const items = [];
319
320
  let attrs = this.node.attrs;
@@ -34,7 +34,6 @@ const icons = new Map([
34
34
  [nodes.equation_element, EquationIcon],
35
35
  [nodes.figure_element, FigureIcon],
36
36
  [nodes.multi_graphic_figure_element, FigureIcon],
37
- [nodes.keywords_section, SectionIcon],
38
37
  [nodes.listing_element, ListingIcon],
39
38
  [nodes.ordered_list, OrderedListIcon],
40
39
  [nodes.paragraph, ParagraphIcon],