@manuscripts/body-editor 1.5.13 → 1.5.14-LEAN-3030

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 (30) hide show
  1. package/dist/cjs/commands.js +35 -33
  2. package/dist/cjs/components/outline/DraggableTree.js +4 -4
  3. package/dist/cjs/components/toolbar/OrderListSelector.js +3 -11
  4. package/dist/cjs/configs/editor-views.js +2 -2
  5. package/dist/cjs/lib/context-menu.js +6 -5
  6. package/dist/cjs/node-type-icons.js +0 -1
  7. package/dist/cjs/plugins/comment_annotation.js +1 -1
  8. package/dist/cjs/plugins/sections.js +1 -2
  9. package/dist/cjs/plugins/toc.js +28 -23
  10. package/dist/cjs/views/{contributors_section.js → contributors.js} +4 -4
  11. package/dist/cjs/views/editable_block.js +2 -2
  12. package/dist/cjs/views/section_title.js +4 -9
  13. package/dist/es/commands.js +37 -35
  14. package/dist/es/components/outline/DraggableTree.js +4 -4
  15. package/dist/es/components/toolbar/OrderListSelector.js +4 -12
  16. package/dist/es/configs/editor-views.js +2 -2
  17. package/dist/es/lib/context-menu.js +7 -6
  18. package/dist/es/node-type-icons.js +0 -1
  19. package/dist/es/plugins/comment_annotation.js +1 -1
  20. package/dist/es/plugins/sections.js +2 -3
  21. package/dist/es/plugins/toc.js +29 -24
  22. package/dist/es/views/{contributors_section.js → contributors.js} +2 -2
  23. package/dist/es/views/editable_block.js +3 -3
  24. package/dist/es/views/section_title.js +4 -9
  25. package/dist/types/configs/editor-views.d.ts +1 -1
  26. package/dist/types/lib/context-menu.d.ts +0 -1
  27. package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
  28. package/dist/types/views/section_title.d.ts +1 -1
  29. package/package.json +4 -5
  30. package/styles/AdvancedEditor.css +1 -5
@@ -301,6 +301,7 @@ const insertInlineEquation = (state, dispatch) => {
301
301
  };
302
302
  exports.insertInlineEquation = insertInlineEquation;
303
303
  const insertInlineFootnote = (kind) => (state, dispatch) => {
304
+ var _a;
304
305
  const footnote = state.schema.nodes.footnote.createAndFill({
305
306
  id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
306
307
  kind,
@@ -314,22 +315,24 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
314
315
  const tr = state.tr;
315
316
  tr.insert(insertedAt, inlineFootnote);
316
317
  const footnotesElementAndPos = footnotesUtils.findFootnotesElement(tr.doc);
317
- let selectionPos;
318
+ let selectionPos = undefined;
318
319
  if (footnotesElementAndPos === undefined) {
319
320
  const footnotesSection = state.schema.nodes.footnotes_section.create({}, [
320
321
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
321
322
  state.schema.nodes.footnotes_element.create({}, footnote),
322
323
  ]);
323
- const insideEndPos = tr.doc.content.size;
324
- tr.insert(insideEndPos, footnotesSection);
325
- selectionPos = insideEndPos + footnotesSection.nodeSize;
324
+ const backmatterPosition = (_a = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0]) === null || _a === void 0 ? void 0 : _a.pos;
325
+ if (backmatterPosition) {
326
+ tr.insert(backmatterPosition + 1, footnotesSection);
327
+ selectionPos = backmatterPosition + footnotesSection.nodeSize;
328
+ }
326
329
  }
327
330
  else {
328
331
  const [footnotePos, selectPos] = footnotesUtils.getNewFootnoteElementPos(footnotesElementAndPos, thisFootnoteNumbering);
329
332
  tr.insert(footnotePos, footnote);
330
333
  selectionPos = selectPos;
331
334
  }
332
- if (dispatch) {
335
+ if (dispatch && selectionPos) {
333
336
  const selection = prosemirror_state_1.TextSelection.create(tr.doc, selectionPos);
334
337
  dispatch(tr.setSelection(selection).scrollIntoView());
335
338
  }
@@ -343,7 +346,7 @@ const insertGraphicalAbstract = (state, dispatch) => {
343
346
  !(0, transform_1.isInAbstractsSection)(state.selection.$from)) {
344
347
  return false;
345
348
  }
346
- if (!(0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
349
+ if ((0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
347
350
  return false;
348
351
  }
349
352
  const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
@@ -619,11 +622,17 @@ const deleteHighlightMarkers = (rid) => (state, dispatch) => {
619
622
  exports.deleteHighlightMarkers = deleteHighlightMarkers;
620
623
  function addComment(state, dispatch, viewNode, resolvePos) {
621
624
  const { selection } = state;
622
- const isThereTextSelected = selection.content().size > 0;
623
- const selectionNode = getParentNode(selection);
625
+ const hasText = selection.content().size > 0;
626
+ const parent = getParentNode(selection);
627
+ if (!parent) {
628
+ return false;
629
+ }
624
630
  if (viewNode && resolvePos) {
625
631
  const viewNode = getParentNode(prosemirror_state_1.TextSelection.near(resolvePos));
626
- if (isThereTextSelected && selectionNode.attrs.id === viewNode.attrs.id) {
632
+ if (!viewNode) {
633
+ return false;
634
+ }
635
+ if (hasText && parent.attrs.id === viewNode.attrs.id) {
627
636
  return addHighlightComment(viewNode, state, dispatch);
628
637
  }
629
638
  else {
@@ -631,11 +640,11 @@ function addComment(state, dispatch, viewNode, resolvePos) {
631
640
  }
632
641
  }
633
642
  else {
634
- if (isThereTextSelected) {
635
- return addHighlightComment(selectionNode, state, dispatch);
643
+ if (hasText) {
644
+ return addHighlightComment(parent, state, dispatch);
636
645
  }
637
646
  else {
638
- return addBlockComment(selectionNode, state, dispatch);
647
+ return addBlockComment(parent, state, dispatch);
639
648
  }
640
649
  }
641
650
  }
@@ -643,30 +652,23 @@ exports.addComment = addComment;
643
652
  const getParentNode = (selection) => {
644
653
  var _a;
645
654
  const parentNode = (0, utils_1.findParentNodeWithId)(selection);
646
- let node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
647
- if (node.type === node.type.schema.nodes.table && parentNode) {
648
- const findTableElement = (0, prosemirror_utils_1.findParentNode)((node) => node.type === node.type.schema.nodes.table_element);
649
- node = (_a = findTableElement(selection)) === null || _a === void 0 ? void 0 : _a.node;
655
+ const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
656
+ if ((node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.table) {
657
+ return (_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
650
658
  }
651
659
  return node;
652
660
  };
653
- const isAllowedType = (type) => type === type.schema.nodes.section ||
654
- type === type.schema.nodes.footnotes_section ||
655
- type === type.schema.nodes.bibliography_section ||
656
- type === type.schema.nodes.keywords_group ||
657
- type === type.schema.nodes.paragraph ||
658
- type === type.schema.nodes.figure_element ||
659
- type === type.schema.nodes.table_element;
661
+ const isAllowedType = (type) => type === transform_1.schema.nodes.section ||
662
+ type === transform_1.schema.nodes.footnotes_section ||
663
+ type === transform_1.schema.nodes.bibliography_section ||
664
+ type === transform_1.schema.nodes.keyword_group ||
665
+ type === transform_1.schema.nodes.paragraph ||
666
+ type === transform_1.schema.nodes.figure_element ||
667
+ type === transform_1.schema.nodes.table_element;
660
668
  const getNode = (node) => {
661
- if (node.type === node.type.schema.nodes.keywords_section) {
662
- let keywordGroup;
663
- node.descendants((child) => {
664
- if (child.type === node.type.schema.nodes.keywords_group) {
665
- keywordGroup = child;
666
- return false;
667
- }
668
- });
669
- return keywordGroup || node;
669
+ if (node.type === transform_1.schema.nodes.keywords) {
670
+ const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.keyword_group, true);
671
+ return keywordGroups.length ? keywordGroups[0].node : node;
670
672
  }
671
673
  return node;
672
674
  };
@@ -685,7 +687,7 @@ const addBlockComment = (node, state, dispatch) => {
685
687
  const addHighlightComment = (node, state, dispatch) => {
686
688
  const { attrs: { id }, type, } = node;
687
689
  const comment = (0, transform_1.buildComment)(id);
688
- if (type === state.schema.nodes.paragraph) {
690
+ if (type === transform_1.schema.nodes.paragraph) {
689
691
  const { $anchor, $head } = state.selection;
690
692
  const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
691
693
  $anchor.textOffset === $head.textOffset;
@@ -39,9 +39,9 @@ const excludedTypes = [
39
39
  transform_1.schema.nodes.figure,
40
40
  transform_1.schema.nodes.footnotes_element,
41
41
  transform_1.schema.nodes.bibliography_element,
42
- transform_1.schema.nodes.keywords_section,
43
- transform_1.schema.nodes.affiliations_section,
44
- transform_1.schema.nodes.contributors_section,
42
+ transform_1.schema.nodes.keyword,
43
+ transform_1.schema.nodes.affiliations,
44
+ transform_1.schema.nodes.contributors,
45
45
  transform_1.schema.nodes.title,
46
46
  ];
47
47
  const childrenExcludedTypes = [
@@ -61,7 +61,7 @@ const buildTree = ({ node, pos, index, selected, parent, }) => {
61
61
  const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
62
62
  if (!isChildrenExcluded(node.type)) {
63
63
  node.forEach((childNode, offset, childIndex) => {
64
- if ((!childNode.isAtom || (0, transform_1.isElementNodeType)(childNode.type)) &&
64
+ if ((!childNode.isAtom || (0, transform_1.isElementNodeType)(childNode.type) || (0, section_title_1.isSpecialSection)(childNode)) &&
65
65
  childNode.attrs.id &&
66
66
  !isExcluded(childNode.type)) {
67
67
  items.push((0, exports.buildTree)({
@@ -37,15 +37,7 @@ const list_1 = require("../../keys/list");
37
37
  const ListStyleSelector_1 = require("./ListStyleSelector");
38
38
  const ManuscriptToolbar_1 = require("./ManuscriptToolbar");
39
39
  const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }) => {
40
- const disabled = (0, react_1.useMemo)(() => enable && !enable(state), [state.selection]);
41
- const dropDownDisabled = (0, react_1.useMemo)(() => {
42
- const { $from, $to } = state.selection;
43
- const range = $from.blockRange($to);
44
- return !!(enable &&
45
- !enable(state) &&
46
- range &&
47
- !transform_1.schema.nodes.ordered_list.compatibleContent($from.node(range.depth - 1).type));
48
- }, [state.selection]);
40
+ const isEnabled = !enable || enable(state);
49
41
  const onClickListType = (0, react_1.useCallback)((type) => {
50
42
  if (!dispatch) {
51
43
  return;
@@ -63,13 +55,13 @@ const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }
63
55
  }
64
56
  }, [dispatch, state, view]);
65
57
  return (react_1.default.createElement(ManuscriptToolbar_1.ToolbarItem, null,
66
- react_1.default.createElement(ListStyleSelector_1.ListButton, { title: title, "data-active": active && active(state), disabled: disabled, onMouseDown: (event) => {
58
+ react_1.default.createElement(ListStyleSelector_1.ListButton, { title: title, "data-active": active && active(state), disabled: !isEnabled, onMouseDown: (event) => {
67
59
  event.preventDefault();
68
60
  run(state, dispatch);
69
61
  view && view.focus();
70
62
  } },
71
63
  react_1.default.createElement(ToolbarIconOrderedList_1.default, null)),
72
- react_1.default.createElement(ListStyleSelector_1.ListStyleSelector, { disabled: dropDownDisabled, onClickListType: onClickListType, list: [
64
+ react_1.default.createElement(ListStyleSelector_1.ListStyleSelector, { disabled: !isEnabled, onClickListType: onClickListType, list: [
73
65
  { items: ['1.', '2.', '3.'], type: 'order' },
74
66
  { items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
75
67
  { items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
@@ -23,7 +23,7 @@ const bibliography_item_editable_1 = __importDefault(require("../views/bibliogra
23
23
  const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
24
24
  const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
25
25
  const citation_editable_1 = __importDefault(require("../views/citation_editable"));
26
- const contributors_section_1 = __importDefault(require("../views/contributors_section"));
26
+ const contributors_1 = __importDefault(require("../views/contributors"));
27
27
  const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
28
28
  const equation_editable_1 = __importDefault(require("../views/equation_editable"));
29
29
  const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
@@ -58,7 +58,7 @@ exports.default = (props, dispatch) => {
58
58
  bullet_list: (0, bullet_list_editable_1.default)(props),
59
59
  citation: (0, citation_editable_1.default)(props),
60
60
  cross_reference: (0, cross_reference_editable_1.default)(props),
61
- contributors_section: (0, contributors_section_1.default)(props, dispatch),
61
+ contributors: (0, contributors_1.default)(props, dispatch),
62
62
  equation: (0, equation_editable_1.default)(props),
63
63
  equation_element: (0, equation_element_editable_1.default)(props),
64
64
  figure: (0, figure_editable_1.default)(props, dispatch),
@@ -21,6 +21,8 @@ const prosemirror_model_1 = require("prosemirror-model");
21
21
  const commands_1 = require("../commands");
22
22
  const popper_1 = require("./popper");
23
23
  const popper = new popper_1.PopperManager();
24
+ const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
25
+ const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
24
26
  const sectionLevel = (depth) => {
25
27
  switch (depth) {
26
28
  case 1:
@@ -159,8 +161,8 @@ class ContextMenu {
159
161
  menu.className = 'menu';
160
162
  const $pos = this.resolvePos();
161
163
  const nodeType = this.node.type;
162
- const { nodes } = this.view.state.schema;
163
- if (this.isListType(nodeType.name)) {
164
+ const nodes = transform_1.schema.nodes;
165
+ if (listTypes.includes(nodeType)) {
164
166
  menu.appendChild(this.createMenuSection((section) => {
165
167
  if (nodeType === nodes.bullet_list) {
166
168
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
@@ -208,8 +210,8 @@ class ContextMenu {
208
210
  }));
209
211
  }));
210
212
  }
211
- if (nodeType !== nodes.bibliography_element &&
212
- $pos.parent.type !== nodes.keywords_section) {
213
+ if (!readonlyTypes.includes(nodeType) &&
214
+ !readonlyTypes.includes($pos.parent.type)) {
213
215
  menu.appendChild(this.createMenuSection((section) => {
214
216
  const nodeName = transform_1.nodeNames.get(nodeType) || '';
215
217
  section.appendChild(this.createMenuItem(`Delete ${nodeName}`, () => {
@@ -317,7 +319,6 @@ class ContextMenu {
317
319
  const { getPos, attr, attrs } = option;
318
320
  this.view.dispatch(this.view.state.tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, attrs), { [attr]: !attrs[attr] })));
319
321
  };
320
- this.isListType = (type) => ['bullet_list', 'ordered_list'].includes(type);
321
322
  this.buildSuppressOptions = () => {
322
323
  const items = [];
323
324
  let attrs = this.node.attrs;
@@ -40,7 +40,6 @@ const icons = new Map([
40
40
  [nodes.equation_element, OutlineIconEquation_1.default],
41
41
  [nodes.figure_element, OutlineIconFigure_1.default],
42
42
  [nodes.multi_graphic_figure_element, OutlineIconFigure_1.default],
43
- [nodes.keywords_section, OutlineIconSection_1.default],
44
43
  [nodes.listing_element, OutlineIconCodeSnippet_1.default],
45
44
  [nodes.ordered_list, OutlineIconOrderedList_1.default],
46
45
  [nodes.paragraph, OutlineIconParagraph_1.default],
@@ -65,7 +65,7 @@ exports.default = (props) => {
65
65
  };
66
66
  const getNodePosition = (node, pos) => {
67
67
  switch (node.type) {
68
- case node.type.schema.nodes.keywords_section:
68
+ case transform_1.schema.nodes.keywords:
69
69
  return pos + 2;
70
70
  default:
71
71
  return pos + 1;
@@ -40,8 +40,7 @@ const preventTitleEdit = (tr) => {
40
40
  const currentDoc = tr.docs[i];
41
41
  step.getMap().forEach((fromA, toA) => {
42
42
  currentDoc.nodesBetween(fromA, toA, (node, nodePos) => {
43
- if ((0, transform_1.isGraphicalAbstractSectionNode)(node) ||
44
- (0, transform_1.isKeywordsSectionNode)(node)) {
43
+ if ((0, transform_1.isGraphicalAbstractSectionNode)(node) || (0, transform_1.isKeywordsNode)(node)) {
45
44
  node.descendants((childNode, childPos) => {
46
45
  const inDocPos = nodePos + childPos;
47
46
  if ((0, transform_1.isSectionTitleNode)(childNode) &&
@@ -37,32 +37,37 @@ const buildTOCList = (headingStyles, list, node, depth = 1, prefix = '') => {
37
37
  ? sectionNumberingStyle.suffix
38
38
  : '.';
39
39
  let index = sectionNumberingStyle ? sectionNumberingStyle.startIndex : 1;
40
- for (const childNode of (0, utils_1.iterateChildren)(node)) {
41
- if ((0, transform_1.isSectionNodeType)(childNode.type) && !(0, transform_1.isTOCSectionNode)(childNode)) {
42
- const numbering = numberingScheme === 'none' ? '' : `${prefix}${index}`;
43
- const firstChildNode = childNode.child(0);
44
- if (firstChildNode.type === firstChildNode.type.schema.nodes.section_title) {
45
- const item = document.createElement('li');
46
- item.classList.add('manuscript-toc-list-item');
47
- item.setAttribute('data-referenced-section', childNode.attrs.id);
48
- item.setAttribute('data-referenced-section-path-length', String(depth));
49
- item.textContent = `${numbering ? `${numbering}${suffix}` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
50
- list.appendChild(item);
51
- }
52
- const childSection = (0, utils_1.getMatchingChild)(childNode, (node) => (0, transform_1.isSectionNodeType)(node.type));
53
- if (childSection) {
54
- const paragraphStyle = headingStyles.get(`heading${depth + 1}`);
55
- if (!paragraphStyle || paragraphStyle.partOfTOC) {
56
- const sublist = document.createElement('ul');
57
- buildTOCList(headingStyles, sublist, childNode, depth + 1, numbering ? `${numbering}.` : '');
58
- const item = document.createElement('li');
59
- item.appendChild(sublist);
60
- list.appendChild(item);
40
+ node.forEach((child) => {
41
+ if (child.type === transform_1.schema.nodes.body) {
42
+ for (const childNode of (0, utils_1.iterateChildren)(child)) {
43
+ if ((0, transform_1.isSectionNodeType)(childNode.type) && !(0, transform_1.isTOCSectionNode)(childNode)) {
44
+ const numbering = numberingScheme === 'none' ? '' : `${prefix}${index}`;
45
+ const firstChildNode = childNode.child(0);
46
+ if (firstChildNode.type ===
47
+ firstChildNode.type.schema.nodes.section_title) {
48
+ const item = document.createElement('li');
49
+ item.classList.add('manuscript-toc-list-item');
50
+ item.setAttribute('data-referenced-section', childNode.attrs.id);
51
+ item.setAttribute('data-referenced-section-path-length', String(depth));
52
+ item.textContent = `${numbering ? `${numbering}${suffix}` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
53
+ list.appendChild(item);
54
+ }
55
+ const childSection = (0, utils_1.getMatchingChild)(childNode, (node) => (0, transform_1.isSectionNodeType)(node.type));
56
+ if (childSection) {
57
+ const paragraphStyle = headingStyles.get(`heading${depth + 1}`);
58
+ if (!paragraphStyle || paragraphStyle.partOfTOC) {
59
+ const sublist = document.createElement('ul');
60
+ buildTOCList(headingStyles, sublist, childNode, depth + 1, numbering ? `${numbering}.` : '');
61
+ const item = document.createElement('li');
62
+ item.appendChild(sublist);
63
+ list.appendChild(item);
64
+ }
65
+ }
66
+ index++;
61
67
  }
62
68
  }
63
- index++;
64
69
  }
65
- }
70
+ });
66
71
  };
67
72
  const isParagraphStyle = (0, transform_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphStyle);
68
73
  const buildHeadingStyles = (modelMap) => {
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ContributorsSectionView = void 0;
6
+ exports.ContributorsView = void 0;
7
7
  const base_node_view_1 = require("./base_node_view");
8
8
  const creators_1 = require("./creators");
9
9
  const ReactSubView_1 = __importDefault(require("./ReactSubView"));
10
- class ContributorsSectionView extends base_node_view_1.BaseNodeView {
10
+ class ContributorsView extends base_node_view_1.BaseNodeView {
11
11
  constructor() {
12
12
  super(...arguments);
13
13
  this.initialise = () => {
@@ -31,5 +31,5 @@ class ContributorsSectionView extends base_node_view_1.BaseNodeView {
31
31
  this.stopEvent = () => true;
32
32
  }
33
33
  }
34
- exports.ContributorsSectionView = ContributorsSectionView;
35
- exports.default = (0, creators_1.createNodeView)(ContributorsSectionView);
34
+ exports.ContributorsView = ContributorsView;
35
+ exports.default = (0, creators_1.createNodeView)(ContributorsView);
@@ -71,8 +71,8 @@ const EditableBlock = (Base) => {
71
71
  this.createAddButton = (after) => {
72
72
  var _a;
73
73
  const $pos = this.view.state.doc.resolve(this.getPos());
74
- if (!((_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle) ||
75
- $pos.parent.type === this.node.type.schema.nodes.keywords_section) {
74
+ const hasAccess = (_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle;
75
+ if (!hasAccess || $pos.parent.type === transform_1.schema.nodes.keywords) {
76
76
  return null;
77
77
  }
78
78
  const button = document.createElement('a');
@@ -19,17 +19,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.SectionTitleView = exports.isSpecialSection = void 0;
22
- const transform_1 = require("@manuscripts/transform");
23
22
  const context_menu_1 = require("../lib/context-menu");
24
23
  const block_view_1 = __importDefault(require("./block_view"));
25
24
  const creators_1 = require("./creators");
26
25
  const isSpecialSection = (node) => {
27
- if ((0, transform_1.isSectionNode)(node)) {
28
- const { attrs } = node;
29
- return (attrs.category === 'MPSectionCategory:abstracts' ||
30
- attrs.category === 'MPSectionCategory:body' ||
31
- attrs.category === 'MPSectionCategory:backmatter');
32
- }
26
+ const type = node.type;
27
+ const nodes = type.schema.nodes;
28
+ return (type === nodes.abstracts || type === nodes.body || type === nodes.backmatter);
33
29
  };
34
30
  exports.isSpecialSection = isSpecialSection;
35
31
  class SectionTitleView extends block_view_1.default {
@@ -41,9 +37,8 @@ class SectionTitleView extends block_view_1.default {
41
37
  if ((0, exports.isSpecialSection)($pos.parent)) {
42
38
  this.dom = document.createElement('div');
43
39
  this.dom.classList.add('no-title');
44
- return;
45
40
  }
46
- if (this.node.childCount) {
41
+ else if (this.node.childCount) {
47
42
  this.contentDOM.classList.remove('empty-node');
48
43
  }
49
44
  else {
@@ -14,11 +14,11 @@
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 { buildCitation, buildComment, buildInlineMathFragment, generateID, isElementNodeType, isInAbstractsSection, 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
23
  import { findParentNodeWithId, getChildOfType, getMatchingDescendant, } from './lib/utils';
24
24
  import { bibliographyKey } from './plugins/bibliography';
@@ -260,6 +260,7 @@ export const insertInlineEquation = (state, dispatch) => {
260
260
  return true;
261
261
  };
262
262
  export const insertInlineFootnote = (kind) => (state, dispatch) => {
263
+ var _a;
263
264
  const footnote = state.schema.nodes.footnote.createAndFill({
264
265
  id: generateID(ObjectTypes.Footnote),
265
266
  kind,
@@ -273,22 +274,24 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
273
274
  const tr = state.tr;
274
275
  tr.insert(insertedAt, inlineFootnote);
275
276
  const footnotesElementAndPos = footnotesUtils.findFootnotesElement(tr.doc);
276
- let selectionPos;
277
+ let selectionPos = undefined;
277
278
  if (footnotesElementAndPos === undefined) {
278
279
  const footnotesSection = state.schema.nodes.footnotes_section.create({}, [
279
280
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
280
281
  state.schema.nodes.footnotes_element.create({}, footnote),
281
282
  ]);
282
- const insideEndPos = tr.doc.content.size;
283
- tr.insert(insideEndPos, footnotesSection);
284
- selectionPos = insideEndPos + footnotesSection.nodeSize;
283
+ const backmatterPosition = (_a = findChildrenByType(tr.doc, schema.nodes.backmatter)[0]) === null || _a === void 0 ? void 0 : _a.pos;
284
+ if (backmatterPosition) {
285
+ tr.insert(backmatterPosition + 1, footnotesSection);
286
+ selectionPos = backmatterPosition + footnotesSection.nodeSize;
287
+ }
285
288
  }
286
289
  else {
287
290
  const [footnotePos, selectPos] = footnotesUtils.getNewFootnoteElementPos(footnotesElementAndPos, thisFootnoteNumbering);
288
291
  tr.insert(footnotePos, footnote);
289
292
  selectionPos = selectPos;
290
293
  }
291
- if (dispatch) {
294
+ if (dispatch && selectionPos) {
292
295
  const selection = TextSelection.create(tr.doc, selectionPos);
293
296
  dispatch(tr.setSelection(selection).scrollIntoView());
294
297
  }
@@ -301,7 +304,7 @@ export const insertGraphicalAbstract = (state, dispatch) => {
301
304
  !isInAbstractsSection(state.selection.$from)) {
302
305
  return false;
303
306
  }
304
- if (!getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
307
+ if (getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
305
308
  return false;
306
309
  }
307
310
  const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
@@ -562,11 +565,17 @@ export const deleteHighlightMarkers = (rid) => (state, dispatch) => {
562
565
  };
563
566
  export function addComment(state, dispatch, viewNode, resolvePos) {
564
567
  const { selection } = state;
565
- const isThereTextSelected = selection.content().size > 0;
566
- const selectionNode = getParentNode(selection);
568
+ const hasText = selection.content().size > 0;
569
+ const parent = getParentNode(selection);
570
+ if (!parent) {
571
+ return false;
572
+ }
567
573
  if (viewNode && resolvePos) {
568
574
  const viewNode = getParentNode(TextSelection.near(resolvePos));
569
- if (isThereTextSelected && selectionNode.attrs.id === viewNode.attrs.id) {
575
+ if (!viewNode) {
576
+ return false;
577
+ }
578
+ if (hasText && parent.attrs.id === viewNode.attrs.id) {
570
579
  return addHighlightComment(viewNode, state, dispatch);
571
580
  }
572
581
  else {
@@ -574,41 +583,34 @@ export function addComment(state, dispatch, viewNode, resolvePos) {
574
583
  }
575
584
  }
576
585
  else {
577
- if (isThereTextSelected) {
578
- return addHighlightComment(selectionNode, state, dispatch);
586
+ if (hasText) {
587
+ return addHighlightComment(parent, state, dispatch);
579
588
  }
580
589
  else {
581
- return addBlockComment(selectionNode, state, dispatch);
590
+ return addBlockComment(parent, state, dispatch);
582
591
  }
583
592
  }
584
593
  }
585
594
  const getParentNode = (selection) => {
586
595
  var _a;
587
596
  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;
597
+ const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
598
+ if ((node === null || node === void 0 ? void 0 : node.type) === schema.nodes.table) {
599
+ return (_a = findParentNodeOfType(schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
592
600
  }
593
601
  return node;
594
602
  };
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;
603
+ const isAllowedType = (type) => type === schema.nodes.section ||
604
+ type === schema.nodes.footnotes_section ||
605
+ type === schema.nodes.bibliography_section ||
606
+ type === schema.nodes.keyword_group ||
607
+ type === schema.nodes.paragraph ||
608
+ type === schema.nodes.figure_element ||
609
+ type === schema.nodes.table_element;
602
610
  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;
611
+ if (node.type === schema.nodes.keywords) {
612
+ const keywordGroups = findChildrenByType(node, schema.nodes.keyword_group, true);
613
+ return keywordGroups.length ? keywordGroups[0].node : node;
612
614
  }
613
615
  return node;
614
616
  };
@@ -627,7 +629,7 @@ const addBlockComment = (node, state, dispatch) => {
627
629
  const addHighlightComment = (node, state, dispatch) => {
628
630
  const { attrs: { id }, type, } = node;
629
631
  const comment = buildComment(id);
630
- if (type === state.schema.nodes.paragraph) {
632
+ if (type === schema.nodes.paragraph) {
631
633
  const { $anchor, $head } = state.selection;
632
634
  const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
633
635
  $anchor.textOffset === $head.textOffset;
@@ -13,9 +13,9 @@ const excludedTypes = [
13
13
  schema.nodes.figure,
14
14
  schema.nodes.footnotes_element,
15
15
  schema.nodes.bibliography_element,
16
- schema.nodes.keywords_section,
17
- schema.nodes.affiliations_section,
18
- schema.nodes.contributors_section,
16
+ schema.nodes.keyword,
17
+ schema.nodes.affiliations,
18
+ schema.nodes.contributors,
19
19
  schema.nodes.title,
20
20
  ];
21
21
  const childrenExcludedTypes = [
@@ -35,7 +35,7 @@ export const buildTree = ({ node, pos, index, selected, parent, }) => {
35
35
  const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
36
36
  if (!isChildrenExcluded(node.type)) {
37
37
  node.forEach((childNode, offset, childIndex) => {
38
- if ((!childNode.isAtom || isElementNodeType(childNode.type)) &&
38
+ if ((!childNode.isAtom || isElementNodeType(childNode.type) || isSpecialSection(childNode)) &&
39
39
  childNode.attrs.id &&
40
40
  !isExcluded(childNode.type)) {
41
41
  items.push(buildTree({
@@ -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' },
@@ -18,7 +18,7 @@ import bibliographyItem from '../views/bibliography_item_editable';
18
18
  import blockquoteElement from '../views/blockquote_element_editable';
19
19
  import bulletList from '../views/bullet_list_editable';
20
20
  import citation from '../views/citation_editable';
21
- import contributorsSection from '../views/contributors_section';
21
+ import contributorsSection from '../views/contributors';
22
22
  import crossReference from '../views/cross_reference_editable';
23
23
  import equation from '../views/equation_editable';
24
24
  import equationElement from '../views/equation_element_editable';
@@ -53,7 +53,7 @@ export default (props, dispatch) => {
53
53
  bullet_list: bulletList(props),
54
54
  citation: citation(props),
55
55
  cross_reference: crossReference(props),
56
- contributors_section: contributorsSection(props, dispatch),
56
+ contributors: contributorsSection(props, dispatch),
57
57
  equation: equation(props),
58
58
  equation_element: equationElement(props),
59
59
  figure: figure(props, dispatch),
@@ -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],
@@ -59,7 +59,7 @@ export default (props) => {
59
59
  };
60
60
  const getNodePosition = (node, pos) => {
61
61
  switch (node.type) {
62
- case node.type.schema.nodes.keywords_section:
62
+ case schema.nodes.keywords:
63
63
  return pos + 2;
64
64
  default:
65
65
  return pos + 1;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { trackChangesPluginKey } from '@manuscripts/track-changes-plugin';
17
- import { isGraphicalAbstractSectionNode, isKeywordsSectionNode, isSectionTitleNode, } from '@manuscripts/transform';
17
+ import { isGraphicalAbstractSectionNode, isKeywordsNode, isSectionTitleNode, } from '@manuscripts/transform';
18
18
  import { Plugin } from 'prosemirror-state';
19
19
  import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
20
20
  import { highlightKey, SET_COMMENT } from './highlight';
@@ -38,8 +38,7 @@ const preventTitleEdit = (tr) => {
38
38
  const currentDoc = tr.docs[i];
39
39
  step.getMap().forEach((fromA, toA) => {
40
40
  currentDoc.nodesBetween(fromA, toA, (node, nodePos) => {
41
- if (isGraphicalAbstractSectionNode(node) ||
42
- isKeywordsSectionNode(node)) {
41
+ if (isGraphicalAbstractSectionNode(node) || isKeywordsNode(node)) {
43
42
  node.descendants((childNode, childPos) => {
44
43
  const inDocPos = nodePos + childPos;
45
44
  if (isSectionTitleNode(childNode) &&
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ObjectTypes, } from '@manuscripts/json-schema';
17
- import { generateID, hasObjectType, isSectionNodeType, isTOCSectionNode, } from '@manuscripts/transform';
17
+ import { generateID, hasObjectType, isSectionNodeType, isTOCSectionNode, schema, } from '@manuscripts/transform';
18
18
  import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
19
19
  import { getMatchingChild, iterateChildren } from '../lib/utils';
20
20
  export const tocKey = new PluginKey('toc');
@@ -34,32 +34,37 @@ const buildTOCList = (headingStyles, list, node, depth = 1, prefix = '') => {
34
34
  ? sectionNumberingStyle.suffix
35
35
  : '.';
36
36
  let index = sectionNumberingStyle ? sectionNumberingStyle.startIndex : 1;
37
- for (const childNode of iterateChildren(node)) {
38
- if (isSectionNodeType(childNode.type) && !isTOCSectionNode(childNode)) {
39
- const numbering = numberingScheme === 'none' ? '' : `${prefix}${index}`;
40
- const firstChildNode = childNode.child(0);
41
- if (firstChildNode.type === firstChildNode.type.schema.nodes.section_title) {
42
- const item = document.createElement('li');
43
- item.classList.add('manuscript-toc-list-item');
44
- item.setAttribute('data-referenced-section', childNode.attrs.id);
45
- item.setAttribute('data-referenced-section-path-length', String(depth));
46
- item.textContent = `${numbering ? `${numbering}${suffix}` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
47
- list.appendChild(item);
48
- }
49
- const childSection = getMatchingChild(childNode, (node) => isSectionNodeType(node.type));
50
- if (childSection) {
51
- const paragraphStyle = headingStyles.get(`heading${depth + 1}`);
52
- if (!paragraphStyle || paragraphStyle.partOfTOC) {
53
- const sublist = document.createElement('ul');
54
- buildTOCList(headingStyles, sublist, childNode, depth + 1, numbering ? `${numbering}.` : '');
55
- const item = document.createElement('li');
56
- item.appendChild(sublist);
57
- list.appendChild(item);
37
+ node.forEach((child) => {
38
+ if (child.type === schema.nodes.body) {
39
+ for (const childNode of iterateChildren(child)) {
40
+ if (isSectionNodeType(childNode.type) && !isTOCSectionNode(childNode)) {
41
+ const numbering = numberingScheme === 'none' ? '' : `${prefix}${index}`;
42
+ const firstChildNode = childNode.child(0);
43
+ if (firstChildNode.type ===
44
+ firstChildNode.type.schema.nodes.section_title) {
45
+ const item = document.createElement('li');
46
+ item.classList.add('manuscript-toc-list-item');
47
+ item.setAttribute('data-referenced-section', childNode.attrs.id);
48
+ item.setAttribute('data-referenced-section-path-length', String(depth));
49
+ item.textContent = `${numbering ? `${numbering}${suffix}` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
50
+ list.appendChild(item);
51
+ }
52
+ const childSection = getMatchingChild(childNode, (node) => isSectionNodeType(node.type));
53
+ if (childSection) {
54
+ const paragraphStyle = headingStyles.get(`heading${depth + 1}`);
55
+ if (!paragraphStyle || paragraphStyle.partOfTOC) {
56
+ const sublist = document.createElement('ul');
57
+ buildTOCList(headingStyles, sublist, childNode, depth + 1, numbering ? `${numbering}.` : '');
58
+ const item = document.createElement('li');
59
+ item.appendChild(sublist);
60
+ list.appendChild(item);
61
+ }
62
+ }
63
+ index++;
58
64
  }
59
65
  }
60
- index++;
61
66
  }
62
- }
67
+ });
63
68
  };
64
69
  const isParagraphStyle = hasObjectType(ObjectTypes.ParagraphStyle);
65
70
  const buildHeadingStyles = (modelMap) => {
@@ -1,7 +1,7 @@
1
1
  import { BaseNodeView } from './base_node_view';
2
2
  import { createNodeView } from './creators';
3
3
  import ReactSubView from './ReactSubView';
4
- export class ContributorsSectionView extends BaseNodeView {
4
+ export class ContributorsView extends BaseNodeView {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.initialise = () => {
@@ -25,4 +25,4 @@ export class ContributorsSectionView extends BaseNodeView {
25
25
  this.stopEvent = () => true;
26
26
  }
27
27
  }
28
- export default createNodeView(ContributorsSectionView);
28
+ export default createNodeView(ContributorsView);
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
24
  };
25
- import { nodeNames } from '@manuscripts/transform';
25
+ import { nodeNames, schema } from '@manuscripts/transform';
26
26
  import { ContextMenu } from '../lib/context-menu';
27
27
  const isNotNull = (a) => a !== null;
28
28
  export const EditableBlock = (Base) => {
@@ -68,8 +68,8 @@ export const EditableBlock = (Base) => {
68
68
  this.createAddButton = (after) => {
69
69
  var _a;
70
70
  const $pos = this.view.state.doc.resolve(this.getPos());
71
- if (!((_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle) ||
72
- $pos.parent.type === this.node.type.schema.nodes.keywords_section) {
71
+ const hasAccess = (_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle;
72
+ if (!hasAccess || $pos.parent.type === schema.nodes.keywords) {
73
73
  return null;
74
74
  }
75
75
  const button = document.createElement('a');
@@ -13,17 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { isSectionNode } from '@manuscripts/transform';
17
16
  import { sectionLevel } from '../lib/context-menu';
18
17
  import BlockView from './block_view';
19
18
  import { createNodeView } from './creators';
20
19
  export const isSpecialSection = (node) => {
21
- if (isSectionNode(node)) {
22
- const { attrs } = node;
23
- return (attrs.category === 'MPSectionCategory:abstracts' ||
24
- attrs.category === 'MPSectionCategory:body' ||
25
- attrs.category === 'MPSectionCategory:backmatter');
26
- }
20
+ const type = node.type;
21
+ const nodes = type.schema.nodes;
22
+ return (type === nodes.abstracts || type === nodes.body || type === nodes.backmatter);
27
23
  };
28
24
  export class SectionTitleView extends BlockView {
29
25
  constructor() {
@@ -34,9 +30,8 @@ export class SectionTitleView extends BlockView {
34
30
  if (isSpecialSection($pos.parent)) {
35
31
  this.dom = document.createElement('div');
36
32
  this.dom.classList.add('no-title');
37
- return;
38
33
  }
39
- if (this.node.childCount) {
34
+ else if (this.node.childCount) {
40
35
  this.contentDOM.classList.remove('empty-node');
41
36
  }
42
37
  else {
@@ -141,7 +141,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
141
141
  } & import("../views/bullet_list").BulletListView<any>>;
142
142
  citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
143
143
  cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
144
- contributors_section: import("../types").NodeViewCreator<import("../views/contributors_section").ContributorsSectionView<any>>;
144
+ contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView<any>>;
145
145
  equation: import("../types").NodeViewCreator<import("../views/equation_editable").EquationEditableView>;
146
146
  equation_element: import("../types").NodeViewCreator<{
147
147
  gutterButtons: () => HTMLElement[];
@@ -39,7 +39,6 @@ export declare class ContextMenu {
39
39
  private resolvePos;
40
40
  private splitSection;
41
41
  private toggleNodeAttr;
42
- private isListType;
43
42
  private buildSuppressOptions;
44
43
  private addPopperEventListeners;
45
44
  private trimTitle;
@@ -2,16 +2,16 @@ import { ManuscriptNodeView } from '@manuscripts/transform';
2
2
  import React from 'react';
3
3
  import { BaseNodeView } from './base_node_view';
4
4
  import { EditableBlockProps } from './editable_block';
5
- export interface ContributorsSectionProps extends EditableBlockProps {
5
+ export interface ContributorsProps extends EditableBlockProps {
6
6
  components: Record<string, React.ComponentType<unknown>>;
7
7
  subscribeStore: unknown;
8
8
  }
9
- export declare class ContributorsSectionView<PropsType extends ContributorsSectionProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
9
+ export declare class ContributorsView<PropsType extends ContributorsProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
10
10
  private metadata;
11
11
  initialise: () => void;
12
12
  protected createDOM: () => void;
13
13
  ignoreMutation: () => boolean;
14
14
  stopEvent: () => boolean;
15
15
  }
16
- declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<ContributorsSectionView<any>>;
16
+ declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<ContributorsView<any>>;
17
17
  export default _default;
@@ -16,7 +16,7 @@
16
16
  import { Node as ProsemirrorNode } from 'prosemirror-model';
17
17
  import { BaseNodeProps } from './base_node_view';
18
18
  import BlockView from './block_view';
19
- export declare const isSpecialSection: (node: ProsemirrorNode) => boolean | undefined;
19
+ export declare const isSpecialSection: (node: ProsemirrorNode) => boolean;
20
20
  export declare class SectionTitleView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
21
21
  contentDOM: HTMLElement;
22
22
  elementType: string;
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.5.13",
4
+ "version": "1.5.14-LEAN-3030",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,11 +29,10 @@
29
29
  "@iarna/word-count": "^1.1.2",
30
30
  "@manuscripts/assets": "^0.6.4",
31
31
  "@manuscripts/json-schema": "2.2.1",
32
- "@manuscripts/library": "1.2.2",
33
- "@manuscripts/style-guide": "1.4.6",
34
- "@manuscripts/title-editor": "^1.1.0",
32
+ "@manuscripts/library": "1.2.2-LEAN-3030-1",
33
+ "@manuscripts/style-guide": "1.4.6-LEAN-3030",
35
34
  "@manuscripts/track-changes-plugin": "^1.7.4",
36
- "@manuscripts/transform": "1.5.6",
35
+ "@manuscripts/transform": "1.5.7-LEAN-3030",
37
36
  "astrocite-eutils": "^0.16.4",
38
37
  "axios": "^1.2.2",
39
38
  "codemirror": "^5.58.1",
@@ -550,14 +550,9 @@ Next levels are shifted 'up' by 1
550
550
  }
551
551
 
552
552
  .keywords h1 {
553
- color: #353535;
554
- font-family: Lato, sans-serif;
555
553
  font-size: 12px;
556
554
  font-style: italic;
557
555
  font-weight: 400;
558
- line-height: 16px;
559
- margin: 0 0 4px;
560
- padding: 0;
561
556
  }
562
557
 
563
558
  .keywords-list {
@@ -577,6 +572,7 @@ Next levels are shifted 'up' by 1
577
572
  border: 1px solid #f2f2f2;
578
573
  border-radius: 6px;
579
574
  position: relative;
575
+ cursor: default;
580
576
  }
581
577
 
582
578
  .keywords-list span.keyword.no-tracking {