@manuscripts/transform 2.1.12-LEAN-CORRESP-0 → 2.1.12-LEAN-2746-1

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.
@@ -201,7 +201,6 @@ exports.jatsFrontParser = {
201
201
  ]);
202
202
  const authorNotes = [
203
203
  (0, transformer_1.buildAuthorNotes)([
204
- ...correspondingIDs.values(),
205
204
  ...footnoteIDs.values(),
206
205
  ...authorNotesParagraphs.map((p) => p._id),
207
206
  ]),
@@ -617,7 +617,6 @@ class JATSExporter {
617
617
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
618
618
  const nodes = {
619
619
  author_notes: () => ['author-notes', 0],
620
- corresp: () => '',
621
620
  title: () => '',
622
621
  affiliations: () => '',
623
622
  contributors: () => '',
@@ -1048,6 +1047,7 @@ class JATSExporter {
1048
1047
  }
1049
1048
  };
1050
1049
  this.buildContributors = (articleMeta) => {
1050
+ var _a;
1051
1051
  const contributors = this.models.filter(isContributor);
1052
1052
  const authorContributors = contributors
1053
1053
  .filter((contributor) => contributor.role === 'author')
@@ -1266,21 +1266,34 @@ class JATSExporter {
1266
1266
  }
1267
1267
  });
1268
1268
  }
1269
- const authorNotesEl = this.createAuthorNotesElement();
1269
+ const authorNotesEl = this.document.createElement('author-notes');
1270
+ const usedCorrespodings = this.getUsedCorrespondings([
1271
+ ...authorContributors,
1272
+ ...otherContributors,
1273
+ ]);
1274
+ usedCorrespodings.forEach((corresp) => {
1275
+ this.appendCorrespondingToElement(corresp, authorNotesEl);
1276
+ });
1277
+ const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1278
+ if (authorNotes) {
1279
+ authorNotes.containedObjectIDs.forEach((id) => {
1280
+ const model = this.modelMap.get(id);
1281
+ if (!model) {
1282
+ return;
1283
+ }
1284
+ if (id.startsWith('MPParagraphElement')) {
1285
+ this.appendParagraphToElement(model, authorNotesEl);
1286
+ }
1287
+ else if (id.startsWith('MPFootnote')) {
1288
+ this.appendFootnoteToElement(model, authorNotesEl);
1289
+ }
1290
+ });
1291
+ }
1270
1292
  if (authorNotesEl.childNodes.length > 0) {
1271
1293
  articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
1272
1294
  }
1273
1295
  }
1274
1296
  };
1275
- this.createAuthorNotesElement = () => {
1276
- var _a;
1277
- const authorNotesEl = this.document.createElement('author-notes');
1278
- const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1279
- if (authorNotes) {
1280
- this.appendModelsToAuthorNotes(authorNotesEl, authorNotes.containedObjectIDs);
1281
- }
1282
- return authorNotesEl;
1283
- };
1284
1297
  this.appendCorrespondingToElement = (corresponding, element) => {
1285
1298
  const correspondingEl = this.document.createElement('corresp');
1286
1299
  correspondingEl.setAttribute('id', normalizeID(corresponding._id));
@@ -1610,29 +1623,6 @@ class JATSExporter {
1610
1623
  return mathml;
1611
1624
  }
1612
1625
  }
1613
- appendModelsToAuthorNotes(authorNotesEl, containedObjectIDs) {
1614
- const contributors = this.models.filter(isContributor);
1615
- const usedCorrespondings = this.getUsedCorrespondings(contributors);
1616
- containedObjectIDs.forEach((id) => {
1617
- const model = this.modelMap.get(id);
1618
- if (!model) {
1619
- return;
1620
- }
1621
- switch (model.objectType) {
1622
- case json_schema_1.ObjectTypes.ParagraphElement:
1623
- this.appendParagraphToElement(model, authorNotesEl);
1624
- break;
1625
- case json_schema_1.ObjectTypes.Footnote:
1626
- this.appendFootnoteToElement(model, authorNotesEl);
1627
- break;
1628
- case json_schema_1.ObjectTypes.Corresponding:
1629
- if (usedCorrespondings.includes(model)) {
1630
- this.appendCorrespondingToElement(model, authorNotesEl);
1631
- }
1632
- break;
1633
- }
1634
- });
1635
- }
1636
1626
  getUsedCorrespondings(contributors) {
1637
1627
  return contributors
1638
1628
  .flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
@@ -50,7 +50,6 @@ const comment_1 = require("./nodes/comment");
50
50
  const comments_1 = require("./nodes/comments");
51
51
  const contributor_1 = require("./nodes/contributor");
52
52
  const contributors_1 = require("./nodes/contributors");
53
- const corresp_1 = require("./nodes/corresp");
54
53
  const cross_reference_1 = require("./nodes/cross_reference");
55
54
  const doc_1 = require("./nodes/doc");
56
55
  const equation_1 = require("./nodes/equation");
@@ -230,6 +229,5 @@ exports.schema = new prosemirror_model_1.Schema({
230
229
  supplements: supplements_1.supplements,
231
230
  supplement: supplement_1.supplement,
232
231
  author_notes: author_notes_1.authorNotes,
233
- corresp: corresp_1.corresp,
234
232
  },
235
233
  });
@@ -21,7 +21,7 @@ exports.authorNotes = {
21
21
  id: { default: '' },
22
22
  dataTracked: { default: null },
23
23
  },
24
- content: '(corresp | footnote | paragraph)+',
24
+ content: '(footnote | paragraph)+',
25
25
  group: 'block element',
26
26
  toDOM: () => ['author-notes', 0],
27
27
  };
@@ -43,7 +43,7 @@ exports.inlineFootnote = {
43
43
  const footnoteNode = node;
44
44
  const dom = document.createElement('span');
45
45
  dom.className = 'footnote';
46
- dom.setAttribute('data-reference-id', footnoteNode.attrs.rids.join(''));
46
+ dom.setAttribute('data-reference-id', footnoteNode.attrs.rids.join(' '));
47
47
  dom.textContent = footnoteNode.attrs.contents;
48
48
  return dom;
49
49
  },
@@ -17,8 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.title = void 0;
19
19
  exports.title = {
20
- content: 'text*',
21
- marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
20
+ content: 'inline*',
22
21
  attrs: {
23
22
  id: { default: '' },
24
23
  dataTracked: { default: null },
@@ -169,7 +169,9 @@ class Decoder {
169
169
  this.creators = {
170
170
  [json_schema_1.ObjectTypes.Titles]: (data) => {
171
171
  const model = data;
172
- return this.parseContents(model.title, 'div', undefined, {
172
+ const comments = this.createCommentNodes(model);
173
+ comments.forEach((c) => this.comments.set(c.attrs.id, c));
174
+ return this.parseContents(model.title, 'div', this.getComments(model), {
173
175
  topNode: schema_1.schema.nodes.title.create({
174
176
  id: model._id,
175
177
  }),
@@ -502,15 +504,6 @@ class Decoder {
502
504
  id: model._id,
503
505
  }, content);
504
506
  },
505
- [json_schema_1.ObjectTypes.Corresponding]: (data) => {
506
- const model = data;
507
- return this.parseContents(model.contents, 'corresp', [], {
508
- topNode: schema_1.schema.nodes.corresp.create({
509
- id: model._id,
510
- label: model.label,
511
- }),
512
- });
513
- },
514
507
  [json_schema_1.ObjectTypes.Section]: (data) => {
515
508
  const model = data;
516
509
  const elements = [];
@@ -522,10 +522,6 @@ const encoders = {
522
522
  ? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
523
523
  : '',
524
524
  }),
525
- corresp: (node) => ({
526
- contents: (0, exports.inlineContents)(node),
527
- label: node.attrs.label,
528
- }),
529
525
  };
530
526
  const modelData = (node, parent, path, priority) => {
531
527
  const encoder = encoders[node.type.name];
@@ -62,7 +62,6 @@ exports.nodeTypesMap = new Map([
62
62
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
63
63
  [schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
64
64
  [schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
65
- [schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
66
65
  ]);
67
66
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
68
67
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -195,7 +195,6 @@ export const jatsFrontParser = {
195
195
  ]);
196
196
  const authorNotes = [
197
197
  buildAuthorNotes([
198
- ...correspondingIDs.values(),
199
198
  ...footnoteIDs.values(),
200
199
  ...authorNotesParagraphs.map((p) => p._id),
201
200
  ]),
@@ -609,7 +609,6 @@ export class JATSExporter {
609
609
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
610
610
  const nodes = {
611
611
  author_notes: () => ['author-notes', 0],
612
- corresp: () => '',
613
612
  title: () => '',
614
613
  affiliations: () => '',
615
614
  contributors: () => '',
@@ -1040,6 +1039,7 @@ export class JATSExporter {
1040
1039
  }
1041
1040
  };
1042
1041
  this.buildContributors = (articleMeta) => {
1042
+ var _a;
1043
1043
  const contributors = this.models.filter(isContributor);
1044
1044
  const authorContributors = contributors
1045
1045
  .filter((contributor) => contributor.role === 'author')
@@ -1258,21 +1258,34 @@ export class JATSExporter {
1258
1258
  }
1259
1259
  });
1260
1260
  }
1261
- const authorNotesEl = this.createAuthorNotesElement();
1261
+ const authorNotesEl = this.document.createElement('author-notes');
1262
+ const usedCorrespodings = this.getUsedCorrespondings([
1263
+ ...authorContributors,
1264
+ ...otherContributors,
1265
+ ]);
1266
+ usedCorrespodings.forEach((corresp) => {
1267
+ this.appendCorrespondingToElement(corresp, authorNotesEl);
1268
+ });
1269
+ const authorNotes = (_a = getModelsByType(this.modelMap, ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1270
+ if (authorNotes) {
1271
+ authorNotes.containedObjectIDs.forEach((id) => {
1272
+ const model = this.modelMap.get(id);
1273
+ if (!model) {
1274
+ return;
1275
+ }
1276
+ if (id.startsWith('MPParagraphElement')) {
1277
+ this.appendParagraphToElement(model, authorNotesEl);
1278
+ }
1279
+ else if (id.startsWith('MPFootnote')) {
1280
+ this.appendFootnoteToElement(model, authorNotesEl);
1281
+ }
1282
+ });
1283
+ }
1262
1284
  if (authorNotesEl.childNodes.length > 0) {
1263
1285
  articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
1264
1286
  }
1265
1287
  }
1266
1288
  };
1267
- this.createAuthorNotesElement = () => {
1268
- var _a;
1269
- const authorNotesEl = this.document.createElement('author-notes');
1270
- const authorNotes = (_a = getModelsByType(this.modelMap, ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1271
- if (authorNotes) {
1272
- this.appendModelsToAuthorNotes(authorNotesEl, authorNotes.containedObjectIDs);
1273
- }
1274
- return authorNotesEl;
1275
- };
1276
1289
  this.appendCorrespondingToElement = (corresponding, element) => {
1277
1290
  const correspondingEl = this.document.createElement('corresp');
1278
1291
  correspondingEl.setAttribute('id', normalizeID(corresponding._id));
@@ -1602,29 +1615,6 @@ export class JATSExporter {
1602
1615
  return mathml;
1603
1616
  }
1604
1617
  }
1605
- appendModelsToAuthorNotes(authorNotesEl, containedObjectIDs) {
1606
- const contributors = this.models.filter(isContributor);
1607
- const usedCorrespondings = this.getUsedCorrespondings(contributors);
1608
- containedObjectIDs.forEach((id) => {
1609
- const model = this.modelMap.get(id);
1610
- if (!model) {
1611
- return;
1612
- }
1613
- switch (model.objectType) {
1614
- case ObjectTypes.ParagraphElement:
1615
- this.appendParagraphToElement(model, authorNotesEl);
1616
- break;
1617
- case ObjectTypes.Footnote:
1618
- this.appendFootnoteToElement(model, authorNotesEl);
1619
- break;
1620
- case ObjectTypes.Corresponding:
1621
- if (usedCorrespondings.includes(model)) {
1622
- this.appendCorrespondingToElement(model, authorNotesEl);
1623
- }
1624
- break;
1625
- }
1626
- });
1627
- }
1628
1618
  getUsedCorrespondings(contributors) {
1629
1619
  return contributors
1630
1620
  .flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
@@ -33,7 +33,6 @@ import { comment } from './nodes/comment';
33
33
  import { comments } from './nodes/comments';
34
34
  import { contributor } from './nodes/contributor';
35
35
  import { contributors } from './nodes/contributors';
36
- import { corresp } from './nodes/corresp';
37
36
  import { crossReference } from './nodes/cross_reference';
38
37
  import { doc } from './nodes/doc';
39
38
  import { equation } from './nodes/equation';
@@ -213,6 +212,5 @@ export const schema = new Schema({
213
212
  supplements,
214
213
  supplement,
215
214
  author_notes: authorNotes,
216
- corresp,
217
215
  },
218
216
  });
@@ -18,7 +18,7 @@ export const authorNotes = {
18
18
  id: { default: '' },
19
19
  dataTracked: { default: null },
20
20
  },
21
- content: '(corresp | footnote | paragraph)+',
21
+ content: '(footnote | paragraph)+',
22
22
  group: 'block element',
23
23
  toDOM: () => ['author-notes', 0],
24
24
  };
@@ -40,7 +40,7 @@ export const inlineFootnote = {
40
40
  const footnoteNode = node;
41
41
  const dom = document.createElement('span');
42
42
  dom.className = 'footnote';
43
- dom.setAttribute('data-reference-id', footnoteNode.attrs.rids.join(''));
43
+ dom.setAttribute('data-reference-id', footnoteNode.attrs.rids.join(' '));
44
44
  dom.textContent = footnoteNode.attrs.contents;
45
45
  return dom;
46
46
  },
@@ -14,8 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const title = {
17
- content: 'text*',
18
- marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
17
+ content: 'inline*',
19
18
  attrs: {
20
19
  id: { default: '' },
21
20
  dataTracked: { default: null },
@@ -160,7 +160,9 @@ export class Decoder {
160
160
  this.creators = {
161
161
  [ObjectTypes.Titles]: (data) => {
162
162
  const model = data;
163
- return this.parseContents(model.title, 'div', undefined, {
163
+ const comments = this.createCommentNodes(model);
164
+ comments.forEach((c) => this.comments.set(c.attrs.id, c));
165
+ return this.parseContents(model.title, 'div', this.getComments(model), {
164
166
  topNode: schema.nodes.title.create({
165
167
  id: model._id,
166
168
  }),
@@ -493,15 +495,6 @@ export class Decoder {
493
495
  id: model._id,
494
496
  }, content);
495
497
  },
496
- [ObjectTypes.Corresponding]: (data) => {
497
- const model = data;
498
- return this.parseContents(model.contents, 'corresp', [], {
499
- topNode: schema.nodes.corresp.create({
500
- id: model._id,
501
- label: model.label,
502
- }),
503
- });
504
- },
505
498
  [ObjectTypes.Section]: (data) => {
506
499
  const model = data;
507
500
  const elements = [];
@@ -514,10 +514,6 @@ const encoders = {
514
514
  ? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
515
515
  : '',
516
516
  }),
517
- corresp: (node) => ({
518
- contents: inlineContents(node),
519
- label: node.attrs.label,
520
- }),
521
517
  };
522
518
  const modelData = (node, parent, path, priority) => {
523
519
  const encoder = encoders[node.type.name];
@@ -59,7 +59,6 @@ export const nodeTypesMap = new Map([
59
59
  [schema.nodes.title, ObjectTypes.Titles],
60
60
  [schema.nodes.supplement, ObjectTypes.Supplement],
61
61
  [schema.nodes.author_notes, ObjectTypes.AuthorNotes],
62
- [schema.nodes.corresp, ObjectTypes.Corresponding],
63
62
  ]);
64
63
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
65
64
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -87,8 +87,6 @@ export declare class JATSExporter {
87
87
  protected serializeNode: (node: ManuscriptNode) => Node;
88
88
  private validateContributor;
89
89
  private buildContributors;
90
- private createAuthorNotesElement;
91
- private appendModelsToAuthorNotes;
92
90
  private appendCorrespondingToElement;
93
91
  private getUsedCorrespondings;
94
92
  private appendParagraphToElement;
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
17
17
  import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
18
18
  import { EditorView, NodeView } from 'prosemirror-view';
19
19
  export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
20
- export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes' | 'corresp';
20
+ export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'table_header' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'author_notes';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.12-LEAN-CORRESP-0",
4
+ "version": "2.1.12-LEAN-2746-1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.corresp = void 0;
4
- exports.corresp = {
5
- content: 'inline*',
6
- attrs: {
7
- id: { default: '' },
8
- label: { default: undefined },
9
- dataTracked: { default: null },
10
- },
11
- group: 'block',
12
- toDOM: () => ['corresp', 0],
13
- };
@@ -1,10 +0,0 @@
1
- export const corresp = {
2
- content: 'inline*',
3
- attrs: {
4
- id: { default: '' },
5
- label: { default: undefined },
6
- dataTracked: { default: null },
7
- },
8
- group: 'block',
9
- toDOM: () => ['corresp', 0],
10
- };
@@ -1,11 +0,0 @@
1
- import { NodeSpec } from 'prosemirror-model';
2
- import { ManuscriptNode } from '../types';
3
- interface Attrs {
4
- id: string;
5
- label?: string;
6
- }
7
- export interface CorrespNode extends ManuscriptNode {
8
- attrs: Attrs;
9
- }
10
- export declare const corresp: NodeSpec;
11
- export {};