@manuscripts/transform 2.3.7-LEAN-3307.3 → 2.3.7

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 (36) hide show
  1. package/dist/cjs/jats/importer/jats-body-dom-parser.js +22 -0
  2. package/dist/cjs/jats/importer/jats-body-transformations.js +12 -0
  3. package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
  4. package/dist/cjs/jats/jats-exporter.js +15 -0
  5. package/dist/cjs/schema/index.js +3 -0
  6. package/dist/cjs/schema/nodes/backmatter.js +2 -3
  7. package/dist/cjs/schema/nodes/contributors.js +0 -1
  8. package/dist/cjs/schema/nodes/general_table_footnote.js +27 -0
  9. package/dist/cjs/schema/nodes/table_element_footer.js +1 -1
  10. package/dist/cjs/schema/nodes/title.js +0 -1
  11. package/dist/cjs/transformer/decode.js +45 -24
  12. package/dist/cjs/transformer/encode.js +14 -2
  13. package/dist/cjs/transformer/object-types.js +1 -0
  14. package/dist/cjs/version.js +1 -1
  15. package/dist/es/jats/importer/jats-body-dom-parser.js +23 -1
  16. package/dist/es/jats/importer/jats-body-transformations.js +12 -0
  17. package/dist/es/jats/importer/jats-parser-utils.js +4 -0
  18. package/dist/es/jats/jats-exporter.js +15 -0
  19. package/dist/es/schema/index.js +3 -0
  20. package/dist/es/schema/nodes/backmatter.js +2 -3
  21. package/dist/es/schema/nodes/contributors.js +0 -1
  22. package/dist/es/schema/nodes/general_table_footnote.js +24 -0
  23. package/dist/es/schema/nodes/table_element_footer.js +1 -1
  24. package/dist/es/schema/nodes/title.js +0 -1
  25. package/dist/es/transformer/decode.js +45 -24
  26. package/dist/es/transformer/encode.js +14 -2
  27. package/dist/es/transformer/object-types.js +1 -0
  28. package/dist/es/version.js +1 -1
  29. package/dist/types/lib/table-cell-styles.d.ts +1 -1
  30. package/dist/types/schema/index.d.ts +1 -0
  31. package/dist/types/schema/nodes/general_table_footnote.d.ts +25 -0
  32. package/dist/types/schema/nodes/title.d.ts +0 -1
  33. package/dist/types/schema/types.d.ts +1 -1
  34. package/dist/types/transformer/object-types.d.ts +2 -1
  35. package/dist/types/version.d.ts +1 -1
  36. package/package.json +3 -3
@@ -315,6 +315,28 @@ const nodes = [
315
315
  };
316
316
  },
317
317
  },
318
+ {
319
+ tag: 'general-table-footnote',
320
+ node: 'general_table_footnote',
321
+ context: 'table_element_footer/',
322
+ getAttrs: (node) => {
323
+ const element = node;
324
+ return {
325
+ id: element.getAttribute('id'),
326
+ };
327
+ },
328
+ getContent: (node) => {
329
+ const paragraphs = [];
330
+ node.childNodes.forEach((p) => {
331
+ const paragraph = schema_1.schema.nodes.paragraph.create();
332
+ const content = exports.jatsBodyDOMParser.parse(p, {
333
+ topNode: paragraph,
334
+ });
335
+ paragraphs.push(content);
336
+ });
337
+ return prosemirror_model_1.Fragment.from([...paragraphs]);
338
+ },
339
+ },
318
340
  {
319
341
  tag: 'fn',
320
342
  node: 'footnote',
@@ -242,6 +242,18 @@ exports.jatsBodyTransformations = {
242
242
  }
243
243
  tableWrap.insertBefore(colgroup, table.nextSibling);
244
244
  }
245
+ const tableFootWrap = tableWrap.querySelector('table-wrap-foot');
246
+ if (tableFootWrap) {
247
+ const paragraphs = tableFootWrap.querySelectorAll(':scope > p');
248
+ if (paragraphs.length) {
249
+ const generalTableFootnote = createElement('general-table-footnote');
250
+ for (const paragraph of paragraphs) {
251
+ removeNodeFromParent(paragraph);
252
+ generalTableFootnote.append(paragraph);
253
+ }
254
+ tableFootWrap.prepend(generalTableFootnote);
255
+ }
256
+ }
245
257
  });
246
258
  },
247
259
  orderTableFootnote(doc, body) {
@@ -36,6 +36,10 @@ const updateNodeID = (node, replacements, warnings) => {
36
36
  node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, uuid_1.v4)()}` });
37
37
  return;
38
38
  }
39
+ if (node.type === schema_1.schema.nodes.general_table_footnote) {
40
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${(0, uuid_1.v4)()}` });
41
+ return;
42
+ }
39
43
  if (!('id' in node.attrs)) {
40
44
  return;
41
45
  }
@@ -679,6 +679,12 @@ class JATSExporter {
679
679
  equation: (node) => {
680
680
  return this.createEquation(node);
681
681
  },
682
+ general_table_footnote: (node) => {
683
+ const el = this.document.createElement('general-table-footnote');
684
+ el.setAttribute('id', normalizeID(node.attrs.id));
685
+ processChildNodes(el, node, schema_1.schema.nodes.general_table_footnote);
686
+ return el;
687
+ },
682
688
  inline_equation: (node) => {
683
689
  const eqElement = this.document.createElement('inline-formula');
684
690
  const equation = this.createEquation(node, true);
@@ -1302,6 +1308,15 @@ class JATSExporter {
1302
1308
  label.remove();
1303
1309
  }
1304
1310
  }
1311
+ if ((0, node_types_1.isNodeType)(node, 'general_table_footnote')) {
1312
+ const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
1313
+ if (generalTableFootnote) {
1314
+ Array.from(generalTableFootnote.childNodes).forEach((cn) => {
1315
+ generalTableFootnote.before(cn);
1316
+ });
1317
+ generalTableFootnote.remove();
1318
+ }
1319
+ }
1305
1320
  if ((0, node_types_1.isNodeType)(node, 'table_element')) {
1306
1321
  const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
1307
1322
  if (tableElement) {
@@ -61,6 +61,7 @@ const figure_element_1 = require("./nodes/figure_element");
61
61
  const footnote_1 = require("./nodes/footnote");
62
62
  const footnotes_element_1 = require("./nodes/footnotes_element");
63
63
  const footnotes_section_1 = require("./nodes/footnotes_section");
64
+ const general_table_footnote_1 = require("./nodes/general_table_footnote");
64
65
  const graphical_abstract_section_1 = require("./nodes/graphical_abstract_section");
65
66
  const hard_break_1 = require("./nodes/hard_break");
66
67
  const highlight_marker_1 = require("./nodes/highlight_marker");
@@ -112,6 +113,7 @@ __exportStar(require("./nodes/equation_element"), exports);
112
113
  __exportStar(require("./nodes/figcaption"), exports);
113
114
  __exportStar(require("./nodes/figure"), exports);
114
115
  __exportStar(require("./nodes/figure_element"), exports);
116
+ __exportStar(require("./nodes/general_table_footnote"), exports);
115
117
  __exportStar(require("./nodes/footnote"), exports);
116
118
  __exportStar(require("./nodes/footnotes_element"), exports);
117
119
  __exportStar(require("./nodes/footnotes_section"), exports);
@@ -187,6 +189,7 @@ exports.schema = new prosemirror_model_1.Schema({
187
189
  footnote: footnote_1.footnote,
188
190
  footnotes_element: footnotes_element_1.footnotesElement,
189
191
  footnotes_section: footnotes_section_1.footnotesSection,
192
+ general_table_footnote: general_table_footnote_1.generalTableFootnote,
190
193
  graphical_abstract_section: graphical_abstract_section_1.graphicalAbstractSection,
191
194
  hard_break: hard_break_1.hardBreak,
192
195
  highlight_marker: highlight_marker_1.highlightMarker,
@@ -18,11 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.backmatter = void 0;
19
19
  exports.backmatter = {
20
20
  content: 'sections*',
21
+ atom: true,
21
22
  attrs: {
22
23
  id: { default: '' },
23
- placeholder: { default: ' ' },
24
24
  },
25
- group: 'block element',
26
- parseDOM: [{ tag: 'div.backmatter' }],
25
+ group: 'block',
27
26
  toDOM: () => ['div', { class: 'backmatter' }, 0],
28
27
  };
@@ -20,7 +20,6 @@ exports.contributors = {
20
20
  content: 'contributor* author_notes?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- firstInitials: { default: false },
24
23
  },
25
24
  group: 'block',
26
25
  selectable: false,
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.generalTableFootnote = void 0;
19
+ exports.generalTableFootnote = {
20
+ content: 'paragraph*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ dataTracked: { default: null },
24
+ },
25
+ group: 'block',
26
+ toDOM: () => ['div', { class: 'general-table-footnote' }, 0],
27
+ };
@@ -21,7 +21,7 @@ exports.tableElementFooter = {
21
21
  id: { default: '' },
22
22
  dataTracked: { default: null },
23
23
  },
24
- content: '(paragraph | footnotes_element)*',
24
+ content: 'general_table_footnote? footnotes_element?',
25
25
  group: 'block element',
26
26
  toDOM: () => ['table-wrap-foot', 0],
27
27
  };
@@ -20,7 +20,6 @@ exports.title = {
20
20
  content: '(text | highlight_marker)*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- placeholder: { default: 'Insert title here...' },
24
23
  dataTracked: { default: null },
25
24
  },
26
25
  group: 'block element',
@@ -38,6 +38,7 @@ const section_group_type_1 = require("../lib/section-group-type");
38
38
  const schema_1 = require("../schema");
39
39
  const builders_1 = require("./builders");
40
40
  const highlight_markers_1 = require("./highlight-markers");
41
+ const id_1 = require("./id");
41
42
  const object_types_1 = require("./object-types");
42
43
  const section_category_1 = require("./section-category");
43
44
  const timestamp_1 = require("./timestamp");
@@ -86,9 +87,6 @@ class Decoder {
86
87
  const affiliations = getAffiliations(this.modelMap)
87
88
  .map((a) => this.decode(a))
88
89
  .filter(Boolean);
89
- if (!affiliations.length) {
90
- return false;
91
- }
92
90
  return schema_1.schema.nodes.affiliations.createAndFill({}, affiliations);
93
91
  }
94
92
  createContributorsNode() {
@@ -99,18 +97,12 @@ class Decoder {
99
97
  .map((authorNote) => this.decode(authorNote))
100
98
  .filter(Boolean);
101
99
  const content = [...contributors, ...authorNotes];
102
- if (!content.length) {
103
- return false;
104
- }
105
100
  return schema_1.schema.nodes.contributors.createAndFill({}, content);
106
101
  }
107
102
  createKeywordsNode() {
108
103
  const elements = getKeywordElements(this.modelMap)
109
104
  .map((e) => this.decode(e))
110
105
  .filter(Boolean);
111
- if (!elements.length) {
112
- return false;
113
- }
114
106
  return schema_1.schema.nodes.keywords.createAndFill({}, [
115
107
  schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
116
108
  ...elements,
@@ -120,9 +112,6 @@ class Decoder {
120
112
  const elements = getSupplements(this.modelMap)
121
113
  .map((e) => this.decode(e))
122
114
  .filter(Boolean);
123
- if (!elements.length) {
124
- return false;
125
- }
126
115
  return schema_1.schema.nodes.supplements.createAndFill({}, [
127
116
  schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('SupplementaryMaterials')),
128
117
  ...elements,
@@ -155,7 +144,11 @@ class Decoder {
155
144
  const abstracts = schema_1.schema.nodes.abstracts.createAndFill({}, groups[section_group_type_1.abstractsType._id]);
156
145
  const body = schema_1.schema.nodes.body.createAndFill({}, groups[section_group_type_1.bodyType._id]);
157
146
  const backmatter = schema_1.schema.nodes.backmatter.createAndFill({}, groups[section_group_type_1.backmatterType._id]);
158
- return [abstracts, body, backmatter];
147
+ return {
148
+ abstracts,
149
+ body,
150
+ backmatter,
151
+ };
159
152
  }
160
153
  createCommentNodes(model) {
161
154
  const comments = [];
@@ -500,10 +493,30 @@ class Decoder {
500
493
  },
501
494
  [json_schema_1.ObjectTypes.TableElementFooter]: (data) => {
502
495
  const model = data;
503
- const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
496
+ const contents = [];
497
+ const generalTableFootnotes = [];
498
+ const footnotesElements = [];
499
+ for (const containedObjectID of model.containedObjectIDs) {
500
+ const model = this.modelMap.get(containedObjectID);
501
+ if (model.objectType === json_schema_1.ObjectTypes.ParagraphElement) {
502
+ const paragraph = this.decode(model);
503
+ if (paragraph) {
504
+ generalTableFootnotes.push(paragraph);
505
+ }
506
+ }
507
+ else {
508
+ footnotesElements.push(this.decode(model));
509
+ }
510
+ }
511
+ if (generalTableFootnotes && generalTableFootnotes.length) {
512
+ contents.push(schema_1.schema.nodes.general_table_footnote.create({ id: (0, id_1.generateID)(object_types_1.ExtraObjectTypes.GeneralTableFootnote) }, [...generalTableFootnotes]));
513
+ }
514
+ if (footnotesElements && footnotesElements.length) {
515
+ contents.push(...footnotesElements);
516
+ }
504
517
  return schema_1.schema.nodes.table_element_footer.create({
505
518
  id: model._id,
506
- }, content);
519
+ }, contents);
507
520
  },
508
521
  [json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
509
522
  const model = data;
@@ -703,16 +716,24 @@ class Decoder {
703
716
  };
704
717
  this.getModel = (id) => this.modelMap.get(id);
705
718
  this.createArticleNode = (manuscriptID) => {
706
- const nodes = [
707
- this.createTitleNode(),
708
- this.createContributorsNode(),
709
- this.createAffiliationsNode(),
710
- this.createKeywordsNode(),
711
- this.createSupplementsNode(),
712
- ...this.createContentSections(),
713
- this.createCommentsNode(),
719
+ const title = this.createTitleNode();
720
+ const contributors = this.createContributorsNode();
721
+ const affiliations = this.createAffiliationsNode();
722
+ const keywords = this.createKeywordsNode();
723
+ const suppl = this.createSupplementsNode();
724
+ const { abstracts, body, backmatter } = this.createContentSections();
725
+ const comments = this.createCommentsNode();
726
+ const contents = [
727
+ title,
728
+ contributors,
729
+ affiliations,
730
+ keywords,
731
+ suppl,
732
+ abstracts,
733
+ body,
734
+ backmatter,
735
+ comments,
714
736
  ];
715
- const contents = nodes.filter((node) => node !== false);
716
737
  return schema_1.schema.nodes.manuscript.create({
717
738
  id: manuscriptID || this.getManuscriptID(),
718
739
  }, contents);
@@ -210,6 +210,18 @@ const containedBibliographyItemIDs = (node) => {
210
210
  const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
211
211
  return containedObjectIDs(node, [bibliographyItemNodeType]);
212
212
  };
213
+ const tableElementFooterContainedIDs = (node) => {
214
+ const containedGeneralTableFootnoteIDs = containedObjectIDs(node, [
215
+ schema_1.schema.nodes.footnotes_element,
216
+ ]);
217
+ for (let i = 0; i < node.childCount; i++) {
218
+ const childNode = node.child(i);
219
+ if (childNode.type === schema_1.schema.nodes.general_table_footnote) {
220
+ containedGeneralTableFootnoteIDs.push(...containedObjectIDs(childNode));
221
+ }
222
+ }
223
+ return containedGeneralTableFootnoteIDs;
224
+ };
213
225
  const containedObjectIDs = (node, nodeTypes) => {
214
226
  const ids = [];
215
227
  for (let i = 0; i < node.childCount; i++) {
@@ -262,7 +274,6 @@ const encoders = {
262
274
  title: (0, exports.inlineContents)(node),
263
275
  subtitle: node.attrs.subtitle,
264
276
  runningTitle: node.attrs.runningTitle,
265
- placeholder: node.attrs.placeholder,
266
277
  _id: node.attrs._id,
267
278
  }),
268
279
  bibliography_element: (node) => ({
@@ -383,7 +394,7 @@ const encoders = {
383
394
  paragraphStyle: node.attrs.paragraphStyle || undefined,
384
395
  }),
385
396
  table_element_footer: (node) => ({
386
- containedObjectIDs: containedObjectIDs(node),
397
+ containedObjectIDs: tableElementFooterContainedIDs(node),
387
398
  }),
388
399
  author_notes: (node) => ({
389
400
  containedObjectIDs: containedObjectIDs(node),
@@ -559,6 +570,7 @@ const containerTypes = [
559
570
  schema_1.schema.nodes.abstracts,
560
571
  schema_1.schema.nodes.body,
561
572
  schema_1.schema.nodes.backmatter,
573
+ schema_1.schema.nodes.general_table_footnote,
562
574
  ];
563
575
  const placeholderTypes = [
564
576
  schema_1.schema.nodes.placeholder,
@@ -20,6 +20,7 @@ const json_schema_1 = require("@manuscripts/json-schema");
20
20
  var ExtraObjectTypes;
21
21
  (function (ExtraObjectTypes) {
22
22
  ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
23
+ ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
23
24
  })(ExtraObjectTypes = exports.ExtraObjectTypes || (exports.ExtraObjectTypes = {}));
24
25
  exports.elementObjects = [
25
26
  json_schema_1.ObjectTypes.BibliographyElement,
@@ -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-3307.3";
4
+ exports.VERSION = "2.3.7";
@@ -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) => {
@@ -309,6 +309,28 @@ const nodes = [
309
309
  };
310
310
  },
311
311
  },
312
+ {
313
+ tag: 'general-table-footnote',
314
+ node: 'general_table_footnote',
315
+ context: 'table_element_footer/',
316
+ getAttrs: (node) => {
317
+ const element = node;
318
+ return {
319
+ id: element.getAttribute('id'),
320
+ };
321
+ },
322
+ getContent: (node) => {
323
+ const paragraphs = [];
324
+ node.childNodes.forEach((p) => {
325
+ const paragraph = schema.nodes.paragraph.create();
326
+ const content = jatsBodyDOMParser.parse(p, {
327
+ topNode: paragraph,
328
+ });
329
+ paragraphs.push(content);
330
+ });
331
+ return Fragment.from([...paragraphs]);
332
+ },
333
+ },
312
334
  {
313
335
  tag: 'fn',
314
336
  node: 'footnote',
@@ -239,6 +239,18 @@ export const jatsBodyTransformations = {
239
239
  }
240
240
  tableWrap.insertBefore(colgroup, table.nextSibling);
241
241
  }
242
+ const tableFootWrap = tableWrap.querySelector('table-wrap-foot');
243
+ if (tableFootWrap) {
244
+ const paragraphs = tableFootWrap.querySelectorAll(':scope > p');
245
+ if (paragraphs.length) {
246
+ const generalTableFootnote = createElement('general-table-footnote');
247
+ for (const paragraph of paragraphs) {
248
+ removeNodeFromParent(paragraph);
249
+ generalTableFootnote.append(paragraph);
250
+ }
251
+ tableFootWrap.prepend(generalTableFootnote);
252
+ }
253
+ }
242
254
  });
243
255
  },
244
256
  orderTableFootnote(doc, body) {
@@ -32,6 +32,10 @@ const updateNodeID = (node, replacements, warnings) => {
32
32
  node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${uuidv4()}` });
33
33
  return;
34
34
  }
35
+ if (node.type === schema.nodes.general_table_footnote) {
36
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${uuidv4()}` });
37
+ return;
38
+ }
35
39
  if (!('id' in node.attrs)) {
36
40
  return;
37
41
  }
@@ -671,6 +671,12 @@ export class JATSExporter {
671
671
  equation: (node) => {
672
672
  return this.createEquation(node);
673
673
  },
674
+ general_table_footnote: (node) => {
675
+ const el = this.document.createElement('general-table-footnote');
676
+ el.setAttribute('id', normalizeID(node.attrs.id));
677
+ processChildNodes(el, node, schema.nodes.general_table_footnote);
678
+ return el;
679
+ },
674
680
  inline_equation: (node) => {
675
681
  const eqElement = this.document.createElement('inline-formula');
676
682
  const equation = this.createEquation(node, true);
@@ -1294,6 +1300,15 @@ export class JATSExporter {
1294
1300
  label.remove();
1295
1301
  }
1296
1302
  }
1303
+ if (isNodeType(node, 'general_table_footnote')) {
1304
+ const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
1305
+ if (generalTableFootnote) {
1306
+ Array.from(generalTableFootnote.childNodes).forEach((cn) => {
1307
+ generalTableFootnote.before(cn);
1308
+ });
1309
+ generalTableFootnote.remove();
1310
+ }
1311
+ }
1297
1312
  if (isNodeType(node, 'table_element')) {
1298
1313
  const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
1299
1314
  if (tableElement) {
@@ -44,6 +44,7 @@ import { figureElement } from './nodes/figure_element';
44
44
  import { footnote } from './nodes/footnote';
45
45
  import { footnotesElement } from './nodes/footnotes_element';
46
46
  import { footnotesSection } from './nodes/footnotes_section';
47
+ import { generalTableFootnote } from './nodes/general_table_footnote';
47
48
  import { graphicalAbstractSection } from './nodes/graphical_abstract_section';
48
49
  import { hardBreak } from './nodes/hard_break';
49
50
  import { highlightMarker } from './nodes/highlight_marker';
@@ -95,6 +96,7 @@ export * from './nodes/equation_element';
95
96
  export * from './nodes/figcaption';
96
97
  export * from './nodes/figure';
97
98
  export * from './nodes/figure_element';
99
+ export * from './nodes/general_table_footnote';
98
100
  export * from './nodes/footnote';
99
101
  export * from './nodes/footnotes_element';
100
102
  export * from './nodes/footnotes_section';
@@ -170,6 +172,7 @@ export const schema = new Schema({
170
172
  footnote,
171
173
  footnotes_element: footnotesElement,
172
174
  footnotes_section: footnotesSection,
175
+ general_table_footnote: generalTableFootnote,
173
176
  graphical_abstract_section: graphicalAbstractSection,
174
177
  hard_break: hardBreak,
175
178
  highlight_marker: highlightMarker,
@@ -15,11 +15,10 @@
15
15
  */
16
16
  export const backmatter = {
17
17
  content: 'sections*',
18
+ atom: true,
18
19
  attrs: {
19
20
  id: { default: '' },
20
- placeholder: { default: ' ' },
21
21
  },
22
- group: 'block element',
23
- parseDOM: [{ tag: 'div.backmatter' }],
22
+ group: 'block',
24
23
  toDOM: () => ['div', { class: 'backmatter' }, 0],
25
24
  };
@@ -17,7 +17,6 @@ export const contributors = {
17
17
  content: 'contributor* author_notes?',
18
18
  attrs: {
19
19
  id: { default: '' },
20
- firstInitials: { default: false },
21
20
  },
22
21
  group: 'block',
23
22
  selectable: false,
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const generalTableFootnote = {
17
+ content: 'paragraph*',
18
+ attrs: {
19
+ id: { default: '' },
20
+ dataTracked: { default: null },
21
+ },
22
+ group: 'block',
23
+ toDOM: () => ['div', { class: 'general-table-footnote' }, 0],
24
+ };
@@ -18,7 +18,7 @@ export const tableElementFooter = {
18
18
  id: { default: '' },
19
19
  dataTracked: { default: null },
20
20
  },
21
- content: '(paragraph | footnotes_element)*',
21
+ content: 'general_table_footnote? footnotes_element?',
22
22
  group: 'block element',
23
23
  toDOM: () => ['table-wrap-foot', 0],
24
24
  };
@@ -17,7 +17,6 @@ export const title = {
17
17
  content: '(text | highlight_marker)*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
- placeholder: { default: 'Insert title here...' },
21
20
  dataTracked: { default: null },
22
21
  },
23
22
  group: 'block element',
@@ -32,6 +32,7 @@ import { abstractsType, backmatterType, bodyType, } from '../lib/section-group-t
32
32
  import { schema, } from '../schema';
33
33
  import { buildTitles } from './builders';
34
34
  import { insertHighlightMarkers } from './highlight-markers';
35
+ import { generateID } from './id';
35
36
  import { ExtraObjectTypes, isCommentAnnotation, isManuscript, } from './object-types';
36
37
  import { chooseSectionLableName, chooseSectionNodeType, chooseSecType, getSectionGroupType, guessSectionCategory, } from './section-category';
37
38
  import { timestamp } from './timestamp';
@@ -77,9 +78,6 @@ export class Decoder {
77
78
  const affiliations = getAffiliations(this.modelMap)
78
79
  .map((a) => this.decode(a))
79
80
  .filter(Boolean);
80
- if (!affiliations.length) {
81
- return false;
82
- }
83
81
  return schema.nodes.affiliations.createAndFill({}, affiliations);
84
82
  }
85
83
  createContributorsNode() {
@@ -90,18 +88,12 @@ export class Decoder {
90
88
  .map((authorNote) => this.decode(authorNote))
91
89
  .filter(Boolean);
92
90
  const content = [...contributors, ...authorNotes];
93
- if (!content.length) {
94
- return false;
95
- }
96
91
  return schema.nodes.contributors.createAndFill({}, content);
97
92
  }
98
93
  createKeywordsNode() {
99
94
  const elements = getKeywordElements(this.modelMap)
100
95
  .map((e) => this.decode(e))
101
96
  .filter(Boolean);
102
- if (!elements.length) {
103
- return false;
104
- }
105
97
  return schema.nodes.keywords.createAndFill({}, [
106
98
  schema.nodes.section_title.create({}, schema.text('Keywords')),
107
99
  ...elements,
@@ -111,9 +103,6 @@ export class Decoder {
111
103
  const elements = getSupplements(this.modelMap)
112
104
  .map((e) => this.decode(e))
113
105
  .filter(Boolean);
114
- if (!elements.length) {
115
- return false;
116
- }
117
106
  return schema.nodes.supplements.createAndFill({}, [
118
107
  schema.nodes.section_title.create({}, schema.text('SupplementaryMaterials')),
119
108
  ...elements,
@@ -146,7 +135,11 @@ export class Decoder {
146
135
  const abstracts = schema.nodes.abstracts.createAndFill({}, groups[abstractsType._id]);
147
136
  const body = schema.nodes.body.createAndFill({}, groups[bodyType._id]);
148
137
  const backmatter = schema.nodes.backmatter.createAndFill({}, groups[backmatterType._id]);
149
- return [abstracts, body, backmatter];
138
+ return {
139
+ abstracts,
140
+ body,
141
+ backmatter,
142
+ };
150
143
  }
151
144
  createCommentNodes(model) {
152
145
  const comments = [];
@@ -491,10 +484,30 @@ export class Decoder {
491
484
  },
492
485
  [ObjectTypes.TableElementFooter]: (data) => {
493
486
  const model = data;
494
- const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
487
+ const contents = [];
488
+ const generalTableFootnotes = [];
489
+ const footnotesElements = [];
490
+ for (const containedObjectID of model.containedObjectIDs) {
491
+ const model = this.modelMap.get(containedObjectID);
492
+ if (model.objectType === ObjectTypes.ParagraphElement) {
493
+ const paragraph = this.decode(model);
494
+ if (paragraph) {
495
+ generalTableFootnotes.push(paragraph);
496
+ }
497
+ }
498
+ else {
499
+ footnotesElements.push(this.decode(model));
500
+ }
501
+ }
502
+ if (generalTableFootnotes && generalTableFootnotes.length) {
503
+ contents.push(schema.nodes.general_table_footnote.create({ id: generateID(ExtraObjectTypes.GeneralTableFootnote) }, [...generalTableFootnotes]));
504
+ }
505
+ if (footnotesElements && footnotesElements.length) {
506
+ contents.push(...footnotesElements);
507
+ }
495
508
  return schema.nodes.table_element_footer.create({
496
509
  id: model._id,
497
- }, content);
510
+ }, contents);
498
511
  },
499
512
  [ObjectTypes.AuthorNotes]: (data) => {
500
513
  const model = data;
@@ -694,16 +707,24 @@ export class Decoder {
694
707
  };
695
708
  this.getModel = (id) => this.modelMap.get(id);
696
709
  this.createArticleNode = (manuscriptID) => {
697
- const nodes = [
698
- this.createTitleNode(),
699
- this.createContributorsNode(),
700
- this.createAffiliationsNode(),
701
- this.createKeywordsNode(),
702
- this.createSupplementsNode(),
703
- ...this.createContentSections(),
704
- this.createCommentsNode(),
710
+ const title = this.createTitleNode();
711
+ const contributors = this.createContributorsNode();
712
+ const affiliations = this.createAffiliationsNode();
713
+ const keywords = this.createKeywordsNode();
714
+ const suppl = this.createSupplementsNode();
715
+ const { abstracts, body, backmatter } = this.createContentSections();
716
+ const comments = this.createCommentsNode();
717
+ const contents = [
718
+ title,
719
+ contributors,
720
+ affiliations,
721
+ keywords,
722
+ suppl,
723
+ abstracts,
724
+ body,
725
+ backmatter,
726
+ comments,
705
727
  ];
706
- const contents = nodes.filter((node) => node !== false);
707
728
  return schema.nodes.manuscript.create({
708
729
  id: manuscriptID || this.getManuscriptID(),
709
730
  }, contents);
@@ -202,6 +202,18 @@ const containedBibliographyItemIDs = (node) => {
202
202
  const bibliographyItemNodeType = node.type.schema.nodes.bibliography_item;
203
203
  return containedObjectIDs(node, [bibliographyItemNodeType]);
204
204
  };
205
+ const tableElementFooterContainedIDs = (node) => {
206
+ const containedGeneralTableFootnoteIDs = containedObjectIDs(node, [
207
+ schema.nodes.footnotes_element,
208
+ ]);
209
+ for (let i = 0; i < node.childCount; i++) {
210
+ const childNode = node.child(i);
211
+ if (childNode.type === schema.nodes.general_table_footnote) {
212
+ containedGeneralTableFootnoteIDs.push(...containedObjectIDs(childNode));
213
+ }
214
+ }
215
+ return containedGeneralTableFootnoteIDs;
216
+ };
205
217
  const containedObjectIDs = (node, nodeTypes) => {
206
218
  const ids = [];
207
219
  for (let i = 0; i < node.childCount; i++) {
@@ -254,7 +266,6 @@ const encoders = {
254
266
  title: inlineContents(node),
255
267
  subtitle: node.attrs.subtitle,
256
268
  runningTitle: node.attrs.runningTitle,
257
- placeholder: node.attrs.placeholder,
258
269
  _id: node.attrs._id,
259
270
  }),
260
271
  bibliography_element: (node) => ({
@@ -375,7 +386,7 @@ const encoders = {
375
386
  paragraphStyle: node.attrs.paragraphStyle || undefined,
376
387
  }),
377
388
  table_element_footer: (node) => ({
378
- containedObjectIDs: containedObjectIDs(node),
389
+ containedObjectIDs: tableElementFooterContainedIDs(node),
379
390
  }),
380
391
  author_notes: (node) => ({
381
392
  containedObjectIDs: containedObjectIDs(node),
@@ -550,6 +561,7 @@ const containerTypes = [
550
561
  schema.nodes.abstracts,
551
562
  schema.nodes.body,
552
563
  schema.nodes.backmatter,
564
+ schema.nodes.general_table_footnote,
553
565
  ];
554
566
  const placeholderTypes = [
555
567
  schema.nodes.placeholder,
@@ -17,6 +17,7 @@ import { manuscriptIDTypes, ObjectTypes, } from '@manuscripts/json-schema';
17
17
  export var ExtraObjectTypes;
18
18
  (function (ExtraObjectTypes) {
19
19
  ExtraObjectTypes["PlaceholderElement"] = "MPPlaceholderElement";
20
+ ExtraObjectTypes["GeneralTableFootnote"] = "MPGeneralTableFootnote";
20
21
  })(ExtraObjectTypes || (ExtraObjectTypes = {}));
21
22
  export const elementObjects = [
22
23
  ObjectTypes.BibliographyElement,
@@ -1 +1 @@
1
- export const VERSION = "2.3.7-LEAN-3307.3";
1
+ export const VERSION = "2.3.7";
@@ -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;
@@ -34,6 +34,7 @@ export * from './nodes/equation_element';
34
34
  export * from './nodes/figcaption';
35
35
  export * from './nodes/figure';
36
36
  export * from './nodes/figure_element';
37
+ export * from './nodes/general_table_footnote';
37
38
  export * from './nodes/footnote';
38
39
  export * from './nodes/footnotes_element';
39
40
  export * from './nodes/footnotes_section';
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { NodeSpec } from 'prosemirror-model';
17
+ import { ManuscriptNode } from '../types';
18
+ interface Attrs {
19
+ id: string;
20
+ }
21
+ export interface GeneralTableFootnote extends ManuscriptNode {
22
+ attrs: Attrs;
23
+ }
24
+ export declare const generalTableFootnote: NodeSpec;
25
+ export {};
@@ -20,7 +20,6 @@ interface Attrs {
20
20
  title: string;
21
21
  subtitle: string;
22
22
  runningTitle: string;
23
- placeholder: string;
24
23
  }
25
24
  export interface TitleNode extends ManuscriptNode {
26
25
  attrs: Attrs;
@@ -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' | 'corresp' | 'general_table_footnote';
21
21
  export type ManuscriptSchema = Schema<Nodes, Marks>;
22
22
  export type ManuscriptEditorState = EditorState;
23
23
  export type ManuscriptEditorView = EditorView;
@@ -16,7 +16,8 @@
16
16
  import { CommentAnnotation, Figure, Keyword, Manuscript, Model, ObjectTypes, Table } from '@manuscripts/json-schema';
17
17
  import { ManuscriptModel } from './models';
18
18
  export declare enum ExtraObjectTypes {
19
- PlaceholderElement = "MPPlaceholderElement"
19
+ PlaceholderElement = "MPPlaceholderElement",
20
+ GeneralTableFootnote = "MPGeneralTableFootnote"
20
21
  }
21
22
  export declare const elementObjects: ObjectTypes[];
22
23
  export declare const manuscriptObjects: ObjectTypes[];
@@ -1 +1 @@
1
- export declare const VERSION = "2.3.7-LEAN-3307.3";
1
+ export declare const VERSION = "2.3.7";
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-3307.3",
4
+ "version": "2.3.7",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,8 +30,8 @@
30
30
  "version": "yarn build"
31
31
  },
32
32
  "dependencies": {
33
- "@manuscripts/json-schema": "2.2.9-LEAN-3307.0",
34
- "@manuscripts/library": "1.3.8-LEAN-3307.0",
33
+ "@manuscripts/json-schema": "2.2.8",
34
+ "@manuscripts/library": "1.3.7",
35
35
  "debug": "^4.3.4",
36
36
  "jszip": "^3.10.1",
37
37
  "mime": "^3.0.0",