@manuscripts/transform 3.0.66 → 3.0.67

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.
@@ -25,6 +25,7 @@ const debug_1 = __importDefault(require("debug"));
25
25
  const prosemirror_model_1 = require("prosemirror-model");
26
26
  const prosemirror_utils_1 = require("prosemirror-utils");
27
27
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
28
+ const credit_roles_1 = require("../../lib/credit-roles");
28
29
  const footnotes_1 = require("../../lib/footnotes");
29
30
  const html_1 = require("../../lib/html");
30
31
  const schema_1 = require("../../schema");
@@ -1135,6 +1136,20 @@ class JATSExporter {
1135
1136
  contrib.appendChild(xref);
1136
1137
  });
1137
1138
  }
1139
+ if (contributor.attrs.CRediTRoles) {
1140
+ contributor.attrs.CRediTRoles.forEach((cr) => {
1141
+ const role = this.createElement('role');
1142
+ const creditUrl = credit_roles_1.CRediTRoleUrls.get(cr.vocabTerm);
1143
+ if (creditUrl) {
1144
+ role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1145
+ role.setAttribute('vocab', 'CRediT');
1146
+ role.setAttribute('vocab-term', cr.vocabTerm);
1147
+ role.setAttribute('vocab-term-identifier', creditUrl);
1148
+ role.innerHTML = cr.vocabTerm;
1149
+ }
1150
+ contrib.appendChild(role);
1151
+ });
1152
+ }
1138
1153
  contribGroup.appendChild(contrib);
1139
1154
  });
1140
1155
  const affiliationRIDs = [];
@@ -407,7 +407,7 @@ class JATSDOMParser {
407
407
  }
408
408
  }
409
409
  return {
410
- id: element.getAttribute('id'),
410
+ id: element.getAttribute('id') || undefined,
411
411
  role: (0, utils_1.getTrimmedTextContent)(element, 'role'),
412
412
  affiliations,
413
413
  corresp,
@@ -421,6 +421,7 @@ class JATSDOMParser {
421
421
  ObjectType: json_schema_1.ObjectTypes.BibliographicName,
422
422
  },
423
423
  ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
424
+ CRediTRoles: (0, utils_1.getCRediTRoleRole)(element),
424
425
  priority: this.parsePriority(element.getAttribute('priority')),
425
426
  email: (0, utils_1.getTrimmedTextContent)(element, 'email') || '',
426
427
  prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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.CRediTRoleUrls = void 0;
19
+ exports.CRediTRoleUrls = new Map([
20
+ [
21
+ "Conceptualization",
22
+ 'https://credit.niso.org/contributor-roles/conceptualization/',
23
+ ],
24
+ [
25
+ "Data curation",
26
+ 'https://credit.niso.org/contributor-roles/data-curation/',
27
+ ],
28
+ [
29
+ "Formal analysis",
30
+ 'https://credit.niso.org/contributor-roles/formal-analysis/',
31
+ ],
32
+ [
33
+ "Funding acquisition",
34
+ 'https://credit.niso.org/contributor-roles/funding-acquisition/',
35
+ ],
36
+ [
37
+ "Investigation",
38
+ 'https://credit.niso.org/contributor-roles/investigation/',
39
+ ],
40
+ [
41
+ "Methodology",
42
+ 'https://credit.niso.org/contributor-roles/methodology/',
43
+ ],
44
+ [
45
+ "ProjectAdministration",
46
+ 'https://credit.niso.org/contributor-roles/project-administration/',
47
+ ],
48
+ [
49
+ "Resources",
50
+ 'https://credit.niso.org/contributor-roles/resources/',
51
+ ],
52
+ [
53
+ "Software",
54
+ 'https://credit.niso.org/contributor-roles/software/',
55
+ ],
56
+ [
57
+ "Supervision",
58
+ 'https://credit.niso.org/contributor-roles/supervision/',
59
+ ],
60
+ [
61
+ "Validation",
62
+ 'https://credit.niso.org/contributor-roles/validation/',
63
+ ],
64
+ [
65
+ "Visualization",
66
+ 'https://credit.niso.org/contributor-roles/visualization/',
67
+ ],
68
+ [
69
+ "Writing \u2013 original draft",
70
+ 'https://credit.niso.org/contributor-roles/writing-original-draft/',
71
+ ],
72
+ [
73
+ "Writing \u2013 review & editing",
74
+ 'https://credit.niso.org/contributor-roles/writing-review-editing/',
75
+ ],
76
+ ]);
@@ -15,9 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.getCRediTRoleRole = exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
19
19
  const jats_parser_utils_1 = require("../jats/importer/jats-parser-utils");
20
20
  const schema_1 = require("../schema");
21
+ const credit_roles_1 = require("./credit-roles");
21
22
  function* iterateChildren(node, recurse = false) {
22
23
  for (let i = 0; i < node.childCount; i++) {
23
24
  const child = node.child(i);
@@ -102,3 +103,18 @@ const dateToTimestamp = (dateElement) => {
102
103
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
103
104
  };
104
105
  exports.dateToTimestamp = dateToTimestamp;
106
+ function getCRediTRoleRole(elem) {
107
+ const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
108
+ const results = [];
109
+ sources.forEach((source) => {
110
+ if (source &&
111
+ credit_roles_1.CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
112
+ const result = {
113
+ vocabTerm: source.getAttribute('vocab-term'),
114
+ };
115
+ results.push(result);
116
+ }
117
+ });
118
+ return results;
119
+ }
120
+ exports.getCRediTRoleRole = getCRediTRoleRole;
@@ -17,6 +17,7 @@ exports.contributor = {
17
17
  isJointContributor: { default: undefined },
18
18
  ORCIDIdentifier: { default: undefined },
19
19
  priority: { default: undefined },
20
+ CRediTRoles: { default: [] },
20
21
  dataTracked: { default: null },
21
22
  contents: { default: '' },
22
23
  prefix: { default: '' },
@@ -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 = "3.0.66";
4
+ exports.VERSION = "3.0.67";
@@ -19,6 +19,7 @@ import debug from 'debug';
19
19
  import { DOMParser as ProsemirrorDOMParser, DOMSerializer, } from 'prosemirror-model';
20
20
  import { findChildrenByAttr, findChildrenByType } from 'prosemirror-utils';
21
21
  import serializeToXML from 'w3c-xmlserializer';
22
+ import { CRediTRoleUrls } from '../../lib/credit-roles';
22
23
  import { generateFootnoteLabels } from '../../lib/footnotes';
23
24
  import { nodeFromHTML, textFromHTML } from '../../lib/html';
24
25
  import { isCitationNode, isNodeOfType, schema, } from '../../schema';
@@ -1127,6 +1128,20 @@ export class JATSExporter {
1127
1128
  contrib.appendChild(xref);
1128
1129
  });
1129
1130
  }
1131
+ if (contributor.attrs.CRediTRoles) {
1132
+ contributor.attrs.CRediTRoles.forEach((cr) => {
1133
+ const role = this.createElement('role');
1134
+ const creditUrl = CRediTRoleUrls.get(cr.vocabTerm);
1135
+ if (creditUrl) {
1136
+ role.setAttribute('vocab-identifier', 'http://credit.niso.org/');
1137
+ role.setAttribute('vocab', 'CRediT');
1138
+ role.setAttribute('vocab-term', cr.vocabTerm);
1139
+ role.setAttribute('vocab-term-identifier', creditUrl);
1140
+ role.innerHTML = cr.vocabTerm;
1141
+ }
1142
+ contrib.appendChild(role);
1143
+ });
1144
+ }
1130
1145
  contribGroup.appendChild(contrib);
1131
1146
  });
1132
1147
  const affiliationRIDs = [];
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { buildBibliographicDate, buildBibliographicName, buildContribution, ObjectTypes, } from '@manuscripts/json-schema';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
- import { dateToTimestamp, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
18
+ import { dateToTimestamp, getCRediTRoleRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
19
19
  import { publicationTypeToPM, } from '../../schema';
20
20
  import { DEFAULT_PROFILE_ID } from './jats-comments';
21
21
  export class JATSDOMParser {
@@ -404,7 +404,7 @@ export class JATSDOMParser {
404
404
  }
405
405
  }
406
406
  return {
407
- id: element.getAttribute('id'),
407
+ id: element.getAttribute('id') || undefined,
408
408
  role: getTrimmedTextContent(element, 'role'),
409
409
  affiliations,
410
410
  corresp,
@@ -418,6 +418,7 @@ export class JATSDOMParser {
418
418
  ObjectType: ObjectTypes.BibliographicName,
419
419
  },
420
420
  ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
421
+ CRediTRoles: getCRediTRoleRole(element),
421
422
  priority: this.parsePriority(element.getAttribute('priority')),
422
423
  email: getTrimmedTextContent(element, 'email') || '',
423
424
  prefix: getTrimmedTextContent(element, 'prefix'),
@@ -0,0 +1,73 @@
1
+ /*!
2
+ * © 2025 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 CRediTRoleUrls = new Map([
17
+ [
18
+ "Conceptualization",
19
+ 'https://credit.niso.org/contributor-roles/conceptualization/',
20
+ ],
21
+ [
22
+ "Data curation",
23
+ 'https://credit.niso.org/contributor-roles/data-curation/',
24
+ ],
25
+ [
26
+ "Formal analysis",
27
+ 'https://credit.niso.org/contributor-roles/formal-analysis/',
28
+ ],
29
+ [
30
+ "Funding acquisition",
31
+ 'https://credit.niso.org/contributor-roles/funding-acquisition/',
32
+ ],
33
+ [
34
+ "Investigation",
35
+ 'https://credit.niso.org/contributor-roles/investigation/',
36
+ ],
37
+ [
38
+ "Methodology",
39
+ 'https://credit.niso.org/contributor-roles/methodology/',
40
+ ],
41
+ [
42
+ "ProjectAdministration",
43
+ 'https://credit.niso.org/contributor-roles/project-administration/',
44
+ ],
45
+ [
46
+ "Resources",
47
+ 'https://credit.niso.org/contributor-roles/resources/',
48
+ ],
49
+ [
50
+ "Software",
51
+ 'https://credit.niso.org/contributor-roles/software/',
52
+ ],
53
+ [
54
+ "Supervision",
55
+ 'https://credit.niso.org/contributor-roles/supervision/',
56
+ ],
57
+ [
58
+ "Validation",
59
+ 'https://credit.niso.org/contributor-roles/validation/',
60
+ ],
61
+ [
62
+ "Visualization",
63
+ 'https://credit.niso.org/contributor-roles/visualization/',
64
+ ],
65
+ [
66
+ "Writing \u2013 original draft",
67
+ 'https://credit.niso.org/contributor-roles/writing-original-draft/',
68
+ ],
69
+ [
70
+ "Writing \u2013 review & editing",
71
+ 'https://credit.niso.org/contributor-roles/writing-review-editing/',
72
+ ],
73
+ ]);
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { htmlFromJatsNode } from '../jats/importer/jats-parser-utils';
17
17
  import { isBibliographySectionNode, isGraphicalAbstractSectionNode, } from '../schema';
18
+ import { CRediTRoleUrls } from './credit-roles';
18
19
  export function* iterateChildren(node, recurse = false) {
19
20
  for (let i = 0; i < node.childCount; i++) {
20
21
  const child = node.child(i);
@@ -91,3 +92,17 @@ export const dateToTimestamp = (dateElement) => {
91
92
  }
92
93
  return Date.UTC(values[0], values[1] - 1, values[2]) / 1000;
93
94
  };
95
+ export function getCRediTRoleRole(elem) {
96
+ const sources = elem.querySelectorAll('role[vocab="CRediT"][vocab-identifier="http://credit.niso.org/"][vocab-term][vocab-term-identifier]');
97
+ const results = [];
98
+ sources.forEach((source) => {
99
+ if (source &&
100
+ CRediTRoleUrls.has(source.getAttribute('vocab-term'))) {
101
+ const result = {
102
+ vocabTerm: source.getAttribute('vocab-term'),
103
+ };
104
+ results.push(result);
105
+ }
106
+ });
107
+ return results;
108
+ }
@@ -14,6 +14,7 @@ export const contributor = {
14
14
  isJointContributor: { default: undefined },
15
15
  ORCIDIdentifier: { default: undefined },
16
16
  priority: { default: undefined },
17
+ CRediTRoles: { default: [] },
17
18
  dataTracked: { default: null },
18
19
  contents: { default: '' },
19
20
  prefix: { default: '' },
@@ -1 +1 @@
1
- export const VERSION = "3.0.66";
1
+ export const VERSION = "3.0.67";
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * © 2025 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 declare const enum CreditVocabTerm {
17
+ Conceptualization = "Conceptualization",
18
+ DataCuration = "Data curation",
19
+ FormalAnalysis = "Formal analysis",
20
+ FundingAcquisition = "Funding acquisition",
21
+ Investigation = "Investigation",
22
+ Methodology = "Methodology",
23
+ ProjectAdministration = "ProjectAdministration",
24
+ Resources = "Resources",
25
+ Software = "Software",
26
+ Supervision = "Supervision",
27
+ Validation = "Validation",
28
+ Visualization = "Visualization",
29
+ WritingOriginalDraft = "Writing \u2013 original draft",
30
+ WritingReviewEditing = "Writing \u2013 review & editing"
31
+ }
32
+ export declare const CRediTRoleUrls: Map<CreditVocabTerm, string>;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Node as ProsemirrorNode, ResolvedPos } from 'prosemirror-model';
17
- import { ManuscriptEditorState, ManuscriptNode } from '../schema';
17
+ import { CRediTRole, ManuscriptEditorState, ManuscriptNode } from '../schema';
18
18
  export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
19
19
  export declare const findNodePositions: (state: ManuscriptEditorState, predicate: (node: ManuscriptNode) => boolean) => number[];
20
20
  export declare const isInGraphicalAbstractSection: ($pos: ResolvedPos) => boolean;
@@ -28,3 +28,4 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
28
28
  export declare const getTrimmedTextContent: (node: Element | Document | null, selector?: string) => string | undefined;
29
29
  export declare const getHTMLContent: (node: Element, querySelector: string) => string | undefined;
30
30
  export declare const dateToTimestamp: (dateElement: Element) => number | undefined;
31
+ export declare function getCRediTRoleRole(elem: Element): CRediTRole[];
@@ -1,5 +1,6 @@
1
1
  import { BibliographicName } from '@manuscripts/json-schema';
2
2
  import { NodeSpec } from 'prosemirror-model';
3
+ import { CreditVocabTerm } from '../../lib/credit-roles';
3
4
  import { ManuscriptNode } from '../types';
4
5
  export type ContributorCorresp = {
5
6
  correspID: string;
@@ -9,6 +10,10 @@ export type ContributorFootnote = {
9
10
  noteID: string;
10
11
  noteLabel: string;
11
12
  };
13
+ export type CRediTRole = {
14
+ vocabTerm: CreditVocabTerm;
15
+ degreeContribution?: string;
16
+ };
12
17
  interface Attrs {
13
18
  id: string;
14
19
  role: string;
@@ -24,6 +29,7 @@ interface Attrs {
24
29
  isJointContributor: boolean;
25
30
  footnote: ContributorFootnote[];
26
31
  prefix: string;
32
+ CRediTRoles?: CRediTRole[];
27
33
  }
28
34
  export interface ContributorNode extends ManuscriptNode {
29
35
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.66";
1
+ export declare const VERSION = "3.0.67";
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": "3.0.66",
4
+ "version": "3.0.67",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -30,7 +30,7 @@
30
30
  "version": "yarn build"
31
31
  },
32
32
  "dependencies": {
33
- "@manuscripts/json-schema": "2.2.11",
33
+ "@manuscripts/json-schema": "2.2.12",
34
34
  "@manuscripts/library": "1.3.14",
35
35
  "debug": "^4.3.4",
36
36
  "jszip": "^3.10.1",