@manuscripts/body-editor 1.5.16 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/commands.js +53 -132
  2. package/dist/cjs/components/outline/DraggableTree.js +33 -25
  3. package/dist/cjs/components/toolbar/OrderListSelector.js +3 -11
  4. package/dist/cjs/configs/editor-plugins.js +2 -2
  5. package/dist/cjs/configs/editor-views.js +4 -6
  6. package/dist/cjs/lib/context-menu.js +6 -5
  7. package/dist/cjs/node-type-icons.js +0 -1
  8. package/dist/cjs/plugins/bibliography/bibliography-utils.js +60 -47
  9. package/dist/cjs/plugins/bibliography/index.js +48 -63
  10. package/dist/cjs/plugins/comment_annotation.js +2 -2
  11. package/dist/cjs/plugins/footnotes/index.js +19 -10
  12. package/dist/cjs/plugins/persist.js +21 -31
  13. package/dist/cjs/plugins/sections.js +1 -2
  14. package/dist/cjs/plugins/toc.js +28 -23
  15. package/dist/cjs/views/bibliography_element.js +20 -38
  16. package/dist/cjs/views/citation.js +29 -26
  17. package/dist/cjs/views/citation_editable.js +25 -44
  18. package/dist/cjs/views/{contributors_section.js → contributors.js} +4 -4
  19. package/dist/cjs/views/cross_reference.js +7 -36
  20. package/dist/cjs/views/cross_reference_editable.js +6 -14
  21. package/dist/cjs/views/editable_block.js +2 -2
  22. package/dist/cjs/views/{meta_section.js → empty.js} +3 -3
  23. package/dist/cjs/views/section_title.js +1 -16
  24. package/dist/es/commands.js +55 -110
  25. package/dist/es/components/outline/DraggableTree.js +33 -25
  26. package/dist/es/components/toolbar/OrderListSelector.js +4 -12
  27. package/dist/es/configs/editor-plugins.js +2 -2
  28. package/dist/es/configs/editor-views.js +4 -6
  29. package/dist/es/lib/context-menu.js +7 -6
  30. package/dist/es/node-type-icons.js +0 -1
  31. package/dist/es/plugins/bibliography/bibliography-utils.js +56 -45
  32. package/dist/es/plugins/bibliography/index.js +49 -65
  33. package/dist/es/plugins/comment_annotation.js +2 -2
  34. package/dist/es/plugins/footnotes/index.js +20 -11
  35. package/dist/es/plugins/persist.js +22 -32
  36. package/dist/es/plugins/sections.js +2 -3
  37. package/dist/es/plugins/toc.js +29 -24
  38. package/dist/es/views/bibliography_element.js +21 -39
  39. package/dist/es/views/citation.js +31 -28
  40. package/dist/es/views/citation_editable.js +28 -47
  41. package/dist/es/views/{contributors_section.js → contributors.js} +2 -2
  42. package/dist/es/views/cross_reference.js +7 -33
  43. package/dist/es/views/cross_reference_editable.js +6 -14
  44. package/dist/es/views/editable_block.js +3 -3
  45. package/dist/es/views/{meta_section.js → empty.js} +3 -3
  46. package/dist/es/views/section_title.js +0 -14
  47. package/dist/types/commands.d.ts +1 -2
  48. package/dist/types/components/outline/DraggableTree.d.ts +1 -2
  49. package/dist/types/configs/ManuscriptsEditor.d.ts +1 -10
  50. package/dist/types/configs/editor-plugins.d.ts +1 -5
  51. package/dist/types/configs/editor-views.d.ts +5 -6
  52. package/dist/types/lib/context-menu.d.ts +0 -1
  53. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +10 -7
  54. package/dist/types/plugins/bibliography/index.d.ts +21 -3
  55. package/dist/types/views/bibliography_element.d.ts +1 -0
  56. package/dist/types/views/citation.d.ts +3 -4
  57. package/dist/types/views/citation_editable.d.ts +2 -8
  58. package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
  59. package/dist/types/views/cross_reference.d.ts +0 -5
  60. package/dist/types/views/{meta_section.d.ts → empty.d.ts} +2 -2
  61. package/dist/types/views/section_title.d.ts +0 -2
  62. package/package.json +4 -22
  63. package/styles/AdvancedEditor.css +30 -34
  64. package/dist/cjs/plugins/auxiliary_object_order.js +0 -49
  65. package/dist/cjs/plugins/bibliography/types.js +0 -17
  66. package/dist/cjs/plugins/footnotes/footnotes-utils.js +0 -52
  67. package/dist/cjs/views/bibliography_item.js +0 -138
  68. package/dist/cjs/views/bibliography_item_editable.js +0 -20
  69. package/dist/es/plugins/auxiliary_object_order.js +0 -46
  70. package/dist/es/plugins/bibliography/types.js +0 -16
  71. package/dist/es/plugins/footnotes/footnotes-utils.js +0 -46
  72. package/dist/es/views/bibliography_item.js +0 -131
  73. package/dist/es/views/bibliography_item_editable.js +0 -18
  74. package/dist/types/plugins/auxiliary_object_order.d.ts +0 -12
  75. package/dist/types/plugins/bibliography/types.d.ts +0 -40
  76. package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -25
  77. package/dist/types/views/bibliography_item.d.ts +0 -34
  78. package/dist/types/views/bibliography_item_editable.d.ts +0 -18
@@ -13,34 +13,23 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ObjectTypes, } from '@manuscripts/json-schema';
16
+ import { ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { DOMSerializer } from 'prosemirror-model';
18
18
  import React, { createElement } from 'react';
19
19
  import ReactDOM from 'react-dom';
20
20
  import { TrackChangesReview } from '../components/track-changes/TrackChangesReview';
21
21
  import { sanitize } from '../lib/dompurify';
22
22
  import { getChangeClasses, isDeleted, isPendingSetAttrs, } from '../lib/track-changes-utils';
23
- import { getNodeModel } from '../plugins/bibliography/bibliography-utils';
23
+ import { getBibliographyPluginState } from '../plugins/bibliography';
24
+ import { getCitation } from '../plugins/bibliography/bibliography-utils';
24
25
  import { BaseNodeView } from './base_node_view';
25
26
  import { createNodeView } from './creators';
26
27
  export class CitationView extends BaseNodeView {
27
28
  constructor() {
28
29
  super(...arguments);
29
30
  this.showPopper = () => {
30
- const { components: { CitationViewer }, getLibraryItem, projectID, renderReactComponent, } = this.props;
31
- const citation = this.getCitation();
32
- const items = citation.embeddedCitationItems.map((citationItem) => {
33
- const libraryItem = getLibraryItem(citationItem.bibliographyItem);
34
- if (!libraryItem) {
35
- const placeholderItem = {
36
- _id: citationItem.bibliographyItem,
37
- objectType: ObjectTypes.BibliographyItem,
38
- title: '[missing library item]',
39
- };
40
- return placeholderItem;
41
- }
42
- return libraryItem;
43
- });
31
+ const { components: { CitationViewer }, projectID, renderReactComponent, } = this.props;
32
+ const items = this.getBibliographyItems();
44
33
  if (!this.popperContainer) {
45
34
  this.popperContainer = document.createElement('div');
46
35
  this.popperContainer.className = 'citation-editor';
@@ -82,27 +71,25 @@ export class CitationView extends BaseNodeView {
82
71
  return this;
83
72
  };
84
73
  this.updateContents = () => {
74
+ const bib = getBibliographyPluginState(this.view.state);
85
75
  const citation = this.getCitation();
86
- const nodeClasses = ['citation', ...getChangeClasses(this.node)];
87
- const citationElement = document.createElement('span');
88
- citationElement.className = nodeClasses.join(' ');
89
- const citeprocCitations = this.props.getCiteprocCitations();
90
- const citeprocContent = citeprocCitations === null || citeprocCitations === void 0 ? void 0 : citeprocCitations.get(this.node.attrs.rid);
91
- const fragment = sanitize(citeprocContent && citeprocContent !== '[NO_PRINTED_FORM]'
92
- ? citeprocContent
93
- : ' ', {
76
+ const classes = ['citation', ...getChangeClasses(this.node)];
77
+ const element = document.createElement('span');
78
+ element.className = classes.join(' ');
79
+ const text = bib.renderedCitations.get(citation._id);
80
+ const fragment = sanitize(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
94
81
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
95
82
  });
96
- citationElement.appendChild(fragment);
83
+ element.appendChild(fragment);
97
84
  this.dom.className = 'citation-wrapper';
98
85
  this.dom.innerHTML = '';
99
- this.dom.appendChild(citationElement);
86
+ this.dom.appendChild(element);
100
87
  if (isPendingSetAttrs(this.node) &&
101
88
  !isDeleted(this.node) &&
102
89
  citation.embeddedCitationItems.length) {
103
90
  this.dom.appendChild(this.renderTrackChangesReview());
104
91
  }
105
- this.setDomAttrs(this.node, this.dom, ['rid', 'contents', 'selectedText']);
92
+ this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
106
93
  };
107
94
  this.renderTrackChangesReview = () => {
108
95
  const { popper } = this.props;
@@ -116,12 +103,28 @@ export class CitationView extends BaseNodeView {
116
103
  return el;
117
104
  };
118
105
  this.getCitation = () => {
119
- const citation = getNodeModel(this.node);
106
+ const citation = getCitation(this.node);
120
107
  if (!citation) {
121
108
  throw new Error('Citation not found');
122
109
  }
123
110
  return citation;
124
111
  };
112
+ this.getBibliographyItems = () => {
113
+ const bib = getBibliographyPluginState(this.view.state);
114
+ const citation = this.node;
115
+ return citation.attrs.rids.map((rid) => {
116
+ const item = bib.bibliographyItems.get(rid);
117
+ if (!item) {
118
+ const placeholder = {
119
+ _id: rid,
120
+ objectType: ObjectTypes.BibliographyItem,
121
+ title: '[missing library item]',
122
+ };
123
+ return placeholder;
124
+ }
125
+ return item;
126
+ });
127
+ };
125
128
  }
126
129
  }
127
130
  export default createNodeView(CitationView);
@@ -34,12 +34,11 @@ var __rest = (this && this.__rest) || function (s, e) {
34
34
  return t;
35
35
  };
36
36
  import { ObjectTypes, } from '@manuscripts/json-schema';
37
- import { matchLibraryItemByIdentifier } from '@manuscripts/library';
38
- import { buildEmbeddedCitationItem, schema, } from '@manuscripts/transform';
37
+ import { findMatchingBibliographyItem } from '@manuscripts/library';
38
+ import { schema } from '@manuscripts/transform';
39
39
  import { TextSelection } from 'prosemirror-state';
40
40
  import React from 'react';
41
- import { bibliographyKey } from '../plugins/bibliography';
42
- import { getReferencesModelMap } from '../plugins/bibliography/bibliography-utils';
41
+ import { getBibliographyPluginState } from '../plugins/bibliography';
43
42
  import { CitationView } from './citation';
44
43
  import { createEditableNodeView } from './creators';
45
44
  const createBibliographySection = (bibItem) => schema.nodes.bibliography_section.createAndFill({}, [
@@ -53,20 +52,9 @@ export class CitationEditableView extends CitationView {
53
52
  const { components: { CitationEditor, CitationViewer }, getCapabilities, projectID, renderReactComponent, } = this.props;
54
53
  const capabilities = getCapabilities();
55
54
  const citation = this.getCitation();
56
- const items = citation.embeddedCitationItems.map((citationItem) => {
57
- const libraryItem = getReferencesModelMap(this.view.state.doc).get(citationItem.bibliographyItem);
58
- if (!libraryItem) {
59
- const placeholderItem = {
60
- _id: citationItem.bibliographyItem,
61
- objectType: ObjectTypes.BibliographyItem,
62
- title: '[missing library item]',
63
- };
64
- return placeholderItem;
65
- }
66
- return libraryItem;
67
- });
55
+ const items = this.getBibliographyItems();
68
56
  const updateCitation = (data) => __awaiter(this, void 0, void 0, function* () {
69
- this.updateInlineNode(Object.assign(Object.assign({}, citation), data));
57
+ this.updateNode(Object.assign(Object.assign({}, citation), data));
70
58
  this.props.popper.update();
71
59
  });
72
60
  const findPosition = (doc, id) => {
@@ -93,7 +81,8 @@ export class CitationEditableView extends CitationView {
93
81
  this.popperContainer = document.createElement('div');
94
82
  this.popperContainer.className = 'citation-editor';
95
83
  }
96
- const component = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.editArticle) ? (React.createElement(CitationEditor, { items: items, saveModel: handleSave, deleteModel: this.deleteNode, modelMap: getReferencesModelMap(this.view.state.doc, true), insertBibliographyNode: (item) => this.insertBibliographyNode(this.view, item), importItems: this.importItems, selectedText: this.node.attrs.selectedText, setComment: this.props.setComment, handleCancel: this.handleCancel, handleClose: this.handleClose, handleRemove: this.handleRemove, updatePopper: this.updatePopper, handleCite: this.handleCite, canEdit: capabilities.editCitationsAndRefs, citation: citation, updateCitation: updateCitation, projectID: projectID, scheduleUpdate: this.props.popper.update })) : (React.createElement(CitationViewer, { items: items, setComment: this.props.setComment, scheduleUpdate: this.props.popper.update }));
84
+ const bib = getBibliographyPluginState(this.view.state);
85
+ const component = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.editArticle) ? (React.createElement(CitationEditor, { items: items, saveModel: handleSave, deleteModel: this.deleteNode, insertBibliographyNode: (item) => this.insertBibliographyNode(this.view, item), modelMap: bib.bibliographyItems, importItems: this.importItems, selectedText: this.node.attrs.selectedText, setComment: this.props.setComment, handleCancel: this.handleCancel, handleClose: this.handleClose, handleRemove: this.handleRemove, updatePopper: this.updatePopper, handleCite: this.handleCite, canEdit: capabilities.editCitationsAndRefs, citation: citation, updateCitation: updateCitation, projectID: projectID, scheduleUpdate: this.props.popper.update })) : (React.createElement(CitationViewer, { items: items, setComment: this.props.setComment, scheduleUpdate: this.props.popper.update }));
97
86
  renderReactComponent(component, this.popperContainer);
98
87
  this.props.popper.show(this.dom, this.popperContainer, 'right');
99
88
  };
@@ -111,10 +100,10 @@ export class CitationEditableView extends CitationView {
111
100
  };
112
101
  this.handleRemove = (id) => __awaiter(this, void 0, void 0, function* () {
113
102
  const citation = this.getCitation();
114
- const embeddedCitationItems = citation.embeddedCitationItems.filter((item) => item.bibliographyItem !== id);
115
- if (embeddedCitationItems.length > 0) {
116
- citation.embeddedCitationItems = embeddedCitationItems;
117
- this.updateInlineNode(citation);
103
+ const items = citation.embeddedCitationItems.filter((i) => i.bibliographyItem !== id);
104
+ if (items.length > 0) {
105
+ citation.embeddedCitationItems = items;
106
+ this.updateNode(citation);
118
107
  window.setTimeout(() => {
119
108
  this.showPopper();
120
109
  }, 100);
@@ -125,9 +114,6 @@ export class CitationEditableView extends CitationView {
125
114
  tr.delete(pos, pos + 1);
126
115
  this.view.dispatch(tr);
127
116
  }
128
- this.view.dispatch(this.view.state.tr.setMeta(bibliographyKey, {
129
- bibliographyInserted: true,
130
- }));
131
117
  this.props.popper.destroy();
132
118
  });
133
119
  this.updatePopper = () => {
@@ -137,46 +123,43 @@ export class CitationEditableView extends CitationView {
137
123
  }, 100);
138
124
  };
139
125
  this.handleCite = (items) => __awaiter(this, void 0, void 0, function* () {
126
+ const bib = getBibliographyPluginState(this.view.state);
140
127
  const citation = this.getCitation();
141
- let triggerUpdate = false;
142
128
  for (const item of items) {
143
- const existingItem = matchLibraryItemByIdentifier(item, getReferencesModelMap(this.view.state.doc));
129
+ const existingItem = findMatchingBibliographyItem(item, bib.bibliographyItems);
144
130
  if (existingItem) {
145
131
  item._id = existingItem._id;
146
132
  }
147
133
  else {
148
- triggerUpdate = true;
149
- yield this.insertBibliographyNode(this.view, item);
134
+ this.insertBibliographyNode(this.view, item);
150
135
  }
151
- citation.embeddedCitationItems.push(buildEmbeddedCitationItem(item._id));
152
- }
153
- this.updateInlineNode(citation);
154
- if (triggerUpdate) {
155
- this.view.dispatch(this.view.state.tr.setMeta(bibliographyKey, {
156
- bibliographyInserted: true,
157
- }));
136
+ citation.embeddedCitationItems.push({
137
+ _id: '_',
138
+ objectType: ObjectTypes.CitationItem,
139
+ bibliographyItem: item._id,
140
+ });
158
141
  }
142
+ this.updateNode(citation);
159
143
  this.handleClose();
160
144
  });
161
145
  this.importItems = (items) => __awaiter(this, void 0, void 0, function* () {
146
+ const bib = getBibliographyPluginState(this.view.state);
162
147
  const newItems = [];
163
148
  for (const item of items) {
164
- const existingItem = matchLibraryItemByIdentifier(item, getReferencesModelMap(this.view.state.doc));
149
+ const existingItem = findMatchingBibliographyItem(item, bib.bibliographyItems);
165
150
  if (!existingItem) {
166
- yield this.insertBibliographyNode(this.view, item);
151
+ this.insertBibliographyNode(this.view, item);
167
152
  newItems.push(item);
168
153
  }
169
154
  }
170
155
  return newItems;
171
156
  });
172
- this.updateInlineNode = (citation) => {
157
+ this.updateNode = (citation) => {
158
+ const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
173
159
  const { tr } = this.view.state;
174
160
  this.view.dispatch(tr.setNodeMarkup(this.getPos(), undefined, {
175
- rid: citation._id,
176
- embeddedCitationItems: citation.embeddedCitationItems.map((item) => ({
177
- id: item._id,
178
- bibliographyItem: item.bibliographyItem,
179
- })),
161
+ id: citation._id,
162
+ rids,
180
163
  }));
181
164
  };
182
165
  }
@@ -198,9 +181,7 @@ export class CitationEditableView extends CitationView {
198
181
  newTr = tr.insert(pos + 1, bibItem);
199
182
  }
200
183
  else {
201
- newTr = tr
202
- .insert(tr.doc.content.size, createBibliographySection(bibItem))
203
- .setMeta(bibliographyKey, { bibliographyInserted: true });
184
+ newTr = tr.insert(tr.doc.content.size, createBibliographySection(bibItem));
204
185
  }
205
186
  view.dispatch(newTr);
206
187
  return false;
@@ -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);
@@ -13,9 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import React from 'react';
17
16
  import { getChangeClasses } from '../lib/track-changes-utils';
18
- import { objectsKey } from '../plugins/objects';
19
17
  import { BaseNodeView } from './base_node_view';
20
18
  import { createNodeView } from './creators';
21
19
  export class CrossReferenceView extends BaseNodeView {
@@ -24,38 +22,15 @@ export class CrossReferenceView extends BaseNodeView {
24
22
  this.selectNode = () => {
25
23
  };
26
24
  this.handleClick = () => {
27
- const auxiliaryObjectReference = this.getAuxiliaryObjectReference(this.node.attrs.rid);
28
- if (auxiliaryObjectReference) {
29
- if (auxiliaryObjectReference.referencedObjects) {
30
- this.showPopper(auxiliaryObjectReference.referencedObjects);
31
- }
32
- else {
33
- this.props.history.push({
34
- pathname: this.props.history.location.pathname,
35
- hash: '#' + auxiliaryObjectReference.referencedObject,
36
- });
37
- }
25
+ const xref = this.node;
26
+ const rids = xref.attrs.rids;
27
+ if (!rids.length) {
28
+ return;
38
29
  }
39
- };
40
- this.showPopper = (referencedObjects) => {
41
- const { components: { ReferencesViewer }, renderReactComponent, } = this.props;
42
- if (!this.popperContainer) {
43
- this.popperContainer = document.createElement('div');
44
- this.popperContainer.className = 'citation-references';
45
- }
46
- const targets = objectsKey.getState(this.view.state);
47
- const items = [];
48
- referencedObjects.map((referencedObject) => {
49
- const target = targets.get(referencedObject);
50
- if (target && target.label) {
51
- items.push({
52
- label: target.label,
53
- referencedObject,
54
- });
55
- }
30
+ this.props.history.push({
31
+ pathname: this.props.history.location.pathname,
32
+ hash: '#' + rids[0],
56
33
  });
57
- renderReactComponent(React.createElement(ReferencesViewer, { items: items, history: this.props.history }), this.popperContainer);
58
- this.props.popper.show(this.dom, this.popperContainer, 'right');
59
34
  };
60
35
  this.updateContents = () => {
61
36
  const nodeClasses = ['cross-reference', ...getChangeClasses(this.node)];
@@ -68,7 +43,6 @@ export class CrossReferenceView extends BaseNodeView {
68
43
  this.updateContents();
69
44
  };
70
45
  this.ignoreMutation = () => true;
71
- this.getAuxiliaryObjectReference = (id) => this.props.getModelMap().get(id);
72
46
  this.createDOM = () => {
73
47
  this.dom = document.createElement('span');
74
48
  this.dom.className = 'cross-reference';
@@ -23,7 +23,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  });
24
24
  };
25
25
  import { skipTracking } from '@manuscripts/track-changes-plugin';
26
- import { buildAuxiliaryObjectReference } from '@manuscripts/transform';
27
26
  import { TextSelection } from 'prosemirror-state';
28
27
  import React from 'react';
29
28
  import { CrossReferenceItems } from '../components/views/CrossReferenceItems';
@@ -35,21 +34,17 @@ export class CrossReferenceEditableView extends CrossReferenceView {
35
34
  super(...arguments);
36
35
  this.selectNode = () => {
37
36
  const { getCapabilities, renderReactComponent } = this.props;
37
+ const xref = this.node;
38
+ const rids = xref.attrs.rids;
38
39
  const can = getCapabilities();
39
- const { rid } = this.node.attrs;
40
- const auxiliaryObjectReference = rid
41
- ? this.getAuxiliaryObjectReference(rid)
42
- : null;
43
- if (!(can === null || can === void 0 ? void 0 : can.editArticle) ||
44
- (auxiliaryObjectReference === null || auxiliaryObjectReference === void 0 ? void 0 : auxiliaryObjectReference.referencedObject) ||
45
- (auxiliaryObjectReference === null || auxiliaryObjectReference === void 0 ? void 0 : auxiliaryObjectReference.referencedObjects)) {
40
+ if (!(can === null || can === void 0 ? void 0 : can.editArticle) || rids.length) {
46
41
  return;
47
42
  }
48
43
  if (!this.popperContainer) {
49
44
  this.popperContainer = document.createElement('div');
50
45
  this.popperContainer.className = 'cross-reference-editor';
51
46
  }
52
- renderReactComponent(React.createElement(CrossReferenceItems, { handleSelect: this.handleSelect, targets: this.getTargets(), handleCancel: this.handleCancel, currentTargetId: auxiliaryObjectReference === null || auxiliaryObjectReference === void 0 ? void 0 : auxiliaryObjectReference.referencedObject, currentCustomLabel: this.node.attrs.customLabel }), this.popperContainer);
47
+ renderReactComponent(React.createElement(CrossReferenceItems, { handleSelect: this.handleSelect, targets: this.getTargets(), handleCancel: this.handleCancel, currentTargetId: rids[0], currentCustomLabel: this.node.attrs.customLabel }), this.popperContainer);
53
48
  this.props.popper.show(this.dom, this.popperContainer, 'right');
54
49
  };
55
50
  this.destroy = () => {
@@ -66,7 +61,7 @@ export class CrossReferenceEditableView extends CrossReferenceView {
66
61
  return Array.from(targets.values());
67
62
  };
68
63
  this.handleCancel = () => {
69
- if (!this.node.attrs.rid) {
64
+ if (!this.node.attrs.rids.length) {
70
65
  const { state } = this.view;
71
66
  const pos = this.getPos();
72
67
  const tr = state.tr.delete(pos, pos + this.node.nodeSize);
@@ -81,10 +76,7 @@ export class CrossReferenceEditableView extends CrossReferenceView {
81
76
  this.handleSelect = (rid, customLabel) => __awaiter(this, void 0, void 0, function* () {
82
77
  const { state } = this.view;
83
78
  const pos = this.getPos();
84
- const $pos = state.doc.resolve(pos);
85
- const rids = rid.trim().split(/\s+/);
86
- const auxiliaryObjectReference = buildAuxiliaryObjectReference($pos.parent.attrs.id, rids);
87
- const tr = state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { customLabel: customLabel || '', rid: auxiliaryObjectReference._id }));
79
+ const tr = state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { customLabel: customLabel || '', rids: [rid] }));
88
80
  const selection = TextSelection.create(tr.doc, pos);
89
81
  this.view.dispatch(tr.setSelection(selection));
90
82
  this.destroy();
@@ -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,9 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export default () => {
17
- const dom = document.createElement('section');
18
- dom.setAttribute('data-type', 'meta');
16
+ export default (type) => () => {
17
+ const dom = document.createElement('div');
18
+ dom.setAttribute('data-type', type);
19
19
  dom.setAttribute('contenteditable', 'false');
20
20
  dom.style.display = 'inline';
21
21
  return { dom };
@@ -13,29 +13,15 @@
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
- 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
- }
27
- };
28
19
  export class SectionTitleView extends BlockView {
29
20
  constructor() {
30
21
  super(...arguments);
31
22
  this.elementType = 'h1';
32
23
  this.updateContents = () => {
33
24
  const $pos = this.view.state.doc.resolve(this.getPos());
34
- if (isSpecialSection($pos.parent)) {
35
- this.dom = document.createElement('div');
36
- this.dom.classList.add('no-title');
37
- return;
38
- }
39
25
  if (this.node.childCount) {
40
26
  this.contentDOM.classList.remove('empty-node');
41
27
  }
@@ -32,13 +32,12 @@ export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEd
32
32
  export declare const insertBreak: EditorAction;
33
33
  export declare const insertSectionLabel: (state: ManuscriptEditorState, dispatch?: Dispatch, currentTr?: Transaction) => boolean;
34
34
  export declare const insertLink: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
35
- export declare const insertInlineCitation: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: ManuscriptEditorView, embeddedCitationItems?: string[]) => boolean;
35
+ export declare const insertInlineCitation: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: ManuscriptEditorView) => boolean;
36
36
  export declare const insertCrossReference: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
37
37
  export declare const insertInlineEquation: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
38
38
  export declare const insertInlineFootnote: (kind: 'footnote' | 'endnote') => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
39
39
  export declare const insertGraphicalAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
40
40
  export declare const insertSection: (subsection?: boolean) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
41
- export declare const insertFootnotesSection: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
42
41
  export declare const insertBibliographySection: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
43
42
  export declare const insertTOCSection: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
44
43
  export declare const ifInTableBody: (command: (state: ManuscriptEditorState) => boolean) => (state: ManuscriptEditorState) => boolean;
@@ -1,5 +1,4 @@
1
1
  import { ManuscriptEditorView, ManuscriptNode, Selected } from '@manuscripts/transform';
2
- import { Node as ProsemirrorNode } from 'prosemirror-model';
3
2
  import * as React from 'react';
4
3
  import { ConnectDragPreview, ConnectDragSource, ConnectDropTarget } from 'react-dnd';
5
4
  export type DropSide = 'before' | 'after' | null;
@@ -25,7 +24,7 @@ export interface TreeItem {
25
24
  index: number;
26
25
  isSelected: boolean;
27
26
  items: TreeItem[];
28
- node: ManuscriptNode | ProsemirrorNode;
27
+ node: ManuscriptNode;
29
28
  pos: number;
30
29
  endPos: number;
31
30
  parent?: ManuscriptNode;
@@ -14,8 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import 'prosemirror-view/style/prosemirror.css';
17
- import { BibliographyItem, CommentAnnotation, Manuscript, Model, UserProfile } from '@manuscripts/json-schema';
18
- import { CitationProvider } from '@manuscripts/library';
17
+ import { CommentAnnotation, Manuscript, Model, UserProfile } from '@manuscripts/json-schema';
19
18
  import { Capabilities, FileAttachment, FileManagement } from '@manuscripts/style-guide';
20
19
  import { Build, ManuscriptNode } from '@manuscripts/transform';
21
20
  import { History } from 'history';
@@ -51,19 +50,11 @@ export interface EditorProps {
51
50
  components: Record<string, React.ComponentType<any>>;
52
51
  getCapabilities: () => Capabilities;
53
52
  cslProps: CSLProps;
54
- getCitationProvider: () => CitationProvider | undefined;
55
- getLibraryItem: (id: string) => BibliographyItem | undefined;
56
- setLibraryItem: (item: BibliographyItem) => void;
57
- matchLibraryItemByIdentifier: (item: BibliographyItem) => BibliographyItem | undefined;
58
- filterLibraryItems: (query: string) => Promise<BibliographyItem[]>;
59
- removeLibraryItem: (id: string) => void;
60
53
  setComment: (comment?: CommentAnnotation) => void;
61
54
  setSelectedComment: (id?: string) => void;
62
55
  setEditorSelectedSuggestion: (id?: string) => void;
63
56
  retrySync: (componentIDs: string[]) => Promise<void>;
64
57
  environment?: string;
65
- setCiteprocCitations: (citations: Map<string, string>) => void;
66
- getCiteprocCitations: () => Map<string, string>;
67
58
  }
68
59
  declare const _default: {
69
60
  createState: (props: EditorProps) => EditorState;
@@ -15,8 +15,7 @@
15
15
  */
16
16
  import 'prosemirror-gapcursor/style/gapcursor.css';
17
17
  import 'prosemirror-tables/style/tables.css';
18
- import { BibliographyItem, CommentAnnotation, Manuscript, Model } from '@manuscripts/json-schema';
19
- import { CitationProvider } from '@manuscripts/library';
18
+ import { CommentAnnotation, Manuscript, Model } from '@manuscripts/json-schema';
20
19
  import { Capabilities } from '@manuscripts/style-guide';
21
20
  import { Build, ManuscriptSchema } from '@manuscripts/transform';
22
21
  import { Plugin } from 'prosemirror-state';
@@ -27,8 +26,6 @@ interface PluginProps {
27
26
  getManuscript: () => Manuscript;
28
27
  saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
29
28
  deleteModel: (id: string) => Promise<string>;
30
- getCitationProvider: () => CitationProvider | undefined;
31
- getLibraryItem: (id: string) => BibliographyItem | undefined;
32
29
  setComment: (comment?: CommentAnnotation) => void;
33
30
  setSelectedComment: (id?: string) => void;
34
31
  setEditorSelectedSuggestion?: (id?: string) => void;
@@ -36,7 +33,6 @@ interface PluginProps {
36
33
  plugins?: Plugin<ManuscriptSchema>[];
37
34
  cslProps: CSLProps;
38
35
  popper: PopperManager;
39
- setCiteprocCitations: (citations: Map<string, string>) => void;
40
36
  }
41
37
  declare const _default: (props: PluginProps) => any[];
42
38
  export default _default;
@@ -15,16 +15,15 @@
15
15
  */
16
16
  import { DefaultTheme } from 'styled-components';
17
17
  import { Dispatch } from '../commands';
18
- import { CitationEditableProps } from '../views/citation_editable';
18
+ import { CitationViewProps } from '../views/citation';
19
19
  import { EditableBlockProps } from '../views/editable_block';
20
20
  import { FigureProps } from '../views/figure_editable';
21
21
  import { KeywordsElementProps } from '../views/keywords_element';
22
- type EditorProps = EditableBlockProps & CitationEditableProps & FigureProps & KeywordsElementProps & {
22
+ type EditorProps = EditableBlockProps & CitationViewProps & FigureProps & KeywordsElementProps & {
23
23
  theme: DefaultTheme;
24
24
  };
25
25
  declare const _default: (props: EditorProps, dispatch: Dispatch) => {
26
26
  title: import("../types").NodeViewCreator<import("../views/title").TitleView<any>>;
27
- bibliography_item: import("../types").NodeViewCreator<import("../views/bibliography_item").BibliographyItemView<any>>;
28
27
  bibliography_element: import("../types").NodeViewCreator<{
29
28
  gutterButtons: () => HTMLElement[];
30
29
  actionGutterButtons: () => HTMLElement[];
@@ -141,7 +140,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
141
140
  } & import("../views/bullet_list").BulletListView<any>>;
142
141
  citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
143
142
  cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
144
- contributors_section: import("../types").NodeViewCreator<import("../views/contributors_section").ContributorsSectionView<any>>;
143
+ contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView<any>>;
145
144
  equation: import("../types").NodeViewCreator<import("../views/equation_editable").EquationEditableView>;
146
145
  equation_element: import("../types").NodeViewCreator<{
147
146
  gutterButtons: () => HTMLElement[];
@@ -571,8 +570,8 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
571
570
  updateNodeAttrs: (attrs: import("prosemirror-model").Attrs) => void;
572
571
  deleteNode: (id: string) => void;
573
572
  } & import("../views/toc_element").TOCElementView<any>>;
574
- meta_section: () => {
575
- dom: HTMLElement;
573
+ comments: () => {
574
+ dom: HTMLDivElement;
576
575
  };
577
576
  };
578
577
  export default _default;
@@ -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;
@@ -13,12 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Model } from '@manuscripts/json-schema';
17
- import { CitationNodes } from '@manuscripts/library';
18
- import { ManuscriptNode } from '@manuscripts/transform';
16
+ import { BibliographyItem, Citation } from '@manuscripts/json-schema';
17
+ import { BibliographyItemNode, CitationNode, ManuscriptNode } from '@manuscripts/transform';
18
+ import CiteProc from 'citeproc';
19
19
  import { Decoration } from 'prosemirror-view';
20
- import { PopperManager } from '../../lib/popper';
20
+ import { PluginState } from './index';
21
21
  export declare const isBibliographyElement: (node: ManuscriptNode) => boolean;
22
- export declare const buildDecorations: (doc: ManuscriptNode, citationNodes: CitationNodes, popper: PopperManager, referencesModelMap: Map<string, Model>, triggerUpdate?: boolean) => Decoration[];
23
- export declare const getNodeModel: <T extends Model>(node: ManuscriptNode, excludeDeletedNode?: boolean) => T | undefined;
24
- export declare const getReferencesModelMap: (doc: ManuscriptNode, excludeDeletedNode?: boolean) => Map<string, Model>;
22
+ export type CitationNodes = [CitationNode, number][];
23
+ export declare const buildDecorations: (state: PluginState, doc: ManuscriptNode) => Decoration[];
24
+ export declare const getCitation: (node: CitationNode) => Citation | undefined;
25
+ export declare const getBibliographyItem: (node: BibliographyItemNode) => BibliographyItem | undefined;
26
+ export declare const getBibliographyItemModelMap: (doc: ManuscriptNode) => Map<string, BibliographyItem>;
27
+ export declare const buildCitations: (citations: CitationNodes) => CiteProc.Citation[];