@manuscripts/transform 2.1.0 → 2.1.1-LEAN-3336-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.
@@ -568,7 +568,7 @@ const nodes = [
568
568
  },
569
569
  {
570
570
  tag: 'th',
571
- node: 'table_cell',
571
+ node: 'table_header',
572
572
  getAttrs: (node) => {
573
573
  const element = node;
574
574
  const colspan = element.getAttribute('colspan');
@@ -614,6 +614,11 @@ class JATSExporter {
614
614
  this.createSerializer = () => {
615
615
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
616
616
  const nodes = {
617
+ table_header: (node) => [
618
+ node.attrs.celltype,
619
+ Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
620
+ 0,
621
+ ],
617
622
  title: () => '',
618
623
  affiliations: () => '',
619
624
  contributors: () => '',
@@ -230,5 +230,6 @@ exports.schema = new prosemirror_model_1.Schema({
230
230
  contributors: contributors_1.contributors,
231
231
  supplements: supplements_1.supplements,
232
232
  supplement: supplement_1.supplement,
233
+ table_header: table_row_1.tableHeader,
233
234
  },
234
235
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isAffiliationNode = exports.affiliation = void 0;
4
4
  exports.affiliation = {
5
+ content: 'inline*',
5
6
  attrs: {
6
7
  id: { default: '' },
7
8
  institution: { default: '' },
@@ -11,6 +12,8 @@ exports.affiliation = {
11
12
  addressLine3: { default: '' },
12
13
  postCode: { default: '' },
13
14
  country: { default: '' },
15
+ county: { default: '' },
16
+ city: { default: '' },
14
17
  priority: { default: undefined },
15
18
  email: {
16
19
  default: {
@@ -20,7 +23,7 @@ exports.affiliation = {
20
23
  },
21
24
  dataTracked: { default: null },
22
25
  },
23
- group: 'block element',
26
+ group: 'block',
24
27
  parseDOM: [
25
28
  {
26
29
  tag: 'div.affiliation',
@@ -6,6 +6,7 @@ exports.contributor = {
6
6
  attrs: {
7
7
  id: { default: '' },
8
8
  role: { default: '' },
9
+ email: { default: '' },
9
10
  affiliations: { default: [] },
10
11
  footnote: { default: undefined },
11
12
  corresp: { default: undefined },
@@ -13,12 +14,13 @@ exports.contributor = {
13
14
  userID: { default: undefined },
14
15
  invitationID: { default: undefined },
15
16
  isCorresponding: { default: undefined },
17
+ isJointContributor: { default: undefined },
16
18
  ORCIDIdentifier: { default: undefined },
17
19
  priority: { default: undefined },
18
20
  dataTracked: { default: null },
19
21
  contents: { default: '' },
20
22
  },
21
- group: 'block element',
23
+ group: 'block',
22
24
  toDOM: (node) => {
23
25
  const contributorNode = node;
24
26
  return [
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.tableCell = exports.tableRow = void 0;
18
+ exports.tableHeader = exports.tableCell = exports.tableRow = void 0;
19
19
  const table_cell_styles_1 = require("../../lib/table-cell-styles");
20
20
  const getCellAttrs = (p) => {
21
21
  const dom = p;
@@ -43,7 +43,7 @@ const getCellAttrs = (p) => {
43
43
  };
44
44
  };
45
45
  exports.tableRow = {
46
- content: 'table_cell+',
46
+ content: '(table_cell | table_header)*',
47
47
  tableRole: 'row',
48
48
  attrs: {
49
49
  placeholder: { default: '' },
@@ -79,10 +79,62 @@ exports.tableCell = {
79
79
  },
80
80
  tableRole: 'cell',
81
81
  isolating: true,
82
- parseDOM: [
83
- { tag: 'td', getAttrs: getCellAttrs },
84
- { tag: 'th', getAttrs: getCellAttrs },
85
- ],
82
+ parseDOM: [{ tag: 'td', getAttrs: getCellAttrs }],
83
+ toDOM: (node) => {
84
+ const tableCellNode = node;
85
+ const attrs = {};
86
+ const tag = tableCellNode.attrs.celltype;
87
+ if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
88
+ attrs.colspan = String(tableCellNode.attrs.colspan);
89
+ }
90
+ if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
91
+ attrs.rowspan = String(tableCellNode.attrs.rowspan);
92
+ }
93
+ if (tableCellNode.attrs.colwidth) {
94
+ attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
95
+ }
96
+ if (tableCellNode.attrs.placeholder) {
97
+ attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
98
+ }
99
+ if (!tableCellNode.textContent) {
100
+ attrs.class = 'placeholder';
101
+ }
102
+ const styleString = (0, table_cell_styles_1.serializeTableCellStyles)(tableCellNode.attrs.styles);
103
+ if (styleString) {
104
+ attrs.style = styleString;
105
+ }
106
+ if (tableCellNode.attrs.valign) {
107
+ attrs.valign = tableCellNode.attrs.valign;
108
+ }
109
+ if (tableCellNode.attrs.align) {
110
+ attrs.align = tableCellNode.attrs.align;
111
+ }
112
+ if (tableCellNode.attrs.scope) {
113
+ attrs.scope = tableCellNode.attrs.scope;
114
+ }
115
+ if (tableCellNode.attrs.style) {
116
+ attrs.style = tableCellNode.attrs.style;
117
+ }
118
+ return [tag, attrs, 0];
119
+ },
120
+ };
121
+ exports.tableHeader = {
122
+ content: 'inline*',
123
+ attrs: {
124
+ celltype: { default: 'th' },
125
+ colspan: { default: 1 },
126
+ rowspan: { default: 1 },
127
+ colwidth: { default: null },
128
+ placeholder: { default: 'Data' },
129
+ styles: { default: {} },
130
+ valign: { default: null },
131
+ align: { default: null },
132
+ scope: { default: null },
133
+ style: { default: null },
134
+ },
135
+ tableRole: 'header_cell',
136
+ isolating: true,
137
+ parseDOM: [{ tag: 'th', getAttrs: getCellAttrs }],
86
138
  toDOM: (node) => {
87
139
  const tableCellNode = node;
88
140
  const attrs = {};
@@ -567,6 +567,7 @@ class Decoder {
567
567
  });
568
568
  },
569
569
  [json_schema_1.ObjectTypes.TableElement]: (data) => {
570
+ console.log('tableElement');
570
571
  const model = data;
571
572
  const table = this.createTable(model);
572
573
  const tableElementFooter = this.createTableElementFooter(model);
@@ -628,6 +629,8 @@ class Decoder {
628
629
  addressLine3: model.addressLine3,
629
630
  postCode: model.postCode,
630
631
  country: model.country,
632
+ county: model.county,
633
+ city: model.city,
631
634
  email: model.email,
632
635
  department: model.department,
633
636
  priority: model.priority,
@@ -639,6 +642,8 @@ class Decoder {
639
642
  id: model._id,
640
643
  role: model.role,
641
644
  affiliations: model.affiliations,
645
+ email: model.email,
646
+ isJointContributor: model.isJointContributor,
642
647
  bibliographicName: model.bibliographicName,
643
648
  userID: model.userID,
644
649
  invitationID: model.invitationID,
@@ -508,8 +508,11 @@ const encoders = {
508
508
  addressLine1: node.attrs.addressLine1,
509
509
  addressLine2: node.attrs.addressLine2,
510
510
  addressLine3: node.attrs.addressLine3,
511
+ department: node.attrs.department,
511
512
  postCode: node.attrs.postCode,
512
513
  country: node.attrs.country,
514
+ county: node.attrs.county,
515
+ city: node.attrs.city,
513
516
  email: node.attrs.email,
514
517
  priority: node.attrs.priority,
515
518
  }),
@@ -520,6 +523,7 @@ const encoders = {
520
523
  userID: node.attrs.userID,
521
524
  invitationID: node.attrs.invitationID,
522
525
  isCorresponding: node.attrs.isCorresponding,
526
+ isJointContributor: node.attrs.isJointContributor,
523
527
  ORCIDIdentifier: node.attrs.ORCIDIdentifier,
524
528
  footnote: node.attrs.footnote,
525
529
  corresp: node.attrs.corresp,
@@ -571,6 +575,7 @@ const placeholderTypes = [
571
575
  ];
572
576
  const encode = (node) => {
573
577
  const models = new Map();
578
+ console.log('encoding...');
574
579
  const priority = {
575
580
  value: 1,
576
581
  };
@@ -562,7 +562,7 @@ const nodes = [
562
562
  },
563
563
  {
564
564
  tag: 'th',
565
- node: 'table_cell',
565
+ node: 'table_header',
566
566
  getAttrs: (node) => {
567
567
  const element = node;
568
568
  const colspan = element.getAttribute('colspan');
@@ -606,6 +606,11 @@ export class JATSExporter {
606
606
  this.createSerializer = () => {
607
607
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
608
608
  const nodes = {
609
+ table_header: (node) => [
610
+ node.attrs.celltype,
611
+ Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
612
+ 0,
613
+ ],
609
614
  title: () => '',
610
615
  affiliations: () => '',
611
616
  contributors: () => '',
@@ -70,7 +70,7 @@ import { table, tableBody } from './nodes/table';
70
70
  import { tableCol, tableColGroup } from './nodes/table_col';
71
71
  import { tableElement } from './nodes/table_element';
72
72
  import { tableElementFooter } from './nodes/table_element_footer';
73
- import { tableCell, tableRow } from './nodes/table_row';
73
+ import { tableCell, tableHeader, tableRow } from './nodes/table_row';
74
74
  import { text } from './nodes/text';
75
75
  import { title } from './nodes/title';
76
76
  import { tocElement } from './nodes/toc_element';
@@ -213,5 +213,6 @@ export const schema = new Schema({
213
213
  contributors,
214
214
  supplements,
215
215
  supplement,
216
+ table_header: tableHeader,
216
217
  },
217
218
  });
@@ -1,4 +1,5 @@
1
1
  export const affiliation = {
2
+ content: 'inline*',
2
3
  attrs: {
3
4
  id: { default: '' },
4
5
  institution: { default: '' },
@@ -8,6 +9,8 @@ export const affiliation = {
8
9
  addressLine3: { default: '' },
9
10
  postCode: { default: '' },
10
11
  country: { default: '' },
12
+ county: { default: '' },
13
+ city: { default: '' },
11
14
  priority: { default: undefined },
12
15
  email: {
13
16
  default: {
@@ -17,7 +20,7 @@ export const affiliation = {
17
20
  },
18
21
  dataTracked: { default: null },
19
22
  },
20
- group: 'block element',
23
+ group: 'block',
21
24
  parseDOM: [
22
25
  {
23
26
  tag: 'div.affiliation',
@@ -3,6 +3,7 @@ export const contributor = {
3
3
  attrs: {
4
4
  id: { default: '' },
5
5
  role: { default: '' },
6
+ email: { default: '' },
6
7
  affiliations: { default: [] },
7
8
  footnote: { default: undefined },
8
9
  corresp: { default: undefined },
@@ -10,12 +11,13 @@ export const contributor = {
10
11
  userID: { default: undefined },
11
12
  invitationID: { default: undefined },
12
13
  isCorresponding: { default: undefined },
14
+ isJointContributor: { default: undefined },
13
15
  ORCIDIdentifier: { default: undefined },
14
16
  priority: { default: undefined },
15
17
  dataTracked: { default: null },
16
18
  contents: { default: '' },
17
19
  },
18
- group: 'block element',
20
+ group: 'block',
19
21
  toDOM: (node) => {
20
22
  const contributorNode = node;
21
23
  return [
@@ -40,7 +40,7 @@ const getCellAttrs = (p) => {
40
40
  };
41
41
  };
42
42
  export const tableRow = {
43
- content: 'table_cell+',
43
+ content: '(table_cell | table_header)*',
44
44
  tableRole: 'row',
45
45
  attrs: {
46
46
  placeholder: { default: '' },
@@ -76,10 +76,62 @@ export const tableCell = {
76
76
  },
77
77
  tableRole: 'cell',
78
78
  isolating: true,
79
- parseDOM: [
80
- { tag: 'td', getAttrs: getCellAttrs },
81
- { tag: 'th', getAttrs: getCellAttrs },
82
- ],
79
+ parseDOM: [{ tag: 'td', getAttrs: getCellAttrs }],
80
+ toDOM: (node) => {
81
+ const tableCellNode = node;
82
+ const attrs = {};
83
+ const tag = tableCellNode.attrs.celltype;
84
+ if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
85
+ attrs.colspan = String(tableCellNode.attrs.colspan);
86
+ }
87
+ if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
88
+ attrs.rowspan = String(tableCellNode.attrs.rowspan);
89
+ }
90
+ if (tableCellNode.attrs.colwidth) {
91
+ attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
92
+ }
93
+ if (tableCellNode.attrs.placeholder) {
94
+ attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
95
+ }
96
+ if (!tableCellNode.textContent) {
97
+ attrs.class = 'placeholder';
98
+ }
99
+ const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
100
+ if (styleString) {
101
+ attrs.style = styleString;
102
+ }
103
+ if (tableCellNode.attrs.valign) {
104
+ attrs.valign = tableCellNode.attrs.valign;
105
+ }
106
+ if (tableCellNode.attrs.align) {
107
+ attrs.align = tableCellNode.attrs.align;
108
+ }
109
+ if (tableCellNode.attrs.scope) {
110
+ attrs.scope = tableCellNode.attrs.scope;
111
+ }
112
+ if (tableCellNode.attrs.style) {
113
+ attrs.style = tableCellNode.attrs.style;
114
+ }
115
+ return [tag, attrs, 0];
116
+ },
117
+ };
118
+ export const tableHeader = {
119
+ content: 'inline*',
120
+ attrs: {
121
+ celltype: { default: 'th' },
122
+ colspan: { default: 1 },
123
+ rowspan: { default: 1 },
124
+ colwidth: { default: null },
125
+ placeholder: { default: 'Data' },
126
+ styles: { default: {} },
127
+ valign: { default: null },
128
+ align: { default: null },
129
+ scope: { default: null },
130
+ style: { default: null },
131
+ },
132
+ tableRole: 'header_cell',
133
+ isolating: true,
134
+ parseDOM: [{ tag: 'th', getAttrs: getCellAttrs }],
83
135
  toDOM: (node) => {
84
136
  const tableCellNode = node;
85
137
  const attrs = {};
@@ -558,6 +558,7 @@ export class Decoder {
558
558
  });
559
559
  },
560
560
  [ObjectTypes.TableElement]: (data) => {
561
+ console.log('tableElement');
561
562
  const model = data;
562
563
  const table = this.createTable(model);
563
564
  const tableElementFooter = this.createTableElementFooter(model);
@@ -619,6 +620,8 @@ export class Decoder {
619
620
  addressLine3: model.addressLine3,
620
621
  postCode: model.postCode,
621
622
  country: model.country,
623
+ county: model.county,
624
+ city: model.city,
622
625
  email: model.email,
623
626
  department: model.department,
624
627
  priority: model.priority,
@@ -630,6 +633,8 @@ export class Decoder {
630
633
  id: model._id,
631
634
  role: model.role,
632
635
  affiliations: model.affiliations,
636
+ email: model.email,
637
+ isJointContributor: model.isJointContributor,
633
638
  bibliographicName: model.bibliographicName,
634
639
  userID: model.userID,
635
640
  invitationID: model.invitationID,
@@ -500,8 +500,11 @@ const encoders = {
500
500
  addressLine1: node.attrs.addressLine1,
501
501
  addressLine2: node.attrs.addressLine2,
502
502
  addressLine3: node.attrs.addressLine3,
503
+ department: node.attrs.department,
503
504
  postCode: node.attrs.postCode,
504
505
  country: node.attrs.country,
506
+ county: node.attrs.county,
507
+ city: node.attrs.city,
505
508
  email: node.attrs.email,
506
509
  priority: node.attrs.priority,
507
510
  }),
@@ -512,6 +515,7 @@ const encoders = {
512
515
  userID: node.attrs.userID,
513
516
  invitationID: node.attrs.invitationID,
514
517
  isCorresponding: node.attrs.isCorresponding,
518
+ isJointContributor: node.attrs.isJointContributor,
515
519
  ORCIDIdentifier: node.attrs.ORCIDIdentifier,
516
520
  footnote: node.attrs.footnote,
517
521
  corresp: node.attrs.corresp,
@@ -562,6 +566,7 @@ const placeholderTypes = [
562
566
  ];
563
567
  export const encode = (node) => {
564
568
  const models = new Map();
569
+ console.log('encoding...');
565
570
  const priority = {
566
571
  value: 1,
567
572
  };
@@ -13,6 +13,8 @@ interface Attrs {
13
13
  addressLine3: string;
14
14
  postCode: string;
15
15
  country: string;
16
+ county: string;
17
+ city: string;
16
18
  email: Email;
17
19
  priority: number;
18
20
  }
@@ -1,16 +1,18 @@
1
- import { Affiliation, BibliographicName } from '@manuscripts/json-schema';
1
+ import { BibliographicName } from '@manuscripts/json-schema';
2
2
  import { NodeSpec } from 'prosemirror-model';
3
3
  import { ManuscriptNode } from '../types';
4
4
  interface Attrs {
5
5
  id: string;
6
6
  role: string;
7
- affiliations: Affiliation[];
7
+ affiliations: string[];
8
8
  bibliographicName: BibliographicName;
9
9
  userID: string;
10
+ email: string;
10
11
  invitationID: string;
11
12
  isCorresponding: boolean;
12
13
  ORCIDIdentifier: string;
13
14
  priority: number;
15
+ isJointContributor: boolean;
14
16
  }
15
17
  export interface ContributorNode extends ManuscriptNode {
16
18
  attrs: Attrs;
@@ -39,3 +39,4 @@ export interface TableCellNode extends ManuscriptNode {
39
39
  };
40
40
  }
41
41
  export declare const tableCell: TableNodeSpec;
42
+ export declare const tableHeader: TableNodeSpec;
@@ -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_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement';
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_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'table_header';
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.0",
4
+ "version": "2.1.1-LEAN-3336-0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -78,4 +78,4 @@
78
78
  "rimraf": "^3.0.2",
79
79
  "typescript": "^4.0.5"
80
80
  }
81
- }
81
+ }