@manuscripts/transform 2.3.15 → 2.3.17

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.
@@ -594,7 +594,7 @@ class JATSExporter {
594
594
  this.createSerializer = () => {
595
595
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
596
596
  const nodes = {
597
- author_notes: () => ['author-notes', 0],
597
+ author_notes: () => '',
598
598
  corresp: () => '',
599
599
  title: () => '',
600
600
  affiliations: () => '',
@@ -150,6 +150,8 @@ __exportStar(require("./nodes/affiliations"), exports);
150
150
  __exportStar(require("./nodes/contributors"), exports);
151
151
  __exportStar(require("./nodes/supplement"), exports);
152
152
  __exportStar(require("./nodes/supplements"), exports);
153
+ __exportStar(require("./nodes/corresp"), exports);
154
+ __exportStar(require("./nodes/author_notes"), exports);
153
155
  exports.schema = new prosemirror_model_1.Schema({
154
156
  marks: {
155
157
  bold: marks_1.bold,
@@ -21,7 +21,14 @@ exports.authorNotes = {
21
21
  id: { default: '' },
22
22
  dataTracked: { default: null },
23
23
  },
24
- content: '(corresp | footnote | paragraph)+',
24
+ content: 'section_title (corresp | footnote | paragraph)+',
25
25
  group: 'block element',
26
- toDOM: () => ['author-notes', 0],
26
+ toDOM: (node) => [
27
+ 'div',
28
+ {
29
+ class: 'author-notes',
30
+ id: node.attrs.id,
31
+ },
32
+ 0,
33
+ ],
27
34
  };
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.contributors = void 0;
19
19
  exports.contributors = {
20
- content: 'contributor* author_notes?',
20
+ content: 'contributor*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.corresp = void 0;
3
+ exports.isCorrespNode = exports.corresp = void 0;
4
4
  exports.corresp = {
5
5
  content: 'inline*',
6
6
  attrs: {
@@ -9,5 +9,16 @@ exports.corresp = {
9
9
  dataTracked: { default: null },
10
10
  },
11
11
  group: 'block',
12
- toDOM: () => ['corresp', 0],
12
+ toDOM: (node) => {
13
+ return [
14
+ 'div',
15
+ {
16
+ class: 'corresp',
17
+ id: node.attrs.id,
18
+ },
19
+ 0,
20
+ ];
21
+ },
13
22
  };
23
+ const isCorrespNode = (node) => node.type === node.type.schema.nodes.corresp;
24
+ exports.isCorrespNode = isCorrespNode;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isManuscriptNode = exports.manuscript = void 0;
19
19
  exports.manuscript = {
20
- content: 'title? contributors? affiliations? keywords? supplements? abstracts body backmatter comments',
20
+ content: 'title? contributors? affiliations? author_notes? keywords? supplements? abstracts body backmatter comments',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  doi: { default: '' },
@@ -63,8 +63,8 @@ const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(
63
63
  exports.sortSectionsByPriority = sortSectionsByPriority;
64
64
  const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
65
65
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
66
- const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
67
66
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
67
+ const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
68
68
  const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
69
69
  const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
70
70
  const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
@@ -96,15 +96,17 @@ class Decoder {
96
96
  const contributors = getContributors(this.modelMap)
97
97
  .map((c) => this.decode(c))
98
98
  .filter(Boolean);
99
- const authorNotes = getAuthorNotes(this.modelMap)
100
- .map((authorNote) => this.decode(authorNote))
101
- .filter(Boolean);
102
- const content = [...contributors, ...authorNotes];
99
+ const content = [...contributors];
103
100
  if (!content.length) {
104
101
  return false;
105
102
  }
106
103
  return schema_1.schema.nodes.contributors.createAndFill({}, content);
107
104
  }
105
+ createAuthorNotesNode() {
106
+ return getAuthorNotes(this.modelMap)
107
+ .map((authorNote) => this.decode(authorNote))
108
+ .filter(Boolean);
109
+ }
108
110
  createKeywordsNode() {
109
111
  const elements = getKeywordElements(this.modelMap)
110
112
  .map((e) => this.decode(e))
@@ -529,9 +531,12 @@ class Decoder {
529
531
  [json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
530
532
  const model = data;
531
533
  const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
532
- return schema_1.schema.nodes.author_notes.create({
534
+ return schema_1.schema.nodes.author_notes.createAndFill({
533
535
  id: model._id,
534
- }, content);
536
+ }, [
537
+ schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Correspondence')),
538
+ ...content,
539
+ ]);
535
540
  },
536
541
  [json_schema_1.ObjectTypes.Corresponding]: (data) => {
537
542
  const model = data;
@@ -728,6 +733,7 @@ class Decoder {
728
733
  this.createTitleNode(),
729
734
  this.createContributorsNode(),
730
735
  this.createAffiliationsNode(),
736
+ ...this.createAuthorNotesNode(),
731
737
  this.createKeywordsNode(),
732
738
  this.createSupplementsNode(),
733
739
  ...this.createContentSections(),
@@ -206,6 +206,16 @@ const containedParagraphIDs = (node) => {
206
206
  const paragraphNodeType = node.type.schema.nodes.paragraph;
207
207
  return containedObjectIDs(node, [paragraphNodeType]);
208
208
  };
209
+ const containedAuthorNotesIDs = (node) => {
210
+ const correspNodeType = node.type.schema.nodes.corresp;
211
+ const footnoteNodetype = node.type.schema.nodes.footnote;
212
+ const paragraphNodeType = node.type.schema.nodes.paragraph;
213
+ return containedObjectIDs(node, [
214
+ correspNodeType,
215
+ footnoteNodetype,
216
+ paragraphNodeType,
217
+ ]);
218
+ };
209
219
  const containedBibliographyItemIDs = (node) => {
210
220
  const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
211
221
  return containedObjectIDs(node, [bibliographyItemNodeType]);
@@ -398,7 +408,7 @@ const encoders = {
398
408
  containedObjectIDs: tableElementFooterContainedIDs(node),
399
409
  }),
400
410
  author_notes: (node) => ({
401
- containedObjectIDs: containedObjectIDs(node),
411
+ containedObjectIDs: containedAuthorNotesIDs(node),
402
412
  }),
403
413
  footnotes_section: (node, parent, path, priority) => ({
404
414
  category: (0, section_category_1.buildSectionCategory)(node),
@@ -559,7 +569,6 @@ exports.modelFromNode = modelFromNode;
559
569
  const containerTypes = [
560
570
  schema_1.schema.nodes.affiliations,
561
571
  schema_1.schema.nodes.contributors,
562
- schema_1.schema.nodes.affiliations,
563
572
  schema_1.schema.nodes.keywords,
564
573
  schema_1.schema.nodes.supplements,
565
574
  schema_1.schema.nodes.abstracts,
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "2.3.15";
4
+ exports.VERSION = "2.3.17";
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import mime from 'mime';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
- import { schema, } from '../../schema';
18
+ import { schema } from '../../schema';
19
19
  import { chooseSectionCategory } from '../../transformer';
20
20
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
21
21
  const chooseContentType = (graphicNode) => {
@@ -586,7 +586,7 @@ export class JATSExporter {
586
586
  this.createSerializer = () => {
587
587
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
588
588
  const nodes = {
589
- author_notes: () => ['author-notes', 0],
589
+ author_notes: () => '',
590
590
  corresp: () => '',
591
591
  title: () => '',
592
592
  affiliations: () => '',
@@ -133,6 +133,8 @@ export * from './nodes/affiliations';
133
133
  export * from './nodes/contributors';
134
134
  export * from './nodes/supplement';
135
135
  export * from './nodes/supplements';
136
+ export * from './nodes/corresp';
137
+ export * from './nodes/author_notes';
136
138
  export const schema = new Schema({
137
139
  marks: {
138
140
  bold,
@@ -18,7 +18,14 @@ export const authorNotes = {
18
18
  id: { default: '' },
19
19
  dataTracked: { default: null },
20
20
  },
21
- content: '(corresp | footnote | paragraph)+',
21
+ content: 'section_title (corresp | footnote | paragraph)+',
22
22
  group: 'block element',
23
- toDOM: () => ['author-notes', 0],
23
+ toDOM: (node) => [
24
+ 'div',
25
+ {
26
+ class: 'author-notes',
27
+ id: node.attrs.id,
28
+ },
29
+ 0,
30
+ ],
24
31
  };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const contributors = {
17
- content: 'contributor* author_notes?',
17
+ content: 'contributor*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -6,5 +6,15 @@ export const corresp = {
6
6
  dataTracked: { default: null },
7
7
  },
8
8
  group: 'block',
9
- toDOM: () => ['corresp', 0],
9
+ toDOM: (node) => {
10
+ return [
11
+ 'div',
12
+ {
13
+ class: 'corresp',
14
+ id: node.attrs.id,
15
+ },
16
+ 0,
17
+ ];
18
+ },
10
19
  };
20
+ export const isCorrespNode = (node) => node.type === node.type.schema.nodes.corresp;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const manuscript = {
17
- content: 'title? contributors? affiliations? keywords? supplements? abstracts body backmatter comments',
17
+ content: 'title? contributors? affiliations? author_notes? keywords? supplements? abstracts body backmatter comments',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  doi: { default: '' },
@@ -54,8 +54,8 @@ export const getModelsByType = (modelMap, objectType) => {
54
54
  export const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(a.priority) - Number(b.priority);
55
55
  const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section).sort(sortSectionsByPriority);
56
56
  const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
57
- const getAuthorNotes = (modelMap) => getModelsByType(modelMap, ObjectTypes.AuthorNotes);
58
57
  const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
58
+ const getAuthorNotes = (modelMap) => getModelsByType(modelMap, ObjectTypes.AuthorNotes);
59
59
  const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
60
60
  const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
61
61
  const getKeywordGroups = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordGroup);
@@ -87,15 +87,17 @@ export class Decoder {
87
87
  const contributors = getContributors(this.modelMap)
88
88
  .map((c) => this.decode(c))
89
89
  .filter(Boolean);
90
- const authorNotes = getAuthorNotes(this.modelMap)
91
- .map((authorNote) => this.decode(authorNote))
92
- .filter(Boolean);
93
- const content = [...contributors, ...authorNotes];
90
+ const content = [...contributors];
94
91
  if (!content.length) {
95
92
  return false;
96
93
  }
97
94
  return schema.nodes.contributors.createAndFill({}, content);
98
95
  }
96
+ createAuthorNotesNode() {
97
+ return getAuthorNotes(this.modelMap)
98
+ .map((authorNote) => this.decode(authorNote))
99
+ .filter(Boolean);
100
+ }
99
101
  createKeywordsNode() {
100
102
  const elements = getKeywordElements(this.modelMap)
101
103
  .map((e) => this.decode(e))
@@ -520,9 +522,12 @@ export class Decoder {
520
522
  [ObjectTypes.AuthorNotes]: (data) => {
521
523
  const model = data;
522
524
  const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
523
- return schema.nodes.author_notes.create({
525
+ return schema.nodes.author_notes.createAndFill({
524
526
  id: model._id,
525
- }, content);
527
+ }, [
528
+ schema.nodes.section_title.create({}, schema.text('Correspondence')),
529
+ ...content,
530
+ ]);
526
531
  },
527
532
  [ObjectTypes.Corresponding]: (data) => {
528
533
  const model = data;
@@ -719,6 +724,7 @@ export class Decoder {
719
724
  this.createTitleNode(),
720
725
  this.createContributorsNode(),
721
726
  this.createAffiliationsNode(),
727
+ ...this.createAuthorNotesNode(),
722
728
  this.createKeywordsNode(),
723
729
  this.createSupplementsNode(),
724
730
  ...this.createContentSections(),
@@ -198,6 +198,16 @@ const containedParagraphIDs = (node) => {
198
198
  const paragraphNodeType = node.type.schema.nodes.paragraph;
199
199
  return containedObjectIDs(node, [paragraphNodeType]);
200
200
  };
201
+ const containedAuthorNotesIDs = (node) => {
202
+ const correspNodeType = node.type.schema.nodes.corresp;
203
+ const footnoteNodetype = node.type.schema.nodes.footnote;
204
+ const paragraphNodeType = node.type.schema.nodes.paragraph;
205
+ return containedObjectIDs(node, [
206
+ correspNodeType,
207
+ footnoteNodetype,
208
+ paragraphNodeType,
209
+ ]);
210
+ };
201
211
  const containedBibliographyItemIDs = (node) => {
202
212
  const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
203
213
  return containedObjectIDs(node, [bibliographyItemNodeType]);
@@ -390,7 +400,7 @@ const encoders = {
390
400
  containedObjectIDs: tableElementFooterContainedIDs(node),
391
401
  }),
392
402
  author_notes: (node) => ({
393
- containedObjectIDs: containedObjectIDs(node),
403
+ containedObjectIDs: containedAuthorNotesIDs(node),
394
404
  }),
395
405
  footnotes_section: (node, parent, path, priority) => ({
396
406
  category: buildSectionCategory(node),
@@ -550,7 +560,6 @@ export const modelFromNode = (node, parent, path, priority) => {
550
560
  const containerTypes = [
551
561
  schema.nodes.affiliations,
552
562
  schema.nodes.contributors,
553
- schema.nodes.affiliations,
554
563
  schema.nodes.keywords,
555
564
  schema.nodes.supplements,
556
565
  schema.nodes.abstracts,
@@ -1 +1 @@
1
- export const VERSION = "2.3.15";
1
+ export const VERSION = "2.3.17";
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const TABLE_CELL_STYLES: readonly ["backgroundColor", "border-top", "border-right", "border-bottom", "border-left", "verticalAlign", "textAlign"];
17
- export type TableCellStyleKey = (typeof TABLE_CELL_STYLES)[number];
17
+ export type TableCellStyleKey = typeof TABLE_CELL_STYLES[number];
18
18
  export declare const serializeTableCellStyles: (styles: {
19
19
  backgroundColor?: string | null | undefined;
20
20
  "border-top"?: string | null | undefined;
@@ -71,4 +71,6 @@ export * from './nodes/affiliations';
71
71
  export * from './nodes/contributors';
72
72
  export * from './nodes/supplement';
73
73
  export * from './nodes/supplements';
74
+ export * from './nodes/corresp';
75
+ export * from './nodes/author_notes';
74
76
  export declare const schema: Schema<Nodes, Marks>;
@@ -8,4 +8,5 @@ export interface CorrespNode extends ManuscriptNode {
8
8
  attrs: Attrs;
9
9
  }
10
10
  export declare const corresp: NodeSpec;
11
+ export declare const isCorrespNode: (node: ManuscriptNode) => node is CorrespNode;
11
12
  export {};
@@ -27,6 +27,7 @@ export declare class Decoder {
27
27
  private createTitleNode;
28
28
  private createAffiliationsNode;
29
29
  private createContributorsNode;
30
+ private createAuthorNotesNode;
30
31
  private createKeywordsNode;
31
32
  private createSupplementsNode;
32
33
  private createCommentsNode;
@@ -1 +1 @@
1
- export declare const VERSION = "2.3.15";
1
+ export declare const VERSION = "2.3.17";
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.3.15",
4
+ "version": "2.3.17",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",