@manuscripts/transform 3.0.44 → 3.0.45-LEAN-4351.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.
@@ -209,8 +209,7 @@ class JATSExporter {
209
209
  }
210
210
  };
211
211
  this.buildFront = (journal) => {
212
- var _a;
213
- const titleNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
212
+ const titleNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.title).map((result) => result.node);
214
213
  const front = this.document.createElement('front');
215
214
  const journalMeta = this.document.createElement('journal-meta');
216
215
  front.appendChild(journalMeta);
@@ -273,11 +272,18 @@ class JATSExporter {
273
272
  const titleGroup = this.document.createElement('title-group');
274
273
  articleMeta.appendChild(titleGroup);
275
274
  this.buildContributors(articleMeta);
276
- if (titleNode) {
277
- const element = this.document.createElement('article-title');
275
+ titleNodes.forEach((titleNode) => {
276
+ let element;
277
+ if (titleNode.attrs.type === 'primary') {
278
+ element = this.document.createElement('article-title');
279
+ }
280
+ else {
281
+ element = this.document.createElement('alt-title');
282
+ element.setAttribute('alt-title-type', titleNode.attrs.type);
283
+ }
278
284
  this.setTitleContent(element, titleNode.textContent);
279
285
  titleGroup.appendChild(element);
280
- }
286
+ });
281
287
  const supplementsNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.supplement);
282
288
  supplementsNodes.forEach(({ node }) => {
283
289
  var _a, _b, _c, _d;
@@ -253,6 +253,7 @@ class JATSDOMParser {
253
253
  const element = node;
254
254
  return {
255
255
  id: element.getAttribute('id'),
256
+ type: element.getAttribute('type') || '',
256
257
  };
257
258
  },
258
259
  },
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.fixTables = exports.createAttachments = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.moveTitle = exports.addMissingCaptions = void 0;
18
+ exports.fixTables = exports.createAttachments = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.createTitles = exports.addMissingCaptions = void 0;
19
19
  const deafults_1 = require("../../lib/deafults");
20
20
  const jats_parser_utils_1 = require("./jats-parser-utils");
21
21
  const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
@@ -44,19 +44,23 @@ const addMissingCaptions = (doc, createElement) => {
44
44
  }
45
45
  };
46
46
  exports.addMissingCaptions = addMissingCaptions;
47
- const moveTitle = (front, createElement) => {
48
- var _a, _b;
49
- let title = front.querySelector('article-meta > title-group > article-title');
50
- if (title) {
51
- title.innerHTML = (_a = (0, jats_parser_utils_1.htmlFromJatsNode)(title, createElement)) !== null && _a !== void 0 ? _a : deafults_1.defaultTitle;
52
- }
53
- else {
54
- title = createElement('article-title');
55
- title.innerHTML = deafults_1.defaultTitle;
56
- }
57
- (_b = front.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(title, front);
47
+ const createTitles = (front, createElement) => {
48
+ const insertTitle = (selector, type, defaultContent = '') => {
49
+ var _a, _b;
50
+ const existingTitle = front.querySelector(selector);
51
+ const titleEl = createElement('article-title');
52
+ titleEl.innerHTML =
53
+ (_a = (0, jats_parser_utils_1.htmlFromJatsNode)(existingTitle, createElement)) !== null && _a !== void 0 ? _a : defaultContent;
54
+ titleEl.setAttribute('type', type);
55
+ if (type === 'primary' || existingTitle) {
56
+ (_b = front.parentElement) === null || _b === void 0 ? void 0 : _b.insertBefore(titleEl, front);
57
+ }
58
+ };
59
+ insertTitle('article-meta > title-group > article-title', 'primary', deafults_1.defaultTitle);
60
+ insertTitle('article-meta > title-group > alt-title[alt-title-type="running"]', 'running');
61
+ insertTitle('article-meta > title-group > alt-title[alt-title-type="short"]', 'short');
58
62
  };
59
- exports.moveTitle = moveTitle;
63
+ exports.createTitles = createTitles;
60
64
  const moveAuthorNotes = (front, createElement) => {
61
65
  var _a;
62
66
  const authorNotes = front.querySelector('article-meta > author-notes');
@@ -30,7 +30,7 @@ const processJATS = (doc, sectionCategories) => {
30
30
  return;
31
31
  }
32
32
  (0, jats_transformations_1.addMissingCaptions)(doc, createElement);
33
- (0, jats_transformations_1.moveTitle)(front, createElement);
33
+ (0, jats_transformations_1.createTitles)(front, createElement);
34
34
  (0, jats_transformations_1.moveContributors)(front, createElement);
35
35
  (0, jats_transformations_1.moveAffiliations)(front, createElement);
36
36
  (0, jats_transformations_1.moveAuthorNotes)(front, createElement);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Migration3044 {
4
+ constructor() {
5
+ this.fromVersion = '3.0.43';
6
+ this.toVersion = '3.0.44';
7
+ }
8
+ migrateNode(node) {
9
+ if (node.type === 'title') {
10
+ return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { type: 'primary' }) });
11
+ }
12
+ return node;
13
+ }
14
+ }
15
+ exports.default = Migration3044;
@@ -25,6 +25,7 @@ const _3_0_21_1 = __importDefault(require("./3.0.21"));
25
25
  const _3_0_30_1 = __importDefault(require("./3.0.30"));
26
26
  const _3_0_31_1 = __importDefault(require("./3.0.31"));
27
27
  const _3_0_41_1 = __importDefault(require("./3.0.41"));
28
+ const _3_0_44_1 = __importDefault(require("./3.0.44"));
28
29
  const migrations = [
29
30
  new _1_2_5_1.default(),
30
31
  new _2_3_22_1.default(),
@@ -33,5 +34,6 @@ const migrations = [
33
34
  new _3_0_30_1.default(),
34
35
  new _3_0_31_1.default(),
35
36
  new _3_0_41_1.default(),
37
+ new _3_0_44_1.default(),
36
38
  ];
37
39
  exports.default = migrations;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isManuscriptNode = exports.manuscript = void 0;
19
19
  exports.manuscript = {
20
- content: 'title? contributors? affiliations? author_notes? awards? keywords? supplements? abstracts body backmatter comments attachments?',
20
+ content: 'title* contributors? affiliations? author_notes? awards? keywords? supplements? abstracts body backmatter comments attachments?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  doi: { default: '' },
@@ -20,6 +20,7 @@ exports.title = {
20
20
  content: '(text | highlight_marker)*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
+ type: { default: 'primary' },
23
24
  placeholder: { default: 'Insert title here...' },
24
25
  dataTracked: { default: null },
25
26
  },
@@ -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.44";
4
+ exports.VERSION = "3.0.45-LEAN-4351.0";
@@ -201,8 +201,7 @@ export class JATSExporter {
201
201
  }
202
202
  };
203
203
  this.buildFront = (journal) => {
204
- var _a;
205
- const titleNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
204
+ const titleNodes = findChildrenByType(this.manuscriptNode, schema.nodes.title).map((result) => result.node);
206
205
  const front = this.document.createElement('front');
207
206
  const journalMeta = this.document.createElement('journal-meta');
208
207
  front.appendChild(journalMeta);
@@ -265,11 +264,18 @@ export class JATSExporter {
265
264
  const titleGroup = this.document.createElement('title-group');
266
265
  articleMeta.appendChild(titleGroup);
267
266
  this.buildContributors(articleMeta);
268
- if (titleNode) {
269
- const element = this.document.createElement('article-title');
267
+ titleNodes.forEach((titleNode) => {
268
+ let element;
269
+ if (titleNode.attrs.type === 'primary') {
270
+ element = this.document.createElement('article-title');
271
+ }
272
+ else {
273
+ element = this.document.createElement('alt-title');
274
+ element.setAttribute('alt-title-type', titleNode.attrs.type);
275
+ }
270
276
  this.setTitleContent(element, titleNode.textContent);
271
277
  titleGroup.appendChild(element);
272
- }
278
+ });
273
279
  const supplementsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.supplement);
274
280
  supplementsNodes.forEach(({ node }) => {
275
281
  var _a, _b, _c, _d;
@@ -250,6 +250,7 @@ export class JATSDOMParser {
250
250
  const element = node;
251
251
  return {
252
252
  id: element.getAttribute('id'),
253
+ type: element.getAttribute('type') || '',
253
254
  };
254
255
  },
255
256
  },
@@ -40,17 +40,21 @@ export const addMissingCaptions = (doc, createElement) => {
40
40
  }
41
41
  }
42
42
  };
43
- export const moveTitle = (front, createElement) => {
44
- var _a, _b;
45
- let title = front.querySelector('article-meta > title-group > article-title');
46
- if (title) {
47
- title.innerHTML = (_a = htmlFromJatsNode(title, createElement)) !== null && _a !== void 0 ? _a : defaultTitle;
48
- }
49
- else {
50
- title = createElement('article-title');
51
- title.innerHTML = defaultTitle;
52
- }
53
- (_b = front.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(title, front);
43
+ export const createTitles = (front, createElement) => {
44
+ const insertTitle = (selector, type, defaultContent = '') => {
45
+ var _a, _b;
46
+ const existingTitle = front.querySelector(selector);
47
+ const titleEl = createElement('article-title');
48
+ titleEl.innerHTML =
49
+ (_a = htmlFromJatsNode(existingTitle, createElement)) !== null && _a !== void 0 ? _a : defaultContent;
50
+ titleEl.setAttribute('type', type);
51
+ if (type === 'primary' || existingTitle) {
52
+ (_b = front.parentElement) === null || _b === void 0 ? void 0 : _b.insertBefore(titleEl, front);
53
+ }
54
+ };
55
+ insertTitle('article-meta > title-group > article-title', 'primary', defaultTitle);
56
+ insertTitle('article-meta > title-group > alt-title[alt-title-type="running"]', 'running');
57
+ insertTitle('article-meta > title-group > alt-title[alt-title-type="short"]', 'short');
54
58
  };
55
59
  export const moveAuthorNotes = (front, createElement) => {
56
60
  var _a;
@@ -18,7 +18,7 @@ import { markComments } from './jats-comments';
18
18
  import { JATSDOMParser } from './jats-dom-parser';
19
19
  import { parseJournal } from './jats-journal-meta-parser';
20
20
  import { updateDocumentIDs } from './jats-parser-utils';
21
- import { addMissingCaptions, createAbstracts, createAttachments, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
21
+ import { addMissingCaptions, createAbstracts, createAttachments, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, createTitles, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, orderTableFootnote, } from './jats-transformations';
22
22
  const processJATS = (doc, sectionCategories) => {
23
23
  const createElement = createElementFn(doc);
24
24
  markComments(doc);
@@ -27,7 +27,7 @@ const processJATS = (doc, sectionCategories) => {
27
27
  return;
28
28
  }
29
29
  addMissingCaptions(doc, createElement);
30
- moveTitle(front, createElement);
30
+ createTitles(front, createElement);
31
31
  moveContributors(front, createElement);
32
32
  moveAffiliations(front, createElement);
33
33
  moveAuthorNotes(front, createElement);
@@ -0,0 +1,13 @@
1
+ class Migration3044 {
2
+ constructor() {
3
+ this.fromVersion = '3.0.43';
4
+ this.toVersion = '3.0.44';
5
+ }
6
+ migrateNode(node) {
7
+ if (node.type === 'title') {
8
+ return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { type: 'primary' }) });
9
+ }
10
+ return node;
11
+ }
12
+ }
13
+ export default Migration3044;
@@ -20,6 +20,7 @@ import Migration3021 from './3.0.21';
20
20
  import Migration3030 from './3.0.30';
21
21
  import Migration3031 from './3.0.31';
22
22
  import Migration3041 from './3.0.41';
23
+ import Migration3044 from './3.0.44';
23
24
  const migrations = [
24
25
  new Migration125(),
25
26
  new Migration2322(),
@@ -28,5 +29,6 @@ const migrations = [
28
29
  new Migration3030(),
29
30
  new Migration3031(),
30
31
  new Migration3041(),
32
+ new Migration3044(),
31
33
  ];
32
34
  export default migrations;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const manuscript = {
17
- content: 'title? contributors? affiliations? author_notes? awards? keywords? supplements? abstracts body backmatter comments attachments?',
17
+ content: 'title* contributors? affiliations? author_notes? awards? keywords? supplements? abstracts body backmatter comments attachments?',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  doi: { default: '' },
@@ -17,6 +17,7 @@ export const title = {
17
17
  content: '(text | highlight_marker)*',
18
18
  attrs: {
19
19
  id: { default: '' },
20
+ type: { default: 'primary' },
20
21
  placeholder: { default: 'Insert title here...' },
21
22
  dataTracked: { default: null },
22
23
  },
@@ -1 +1 @@
1
- export const VERSION = "3.0.44";
1
+ export const VERSION = "3.0.45-LEAN-4351.0";
@@ -16,7 +16,7 @@
16
16
  import { SectionCategory } from '../../schema';
17
17
  export type CreateElement = (tagName: string) => HTMLElement;
18
18
  export declare const addMissingCaptions: (doc: Document, createElement: CreateElement) => void;
19
- export declare const moveTitle: (front: Element, createElement: CreateElement) => void;
19
+ export declare const createTitles: (front: Element, createElement: CreateElement) => void;
20
20
  export declare const moveAuthorNotes: (front: Element, createElement: CreateElement) => void;
21
21
  export declare const moveAwards: (front: Element) => void;
22
22
  export declare const moveContributors: (front: Element, createElement: CreateElement) => void;
@@ -0,0 +1,8 @@
1
+ import { JSONNode } from '../migrate';
2
+ import { MigrationScript } from '../migration-script';
3
+ declare class Migration3044 implements MigrationScript {
4
+ fromVersion: string;
5
+ toVersion: string;
6
+ migrateNode(node: JSONNode): JSONNode;
7
+ }
8
+ export default Migration3044;
@@ -20,5 +20,6 @@ import Migration3021 from './3.0.21';
20
20
  import Migration3030 from './3.0.30';
21
21
  import Migration3031 from './3.0.31';
22
22
  import Migration3041 from './3.0.41';
23
- declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031 | Migration3041)[];
23
+ import Migration3044 from './3.0.44';
24
+ declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031 | Migration3041 | Migration3044)[];
24
25
  export default migrations;
@@ -15,12 +15,12 @@
15
15
  */
16
16
  import { NodeSpec } from 'prosemirror-model';
17
17
  import { ManuscriptNode } from '../types';
18
- interface Attrs {
18
+ export interface TitleAttrs {
19
19
  id: string;
20
+ type: string;
20
21
  placeholder: string;
21
22
  }
22
23
  export interface TitleNode extends ManuscriptNode {
23
- attrs: Attrs;
24
+ attrs: TitleAttrs;
24
25
  }
25
26
  export declare const title: NodeSpec;
26
- export {};
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.44";
1
+ export declare const VERSION = "3.0.45-LEAN-4351.0";
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.44",
4
+ "version": "3.0.45-LEAN-4351.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -74,7 +74,7 @@
74
74
  "husky": "^8.0.2",
75
75
  "jest": "^29.3.1",
76
76
  "jest-environment-jsdom": "^29.3.1",
77
- "libxmljs2": "^0.33.0",
77
+ "libxmljs2": "^0.35.0",
78
78
  "migration-base": "npm:@manuscripts/transform@2.3.20",
79
79
  "npm-run-all": "^4.1.5",
80
80
  "prettier": "^2.8.1",