@manuscripts/transform 2.3.7-LEAN-3582.0 → 2.3.7-LEAN-3307.3

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.
@@ -87,13 +87,9 @@ const createBibliographyModels = (references) => {
87
87
  models.push(...comments);
88
88
  return models;
89
89
  };
90
- const clearUnsupportedChars = (input = '') => {
91
- return input.replace(/[\u2028\u2029]/gim, '<break/>');
92
- };
93
90
  const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
94
91
  const generateIDs = (models) => models.map((m) => m._id ? m : Object.assign(Object.assign({}, m), { _id: (0, id_1.generateID)(m.objectType) }));
95
- const parseJATSArticle = (rawDoc) => {
96
- const doc = new DOMParser().parseFromString(clearUnsupportedChars(rawDoc), 'application/xml');
92
+ const parseJATSArticle = (doc) => {
97
93
  const article = doc.querySelector('article');
98
94
  const front = doc.querySelector('front');
99
95
  const body = doc.querySelector('body');
@@ -18,10 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.backmatter = void 0;
19
19
  exports.backmatter = {
20
20
  content: 'sections*',
21
- atom: true,
22
21
  attrs: {
23
22
  id: { default: '' },
23
+ placeholder: { default: ' ' },
24
24
  },
25
- group: 'block',
25
+ group: 'block element',
26
+ parseDOM: [{ tag: 'div.backmatter' }],
26
27
  toDOM: () => ['div', { class: 'backmatter' }, 0],
27
28
  };
@@ -20,6 +20,7 @@ exports.contributors = {
20
20
  content: 'contributor* author_notes?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ firstInitials: { default: false },
23
24
  },
24
25
  group: 'block',
25
26
  selectable: false,
@@ -20,6 +20,7 @@ exports.title = {
20
20
  content: '(text | highlight_marker)*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ placeholder: { default: 'Insert title here...' },
23
24
  dataTracked: { default: null },
24
25
  },
25
26
  group: 'block element',
@@ -86,6 +86,9 @@ class Decoder {
86
86
  const affiliations = getAffiliations(this.modelMap)
87
87
  .map((a) => this.decode(a))
88
88
  .filter(Boolean);
89
+ if (!affiliations.length) {
90
+ return false;
91
+ }
89
92
  return schema_1.schema.nodes.affiliations.createAndFill({}, affiliations);
90
93
  }
91
94
  createContributorsNode() {
@@ -96,12 +99,18 @@ class Decoder {
96
99
  .map((authorNote) => this.decode(authorNote))
97
100
  .filter(Boolean);
98
101
  const content = [...contributors, ...authorNotes];
102
+ if (!content.length) {
103
+ return false;
104
+ }
99
105
  return schema_1.schema.nodes.contributors.createAndFill({}, content);
100
106
  }
101
107
  createKeywordsNode() {
102
108
  const elements = getKeywordElements(this.modelMap)
103
109
  .map((e) => this.decode(e))
104
110
  .filter(Boolean);
111
+ if (!elements.length) {
112
+ return false;
113
+ }
105
114
  return schema_1.schema.nodes.keywords.createAndFill({}, [
106
115
  schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
107
116
  ...elements,
@@ -111,6 +120,9 @@ class Decoder {
111
120
  const elements = getSupplements(this.modelMap)
112
121
  .map((e) => this.decode(e))
113
122
  .filter(Boolean);
123
+ if (!elements.length) {
124
+ return false;
125
+ }
114
126
  return schema_1.schema.nodes.supplements.createAndFill({}, [
115
127
  schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('SupplementaryMaterials')),
116
128
  ...elements,
@@ -143,11 +155,7 @@ class Decoder {
143
155
  const abstracts = schema_1.schema.nodes.abstracts.createAndFill({}, groups[section_group_type_1.abstractsType._id]);
144
156
  const body = schema_1.schema.nodes.body.createAndFill({}, groups[section_group_type_1.bodyType._id]);
145
157
  const backmatter = schema_1.schema.nodes.backmatter.createAndFill({}, groups[section_group_type_1.backmatterType._id]);
146
- return {
147
- abstracts,
148
- body,
149
- backmatter,
150
- };
158
+ return [abstracts, body, backmatter];
151
159
  }
152
160
  createCommentNodes(model) {
153
161
  const comments = [];
@@ -695,24 +703,16 @@ class Decoder {
695
703
  };
696
704
  this.getModel = (id) => this.modelMap.get(id);
697
705
  this.createArticleNode = (manuscriptID) => {
698
- const title = this.createTitleNode();
699
- const contributors = this.createContributorsNode();
700
- const affiliations = this.createAffiliationsNode();
701
- const keywords = this.createKeywordsNode();
702
- const suppl = this.createSupplementsNode();
703
- const { abstracts, body, backmatter } = this.createContentSections();
704
- const comments = this.createCommentsNode();
705
- const contents = [
706
- title,
707
- contributors,
708
- affiliations,
709
- keywords,
710
- suppl,
711
- abstracts,
712
- body,
713
- backmatter,
714
- comments,
706
+ const nodes = [
707
+ this.createTitleNode(),
708
+ this.createContributorsNode(),
709
+ this.createAffiliationsNode(),
710
+ this.createKeywordsNode(),
711
+ this.createSupplementsNode(),
712
+ ...this.createContentSections(),
713
+ this.createCommentsNode(),
715
714
  ];
715
+ const contents = nodes.filter((node) => node !== false);
716
716
  return schema_1.schema.nodes.manuscript.create({
717
717
  id: manuscriptID || this.getManuscriptID(),
718
718
  }, contents);
@@ -262,6 +262,7 @@ const encoders = {
262
262
  title: (0, exports.inlineContents)(node),
263
263
  subtitle: node.attrs.subtitle,
264
264
  runningTitle: node.attrs.runningTitle,
265
+ placeholder: node.attrs.placeholder,
265
266
  _id: node.attrs._id,
266
267
  }),
267
268
  bibliography_element: (node) => ({
@@ -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.7-LEAN-3582.0";
4
+ exports.VERSION = "2.3.7-LEAN-3307.3";
@@ -82,13 +82,9 @@ const createBibliographyModels = (references) => {
82
82
  models.push(...comments);
83
83
  return models;
84
84
  };
85
- const clearUnsupportedChars = (input = '') => {
86
- return input.replace(/[\u2028\u2029]/gim, '<break/>');
87
- };
88
85
  const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
89
86
  const generateIDs = (models) => models.map((m) => m._id ? m : Object.assign(Object.assign({}, m), { _id: generateID(m.objectType) }));
90
- export const parseJATSArticle = (rawDoc) => {
91
- const doc = new DOMParser().parseFromString(clearUnsupportedChars(rawDoc), 'application/xml');
87
+ export const parseJATSArticle = (doc) => {
92
88
  const article = doc.querySelector('article');
93
89
  const front = doc.querySelector('front');
94
90
  const body = doc.querySelector('body');
@@ -15,10 +15,11 @@
15
15
  */
16
16
  export const backmatter = {
17
17
  content: 'sections*',
18
- atom: true,
19
18
  attrs: {
20
19
  id: { default: '' },
20
+ placeholder: { default: ' ' },
21
21
  },
22
- group: 'block',
22
+ group: 'block element',
23
+ parseDOM: [{ tag: 'div.backmatter' }],
23
24
  toDOM: () => ['div', { class: 'backmatter' }, 0],
24
25
  };
@@ -17,6 +17,7 @@ export const contributors = {
17
17
  content: 'contributor* author_notes?',
18
18
  attrs: {
19
19
  id: { default: '' },
20
+ firstInitials: { default: false },
20
21
  },
21
22
  group: 'block',
22
23
  selectable: false,
@@ -17,6 +17,7 @@ export const title = {
17
17
  content: '(text | highlight_marker)*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
+ placeholder: { default: 'Insert title here...' },
20
21
  dataTracked: { default: null },
21
22
  },
22
23
  group: 'block element',
@@ -77,6 +77,9 @@ export class Decoder {
77
77
  const affiliations = getAffiliations(this.modelMap)
78
78
  .map((a) => this.decode(a))
79
79
  .filter(Boolean);
80
+ if (!affiliations.length) {
81
+ return false;
82
+ }
80
83
  return schema.nodes.affiliations.createAndFill({}, affiliations);
81
84
  }
82
85
  createContributorsNode() {
@@ -87,12 +90,18 @@ export class Decoder {
87
90
  .map((authorNote) => this.decode(authorNote))
88
91
  .filter(Boolean);
89
92
  const content = [...contributors, ...authorNotes];
93
+ if (!content.length) {
94
+ return false;
95
+ }
90
96
  return schema.nodes.contributors.createAndFill({}, content);
91
97
  }
92
98
  createKeywordsNode() {
93
99
  const elements = getKeywordElements(this.modelMap)
94
100
  .map((e) => this.decode(e))
95
101
  .filter(Boolean);
102
+ if (!elements.length) {
103
+ return false;
104
+ }
96
105
  return schema.nodes.keywords.createAndFill({}, [
97
106
  schema.nodes.section_title.create({}, schema.text('Keywords')),
98
107
  ...elements,
@@ -102,6 +111,9 @@ export class Decoder {
102
111
  const elements = getSupplements(this.modelMap)
103
112
  .map((e) => this.decode(e))
104
113
  .filter(Boolean);
114
+ if (!elements.length) {
115
+ return false;
116
+ }
105
117
  return schema.nodes.supplements.createAndFill({}, [
106
118
  schema.nodes.section_title.create({}, schema.text('SupplementaryMaterials')),
107
119
  ...elements,
@@ -134,11 +146,7 @@ export class Decoder {
134
146
  const abstracts = schema.nodes.abstracts.createAndFill({}, groups[abstractsType._id]);
135
147
  const body = schema.nodes.body.createAndFill({}, groups[bodyType._id]);
136
148
  const backmatter = schema.nodes.backmatter.createAndFill({}, groups[backmatterType._id]);
137
- return {
138
- abstracts,
139
- body,
140
- backmatter,
141
- };
149
+ return [abstracts, body, backmatter];
142
150
  }
143
151
  createCommentNodes(model) {
144
152
  const comments = [];
@@ -686,24 +694,16 @@ export class Decoder {
686
694
  };
687
695
  this.getModel = (id) => this.modelMap.get(id);
688
696
  this.createArticleNode = (manuscriptID) => {
689
- const title = this.createTitleNode();
690
- const contributors = this.createContributorsNode();
691
- const affiliations = this.createAffiliationsNode();
692
- const keywords = this.createKeywordsNode();
693
- const suppl = this.createSupplementsNode();
694
- const { abstracts, body, backmatter } = this.createContentSections();
695
- const comments = this.createCommentsNode();
696
- const contents = [
697
- title,
698
- contributors,
699
- affiliations,
700
- keywords,
701
- suppl,
702
- abstracts,
703
- body,
704
- backmatter,
705
- comments,
697
+ const nodes = [
698
+ this.createTitleNode(),
699
+ this.createContributorsNode(),
700
+ this.createAffiliationsNode(),
701
+ this.createKeywordsNode(),
702
+ this.createSupplementsNode(),
703
+ ...this.createContentSections(),
704
+ this.createCommentsNode(),
706
705
  ];
706
+ const contents = nodes.filter((node) => node !== false);
707
707
  return schema.nodes.manuscript.create({
708
708
  id: manuscriptID || this.getManuscriptID(),
709
709
  }, contents);
@@ -254,6 +254,7 @@ const encoders = {
254
254
  title: inlineContents(node),
255
255
  subtitle: node.attrs.subtitle,
256
256
  runningTitle: node.attrs.runningTitle,
257
+ placeholder: node.attrs.placeholder,
257
258
  _id: node.attrs._id,
258
259
  }),
259
260
  bibliography_element: (node) => ({
@@ -1 +1 @@
1
- export const VERSION = "2.3.7-LEAN-3582.0";
1
+ export const VERSION = "2.3.7-LEAN-3307.3";
@@ -17,4 +17,4 @@ import { Model } from '@manuscripts/json-schema';
17
17
  import { References } from './jats-references';
18
18
  export declare const parseJATSFront: (doc: Document, front: Element) => Model[];
19
19
  export declare const parseJATSBody: (doc: Document, body: Element, references?: References) => IterableIterator<Model>;
20
- export declare const parseJATSArticle: (rawDoc: string) => Model[];
20
+ export declare const parseJATSArticle: (doc: Document) => Model[];
@@ -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;
@@ -20,6 +20,7 @@ interface Attrs {
20
20
  title: string;
21
21
  subtitle: string;
22
22
  runningTitle: string;
23
+ placeholder: string;
23
24
  }
24
25
  export interface TitleNode extends ManuscriptNode {
25
26
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "2.3.7-LEAN-3582.0";
1
+ export declare const VERSION = "2.3.7-LEAN-3307.3";
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.7-LEAN-3582.0",
4
+ "version": "2.3.7-LEAN-3307.3",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -25,14 +25,13 @@
25
25
  "prettier": "prettier --write \"src/**/*.{ts,tsx}\" \"*.{js,json}\"",
26
26
  "preversion": "npm-run-all --parallel typecheck lint build test",
27
27
  "test": "jest --runInBand",
28
- "test-inv": "jest -i src/jats/__tests__/jats-importer-invalid.test.ts",
29
28
  "test:debug": "DEBUG=manuscripts-transform yarn test",
30
29
  "typecheck": "tsc --noEmit",
31
30
  "version": "yarn build"
32
31
  },
33
32
  "dependencies": {
34
- "@manuscripts/json-schema": "2.2.8",
35
- "@manuscripts/library": "1.3.7",
33
+ "@manuscripts/json-schema": "2.2.9-LEAN-3307.0",
34
+ "@manuscripts/library": "1.3.8-LEAN-3307.0",
36
35
  "debug": "^4.3.4",
37
36
  "jszip": "^3.10.1",
38
37
  "mime": "^3.0.0",