@manuscripts/body-editor 1.5.7 → 1.5.8-LEAN-2852

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 (56) hide show
  1. package/dist/cjs/commands.js +2 -8
  2. package/dist/cjs/components/outline/DraggableTree.js +31 -30
  3. package/dist/cjs/components/outline/ManuscriptOutline.js +2 -13
  4. package/dist/cjs/components/outline/OutlineManuscript.js +2 -9
  5. package/dist/cjs/configs/editor-views.js +4 -0
  6. package/dist/cjs/lib/utils.js +3 -3
  7. package/dist/cjs/node-type-icons.js +1 -4
  8. package/dist/cjs/views/bibliography_element.js +2 -0
  9. package/dist/cjs/views/block_view.js +4 -0
  10. package/dist/cjs/views/citation_editable.js +22 -4
  11. package/dist/cjs/views/contributors_section.js +36 -0
  12. package/dist/cjs/views/footnotes_element.js +9 -0
  13. package/dist/cjs/views/title.js +37 -0
  14. package/dist/cjs/views/title_editable.js +20 -0
  15. package/dist/es/commands.js +2 -8
  16. package/dist/es/components/outline/DraggableTree.js +32 -31
  17. package/dist/es/components/outline/ManuscriptOutline.js +2 -13
  18. package/dist/es/components/outline/OutlineManuscript.js +4 -11
  19. package/dist/es/configs/editor-views.js +4 -0
  20. package/dist/es/lib/utils.js +3 -3
  21. package/dist/es/node-type-icons.js +1 -4
  22. package/dist/es/views/bibliography_element.js +2 -0
  23. package/dist/es/views/block_view.js +4 -0
  24. package/dist/es/views/citation_editable.js +22 -4
  25. package/dist/es/views/contributors_section.js +29 -0
  26. package/dist/es/views/footnotes_element.js +9 -0
  27. package/dist/es/views/title.js +33 -0
  28. package/dist/es/views/title_editable.js +18 -0
  29. package/dist/types/components/outline/DraggableTree.d.ts +0 -1
  30. package/dist/types/components/outline/OutlineManuscript.d.ts +2 -0
  31. package/dist/types/configs/editor-views.d.ts +16 -0
  32. package/dist/types/lib/utils.d.ts +2 -2
  33. package/dist/types/views/bibliography_element_editable.d.ts +1 -0
  34. package/dist/types/views/block_view.d.ts +1 -0
  35. package/dist/types/views/blockquote_element_editable.d.ts +1 -0
  36. package/dist/types/views/bullet_list_editable.d.ts +1 -0
  37. package/dist/types/views/contributors_section.d.ts +17 -0
  38. package/dist/types/views/editable_block.d.ts +1 -0
  39. package/dist/types/views/equation_element_editable.d.ts +1 -0
  40. package/dist/types/views/figure_element_editable.d.ts +1 -0
  41. package/dist/types/views/footnote_editable.d.ts +1 -0
  42. package/dist/types/views/footnotes_element.d.ts +2 -0
  43. package/dist/types/views/footnotes_element_editable.d.ts +1 -0
  44. package/dist/types/views/listing_element_editable.d.ts +1 -0
  45. package/dist/types/views/ordered_list_editable.d.ts +1 -0
  46. package/dist/types/views/paragraph_editable.d.ts +1 -0
  47. package/dist/types/views/placeholder_element_editable.d.ts +1 -0
  48. package/dist/types/views/pullquote_element_editable.d.ts +1 -0
  49. package/dist/types/views/section_title_editable.d.ts +1 -0
  50. package/dist/types/views/table_element_editable.d.ts +1 -0
  51. package/dist/types/views/title.d.ts +24 -0
  52. package/dist/types/views/title_editable.d.ts +18 -0
  53. package/dist/types/views/toc_element_editable.d.ts +1 -0
  54. package/package.json +5 -5
  55. package/styles/AdvancedEditor.css +24 -0
  56. package/styles/Editor.css +8 -0
@@ -257,9 +257,6 @@ const insertLink = (state, dispatch) => {
257
257
  return true;
258
258
  };
259
259
  exports.insertLink = insertLink;
260
- const needsBibliography = (state) => !bibliography_1.bibliographyKey.getState(state).citations.length &&
261
- !(0, utils_1.getChildOfType)(state.tr.doc, state.schema.nodes.bibliography_section);
262
- const createBibliographySection = (state) => state.schema.nodes.bibliography_section.createAndFill({}, state.schema.nodes.section_title.create({}, state.schema.text('Bibliography')));
263
260
  const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = []) => {
264
261
  const citation = (0, transform_1.buildCitation)(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
265
262
  const node = state.schema.nodes.citation.create({
@@ -270,9 +267,6 @@ const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = [])
270
267
  const pos = state.selection.to;
271
268
  const { tr } = state;
272
269
  tr.insert(pos, node);
273
- if (needsBibliography(state)) {
274
- tr.insert(tr.doc.content.size, createBibliographySection(state)).setMeta(bibliography_1.bibliographyKey, { bibliographyInserted: true });
275
- }
276
270
  if (dispatch) {
277
271
  const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
278
272
  dispatch(tr.setSelection(selection).scrollIntoView());
@@ -349,7 +343,7 @@ const insertGraphicalAbstract = (state, dispatch) => {
349
343
  !(0, transform_1.isInAbstractsSection)(state.selection.$from)) {
350
344
  return false;
351
345
  }
352
- if ((0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
346
+ if (!!(0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
353
347
  return false;
354
348
  }
355
349
  const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
@@ -399,7 +393,7 @@ const insertFootnotesSection = (state, dispatch) => {
399
393
  };
400
394
  exports.insertFootnotesSection = insertFootnotesSection;
401
395
  const insertBibliographySection = (state, dispatch) => {
402
- if ((0, utils_1.getChildOfType)(state.doc, state.schema.nodes.bibliography_section)) {
396
+ if ((0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.bibliography_section)) {
403
397
  return false;
404
398
  }
405
399
  const section = state.schema.nodes.bibliography_section.createAndFill({}, [
@@ -34,23 +34,25 @@ const track_changes_utils_1 = require("../../lib/track-changes-utils");
34
34
  const node_type_icons_1 = require("../../node-type-icons");
35
35
  const section_title_1 = require("../../views/section_title");
36
36
  const Outline_1 = require("./Outline");
37
+ const excludedTypes = [
38
+ transform_1.schema.nodes.table,
39
+ transform_1.schema.nodes.figure,
40
+ transform_1.schema.nodes.footnotes_element,
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,
45
+ transform_1.schema.nodes.title,
46
+ ];
47
+ const childrenExcludedTypes = [
48
+ transform_1.schema.nodes.pullquote_element,
49
+ transform_1.schema.nodes.blockquote_element,
50
+ ];
37
51
  const isExcluded = (nodeType) => {
38
- const { nodes } = nodeType.schema;
39
- const excludedTypes = [
40
- nodes.table,
41
- nodes.figure,
42
- nodes.footnotes_element,
43
- nodes.bibliography_element,
44
- nodes.keywords_section,
45
- nodes.affiliations_section,
46
- nodes.contributors_section,
47
- ];
48
52
  return excludedTypes.includes(nodeType);
49
53
  };
50
54
  const isChildrenExcluded = (nodeType) => {
51
- const { nodes } = nodeType.schema;
52
- const excludedTypes = [nodes.pullquote_element, nodes.blockquote_element];
53
- return excludedTypes.includes(nodeType);
55
+ return childrenExcludedTypes.includes(nodeType);
54
56
  };
55
57
  const buildTree = ({ node, pos, index, selected, parent, }) => {
56
58
  const items = [];
@@ -136,23 +138,22 @@ class Tree extends React.Component {
136
138
  if (isRejectedItem || node.attrs.id === 'META_SECTION') {
137
139
  return null;
138
140
  }
139
- return connectDropTarget(React.createElement("div", null,
140
- React.createElement(Outline_1.Outline, { style: this.outlineStyles(isDragging) },
141
- React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
142
- !(0, section_title_1.isSpecialSection)(node) && (React.createElement(React.Fragment, null, connectDragSource(React.createElement("div", null,
143
- React.createElement(Outline_1.OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
144
- items.length ? (React.createElement(Outline_1.OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(Outline_1.StyledTriangleExpanded, null)) : (React.createElement(Outline_1.StyledTriangleCollapsed, null)))) : (React.createElement(Outline_1.OutlineItemNoArrow, null)),
145
- React.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id || ''}` },
146
- connectDragPreview(React.createElement("span", { style: {
147
- display: 'inline-flex',
148
- alignItems: 'center',
149
- } },
150
- React.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)))),
151
- React.createElement(Outline_1.OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))))),
152
- items.length ? (React.createElement("div", { style: {
153
- display: open || (0, section_title_1.isSpecialSection)(node) ? '' : 'none',
154
- } }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: (0, section_title_1.isSpecialSection)(node) ? depth : depth + 1 })))))) : null,
155
- React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
141
+ return connectDropTarget(React.createElement("div", null, node.type.name !== 'titles' && (React.createElement(Outline_1.Outline, { style: this.outlineStyles(isDragging) },
142
+ React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
143
+ !(0, section_title_1.isSpecialSection)(node) && (React.createElement(React.Fragment, null, connectDragSource(React.createElement("div", null,
144
+ React.createElement(Outline_1.OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
145
+ items.length ? (React.createElement(Outline_1.OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(Outline_1.StyledTriangleExpanded, null)) : (React.createElement(Outline_1.StyledTriangleCollapsed, null)))) : (React.createElement(Outline_1.OutlineItemNoArrow, null)),
146
+ React.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id || ''}` },
147
+ connectDragPreview(React.createElement("span", { style: {
148
+ display: 'inline-flex',
149
+ alignItems: 'center',
150
+ } },
151
+ React.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)))),
152
+ React.createElement(Outline_1.OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))))),
153
+ items.length ? (React.createElement("div", { style: {
154
+ display: open || (0, section_title_1.isSpecialSection)(node) ? '' : 'none',
155
+ } }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: (0, section_title_1.isSpecialSection)(node) ? depth : depth + 1 })))))) : null,
156
+ React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) })))));
156
157
  }
157
158
  }
158
159
  const dragSource = (0, react_dnd_1.DragSource)('outline', {
@@ -39,7 +39,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
39
39
  };
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.ManuscriptOutline = void 0;
42
- const title_editor_1 = require("@manuscripts/title-editor");
43
42
  const react_1 = __importStar(require("react"));
44
43
  const use_debounce_1 = require("../hooks/use-debounce");
45
44
  const DraggableTree_1 = __importStar(require("./DraggableTree"));
@@ -49,24 +48,14 @@ const ManuscriptOutline = (props) => {
49
48
  const debouncedProps = (0, use_debounce_1.useDebounce)(props, 500);
50
49
  (0, react_1.useEffect)(() => {
51
50
  var _a;
52
- const { doc, view, manuscript, selected } = debouncedProps;
51
+ const { doc, view, selected } = debouncedProps;
53
52
  if (doc) {
54
- const { items } = (0, DraggableTree_1.buildTree)({
53
+ const tree = (0, DraggableTree_1.buildTree)({
55
54
  node: doc,
56
55
  pos: 0,
57
56
  index: 0,
58
57
  selected,
59
58
  });
60
- const node = (0, title_editor_1.parse)(manuscript.title || '');
61
- const tree = {
62
- node,
63
- requirementsNode: doc,
64
- pos: 0,
65
- endPos: 0,
66
- index: 0,
67
- isSelected: !selected,
68
- items,
69
- };
70
59
  setValues({ tree, view, editArticle: !!((_a = props.capabilities) === null || _a === void 0 ? void 0 : _a.editArticle) });
71
60
  }
72
61
  else {
@@ -20,22 +20,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.OutlineManuscript = void 0;
22
22
  const OutlineIconManuscript_1 = __importDefault(require("@manuscripts/assets/react/OutlineIconManuscript"));
23
- const title_editor_1 = require("@manuscripts/title-editor");
24
23
  const transform_1 = require("@manuscripts/transform");
25
24
  const react_1 = __importDefault(require("react"));
26
25
  const Outline_1 = require("./Outline");
27
- const titleText = (value) => {
28
- const node = (0, title_editor_1.parse)(value, {
29
- topNode: title_editor_1.schema.nodes.title.create(),
30
- });
31
- return node.textContent;
32
- };
33
- const OutlineManuscript = ({ project, manuscript, }) => (react_1.default.createElement(Outline_1.Outline, null,
26
+ const OutlineManuscript = ({ project, manuscript, doc, }) => (react_1.default.createElement(Outline_1.Outline, null,
34
27
  react_1.default.createElement(Outline_1.OutlineItem, { isSelected: false, depth: 0 },
35
28
  react_1.default.createElement(Outline_1.OutlineItemLink, { to: `/projects/${project._id}/manuscripts/${manuscript._id}` },
36
29
  react_1.default.createElement(Outline_1.OutlineItemArrow, null,
37
30
  react_1.default.createElement(Outline_1.StyledTriangleCollapsed, null)),
38
31
  react_1.default.createElement(Outline_1.OutlineItemIcon, null,
39
32
  react_1.default.createElement(OutlineIconManuscript_1.default, null)),
40
- react_1.default.createElement(Outline_1.OutlineItemLinkText, { className: 'outline-text-title' }, manuscript.title ? (titleText(manuscript.title)) : (react_1.default.createElement(Outline_1.OutlineItemPlaceholder, null, (0, transform_1.nodeTitlePlaceholder)(title_editor_1.schema.nodes.title))))))));
33
+ react_1.default.createElement(Outline_1.OutlineItemLinkText, { className: 'outline-text-title' }, (0, transform_1.nodeTitle)(doc))))));
41
34
  exports.OutlineManuscript = OutlineManuscript;
@@ -23,6 +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
27
  const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
27
28
  const equation_editable_1 = __importDefault(require("../views/equation_editable"));
28
29
  const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
@@ -46,15 +47,18 @@ const pullquote_element_editable_1 = __importDefault(require("../views/pullquote
46
47
  const section_label_1 = __importDefault(require("../views/section_label"));
47
48
  const section_title_editable_1 = __importDefault(require("../views/section_title_editable"));
48
49
  const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
50
+ const title_editable_1 = __importDefault(require("../views/title_editable"));
49
51
  const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
50
52
  exports.default = (props, dispatch) => {
51
53
  return {
54
+ title: (0, title_editable_1.default)(props, dispatch),
52
55
  bibliography_item: (0, bibliography_item_editable_1.default)(props),
53
56
  bibliography_element: (0, bibliography_element_editable_1.default)(props),
54
57
  blockquote_element: (0, blockquote_element_editable_1.default)(props),
55
58
  bullet_list: (0, bullet_list_editable_1.default)(props),
56
59
  citation: (0, citation_editable_1.default)(props),
57
60
  cross_reference: (0, cross_reference_editable_1.default)(props),
61
+ contributors_section: (0, contributors_section_1.default)(props, dispatch),
58
62
  equation: (0, equation_editable_1.default)(props),
59
63
  equation_element: (0, equation_element_editable_1.default)(props),
60
64
  figure: (0, figure_editable_1.default)(props, dispatch),
@@ -30,8 +30,8 @@ function* iterateChildren(node, recurse = false) {
30
30
  }
31
31
  }
32
32
  exports.iterateChildren = iterateChildren;
33
- const getMatchingChild = (parent, matcher) => {
34
- for (const node of iterateChildren(parent)) {
33
+ const getMatchingChild = (parent, matcher, deep = false) => {
34
+ for (const node of iterateChildren(parent, deep)) {
35
35
  if (matcher(node)) {
36
36
  return node;
37
37
  }
@@ -46,7 +46,7 @@ const getMatchingDescendant = (parent, matcher) => {
46
46
  }
47
47
  };
48
48
  exports.getMatchingDescendant = getMatchingDescendant;
49
- const getChildOfType = (parent, nodeType) => !!(0, exports.getMatchingChild)(parent, (node) => node.type === nodeType);
49
+ const getChildOfType = (parent, nodeType, deep = false) => !!(0, exports.getMatchingChild)(parent, (node) => node.type.name === nodeType.name, deep);
50
50
  exports.getChildOfType = getChildOfType;
51
51
  exports.findParentNodeWithId = (0, prosemirror_utils_1.findParentNode)((node) => 'id' in node.attrs);
52
52
  exports.findParentNodeWithIdValue = (0, prosemirror_utils_1.findParentNode)((node) => node.attrs.id);
@@ -29,11 +29,11 @@ const OutlineIconSection_1 = __importDefault(require("@manuscripts/assets/react/
29
29
  const OutlineIconTable_1 = __importDefault(require("@manuscripts/assets/react/OutlineIconTable"));
30
30
  const OutlineIconUnorderedList_1 = __importDefault(require("@manuscripts/assets/react/OutlineIconUnorderedList"));
31
31
  const style_guide_1 = require("@manuscripts/style-guide");
32
- const title_editor_1 = require("@manuscripts/title-editor");
33
32
  const transform_1 = require("@manuscripts/transform");
34
33
  const react_1 = __importDefault(require("react"));
35
34
  const { nodes } = transform_1.schema;
36
35
  const icons = new Map([
36
+ [nodes.manuscript, OutlineIconManuscript_1.default],
37
37
  [nodes.bibliography_section, OutlineIconSection_1.default],
38
38
  [nodes.blockquote_element, style_guide_1.BlockQuoteIcon],
39
39
  [nodes.bullet_list, OutlineIconUnorderedList_1.default],
@@ -52,9 +52,6 @@ const icons = new Map([
52
52
  [nodes.footnotes_section, OutlineIconSection_1.default],
53
53
  ]);
54
54
  const nodeTypeIcon = (nodeType) => {
55
- if (nodeType === title_editor_1.schema.nodes.title) {
56
- return react_1.default.createElement(OutlineIconManuscript_1.default, null);
57
- }
58
55
  const Icon = icons.get(nodeType);
59
56
  return Icon ? react_1.default.createElement(Icon, null) : null;
60
57
  };
@@ -30,6 +30,8 @@ class BibliographyElementBlockView extends block_view_1.default {
30
30
  this.contentDOM = document.createElement('div');
31
31
  this.contentDOM.classList.add('block');
32
32
  this.contentDOM.setAttribute('id', this.node.attrs.id);
33
+ this.contentDOM.setAttribute('contenteditable', 'false');
34
+ this.dom.setAttribute('contenteditable', 'false');
33
35
  this.dom.appendChild(this.contentDOM);
34
36
  };
35
37
  }
@@ -34,6 +34,7 @@ class BlockView extends base_node_view_1.BaseNodeView {
34
34
  this.updateContents = () => {
35
35
  this.updateClasses();
36
36
  this.updateAttributes();
37
+ this.onUpdateContent();
37
38
  };
38
39
  this.updateClasses = () => {
39
40
  if (!this.contentDOM) {
@@ -89,5 +90,8 @@ class BlockView extends base_node_view_1.BaseNodeView {
89
90
  this.gutterButtons = () => [];
90
91
  this.actionGutterButtons = () => [];
91
92
  }
93
+ onUpdateContent() {
94
+ return;
95
+ }
92
96
  }
93
97
  exports.default = BlockView;
@@ -48,6 +48,10 @@ const bibliography_1 = require("../plugins/bibliography");
48
48
  const bibliography_utils_1 = require("../plugins/bibliography/bibliography-utils");
49
49
  const citation_1 = require("./citation");
50
50
  const creators_1 = require("./creators");
51
+ const createBibliographySection = (bibItem) => transform_1.schema.nodes.bibliography_section.createAndFill({}, [
52
+ transform_1.schema.nodes.section_title.create({}, transform_1.schema.text('Bibliography')),
53
+ transform_1.schema.nodes.bibliography_element.create({}, bibItem ? [bibItem] : []),
54
+ ]);
51
55
  class CitationEditableView extends citation_1.CitationView {
52
56
  constructor() {
53
57
  super(...arguments);
@@ -185,13 +189,27 @@ class CitationEditableView extends citation_1.CitationView {
185
189
  insertBibliographyNode(view, item) {
186
190
  const { doc, tr } = view.state;
187
191
  const { DOI: doi, ['container-title']: containerTitle } = item, restAttr = __rest(item, ["DOI", 'container-title']);
188
- doc.descendants((node, pos) => {
192
+ let bibElement = null;
193
+ let pos = null;
194
+ doc.descendants((node, nodePos) => {
189
195
  if (node.type === transform_1.schema.nodes.bibliography_element) {
190
- view.dispatch(tr.insert(pos + 1, transform_1.schema.nodes.bibliography_item.create(Object.assign({ id: item._id, doi,
191
- containerTitle }, restAttr))));
192
- return false;
196
+ bibElement = node;
197
+ pos = nodePos;
193
198
  }
194
199
  });
200
+ let newTr;
201
+ const bibItem = transform_1.schema.nodes.bibliography_item.create(Object.assign({ id: item._id, doi,
202
+ containerTitle }, restAttr));
203
+ if (bibElement && pos) {
204
+ newTr = tr.insert(pos + 1, bibItem);
205
+ }
206
+ else {
207
+ newTr = tr
208
+ .insert(tr.doc.content.size, createBibliographySection(bibItem))
209
+ .setMeta(bibliography_1.bibliographyKey, { bibliographyInserted: true });
210
+ }
211
+ view.dispatch(newTr);
212
+ return false;
195
213
  }
196
214
  }
197
215
  exports.CitationEditableView = CitationEditableView;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ContributorsSectionView = void 0;
7
+ const base_node_view_1 = require("./base_node_view");
8
+ const creators_1 = require("./creators");
9
+ const ReactSubView_1 = __importDefault(require("./ReactSubView"));
10
+ class ContributorsSectionView extends base_node_view_1.BaseNodeView {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.initialise = () => {
14
+ this.createDOM();
15
+ };
16
+ this.createDOM = () => {
17
+ this.dom = document.createElement('div');
18
+ this.dom.classList.add('contributors');
19
+ const can = this.props.getCapabilities();
20
+ const { components: { MetadataContainer }, subscribeStore, } = this.props;
21
+ this.metadata = (0, ReactSubView_1.default)(this.props, MetadataContainer, {
22
+ allowInvitingAuthors: false,
23
+ showAuthorEditButton: true,
24
+ disableEditButton: !can.editMetadata,
25
+ subscribe: subscribeStore,
26
+ }, this.node, this.getPos, this.view, 'metadata-container');
27
+ if (this.metadata) {
28
+ this.dom.appendChild(this.metadata);
29
+ }
30
+ };
31
+ this.ignoreMutation = () => true;
32
+ this.stopEvent = () => true;
33
+ }
34
+ }
35
+ exports.ContributorsSectionView = ContributorsSectionView;
36
+ exports.default = (0, creators_1.createNodeView)(ContributorsSectionView);
@@ -25,6 +25,15 @@ class FootnotesElementView extends block_view_1.default {
25
25
  constructor() {
26
26
  super(...arguments);
27
27
  this.elementType = 'div';
28
+ this.checkEditability = () => {
29
+ var _a, _b;
30
+ const editable = this.node.childCount ? 'true' : 'false';
31
+ (_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.setAttribute('contenteditable', editable);
32
+ (_b = this.dom) === null || _b === void 0 ? void 0 : _b.setAttribute('contenteditable', editable);
33
+ };
34
+ }
35
+ onUpdateContent() {
36
+ this.checkEditability();
28
37
  }
29
38
  }
30
39
  exports.FootnotesElementView = FootnotesElementView;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.TitleView = void 0;
19
+ const base_node_view_1 = require("./base_node_view");
20
+ const creators_1 = require("./creators");
21
+ class TitleView extends base_node_view_1.BaseNodeView {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.initialise = () => {
25
+ this.createDOM();
26
+ };
27
+ this.createDOM = () => {
28
+ this.dom = document.createElement('div');
29
+ this.dom.classList.add('manuscript-title');
30
+ this.contentDOM = document.createElement('div');
31
+ this.contentDOM.classList.add('article-titles');
32
+ this.dom.appendChild(this.contentDOM);
33
+ };
34
+ }
35
+ }
36
+ exports.TitleView = TitleView;
37
+ exports.default = (0, creators_1.createNodeView)(TitleView);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const creators_1 = require("./creators");
19
+ const title_1 = require("./title");
20
+ exports.default = (0, creators_1.createEditableNodeView)(title_1.TitleView);
@@ -219,9 +219,6 @@ export const insertLink = (state, dispatch) => {
219
219
  }
220
220
  return true;
221
221
  };
222
- const needsBibliography = (state) => !bibliographyKey.getState(state).citations.length &&
223
- !getChildOfType(state.tr.doc, state.schema.nodes.bibliography_section);
224
- const createBibliographySection = (state) => state.schema.nodes.bibliography_section.createAndFill({}, state.schema.nodes.section_title.create({}, state.schema.text('Bibliography')));
225
222
  export const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = []) => {
226
223
  const citation = buildCitation(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
227
224
  const node = state.schema.nodes.citation.create({
@@ -232,9 +229,6 @@ export const insertInlineCitation = (state, dispatch, view, embeddedCitationItem
232
229
  const pos = state.selection.to;
233
230
  const { tr } = state;
234
231
  tr.insert(pos, node);
235
- if (needsBibliography(state)) {
236
- tr.insert(tr.doc.content.size, createBibliographySection(state)).setMeta(bibliographyKey, { bibliographyInserted: true });
237
- }
238
232
  if (dispatch) {
239
233
  const selection = NodeSelection.create(tr.doc, pos);
240
234
  dispatch(tr.setSelection(selection).scrollIntoView());
@@ -307,7 +301,7 @@ export const insertGraphicalAbstract = (state, dispatch) => {
307
301
  !isInAbstractsSection(state.selection.$from)) {
308
302
  return false;
309
303
  }
310
- if (getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
304
+ if (!!getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
311
305
  return false;
312
306
  }
313
307
  const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
@@ -354,7 +348,7 @@ export const insertFootnotesSection = (state, dispatch) => {
354
348
  return true;
355
349
  };
356
350
  export const insertBibliographySection = (state, dispatch) => {
357
- if (getChildOfType(state.doc, state.schema.nodes.bibliography_section)) {
351
+ if (getMatchingDescendant(state.doc, (node) => node.type === state.schema.nodes.bibliography_section)) {
358
352
  return false;
359
353
  }
360
354
  const section = state.schema.nodes.bibliography_section.createAndFill({}, [
@@ -1,4 +1,4 @@
1
- import { isElementNodeType, nodeTitle, nodeTitlePlaceholder, } from '@manuscripts/transform';
1
+ import { isElementNodeType, nodeTitle, nodeTitlePlaceholder, schema, } from '@manuscripts/transform';
2
2
  import { Fragment } from 'prosemirror-model';
3
3
  import * as React from 'react';
4
4
  import { DragSource, DropTarget, } from 'react-dnd';
@@ -8,23 +8,25 @@ import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
8
8
  import { nodeTypeIcon } from '../../node-type-icons';
9
9
  import { isSpecialSection } from '../../views/section_title';
10
10
  import { Outline, OutlineDropPreview, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, StyledTriangleCollapsed, StyledTriangleExpanded, } from './Outline';
11
+ const excludedTypes = [
12
+ schema.nodes.table,
13
+ schema.nodes.figure,
14
+ schema.nodes.footnotes_element,
15
+ schema.nodes.bibliography_element,
16
+ schema.nodes.keywords_section,
17
+ schema.nodes.affiliations_section,
18
+ schema.nodes.contributors_section,
19
+ schema.nodes.title,
20
+ ];
21
+ const childrenExcludedTypes = [
22
+ schema.nodes.pullquote_element,
23
+ schema.nodes.blockquote_element,
24
+ ];
11
25
  const isExcluded = (nodeType) => {
12
- const { nodes } = nodeType.schema;
13
- const excludedTypes = [
14
- nodes.table,
15
- nodes.figure,
16
- nodes.footnotes_element,
17
- nodes.bibliography_element,
18
- nodes.keywords_section,
19
- nodes.affiliations_section,
20
- nodes.contributors_section,
21
- ];
22
26
  return excludedTypes.includes(nodeType);
23
27
  };
24
28
  const isChildrenExcluded = (nodeType) => {
25
- const { nodes } = nodeType.schema;
26
- const excludedTypes = [nodes.pullquote_element, nodes.blockquote_element];
27
- return excludedTypes.includes(nodeType);
29
+ return childrenExcludedTypes.includes(nodeType);
28
30
  };
29
31
  export const buildTree = ({ node, pos, index, selected, parent, }) => {
30
32
  const items = [];
@@ -109,23 +111,22 @@ class Tree extends React.Component {
109
111
  if (isRejectedItem || node.attrs.id === 'META_SECTION') {
110
112
  return null;
111
113
  }
112
- return connectDropTarget(React.createElement("div", null,
113
- React.createElement(Outline, { style: this.outlineStyles(isDragging) },
114
- React.createElement(OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
115
- !isSpecialSection(node) && (React.createElement(React.Fragment, null, connectDragSource(React.createElement("div", null,
116
- React.createElement(OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
117
- items.length ? (React.createElement(OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(StyledTriangleExpanded, null)) : (React.createElement(StyledTriangleCollapsed, null)))) : (React.createElement(OutlineItemNoArrow, null)),
118
- React.createElement(OutlineItemLink, { to: `#${node.attrs.id || ''}` },
119
- connectDragPreview(React.createElement("span", { style: {
120
- display: 'inline-flex',
121
- alignItems: 'center',
122
- } },
123
- React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)))),
124
- React.createElement(OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))))),
125
- items.length ? (React.createElement("div", { style: {
126
- display: open || isSpecialSection(node) ? '' : 'none',
127
- } }, 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,
128
- React.createElement(OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
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) })))));
129
130
  }
130
131
  }
131
132
  const dragSource = DragSource('outline', {
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { parse } from '@manuscripts/title-editor';
17
16
  import React, { useEffect, useState } from 'react';
18
17
  import { useDebounce } from '../hooks/use-debounce';
19
18
  import DraggableTree, { buildTree } from './DraggableTree';
@@ -23,24 +22,14 @@ export const ManuscriptOutline = (props) => {
23
22
  const debouncedProps = useDebounce(props, 500);
24
23
  useEffect(() => {
25
24
  var _a;
26
- const { doc, view, manuscript, selected } = debouncedProps;
25
+ const { doc, view, selected } = debouncedProps;
27
26
  if (doc) {
28
- const { items } = buildTree({
27
+ const tree = buildTree({
29
28
  node: doc,
30
29
  pos: 0,
31
30
  index: 0,
32
31
  selected,
33
32
  });
34
- const node = parse(manuscript.title || '');
35
- const tree = {
36
- node,
37
- requirementsNode: doc,
38
- pos: 0,
39
- endPos: 0,
40
- index: 0,
41
- isSelected: !selected,
42
- items,
43
- };
44
33
  setValues({ tree, view, editArticle: !!((_a = props.capabilities) === null || _a === void 0 ? void 0 : _a.editArticle) });
45
34
  }
46
35
  else {
@@ -14,21 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import OutlineIconManuscript from '@manuscripts/assets/react/OutlineIconManuscript';
17
- import { parse, schema } from '@manuscripts/title-editor';
18
- import { nodeTitlePlaceholder } from '@manuscripts/transform';
17
+ import { nodeTitle, } from '@manuscripts/transform';
19
18
  import React from 'react';
20
- import { Outline, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemPlaceholder, StyledTriangleCollapsed, } from './Outline';
21
- const titleText = (value) => {
22
- const node = parse(value, {
23
- topNode: schema.nodes.title.create(),
24
- });
25
- return node.textContent;
26
- };
27
- export const OutlineManuscript = ({ project, manuscript, }) => (React.createElement(Outline, null,
19
+ import { Outline, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, StyledTriangleCollapsed, } from './Outline';
20
+ export const OutlineManuscript = ({ project, manuscript, doc, }) => (React.createElement(Outline, null,
28
21
  React.createElement(OutlineItem, { isSelected: false, depth: 0 },
29
22
  React.createElement(OutlineItemLink, { to: `/projects/${project._id}/manuscripts/${manuscript._id}` },
30
23
  React.createElement(OutlineItemArrow, null,
31
24
  React.createElement(StyledTriangleCollapsed, null)),
32
25
  React.createElement(OutlineItemIcon, null,
33
26
  React.createElement(OutlineIconManuscript, null)),
34
- React.createElement(OutlineItemLinkText, { className: 'outline-text-title' }, manuscript.title ? (titleText(manuscript.title)) : (React.createElement(OutlineItemPlaceholder, null, nodeTitlePlaceholder(schema.nodes.title))))))));
27
+ React.createElement(OutlineItemLinkText, { className: 'outline-text-title' }, nodeTitle(doc))))));