@manuscripts/body-editor 1.5.14 → 1.5.15-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 (77) hide show
  1. package/dist/cjs/commands.js +45 -72
  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-plugins.js +2 -2
  5. package/dist/cjs/configs/editor-views.js +4 -6
  6. package/dist/cjs/keys/title.js +4 -0
  7. package/dist/cjs/lib/context-menu.js +6 -5
  8. package/dist/cjs/node-type-icons.js +0 -1
  9. package/dist/cjs/plugins/bibliography/bibliography-utils.js +60 -42
  10. package/dist/cjs/plugins/bibliography/index.js +48 -63
  11. package/dist/cjs/plugins/comment_annotation.js +2 -2
  12. package/dist/cjs/plugins/footnotes/index.js +19 -10
  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 +21 -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 +4 -9
  24. package/dist/es/commands.js +47 -51
  25. package/dist/es/components/outline/DraggableTree.js +4 -4
  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/keys/title.js +4 -0
  30. package/dist/es/lib/context-menu.js +7 -6
  31. package/dist/es/node-type-icons.js +0 -1
  32. package/dist/es/plugins/bibliography/bibliography-utils.js +56 -40
  33. package/dist/es/plugins/bibliography/index.js +49 -65
  34. package/dist/es/plugins/comment_annotation.js +2 -2
  35. package/dist/es/plugins/footnotes/index.js +20 -11
  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 +22 -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 +4 -9
  47. package/dist/types/commands.d.ts +1 -1
  48. package/dist/types/configs/ManuscriptsEditor.d.ts +1 -10
  49. package/dist/types/configs/editor-plugins.d.ts +1 -5
  50. package/dist/types/configs/editor-views.d.ts +5 -6
  51. package/dist/types/lib/context-menu.d.ts +0 -1
  52. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +10 -7
  53. package/dist/types/plugins/bibliography/index.d.ts +21 -3
  54. package/dist/types/views/bibliography_element.d.ts +1 -0
  55. package/dist/types/views/citation.d.ts +3 -4
  56. package/dist/types/views/citation_editable.d.ts +2 -8
  57. package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
  58. package/dist/types/views/cross_reference.d.ts +0 -5
  59. package/dist/types/views/{meta_section.d.ts → empty.d.ts} +2 -2
  60. package/dist/types/views/section_title.d.ts +1 -1
  61. package/package.json +4 -5
  62. package/styles/AdvancedEditor.css +30 -34
  63. package/dist/cjs/plugins/auxiliary_object_order.js +0 -49
  64. package/dist/cjs/plugins/bibliography/types.js +0 -17
  65. package/dist/cjs/plugins/footnotes/footnotes-utils.js +0 -52
  66. package/dist/cjs/views/bibliography_item.js +0 -138
  67. package/dist/cjs/views/bibliography_item_editable.js +0 -20
  68. package/dist/es/plugins/auxiliary_object_order.js +0 -46
  69. package/dist/es/plugins/bibliography/types.js +0 -16
  70. package/dist/es/plugins/footnotes/footnotes-utils.js +0 -46
  71. package/dist/es/views/bibliography_item.js +0 -131
  72. package/dist/es/views/bibliography_item_editable.js +0 -18
  73. package/dist/types/plugins/auxiliary_object_order.d.ts +0 -12
  74. package/dist/types/plugins/bibliography/types.d.ts +0 -40
  75. package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -25
  76. package/dist/types/views/bibliography_item.d.ts +0 -34
  77. package/dist/types/views/bibliography_item_editable.d.ts +0 -18
@@ -14,29 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
17
  Object.defineProperty(exports, "__esModule", { value: true });
41
18
  exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertFootnotesSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
42
19
  const json_schema_1 = require("@manuscripts/json-schema");
@@ -50,7 +27,6 @@ const utils_1 = require("./lib/utils");
50
27
  const bibliography_1 = require("./plugins/bibliography");
51
28
  const comment_annotation_1 = require("./plugins/comment_annotation");
52
29
  const footnotes_1 = require("./plugins/footnotes");
53
- const footnotesUtils = __importStar(require("./plugins/footnotes/footnotes-utils"));
54
30
  const highlight_1 = require("./plugins/highlight");
55
31
  const markActive = (type) => (state) => {
56
32
  const { from, $from, to, empty } = state.selection;
@@ -257,12 +233,11 @@ const insertLink = (state, dispatch) => {
257
233
  return true;
258
234
  };
259
235
  exports.insertLink = insertLink;
260
- const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = []) => {
261
- const citation = (0, transform_1.buildCitation)(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
236
+ const insertInlineCitation = (state, dispatch, view) => {
262
237
  const node = state.schema.nodes.citation.create({
263
- rid: citation._id,
238
+ id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Citation),
239
+ rids: [],
264
240
  selectedText: selectedText(),
265
- embeddedCitationItems: [],
266
241
  });
267
242
  const pos = state.selection.to;
268
243
  const { tr } = state;
@@ -276,7 +251,7 @@ const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = [])
276
251
  exports.insertInlineCitation = insertInlineCitation;
277
252
  const insertCrossReference = (state, dispatch) => {
278
253
  const node = state.schema.nodes.cross_reference.create({
279
- rid: null,
254
+ rids: [],
280
255
  });
281
256
  const pos = state.selection.to;
282
257
  const tr = state.tr.insert(pos, node);
@@ -306,30 +281,29 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
306
281
  kind,
307
282
  });
308
283
  const insertedAt = state.selection.to;
309
- const thisFootnoteNumbering = footnotesUtils.getNewFootnoteNumbering(insertedAt, state);
310
- const inlineFootnote = state.schema.nodes.inline_footnote.create({
311
- rid: footnote.attrs.id,
312
- contents: thisFootnoteNumbering.toString(),
284
+ const node = state.schema.nodes.inline_footnote.create({
285
+ rids: [footnote.attrs.id],
313
286
  });
314
287
  const tr = state.tr;
315
- tr.insert(insertedAt, inlineFootnote);
316
- const footnotesElementAndPos = footnotesUtils.findFootnotesElement(tr.doc);
317
- let selectionPos;
318
- if (footnotesElementAndPos === undefined) {
319
- const footnotesSection = state.schema.nodes.footnotes_section.create({}, [
288
+ tr.insert(insertedAt, node);
289
+ const elements = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_element);
290
+ let selectionPos = undefined;
291
+ if (!elements.length) {
292
+ const section = state.schema.nodes.footnotes_section.create({}, [
320
293
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
321
294
  state.schema.nodes.footnotes_element.create({}, footnote),
322
295
  ]);
323
- const insideEndPos = tr.doc.content.size;
324
- tr.insert(insideEndPos, footnotesSection);
325
- selectionPos = insideEndPos + footnotesSection.nodeSize;
296
+ const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
297
+ tr.insert(backmatter.pos + 1, section);
298
+ selectionPos = backmatter.pos + section.nodeSize;
326
299
  }
327
300
  else {
328
- const [footnotePos, selectPos] = footnotesUtils.getNewFootnoteElementPos(footnotesElementAndPos, thisFootnoteNumbering);
329
- tr.insert(footnotePos, footnote);
330
- selectionPos = selectPos;
301
+ const element = elements[0];
302
+ const pos = element.pos + element.node.nodeSize - 1;
303
+ tr.insert(pos, footnote);
304
+ selectionPos = pos + 2;
331
305
  }
332
- if (dispatch) {
306
+ if (dispatch && selectionPos) {
333
307
  const selection = prosemirror_state_1.TextSelection.create(tr.doc, selectionPos);
334
308
  dispatch(tr.setSelection(selection).scrollIntoView());
335
309
  }
@@ -619,11 +593,17 @@ const deleteHighlightMarkers = (rid) => (state, dispatch) => {
619
593
  exports.deleteHighlightMarkers = deleteHighlightMarkers;
620
594
  function addComment(state, dispatch, viewNode, resolvePos) {
621
595
  const { selection } = state;
622
- const isThereTextSelected = selection.content().size > 0;
623
- const selectionNode = getParentNode(selection);
596
+ const hasText = selection.content().size > 0;
597
+ const parent = getParentNode(selection);
598
+ if (!parent) {
599
+ return false;
600
+ }
624
601
  if (viewNode && resolvePos) {
625
602
  const viewNode = getParentNode(prosemirror_state_1.TextSelection.near(resolvePos));
626
- if (isThereTextSelected && selectionNode.attrs.id === viewNode.attrs.id) {
603
+ if (!viewNode) {
604
+ return false;
605
+ }
606
+ if (hasText && parent.attrs.id === viewNode.attrs.id) {
627
607
  return addHighlightComment(viewNode, state, dispatch);
628
608
  }
629
609
  else {
@@ -631,11 +611,11 @@ function addComment(state, dispatch, viewNode, resolvePos) {
631
611
  }
632
612
  }
633
613
  else {
634
- if (isThereTextSelected) {
635
- return addHighlightComment(selectionNode, state, dispatch);
614
+ if (hasText) {
615
+ return addHighlightComment(parent, state, dispatch);
636
616
  }
637
617
  else {
638
- return addBlockComment(selectionNode, state, dispatch);
618
+ return addBlockComment(parent, state, dispatch);
639
619
  }
640
620
  }
641
621
  }
@@ -643,30 +623,23 @@ exports.addComment = addComment;
643
623
  const getParentNode = (selection) => {
644
624
  var _a;
645
625
  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;
626
+ const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
627
+ if ((node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.table) {
628
+ return (_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
650
629
  }
651
630
  return node;
652
631
  };
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;
632
+ const isAllowedType = (type) => type === transform_1.schema.nodes.section ||
633
+ type === transform_1.schema.nodes.footnotes_section ||
634
+ type === transform_1.schema.nodes.bibliography_section ||
635
+ type === transform_1.schema.nodes.keyword_group ||
636
+ type === transform_1.schema.nodes.paragraph ||
637
+ type === transform_1.schema.nodes.figure_element ||
638
+ type === transform_1.schema.nodes.table_element;
660
639
  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;
640
+ if (node.type === transform_1.schema.nodes.keywords) {
641
+ const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.keyword_group, true);
642
+ return keywordGroups.length ? keywordGroups[0].node : node;
670
643
  }
671
644
  return node;
672
645
  };
@@ -685,7 +658,7 @@ const addBlockComment = (node, state, dispatch) => {
685
658
  const addHighlightComment = (node, state, dispatch) => {
686
659
  const { attrs: { id }, type, } = node;
687
660
  const comment = (0, transform_1.buildComment)(id);
688
- if (type === state.schema.nodes.paragraph) {
661
+ if (type === transform_1.schema.nodes.paragraph) {
689
662
  const { $anchor, $head } = state.selection;
690
663
  const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
691
664
  $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.keywords,
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' },
@@ -24,10 +24,10 @@ const prosemirror_dropcursor_1 = require("prosemirror-dropcursor");
24
24
  const prosemirror_history_1 = require("prosemirror-history");
25
25
  const prosemirror_tables_1 = require("prosemirror-tables");
26
26
  const keys_1 = __importDefault(require("../keys"));
27
- const auxiliary_object_order_1 = __importDefault(require("../plugins/auxiliary_object_order"));
28
27
  const bibliography_1 = __importDefault(require("../plugins/bibliography"));
29
28
  const comment_annotation_1 = __importDefault(require("../plugins/comment_annotation"));
30
29
  const elements_1 = __importDefault(require("../plugins/elements"));
30
+ const footnotes_1 = __importDefault(require("../plugins/footnotes"));
31
31
  const highlight_1 = __importDefault(require("../plugins/highlight"));
32
32
  const keywords_1 = __importDefault(require("../plugins/keywords"));
33
33
  const objects_1 = __importDefault(require("../plugins/objects"));
@@ -56,7 +56,6 @@ exports.default = (props) => {
56
56
  (0, keywords_1.default)(props),
57
57
  (0, bibliography_1.default)(props),
58
58
  (0, objects_1.default)(props),
59
- (0, auxiliary_object_order_1.default)(props),
60
59
  (0, comment_annotation_1.default)(props),
61
60
  (0, paragraphs_1.default)(),
62
61
  (0, placeholder_1.default)(),
@@ -64,6 +63,7 @@ exports.default = (props) => {
64
63
  (0, highlight_1.default)(props),
65
64
  (0, track_changes_ui_1.default)(props),
66
65
  (0, tracking_mark_1.default)(),
66
+ (0, footnotes_1.default)(),
67
67
  ];
68
68
  };
69
69
  document.execCommand('enableObjectResizing', false, 'false');
@@ -19,11 +19,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const bibliography_element_editable_1 = __importDefault(require("../views/bibliography_element_editable"));
22
- const bibliography_item_editable_1 = __importDefault(require("../views/bibliography_item_editable"));
23
22
  const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
24
23
  const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
25
24
  const citation_editable_1 = __importDefault(require("../views/citation_editable"));
26
- const contributors_section_1 = __importDefault(require("../views/contributors_section"));
25
+ const contributors_1 = __importDefault(require("../views/contributors"));
27
26
  const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
28
27
  const equation_editable_1 = __importDefault(require("../views/equation_editable"));
29
28
  const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
@@ -38,7 +37,6 @@ const keywords_element_1 = __importDefault(require("../views/keywords_element"))
38
37
  const link_editable_1 = __importDefault(require("../views/link_editable"));
39
38
  const listing_editable_1 = __importDefault(require("../views/listing_editable"));
40
39
  const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
41
- const meta_section_1 = __importDefault(require("../views/meta_section"));
42
40
  const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
43
41
  const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
44
42
  const placeholder_1 = __importDefault(require("../views/placeholder"));
@@ -49,16 +47,16 @@ const section_title_editable_1 = __importDefault(require("../views/section_title
49
47
  const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
50
48
  const title_editable_1 = __importDefault(require("../views/title_editable"));
51
49
  const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
50
+ const empty_1 = __importDefault(require("../views/empty"));
52
51
  exports.default = (props, dispatch) => {
53
52
  return {
54
53
  title: (0, title_editable_1.default)(props, dispatch),
55
- bibliography_item: (0, bibliography_item_editable_1.default)(props),
56
54
  bibliography_element: (0, bibliography_element_editable_1.default)(props),
57
55
  blockquote_element: (0, blockquote_element_editable_1.default)(props),
58
56
  bullet_list: (0, bullet_list_editable_1.default)(props),
59
57
  citation: (0, citation_editable_1.default)(props),
60
58
  cross_reference: (0, cross_reference_editable_1.default)(props),
61
- contributors_section: (0, contributors_section_1.default)(props, dispatch),
59
+ contributors: (0, contributors_1.default)(props, dispatch),
62
60
  equation: (0, equation_editable_1.default)(props),
63
61
  equation_element: (0, equation_element_editable_1.default)(props),
64
62
  figure: (0, figure_editable_1.default)(props, dispatch),
@@ -81,6 +79,6 @@ exports.default = (props, dispatch) => {
81
79
  section_label: (0, section_label_1.default)(props),
82
80
  table_element: (0, table_element_editable_1.default)(props),
83
81
  toc_element: (0, toc_element_editable_1.default)(props),
84
- meta_section: meta_section_1.default,
82
+ comments: (0, empty_1.default)('comments'),
85
83
  };
86
84
  };
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const transform_1 = require("@manuscripts/transform");
18
19
  const prosemirror_commands_1 = require("prosemirror-commands");
19
20
  const prosemirror_model_1 = require("prosemirror-model");
20
21
  const prosemirror_state_1 = require("prosemirror-state");
@@ -80,6 +81,9 @@ const leaveSectionTitle = (state, dispatch, view) => {
80
81
  if ($cursor.parent.type !== $cursor.parent.type.schema.nodes.section_title) {
81
82
  return false;
82
83
  }
84
+ if ((0, transform_1.isInGraphicalAbstractSection)($cursor)) {
85
+ return false;
86
+ }
83
87
  if (!(0, commands_1.isAtEndOfTextBlock)(state, $cursor, view)) {
84
88
  return false;
85
89
  }
@@ -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],
@@ -26,21 +26,23 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  return t;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getReferencesModelMap = exports.getNodeModel = exports.buildDecorations = exports.isBibliographyElement = void 0;
29
+ exports.buildCitations = exports.getBibliographyItemModelMap = exports.getBibliographyItem = exports.getCitation = exports.buildDecorations = exports.isBibliographyElement = void 0;
30
30
  const json_schema_1 = require("@manuscripts/json-schema");
31
31
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
32
32
  const transform_1 = require("@manuscripts/transform");
33
- const lodash_es_1 = require("lodash-es");
33
+ const lodash_1 = require("lodash");
34
34
  const prosemirror_view_1 = require("prosemirror-view");
35
35
  const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
36
36
  exports.isBibliographyElement = isBibliographyElement;
37
- const buildDecorations = (doc, citationNodes, popper, referencesModelMap, triggerUpdate) => {
37
+ let count = 0;
38
+ const buildDecorations = (state, doc) => {
38
39
  const decorations = [];
39
40
  let hasMissingItems = false;
40
- for (const [node, pos, citation] of citationNodes) {
41
- if (citation.embeddedCitationItems.length) {
42
- for (const citationItem of citation.embeddedCitationItems) {
43
- if (!referencesModelMap.get(citationItem.bibliographyItem)) {
41
+ for (const [node, pos] of state.citationNodes) {
42
+ const rids = node.attrs.rids;
43
+ if (rids.length) {
44
+ for (const rid of rids) {
45
+ if (!state.bibliographyItems.has(rid)) {
44
46
  decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
45
47
  class: 'citation-missing',
46
48
  }));
@@ -72,41 +74,49 @@ const buildDecorations = (doc, citationNodes, popper, referencesModelMap, trigge
72
74
  }
73
75
  });
74
76
  }
75
- if (triggerUpdate) {
76
- doc.descendants((node, pos) => {
77
- if ((0, exports.isBibliographyElement)(node)) {
78
- decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
79
- triggerUpdate: true,
80
- }));
81
- }
82
- });
83
- }
77
+ doc.descendants((node, pos) => {
78
+ if ((0, exports.isBibliographyElement)(node)) {
79
+ decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
80
+ refresh: count++,
81
+ }));
82
+ }
83
+ });
84
84
  return decorations;
85
85
  };
86
86
  exports.buildDecorations = buildDecorations;
87
- const cleanData = (model) => (0, lodash_es_1.pickBy)(model, (value) => value !== undefined);
88
- const getNodeModel = (node, excludeDeletedNode) => {
89
- const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
90
- const mapNodeToModel = (attrs, nodeType) => {
91
- if (nodeType === transform_1.schema.nodes.bibliography_item) {
92
- const { id, containerTitle, doi } = attrs, rest = __rest(attrs, ["id", "containerTitle", "doi"]);
93
- return cleanData(Object.assign(Object.assign({ _id: id, 'container-title': containerTitle, DOI: doi }, rest), { objectType: json_schema_1.ObjectTypes.BibliographyItem }));
94
- }
95
- const { rid, embeddedCitationItems } = attrs;
96
- return {
97
- _id: rid,
98
- embeddedCitationItems: (embeddedCitationItems === null || embeddedCitationItems === void 0 ? void 0 : embeddedCitationItems.map((item) => ({
99
- _id: item.id,
100
- bibliographyItem: item.bibliographyItem,
101
- objectType: json_schema_1.ObjectTypes.CitationItem,
102
- }))) || [],
103
- objectType: json_schema_1.ObjectTypes.Citation,
104
- };
87
+ const getCitation = (node) => {
88
+ const attrs = getEffectiveAttrs(node);
89
+ if (!attrs) {
90
+ return undefined;
91
+ }
92
+ const rids = attrs.rids;
93
+ const items = rids.map((i) => ({
94
+ _id: '_',
95
+ objectType: json_schema_1.ObjectTypes.CitationItem,
96
+ bibliographyItem: i,
97
+ }));
98
+ return {
99
+ _id: attrs.id,
100
+ objectType: json_schema_1.ObjectTypes.Citation,
101
+ embeddedCitationItems: items,
105
102
  };
103
+ };
104
+ exports.getCitation = getCitation;
105
+ const getBibliographyItem = (node) => {
106
+ const attrs = getEffectiveAttrs(node);
107
+ if (!attrs) {
108
+ return undefined;
109
+ }
110
+ const { id, containerTitle, doi } = attrs, rest = __rest(attrs, ["id", "containerTitle", "doi"]);
111
+ const item = Object.assign({ _id: id, objectType: json_schema_1.ObjectTypes.BibliographyItem, 'container-title': containerTitle, DOI: doi }, rest);
112
+ return (0, lodash_1.pickBy)(item, (v) => v !== undefined);
113
+ };
114
+ exports.getBibliographyItem = getBibliographyItem;
115
+ const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
116
+ const getEffectiveAttrs = (node) => {
106
117
  const _a = node.attrs, { dataTracked } = _a, attrs = __rest(_a, ["dataTracked"]);
107
118
  const nodeChange = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.reduce(getLatest);
108
119
  if (nodeChange &&
109
- excludeDeletedNode &&
110
120
  nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.delete &&
111
121
  nodeChange.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
112
122
  return undefined;
@@ -114,15 +124,13 @@ const getNodeModel = (node, excludeDeletedNode) => {
114
124
  const isRejected = nodeChange &&
115
125
  nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes &&
116
126
  nodeChange.status === track_changes_plugin_1.CHANGE_STATUS.rejected;
117
- return mapNodeToModel(isRejected ? nodeChange === null || nodeChange === void 0 ? void 0 : nodeChange.oldAttrs : attrs, node.type);
127
+ return isRejected ? nodeChange === null || nodeChange === void 0 ? void 0 : nodeChange.oldAttrs : attrs;
118
128
  };
119
- exports.getNodeModel = getNodeModel;
120
- const getReferencesModelMap = (doc, excludeDeletedNode) => {
129
+ const getBibliographyItemModelMap = (doc) => {
121
130
  const modelMap = new Map();
122
131
  doc.descendants((node) => {
123
- if (node.type === transform_1.schema.nodes.bibliography_item ||
124
- node.type === transform_1.schema.nodes.citation) {
125
- const model = (0, exports.getNodeModel)(node, excludeDeletedNode);
132
+ if (node.type === transform_1.schema.nodes.bibliography_item) {
133
+ const model = (0, exports.getBibliographyItem)(node);
126
134
  if (model) {
127
135
  modelMap.set(model._id, model);
128
136
  }
@@ -130,4 +138,14 @@ const getReferencesModelMap = (doc, excludeDeletedNode) => {
130
138
  });
131
139
  return modelMap;
132
140
  };
133
- exports.getReferencesModelMap = getReferencesModelMap;
141
+ exports.getBibliographyItemModelMap = getBibliographyItemModelMap;
142
+ const buildCitations = (citations) => citations.map((citation) => ({
143
+ citationID: citation[0].attrs.id,
144
+ citationItems: citation[0].attrs.rids.map((rid) => ({
145
+ id: rid,
146
+ })),
147
+ properties: {
148
+ noteIndex: 0,
149
+ },
150
+ }));
151
+ exports.buildCitations = buildCitations;