@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
@@ -49,6 +49,7 @@ const react_dom_1 = __importDefault(require("react-dom"));
49
49
  const TrackChangesReview_1 = require("../components/track-changes/TrackChangesReview");
50
50
  const dompurify_1 = require("../lib/dompurify");
51
51
  const track_changes_utils_1 = require("../lib/track-changes-utils");
52
+ const bibliography_1 = require("../plugins/bibliography");
52
53
  const bibliography_utils_1 = require("../plugins/bibliography/bibliography-utils");
53
54
  const base_node_view_1 = require("./base_node_view");
54
55
  const creators_1 = require("./creators");
@@ -56,20 +57,8 @@ class CitationView extends base_node_view_1.BaseNodeView {
56
57
  constructor() {
57
58
  super(...arguments);
58
59
  this.showPopper = () => {
59
- const { components: { CitationViewer }, getLibraryItem, projectID, renderReactComponent, } = this.props;
60
- const citation = this.getCitation();
61
- const items = citation.embeddedCitationItems.map((citationItem) => {
62
- const libraryItem = getLibraryItem(citationItem.bibliographyItem);
63
- if (!libraryItem) {
64
- const placeholderItem = {
65
- _id: citationItem.bibliographyItem,
66
- objectType: json_schema_1.ObjectTypes.BibliographyItem,
67
- title: '[missing library item]',
68
- };
69
- return placeholderItem;
70
- }
71
- return libraryItem;
72
- });
60
+ const { components: { CitationViewer }, projectID, renderReactComponent, } = this.props;
61
+ const items = this.getBibliographyItems();
73
62
  if (!this.popperContainer) {
74
63
  this.popperContainer = document.createElement('div');
75
64
  this.popperContainer.className = 'citation-editor';
@@ -111,27 +100,25 @@ class CitationView extends base_node_view_1.BaseNodeView {
111
100
  return this;
112
101
  };
113
102
  this.updateContents = () => {
103
+ const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
114
104
  const citation = this.getCitation();
115
- const nodeClasses = ['citation', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
116
- const citationElement = document.createElement('span');
117
- citationElement.className = nodeClasses.join(' ');
118
- const citeprocCitations = this.props.getCiteprocCitations();
119
- const citeprocContent = citeprocCitations === null || citeprocCitations === void 0 ? void 0 : citeprocCitations.get(this.node.attrs.rid);
120
- const fragment = (0, dompurify_1.sanitize)(citeprocContent && citeprocContent !== '[NO_PRINTED_FORM]'
121
- ? citeprocContent
122
- : ' ', {
105
+ const classes = ['citation', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
106
+ const element = document.createElement('span');
107
+ element.className = classes.join(' ');
108
+ const text = bib.renderedCitations.get(citation._id);
109
+ const fragment = (0, dompurify_1.sanitize)(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
123
110
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
124
111
  });
125
- citationElement.appendChild(fragment);
112
+ element.appendChild(fragment);
126
113
  this.dom.className = 'citation-wrapper';
127
114
  this.dom.innerHTML = '';
128
- this.dom.appendChild(citationElement);
115
+ this.dom.appendChild(element);
129
116
  if ((0, track_changes_utils_1.isPendingSetAttrs)(this.node) &&
130
117
  !(0, track_changes_utils_1.isDeleted)(this.node) &&
131
118
  citation.embeddedCitationItems.length) {
132
119
  this.dom.appendChild(this.renderTrackChangesReview());
133
120
  }
134
- this.setDomAttrs(this.node, this.dom, ['rid', 'contents', 'selectedText']);
121
+ this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
135
122
  };
136
123
  this.renderTrackChangesReview = () => {
137
124
  const { popper } = this.props;
@@ -145,12 +132,28 @@ class CitationView extends base_node_view_1.BaseNodeView {
145
132
  return el;
146
133
  };
147
134
  this.getCitation = () => {
148
- const citation = (0, bibliography_utils_1.getNodeModel)(this.node);
135
+ const citation = (0, bibliography_utils_1.getCitation)(this.node);
149
136
  if (!citation) {
150
137
  throw new Error('Citation not found');
151
138
  }
152
139
  return citation;
153
140
  };
141
+ this.getBibliographyItems = () => {
142
+ const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
143
+ const citation = this.node;
144
+ return citation.attrs.rids.map((rid) => {
145
+ const item = bib.bibliographyItems.get(rid);
146
+ if (!item) {
147
+ const placeholder = {
148
+ _id: rid,
149
+ objectType: json_schema_1.ObjectTypes.BibliographyItem,
150
+ title: '[missing library item]',
151
+ };
152
+ return placeholder;
153
+ }
154
+ return item;
155
+ });
156
+ };
154
157
  }
155
158
  }
156
159
  exports.CitationView = CitationView;
@@ -45,7 +45,6 @@ const transform_1 = require("@manuscripts/transform");
45
45
  const prosemirror_state_1 = require("prosemirror-state");
46
46
  const react_1 = __importDefault(require("react"));
47
47
  const bibliography_1 = require("../plugins/bibliography");
48
- const bibliography_utils_1 = require("../plugins/bibliography/bibliography-utils");
49
48
  const citation_1 = require("./citation");
50
49
  const creators_1 = require("./creators");
51
50
  const createBibliographySection = (bibItem) => transform_1.schema.nodes.bibliography_section.createAndFill({}, [
@@ -59,20 +58,9 @@ class CitationEditableView extends citation_1.CitationView {
59
58
  const { components: { CitationEditor, CitationViewer }, getCapabilities, projectID, renderReactComponent, } = this.props;
60
59
  const capabilities = getCapabilities();
61
60
  const citation = this.getCitation();
62
- const items = citation.embeddedCitationItems.map((citationItem) => {
63
- const libraryItem = (0, bibliography_utils_1.getReferencesModelMap)(this.view.state.doc).get(citationItem.bibliographyItem);
64
- if (!libraryItem) {
65
- const placeholderItem = {
66
- _id: citationItem.bibliographyItem,
67
- objectType: json_schema_1.ObjectTypes.BibliographyItem,
68
- title: '[missing library item]',
69
- };
70
- return placeholderItem;
71
- }
72
- return libraryItem;
73
- });
61
+ const items = this.getBibliographyItems();
74
62
  const updateCitation = (data) => __awaiter(this, void 0, void 0, function* () {
75
- this.updateInlineNode(Object.assign(Object.assign({}, citation), data));
63
+ this.updateNode(Object.assign(Object.assign({}, citation), data));
76
64
  this.props.popper.update();
77
65
  });
78
66
  const findPosition = (doc, id) => {
@@ -99,7 +87,8 @@ class CitationEditableView extends citation_1.CitationView {
99
87
  this.popperContainer = document.createElement('div');
100
88
  this.popperContainer.className = 'citation-editor';
101
89
  }
102
- const component = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.editArticle) ? (react_1.default.createElement(CitationEditor, { items: items, saveModel: handleSave, deleteModel: this.deleteNode, modelMap: (0, bibliography_utils_1.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_1.default.createElement(CitationViewer, { items: items, setComment: this.props.setComment, scheduleUpdate: this.props.popper.update }));
90
+ const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
91
+ const component = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.editArticle) ? (react_1.default.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_1.default.createElement(CitationViewer, { items: items, setComment: this.props.setComment, scheduleUpdate: this.props.popper.update }));
103
92
  renderReactComponent(component, this.popperContainer);
104
93
  this.props.popper.show(this.dom, this.popperContainer, 'right');
105
94
  };
@@ -117,10 +106,10 @@ class CitationEditableView extends citation_1.CitationView {
117
106
  };
118
107
  this.handleRemove = (id) => __awaiter(this, void 0, void 0, function* () {
119
108
  const citation = this.getCitation();
120
- const embeddedCitationItems = citation.embeddedCitationItems.filter((item) => item.bibliographyItem !== id);
121
- if (embeddedCitationItems.length > 0) {
122
- citation.embeddedCitationItems = embeddedCitationItems;
123
- this.updateInlineNode(citation);
109
+ const items = citation.embeddedCitationItems.filter((i) => i.bibliographyItem !== id);
110
+ if (items.length > 0) {
111
+ citation.embeddedCitationItems = items;
112
+ this.updateNode(citation);
124
113
  window.setTimeout(() => {
125
114
  this.showPopper();
126
115
  }, 100);
@@ -131,9 +120,6 @@ class CitationEditableView extends citation_1.CitationView {
131
120
  tr.delete(pos, pos + 1);
132
121
  this.view.dispatch(tr);
133
122
  }
134
- this.view.dispatch(this.view.state.tr.setMeta(bibliography_1.bibliographyKey, {
135
- bibliographyInserted: true,
136
- }));
137
123
  this.props.popper.destroy();
138
124
  });
139
125
  this.updatePopper = () => {
@@ -143,46 +129,43 @@ class CitationEditableView extends citation_1.CitationView {
143
129
  }, 100);
144
130
  };
145
131
  this.handleCite = (items) => __awaiter(this, void 0, void 0, function* () {
132
+ const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
146
133
  const citation = this.getCitation();
147
- let triggerUpdate = false;
148
134
  for (const item of items) {
149
- const existingItem = (0, library_1.matchLibraryItemByIdentifier)(item, (0, bibliography_utils_1.getReferencesModelMap)(this.view.state.doc));
135
+ const existingItem = (0, library_1.findMatchingBibliographyItem)(item, bib.bibliographyItems);
150
136
  if (existingItem) {
151
137
  item._id = existingItem._id;
152
138
  }
153
139
  else {
154
- triggerUpdate = true;
155
- yield this.insertBibliographyNode(this.view, item);
140
+ this.insertBibliographyNode(this.view, item);
156
141
  }
157
- citation.embeddedCitationItems.push((0, transform_1.buildEmbeddedCitationItem)(item._id));
158
- }
159
- this.updateInlineNode(citation);
160
- if (triggerUpdate) {
161
- this.view.dispatch(this.view.state.tr.setMeta(bibliography_1.bibliographyKey, {
162
- bibliographyInserted: true,
163
- }));
142
+ citation.embeddedCitationItems.push({
143
+ _id: '_',
144
+ objectType: json_schema_1.ObjectTypes.CitationItem,
145
+ bibliographyItem: item._id,
146
+ });
164
147
  }
148
+ this.updateNode(citation);
165
149
  this.handleClose();
166
150
  });
167
151
  this.importItems = (items) => __awaiter(this, void 0, void 0, function* () {
152
+ const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
168
153
  const newItems = [];
169
154
  for (const item of items) {
170
- const existingItem = (0, library_1.matchLibraryItemByIdentifier)(item, (0, bibliography_utils_1.getReferencesModelMap)(this.view.state.doc));
155
+ const existingItem = (0, library_1.findMatchingBibliographyItem)(item, bib.bibliographyItems);
171
156
  if (!existingItem) {
172
- yield this.insertBibliographyNode(this.view, item);
157
+ this.insertBibliographyNode(this.view, item);
173
158
  newItems.push(item);
174
159
  }
175
160
  }
176
161
  return newItems;
177
162
  });
178
- this.updateInlineNode = (citation) => {
163
+ this.updateNode = (citation) => {
164
+ const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
179
165
  const { tr } = this.view.state;
180
166
  this.view.dispatch(tr.setNodeMarkup(this.getPos(), undefined, {
181
- rid: citation._id,
182
- embeddedCitationItems: citation.embeddedCitationItems.map((item) => ({
183
- id: item._id,
184
- bibliographyItem: item.bibliographyItem,
185
- })),
167
+ id: citation._id,
168
+ rids,
186
169
  }));
187
170
  };
188
171
  }
@@ -204,9 +187,7 @@ class CitationEditableView extends citation_1.CitationView {
204
187
  newTr = tr.insert(pos + 1, bibItem);
205
188
  }
206
189
  else {
207
- newTr = tr
208
- .insert(tr.doc.content.size, createBibliographySection(bibItem))
209
- .setMeta(bibliography_1.bibliographyKey, { bibliographyInserted: true });
190
+ newTr = tr.insert(tr.doc.content.size, createBibliographySection(bibItem));
210
191
  }
211
192
  view.dispatch(newTr);
212
193
  return false;
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ContributorsSectionView = void 0;
6
+ exports.ContributorsView = void 0;
7
7
  const base_node_view_1 = require("./base_node_view");
8
8
  const creators_1 = require("./creators");
9
9
  const ReactSubView_1 = __importDefault(require("./ReactSubView"));
10
- class ContributorsSectionView extends base_node_view_1.BaseNodeView {
10
+ class ContributorsView extends base_node_view_1.BaseNodeView {
11
11
  constructor() {
12
12
  super(...arguments);
13
13
  this.initialise = () => {
@@ -31,5 +31,5 @@ class ContributorsSectionView extends base_node_view_1.BaseNodeView {
31
31
  this.stopEvent = () => true;
32
32
  }
33
33
  }
34
- exports.ContributorsSectionView = ContributorsSectionView;
35
- exports.default = (0, creators_1.createNodeView)(ContributorsSectionView);
34
+ exports.ContributorsView = ContributorsView;
35
+ exports.default = (0, creators_1.createNodeView)(ContributorsView);
@@ -14,14 +14,9 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
18
  exports.CrossReferenceView = void 0;
22
- const react_1 = __importDefault(require("react"));
23
19
  const track_changes_utils_1 = require("../lib/track-changes-utils");
24
- const objects_1 = require("../plugins/objects");
25
20
  const base_node_view_1 = require("./base_node_view");
26
21
  const creators_1 = require("./creators");
27
22
  class CrossReferenceView extends base_node_view_1.BaseNodeView {
@@ -30,38 +25,15 @@ class CrossReferenceView extends base_node_view_1.BaseNodeView {
30
25
  this.selectNode = () => {
31
26
  };
32
27
  this.handleClick = () => {
33
- const auxiliaryObjectReference = this.getAuxiliaryObjectReference(this.node.attrs.rid);
34
- if (auxiliaryObjectReference) {
35
- if (auxiliaryObjectReference.referencedObjects) {
36
- this.showPopper(auxiliaryObjectReference.referencedObjects);
37
- }
38
- else {
39
- this.props.history.push({
40
- pathname: this.props.history.location.pathname,
41
- hash: '#' + auxiliaryObjectReference.referencedObject,
42
- });
43
- }
28
+ const xref = this.node;
29
+ const rids = xref.attrs.rids;
30
+ if (!rids.length) {
31
+ return;
44
32
  }
45
- };
46
- this.showPopper = (referencedObjects) => {
47
- const { components: { ReferencesViewer }, renderReactComponent, } = this.props;
48
- if (!this.popperContainer) {
49
- this.popperContainer = document.createElement('div');
50
- this.popperContainer.className = 'citation-references';
51
- }
52
- const targets = objects_1.objectsKey.getState(this.view.state);
53
- const items = [];
54
- referencedObjects.map((referencedObject) => {
55
- const target = targets.get(referencedObject);
56
- if (target && target.label) {
57
- items.push({
58
- label: target.label,
59
- referencedObject,
60
- });
61
- }
33
+ this.props.history.push({
34
+ pathname: this.props.history.location.pathname,
35
+ hash: '#' + rids[0],
62
36
  });
63
- renderReactComponent(react_1.default.createElement(ReferencesViewer, { items: items, history: this.props.history }), this.popperContainer);
64
- this.props.popper.show(this.dom, this.popperContainer, 'right');
65
37
  };
66
38
  this.updateContents = () => {
67
39
  const nodeClasses = ['cross-reference', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
@@ -74,7 +46,6 @@ class CrossReferenceView extends base_node_view_1.BaseNodeView {
74
46
  this.updateContents();
75
47
  };
76
48
  this.ignoreMutation = () => true;
77
- this.getAuxiliaryObjectReference = (id) => this.props.getModelMap().get(id);
78
49
  this.createDOM = () => {
79
50
  this.dom = document.createElement('span');
80
51
  this.dom.className = 'cross-reference';
@@ -29,7 +29,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.CrossReferenceEditableView = void 0;
31
31
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
32
- const transform_1 = require("@manuscripts/transform");
33
32
  const prosemirror_state_1 = require("prosemirror-state");
34
33
  const react_1 = __importDefault(require("react"));
35
34
  const CrossReferenceItems_1 = require("../components/views/CrossReferenceItems");
@@ -41,21 +40,17 @@ class CrossReferenceEditableView extends cross_reference_1.CrossReferenceView {
41
40
  super(...arguments);
42
41
  this.selectNode = () => {
43
42
  const { getCapabilities, renderReactComponent } = this.props;
43
+ const xref = this.node;
44
+ const rids = xref.attrs.rids;
44
45
  const can = getCapabilities();
45
- const { rid } = this.node.attrs;
46
- const auxiliaryObjectReference = rid
47
- ? this.getAuxiliaryObjectReference(rid)
48
- : null;
49
- if (!(can === null || can === void 0 ? void 0 : can.editArticle) ||
50
- (auxiliaryObjectReference === null || auxiliaryObjectReference === void 0 ? void 0 : auxiliaryObjectReference.referencedObject) ||
51
- (auxiliaryObjectReference === null || auxiliaryObjectReference === void 0 ? void 0 : auxiliaryObjectReference.referencedObjects)) {
46
+ if (!(can === null || can === void 0 ? void 0 : can.editArticle) || rids.length) {
52
47
  return;
53
48
  }
54
49
  if (!this.popperContainer) {
55
50
  this.popperContainer = document.createElement('div');
56
51
  this.popperContainer.className = 'cross-reference-editor';
57
52
  }
58
- renderReactComponent(react_1.default.createElement(CrossReferenceItems_1.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);
53
+ renderReactComponent(react_1.default.createElement(CrossReferenceItems_1.CrossReferenceItems, { handleSelect: this.handleSelect, targets: this.getTargets(), handleCancel: this.handleCancel, currentTargetId: rids[0], currentCustomLabel: this.node.attrs.customLabel }), this.popperContainer);
59
54
  this.props.popper.show(this.dom, this.popperContainer, 'right');
60
55
  };
61
56
  this.destroy = () => {
@@ -72,7 +67,7 @@ class CrossReferenceEditableView extends cross_reference_1.CrossReferenceView {
72
67
  return Array.from(targets.values());
73
68
  };
74
69
  this.handleCancel = () => {
75
- if (!this.node.attrs.rid) {
70
+ if (!this.node.attrs.rids.length) {
76
71
  const { state } = this.view;
77
72
  const pos = this.getPos();
78
73
  const tr = state.tr.delete(pos, pos + this.node.nodeSize);
@@ -87,10 +82,7 @@ class CrossReferenceEditableView extends cross_reference_1.CrossReferenceView {
87
82
  this.handleSelect = (rid, customLabel) => __awaiter(this, void 0, void 0, function* () {
88
83
  const { state } = this.view;
89
84
  const pos = this.getPos();
90
- const $pos = state.doc.resolve(pos);
91
- const rids = rid.trim().split(/\s+/);
92
- const auxiliaryObjectReference = (0, transform_1.buildAuxiliaryObjectReference)($pos.parent.attrs.id, rids);
93
- const tr = state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { customLabel: customLabel || '', rid: auxiliaryObjectReference._id }));
85
+ const tr = state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { customLabel: customLabel || '', rids: [rid] }));
94
86
  const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos);
95
87
  this.view.dispatch(tr.setSelection(selection));
96
88
  this.destroy();
@@ -71,8 +71,8 @@ const EditableBlock = (Base) => {
71
71
  this.createAddButton = (after) => {
72
72
  var _a;
73
73
  const $pos = this.view.state.doc.resolve(this.getPos());
74
- if (!((_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle) ||
75
- $pos.parent.type === this.node.type.schema.nodes.keywords_section) {
74
+ const hasAccess = (_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle;
75
+ if (!hasAccess || $pos.parent.type === transform_1.schema.nodes.keywords) {
76
76
  return null;
77
77
  }
78
78
  const button = document.createElement('a');
@@ -15,9 +15,9 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.default = () => {
19
- const dom = document.createElement('section');
20
- dom.setAttribute('data-type', 'meta');
18
+ exports.default = (type) => () => {
19
+ const dom = document.createElement('div');
20
+ dom.setAttribute('data-type', type);
21
21
  dom.setAttribute('contenteditable', 'false');
22
22
  dom.style.display = 'inline';
23
23
  return { dom };
@@ -18,31 +18,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.SectionTitleView = exports.isSpecialSection = void 0;
22
- const transform_1 = require("@manuscripts/transform");
21
+ exports.SectionTitleView = void 0;
23
22
  const context_menu_1 = require("../lib/context-menu");
24
23
  const block_view_1 = __importDefault(require("./block_view"));
25
24
  const creators_1 = require("./creators");
26
- const isSpecialSection = (node) => {
27
- if ((0, transform_1.isSectionNode)(node)) {
28
- const { attrs } = node;
29
- return (attrs.category === 'MPSectionCategory:abstracts' ||
30
- attrs.category === 'MPSectionCategory:body' ||
31
- attrs.category === 'MPSectionCategory:backmatter');
32
- }
33
- };
34
- exports.isSpecialSection = isSpecialSection;
35
25
  class SectionTitleView extends block_view_1.default {
36
26
  constructor() {
37
27
  super(...arguments);
38
28
  this.elementType = 'h1';
39
29
  this.updateContents = () => {
40
30
  const $pos = this.view.state.doc.resolve(this.getPos());
41
- if ((0, exports.isSpecialSection)($pos.parent)) {
42
- this.dom = document.createElement('div');
43
- this.dom.classList.add('no-title');
44
- return;
45
- }
46
31
  if (this.node.childCount) {
47
32
  this.contentDOM.classList.remove('empty-node');
48
33
  }