@manuscripts/transform 1.5.4 → 1.5.6

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.
@@ -18,9 +18,30 @@ exports.affiliation = {
18
18
  text: undefined,
19
19
  },
20
20
  },
21
+ dataTracked: { default: null },
21
22
  },
22
23
  group: 'block element',
23
- toDOM: () => ['span'],
24
+ parseDOM: [
25
+ {
26
+ tag: 'div.affiliation',
27
+ getAttrs: (node) => {
28
+ const dom = node;
29
+ return {
30
+ id: dom.getAttribute('id'),
31
+ };
32
+ },
33
+ },
34
+ ],
35
+ toDOM: (node) => {
36
+ const affiliationNode = node;
37
+ return [
38
+ 'div',
39
+ {
40
+ class: 'affiliation',
41
+ id: affiliationNode.attrs.id,
42
+ },
43
+ ];
44
+ },
24
45
  };
25
46
  const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
26
47
  exports.isAffiliationNode = isAffiliationNode;
@@ -4,12 +4,33 @@ exports.isAffiliationsSectionNode = exports.affiliationsSection = void 0;
4
4
  exports.affiliationsSection = {
5
5
  content: 'section_title? affiliation*',
6
6
  attrs: {
7
- id: { default: '' },
7
+ id: { default: 'META_SECTION_AFFILLIATIONS' },
8
8
  dataTracked: { default: null },
9
9
  },
10
10
  group: 'block sections',
11
11
  selectable: false,
12
- toDOM: () => ['section', 0],
12
+ parseDOM: [
13
+ {
14
+ tag: 'section.affiliations',
15
+ getAttrs: (section) => {
16
+ const dom = section;
17
+ return {
18
+ contents: dom.innerHTML,
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ toDOM: (node) => {
24
+ const affiliationsSectionNode = node;
25
+ return [
26
+ 'section',
27
+ {
28
+ class: 'affiliations',
29
+ id: affiliationsSectionNode.attrs.id,
30
+ },
31
+ 0
32
+ ];
33
+ },
13
34
  };
14
35
  const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
15
36
  exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isContributorNode = exports.contributor = void 0;
4
4
  exports.contributor = {
5
+ content: 'inline*',
5
6
  attrs: {
6
7
  id: { default: '' },
7
8
  role: { default: '' },
@@ -14,9 +15,20 @@ exports.contributor = {
14
15
  isCorresponding: { default: undefined },
15
16
  ORCIDIdentifier: { default: undefined },
16
17
  priority: { default: undefined },
18
+ dataTracked: { default: null },
19
+ contents: { default: '' },
17
20
  },
18
21
  group: 'block element',
19
- toDOM: () => ['span'],
22
+ toDOM: (node) => {
23
+ const contributorNode = node;
24
+ return [
25
+ 'div',
26
+ {
27
+ class: 'contributor',
28
+ id: contributorNode.attrs.id,
29
+ },
30
+ ];
31
+ },
20
32
  };
21
33
  const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
22
34
  exports.isContributorNode = isContributorNode;
@@ -0,0 +1,49 @@
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.contributorsElement = void 0;
19
+ exports.contributorsElement = {
20
+ content: 'contributor*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ contents: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ group: 'block element',
27
+ selectable: false,
28
+ parseDOM: [
29
+ {
30
+ tag: 'div.manuscript-contributors',
31
+ getAttrs: () => {
32
+ return {
33
+ contents: '',
34
+ };
35
+ },
36
+ },
37
+ ],
38
+ toDOM: (node) => {
39
+ const contributorsElementNode = node;
40
+ return [
41
+ 'div',
42
+ {
43
+ class: 'manuscript-contributors',
44
+ id: contributorsElementNode.attrs.id,
45
+ },
46
+ 0,
47
+ ];
48
+ },
49
+ };
@@ -4,12 +4,33 @@ exports.isContributorsSectionNode = exports.contributorsSection = void 0;
4
4
  exports.contributorsSection = {
5
5
  content: 'section_title? contributor*',
6
6
  attrs: {
7
- id: { default: '' },
7
+ id: { default: 'META_SECTION_CONTRIBUTORS' },
8
8
  dataTracked: { default: null },
9
+ contents: { default: '' },
9
10
  },
10
11
  group: 'block sections',
11
12
  selectable: false,
12
- toDOM: () => ['section', 0],
13
+ parseDOM: [
14
+ {
15
+ tag: 'section.contributors',
16
+ getAttrs: () => {
17
+ return {
18
+ contents: '',
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ toDOM: (node) => {
24
+ const contributorsSectionNode = node;
25
+ return [
26
+ 'section',
27
+ {
28
+ class: 'contributors',
29
+ id: contributorsSectionNode.attrs.id,
30
+ },
31
+ 0,
32
+ ];
33
+ },
13
34
  };
14
35
  const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
15
36
  exports.isContributorsSectionNode = isContributorsSectionNode;
@@ -617,7 +617,7 @@ class Decoder {
617
617
  email: model.email,
618
618
  department: model.department,
619
619
  priority: model.priority,
620
- });
620
+ }, schema_1.schema.text('_'));
621
621
  },
622
622
  [json_schema_1.ObjectTypes.Contributor]: (data) => {
623
623
  const model = data;
@@ -633,7 +633,7 @@ class Decoder {
633
633
  footnote: model.footnote,
634
634
  corresp: model.corresp,
635
635
  priority: model.priority,
636
- });
636
+ }, schema_1.schema.text('_'));
637
637
  },
638
638
  };
639
639
  this.decode = (model) => {
@@ -573,7 +573,8 @@ const modelFromNode = (node, parent, path, priority) => {
573
573
  if ((0, highlight_markers_1.isHighlightableModel)(model)) {
574
574
  (0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
575
575
  }
576
- return { model, commentAnnotationsMap };
576
+ const comments = [...commentAnnotationsMap.values()];
577
+ return { model, comments };
577
578
  };
578
579
  exports.modelFromNode = modelFromNode;
579
580
  const encode = (node) => {
@@ -595,10 +596,18 @@ const encode = (node) => {
595
596
  if (placeholders.includes(child.type.name)) {
596
597
  return;
597
598
  }
598
- const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
599
+ const { model, comments } = (0, exports.modelFromNode)(child, parent, path, priority);
599
600
  if (models.has(model._id)) {
600
601
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
601
602
  }
603
+ comments.forEach((comment) => {
604
+ const proseMirrorComment = models.get(comment._id);
605
+ if (proseMirrorComment) {
606
+ ;
607
+ proseMirrorComment.selector = comment.selector;
608
+ models.set(comment._id, proseMirrorComment);
609
+ }
610
+ });
602
611
  models.set(model._id, model);
603
612
  child.forEach(addModel(path.concat(child.attrs.id), child));
604
613
  };
@@ -15,8 +15,29 @@ export const affiliation = {
15
15
  text: undefined,
16
16
  },
17
17
  },
18
+ dataTracked: { default: null },
18
19
  },
19
20
  group: 'block element',
20
- toDOM: () => ['span'],
21
+ parseDOM: [
22
+ {
23
+ tag: 'div.affiliation',
24
+ getAttrs: (node) => {
25
+ const dom = node;
26
+ return {
27
+ id: dom.getAttribute('id'),
28
+ };
29
+ },
30
+ },
31
+ ],
32
+ toDOM: (node) => {
33
+ const affiliationNode = node;
34
+ return [
35
+ 'div',
36
+ {
37
+ class: 'affiliation',
38
+ id: affiliationNode.attrs.id,
39
+ },
40
+ ];
41
+ },
21
42
  };
22
43
  export const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
@@ -1,11 +1,32 @@
1
1
  export const affiliationsSection = {
2
2
  content: 'section_title? affiliation*',
3
3
  attrs: {
4
- id: { default: '' },
4
+ id: { default: 'META_SECTION_AFFILLIATIONS' },
5
5
  dataTracked: { default: null },
6
6
  },
7
7
  group: 'block sections',
8
8
  selectable: false,
9
- toDOM: () => ['section', 0],
9
+ parseDOM: [
10
+ {
11
+ tag: 'section.affiliations',
12
+ getAttrs: (section) => {
13
+ const dom = section;
14
+ return {
15
+ contents: dom.innerHTML,
16
+ };
17
+ },
18
+ },
19
+ ],
20
+ toDOM: (node) => {
21
+ const affiliationsSectionNode = node;
22
+ return [
23
+ 'section',
24
+ {
25
+ class: 'affiliations',
26
+ id: affiliationsSectionNode.attrs.id,
27
+ },
28
+ 0
29
+ ];
30
+ },
10
31
  };
11
32
  export const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
@@ -1,4 +1,5 @@
1
1
  export const contributor = {
2
+ content: 'inline*',
2
3
  attrs: {
3
4
  id: { default: '' },
4
5
  role: { default: '' },
@@ -11,8 +12,19 @@ export const contributor = {
11
12
  isCorresponding: { default: undefined },
12
13
  ORCIDIdentifier: { default: undefined },
13
14
  priority: { default: undefined },
15
+ dataTracked: { default: null },
16
+ contents: { default: '' },
14
17
  },
15
18
  group: 'block element',
16
- toDOM: () => ['span'],
19
+ toDOM: (node) => {
20
+ const contributorNode = node;
21
+ return [
22
+ 'div',
23
+ {
24
+ class: 'contributor',
25
+ id: contributorNode.attrs.id,
26
+ },
27
+ ];
28
+ },
17
29
  };
18
30
  export const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
@@ -0,0 +1,46 @@
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 contributorsElement = {
17
+ content: 'contributor*',
18
+ attrs: {
19
+ id: { default: '' },
20
+ contents: { default: '' },
21
+ dataTracked: { default: null },
22
+ },
23
+ group: 'block element',
24
+ selectable: false,
25
+ parseDOM: [
26
+ {
27
+ tag: 'div.manuscript-contributors',
28
+ getAttrs: () => {
29
+ return {
30
+ contents: '',
31
+ };
32
+ },
33
+ },
34
+ ],
35
+ toDOM: (node) => {
36
+ const contributorsElementNode = node;
37
+ return [
38
+ 'div',
39
+ {
40
+ class: 'manuscript-contributors',
41
+ id: contributorsElementNode.attrs.id,
42
+ },
43
+ 0,
44
+ ];
45
+ },
46
+ };
@@ -1,11 +1,32 @@
1
1
  export const contributorsSection = {
2
2
  content: 'section_title? contributor*',
3
3
  attrs: {
4
- id: { default: '' },
4
+ id: { default: 'META_SECTION_CONTRIBUTORS' },
5
5
  dataTracked: { default: null },
6
+ contents: { default: '' },
6
7
  },
7
8
  group: 'block sections',
8
9
  selectable: false,
9
- toDOM: () => ['section', 0],
10
+ parseDOM: [
11
+ {
12
+ tag: 'section.contributors',
13
+ getAttrs: () => {
14
+ return {
15
+ contents: '',
16
+ };
17
+ },
18
+ },
19
+ ],
20
+ toDOM: (node) => {
21
+ const contributorsSectionNode = node;
22
+ return [
23
+ 'section',
24
+ {
25
+ class: 'contributors',
26
+ id: contributorsSectionNode.attrs.id,
27
+ },
28
+ 0,
29
+ ];
30
+ },
10
31
  };
11
32
  export const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
@@ -607,7 +607,7 @@ export class Decoder {
607
607
  email: model.email,
608
608
  department: model.department,
609
609
  priority: model.priority,
610
- });
610
+ }, schema.text('_'));
611
611
  },
612
612
  [ObjectTypes.Contributor]: (data) => {
613
613
  const model = data;
@@ -623,7 +623,7 @@ export class Decoder {
623
623
  footnote: model.footnote,
624
624
  corresp: model.corresp,
625
625
  priority: model.priority,
626
- });
626
+ }, schema.text('_'));
627
627
  },
628
628
  };
629
629
  this.decode = (model) => {
@@ -565,7 +565,8 @@ export const modelFromNode = (node, parent, path, priority) => {
565
565
  if (isHighlightableModel(model)) {
566
566
  extractHighlightMarkers(model, commentAnnotationsMap);
567
567
  }
568
- return { model, commentAnnotationsMap };
568
+ const comments = [...commentAnnotationsMap.values()];
569
+ return { model, comments };
569
570
  };
570
571
  export const encode = (node) => {
571
572
  const models = new Map();
@@ -586,10 +587,18 @@ export const encode = (node) => {
586
587
  if (placeholders.includes(child.type.name)) {
587
588
  return;
588
589
  }
589
- const { model } = modelFromNode(child, parent, path, priority);
590
+ const { model, comments } = modelFromNode(child, parent, path, priority);
590
591
  if (models.has(model._id)) {
591
592
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
592
593
  }
594
+ comments.forEach((comment) => {
595
+ const proseMirrorComment = models.get(comment._id);
596
+ if (proseMirrorComment) {
597
+ ;
598
+ proseMirrorComment.selector = comment.selector;
599
+ models.set(comment._id, proseMirrorComment);
600
+ }
601
+ });
593
602
  models.set(model._id, model);
594
603
  child.forEach(addModel(path.concat(child.attrs.id), child));
595
604
  };
@@ -0,0 +1,27 @@
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
+ contents: string;
20
+ id: string;
21
+ paragraphStyle?: string;
22
+ }
23
+ export interface ContributorsElementNode extends ManuscriptNode {
24
+ attrs: Attrs;
25
+ }
26
+ export declare const contributorsElement: NodeSpec;
27
+ export {};
@@ -2,6 +2,7 @@ import { NodeSpec } from 'prosemirror-model';
2
2
  import { ManuscriptNode } from '../types';
3
3
  interface Attrs {
4
4
  id: string;
5
+ contents: string;
5
6
  }
6
7
  export interface ContributorsSectionNode extends ManuscriptNode {
7
8
  attrs: Attrs;
@@ -20,7 +20,7 @@ export declare const inlineContents: (node: ManuscriptNode) => string;
20
20
  export declare const inlineText: (node: ManuscriptNode) => string;
21
21
  export declare const modelFromNode: (node: ManuscriptNode, parent: ManuscriptNode, path: string[], priority: PrioritizedValue) => {
22
22
  model: Model;
23
- commentAnnotationsMap: Map<string, Build<CommentAnnotation>>;
23
+ comments: Build<CommentAnnotation>[];
24
24
  };
25
25
  interface PrioritizedValue {
26
26
  value: number;
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": "1.5.4",
4
+ "version": "1.5.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -82,4 +82,4 @@
82
82
  "prosemirror-state": "^1.4.2",
83
83
  "prosemirror-view": "^1.29.1"
84
84
  }
85
- }
85
+ }