@manuscripts/transform 3.0.40 → 3.0.41-LEAN-4310.1

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.
@@ -797,7 +797,9 @@ class JATSExporter {
797
797
  const attrs = {
798
798
  id: normalizeID(node.attrs.id),
799
799
  };
800
- attrs['sec-type'] = 'abstract-graphical';
800
+ if (node.attrs.category) {
801
+ attrs['sec-type'] = node.attrs.category;
802
+ }
801
803
  return ['sec', attrs, 0];
802
804
  },
803
805
  section: (node) => {
@@ -1361,45 +1363,13 @@ class JATSExporter {
1361
1363
  }
1362
1364
  };
1363
1365
  this.moveAbstracts = (front, body) => {
1366
+ var _a;
1364
1367
  const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
1365
- let abstractSections;
1366
- if (container) {
1367
- abstractSections = Array.from(container.querySelectorAll(':scope > sec'));
1368
- }
1369
- else {
1370
- abstractSections = Array.from(body.querySelectorAll(':scope > sec')).filter((section) => {
1371
- const sectionType = section.getAttribute('sec-type');
1372
- if (sectionType === 'abstract' ||
1373
- sectionType === 'abstract-teaser' ||
1374
- sectionType === 'abstract-graphical') {
1375
- return true;
1376
- }
1377
- const sectionTitle = section.querySelector(':scope > title');
1378
- if (!sectionTitle) {
1379
- return false;
1380
- }
1381
- return sectionTitle.textContent === 'Abstract';
1382
- });
1383
- }
1368
+ const abstractsNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.abstracts)[0]) === null || _a === void 0 ? void 0 : _a.node;
1369
+ const abstractCategories = this.getAbstractCategories(abstractsNode);
1370
+ const abstractSections = this.getAbstractSections(container, body, abstractCategories);
1384
1371
  if (abstractSections.length) {
1385
- for (const abstractSection of abstractSections) {
1386
- const abstractNode = this.document.createElement('abstract');
1387
- for (const node of abstractSection.childNodes) {
1388
- if (node.nodeName !== 'title') {
1389
- abstractNode.appendChild(node.cloneNode(true));
1390
- }
1391
- }
1392
- const sectionType = abstractSection.getAttribute('sec-type');
1393
- if (sectionType && sectionType !== 'abstract') {
1394
- const [, abstractType] = sectionType.split('-', 2);
1395
- abstractNode.setAttribute('abstract-type', abstractType);
1396
- }
1397
- abstractSection.remove();
1398
- const articleMeta = front.querySelector(':scope > article-meta');
1399
- if (articleMeta) {
1400
- insertAbstractNode(articleMeta, abstractNode);
1401
- }
1402
- }
1372
+ this.processAbstractSections(abstractSections, front);
1403
1373
  }
1404
1374
  if (container) {
1405
1375
  body.removeChild(container);
@@ -1594,6 +1564,54 @@ class JATSExporter {
1594
1564
  articleMeta.appendChild(kwdGroup);
1595
1565
  });
1596
1566
  }
1567
+ getAbstractCategories(abstractsNode) {
1568
+ const categories = [];
1569
+ abstractsNode === null || abstractsNode === void 0 ? void 0 : abstractsNode.content.descendants((node) => {
1570
+ categories.push(node.attrs.category);
1571
+ return false;
1572
+ });
1573
+ return categories;
1574
+ }
1575
+ getAbstractSections(container, body, abstractCategories) {
1576
+ if (container) {
1577
+ return Array.from(container.querySelectorAll(':scope > sec'));
1578
+ }
1579
+ else {
1580
+ const sections = Array.from(body.querySelectorAll(':scope > sec'));
1581
+ return sections.filter((section) => this.isAbstractSection(section, abstractCategories));
1582
+ }
1583
+ }
1584
+ isAbstractSection(section, abstractCategories) {
1585
+ const sectionType = section.getAttribute('sec-type');
1586
+ return sectionType ? abstractCategories.includes(sectionType) : false;
1587
+ }
1588
+ processAbstractSections(abstractSections, front) {
1589
+ for (const abstractSection of abstractSections) {
1590
+ const abstractNode = this.createAbstractNode(abstractSection);
1591
+ abstractSection.remove();
1592
+ const articleMeta = front.querySelector(':scope > article-meta');
1593
+ if (articleMeta) {
1594
+ insertAbstractNode(articleMeta, abstractNode);
1595
+ }
1596
+ }
1597
+ }
1598
+ createAbstractNode(abstractSection) {
1599
+ const abstractNode = this.document.createElement('abstract');
1600
+ for (const node of abstractSection.childNodes) {
1601
+ if (node.nodeName !== 'title') {
1602
+ abstractNode.appendChild(node.cloneNode(true));
1603
+ }
1604
+ }
1605
+ this.setAbstractType(abstractNode, abstractSection);
1606
+ return abstractNode;
1607
+ }
1608
+ setAbstractType(abstractNode, abstractSection) {
1609
+ const sectionType = abstractSection.getAttribute('sec-type');
1610
+ if (sectionType && sectionType !== 'abstract') {
1611
+ const abstractType = sectionType.replace('abstract-', '');
1612
+ abstractNode.setAttribute('abstract-type', abstractType);
1613
+ }
1614
+ }
1597
1615
  moveCoiStatementToAuthorNotes(back, front) {
1598
1616
  const fnGroups = back.querySelectorAll('fn-group');
1599
1617
  fnGroups.forEach((fnGroup) => {
@@ -790,6 +790,22 @@ class JATSDOMParser {
790
790
  {
791
791
  tag: 'sec[sec-type="abstract-graphical"]',
792
792
  node: 'graphical_abstract_section',
793
+ getAttrs: (node) => {
794
+ const element = node;
795
+ return {
796
+ category: this.chooseSectionCategory(element),
797
+ };
798
+ },
799
+ },
800
+ {
801
+ tag: 'sec[sec-type="abstract-key-image"]',
802
+ node: 'graphical_abstract_section',
803
+ getAttrs: (node) => {
804
+ const element = node;
805
+ return {
806
+ category: this.chooseSectionCategory(element),
807
+ };
808
+ },
793
809
  },
794
810
  {
795
811
  tag: 'sec',
@@ -987,7 +1003,8 @@ class JATSDOMParser {
987
1003
  return this.parser.parse(doc, options);
988
1004
  }
989
1005
  isMatchingCategory(secType, titleNode, category) {
990
- if (secType && category.synonyms.includes(secType)) {
1006
+ if ((secType && category.synonyms.includes(secType)) ||
1007
+ category.id === secType) {
991
1008
  return true;
992
1009
  }
993
1010
  if (titleNode && titleNode.nodeName === 'title' && titleNode.textContent) {
@@ -218,7 +218,7 @@ const createAbstractSection = (abstract, createElement) => {
218
218
  if (!abstract.querySelector(':scope > title')) {
219
219
  const title = createElement('title');
220
220
  title.textContent = abstractType
221
- ? `${capitalizeFirstLetter(abstractType)} Abstract`
221
+ ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
222
222
  : 'Abstract';
223
223
  section.appendChild(title);
224
224
  }
@@ -15,6 +15,11 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getGroupCateogries = void 0;
19
- const getGroupCateogries = (sectionsMap, group) => Array.from(sectionsMap.values()).filter((section) => section.group === group);
20
- exports.getGroupCateogries = getGroupCateogries;
18
+ exports.getGroupCategories = void 0;
19
+ const getGroupCategories = (sections, group) => {
20
+ const sectionsArray = Array.isArray(sections)
21
+ ? sections
22
+ : Array.from(sections.values());
23
+ return sectionsArray.filter((section) => section.group === group);
24
+ };
25
+ exports.getGroupCategories = getGroupCategories;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Migration3038 {
4
+ constructor() {
5
+ this.fromVersion = '3.0.37';
6
+ this.toVersion = '3.0.38';
7
+ }
8
+ migrateNode(node) {
9
+ if (node.type === 'graphical_abstract_section') {
10
+ return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { category: 'abstract-graphical' }) });
11
+ }
12
+ return node;
13
+ }
14
+ }
15
+ exports.default = Migration3038;
@@ -24,6 +24,7 @@ const _3_0_12_1 = require("./3.0.12");
24
24
  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
+ const _3_0_38_1 = __importDefault(require("./3.0.38"));
27
28
  const migrations = [
28
29
  new _1_2_5_1.default(),
29
30
  new _2_3_22_1.default(),
@@ -31,5 +32,6 @@ const migrations = [
31
32
  new _3_0_21_1.default(),
32
33
  new _3_0_30_1.default(),
33
34
  new _3_0_31_1.default(),
35
+ new _3_0_38_1.default(),
34
36
  ];
35
37
  exports.default = migrations;
@@ -21,6 +21,7 @@ exports.graphicalAbstractSection = {
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  dataTracked: { default: null },
24
+ category: { default: '' },
24
25
  },
25
26
  group: 'block sections',
26
27
  selectable: false,
@@ -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.40";
4
+ exports.VERSION = "3.0.41-LEAN-4310.1";
@@ -789,7 +789,9 @@ export class JATSExporter {
789
789
  const attrs = {
790
790
  id: normalizeID(node.attrs.id),
791
791
  };
792
- attrs['sec-type'] = 'abstract-graphical';
792
+ if (node.attrs.category) {
793
+ attrs['sec-type'] = node.attrs.category;
794
+ }
793
795
  return ['sec', attrs, 0];
794
796
  },
795
797
  section: (node) => {
@@ -1353,45 +1355,13 @@ export class JATSExporter {
1353
1355
  }
1354
1356
  };
1355
1357
  this.moveAbstracts = (front, body) => {
1358
+ var _a;
1356
1359
  const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
1357
- let abstractSections;
1358
- if (container) {
1359
- abstractSections = Array.from(container.querySelectorAll(':scope > sec'));
1360
- }
1361
- else {
1362
- abstractSections = Array.from(body.querySelectorAll(':scope > sec')).filter((section) => {
1363
- const sectionType = section.getAttribute('sec-type');
1364
- if (sectionType === 'abstract' ||
1365
- sectionType === 'abstract-teaser' ||
1366
- sectionType === 'abstract-graphical') {
1367
- return true;
1368
- }
1369
- const sectionTitle = section.querySelector(':scope > title');
1370
- if (!sectionTitle) {
1371
- return false;
1372
- }
1373
- return sectionTitle.textContent === 'Abstract';
1374
- });
1375
- }
1360
+ const abstractsNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.abstracts)[0]) === null || _a === void 0 ? void 0 : _a.node;
1361
+ const abstractCategories = this.getAbstractCategories(abstractsNode);
1362
+ const abstractSections = this.getAbstractSections(container, body, abstractCategories);
1376
1363
  if (abstractSections.length) {
1377
- for (const abstractSection of abstractSections) {
1378
- const abstractNode = this.document.createElement('abstract');
1379
- for (const node of abstractSection.childNodes) {
1380
- if (node.nodeName !== 'title') {
1381
- abstractNode.appendChild(node.cloneNode(true));
1382
- }
1383
- }
1384
- const sectionType = abstractSection.getAttribute('sec-type');
1385
- if (sectionType && sectionType !== 'abstract') {
1386
- const [, abstractType] = sectionType.split('-', 2);
1387
- abstractNode.setAttribute('abstract-type', abstractType);
1388
- }
1389
- abstractSection.remove();
1390
- const articleMeta = front.querySelector(':scope > article-meta');
1391
- if (articleMeta) {
1392
- insertAbstractNode(articleMeta, abstractNode);
1393
- }
1394
- }
1364
+ this.processAbstractSections(abstractSections, front);
1395
1365
  }
1396
1366
  if (container) {
1397
1367
  body.removeChild(container);
@@ -1586,6 +1556,54 @@ export class JATSExporter {
1586
1556
  articleMeta.appendChild(kwdGroup);
1587
1557
  });
1588
1558
  }
1559
+ getAbstractCategories(abstractsNode) {
1560
+ const categories = [];
1561
+ abstractsNode === null || abstractsNode === void 0 ? void 0 : abstractsNode.content.descendants((node) => {
1562
+ categories.push(node.attrs.category);
1563
+ return false;
1564
+ });
1565
+ return categories;
1566
+ }
1567
+ getAbstractSections(container, body, abstractCategories) {
1568
+ if (container) {
1569
+ return Array.from(container.querySelectorAll(':scope > sec'));
1570
+ }
1571
+ else {
1572
+ const sections = Array.from(body.querySelectorAll(':scope > sec'));
1573
+ return sections.filter((section) => this.isAbstractSection(section, abstractCategories));
1574
+ }
1575
+ }
1576
+ isAbstractSection(section, abstractCategories) {
1577
+ const sectionType = section.getAttribute('sec-type');
1578
+ return sectionType ? abstractCategories.includes(sectionType) : false;
1579
+ }
1580
+ processAbstractSections(abstractSections, front) {
1581
+ for (const abstractSection of abstractSections) {
1582
+ const abstractNode = this.createAbstractNode(abstractSection);
1583
+ abstractSection.remove();
1584
+ const articleMeta = front.querySelector(':scope > article-meta');
1585
+ if (articleMeta) {
1586
+ insertAbstractNode(articleMeta, abstractNode);
1587
+ }
1588
+ }
1589
+ }
1590
+ createAbstractNode(abstractSection) {
1591
+ const abstractNode = this.document.createElement('abstract');
1592
+ for (const node of abstractSection.childNodes) {
1593
+ if (node.nodeName !== 'title') {
1594
+ abstractNode.appendChild(node.cloneNode(true));
1595
+ }
1596
+ }
1597
+ this.setAbstractType(abstractNode, abstractSection);
1598
+ return abstractNode;
1599
+ }
1600
+ setAbstractType(abstractNode, abstractSection) {
1601
+ const sectionType = abstractSection.getAttribute('sec-type');
1602
+ if (sectionType && sectionType !== 'abstract') {
1603
+ const abstractType = sectionType.replace('abstract-', '');
1604
+ abstractNode.setAttribute('abstract-type', abstractType);
1605
+ }
1606
+ }
1589
1607
  moveCoiStatementToAuthorNotes(back, front) {
1590
1608
  const fnGroups = back.querySelectorAll('fn-group');
1591
1609
  fnGroups.forEach((fnGroup) => {
@@ -787,6 +787,22 @@ export class JATSDOMParser {
787
787
  {
788
788
  tag: 'sec[sec-type="abstract-graphical"]',
789
789
  node: 'graphical_abstract_section',
790
+ getAttrs: (node) => {
791
+ const element = node;
792
+ return {
793
+ category: this.chooseSectionCategory(element),
794
+ };
795
+ },
796
+ },
797
+ {
798
+ tag: 'sec[sec-type="abstract-key-image"]',
799
+ node: 'graphical_abstract_section',
800
+ getAttrs: (node) => {
801
+ const element = node;
802
+ return {
803
+ category: this.chooseSectionCategory(element),
804
+ };
805
+ },
790
806
  },
791
807
  {
792
808
  tag: 'sec',
@@ -984,7 +1000,8 @@ export class JATSDOMParser {
984
1000
  return this.parser.parse(doc, options);
985
1001
  }
986
1002
  isMatchingCategory(secType, titleNode, category) {
987
- if (secType && category.synonyms.includes(secType)) {
1003
+ if ((secType && category.synonyms.includes(secType)) ||
1004
+ category.id === secType) {
988
1005
  return true;
989
1006
  }
990
1007
  if (titleNode && titleNode.nodeName === 'title' && titleNode.textContent) {
@@ -203,7 +203,7 @@ const createAbstractSection = (abstract, createElement) => {
203
203
  if (!abstract.querySelector(':scope > title')) {
204
204
  const title = createElement('title');
205
205
  title.textContent = abstractType
206
- ? `${capitalizeFirstLetter(abstractType)} Abstract`
206
+ ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
207
207
  : 'Abstract';
208
208
  section.appendChild(title);
209
209
  }
@@ -13,4 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export const getGroupCateogries = (sectionsMap, group) => Array.from(sectionsMap.values()).filter((section) => section.group === group);
16
+ export const getGroupCategories = (sections, group) => {
17
+ const sectionsArray = Array.isArray(sections)
18
+ ? sections
19
+ : Array.from(sections.values());
20
+ return sectionsArray.filter((section) => section.group === group);
21
+ };
@@ -0,0 +1,13 @@
1
+ class Migration3038 {
2
+ constructor() {
3
+ this.fromVersion = '3.0.37';
4
+ this.toVersion = '3.0.38';
5
+ }
6
+ migrateNode(node) {
7
+ if (node.type === 'graphical_abstract_section') {
8
+ return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { category: 'abstract-graphical' }) });
9
+ }
10
+ return node;
11
+ }
12
+ }
13
+ export default Migration3038;
@@ -19,6 +19,7 @@ import { Migration3012 } from './3.0.12';
19
19
  import Migration3021 from './3.0.21';
20
20
  import Migration3030 from './3.0.30';
21
21
  import Migration3031 from './3.0.31';
22
+ import Migration3038 from './3.0.38';
22
23
  const migrations = [
23
24
  new Migration125(),
24
25
  new Migration2322(),
@@ -26,5 +27,6 @@ const migrations = [
26
27
  new Migration3021(),
27
28
  new Migration3030(),
28
29
  new Migration3031(),
30
+ new Migration3038(),
29
31
  ];
30
32
  export default migrations;
@@ -18,6 +18,7 @@ export const graphicalAbstractSection = {
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  dataTracked: { default: null },
21
+ category: { default: '' },
21
22
  },
22
23
  group: 'block sections',
23
24
  selectable: false,
@@ -1 +1 @@
1
- export const VERSION = "3.0.40";
1
+ export const VERSION = "3.0.41-LEAN-4310.1";
@@ -88,6 +88,12 @@ export declare class JATSExporter {
88
88
  private removeBackContainer;
89
89
  private moveAwards;
90
90
  private moveAbstracts;
91
+ private getAbstractCategories;
92
+ private getAbstractSections;
93
+ private isAbstractSection;
94
+ private processAbstractSections;
95
+ private createAbstractNode;
96
+ private setAbstractType;
91
97
  private moveSectionsToBack;
92
98
  sectionToFootnote: (section: Element, fnType: string) => HTMLElement;
93
99
  private moveFloatsGroup;
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { SectionCategory, SectionGroup } from '../schema';
17
- export declare const getGroupCateogries: (sectionsMap: Map<string, SectionCategory>, group: SectionGroup) => SectionCategory[];
17
+ export declare const getGroupCategories: (sections: Map<string, SectionCategory> | SectionCategory[], group: SectionGroup) => SectionCategory[];
@@ -0,0 +1,8 @@
1
+ import { JSONNode } from '../migrate';
2
+ import { MigrationScript } from '../migration-script';
3
+ declare class Migration3038 implements MigrationScript {
4
+ fromVersion: string;
5
+ toVersion: string;
6
+ migrateNode(node: JSONNode): JSONNode;
7
+ }
8
+ export default Migration3038;
@@ -19,5 +19,6 @@ import { Migration3012 } from './3.0.12';
19
19
  import Migration3021 from './3.0.21';
20
20
  import Migration3030 from './3.0.30';
21
21
  import Migration3031 from './3.0.31';
22
- declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031)[];
22
+ import Migration3038 from './3.0.38';
23
+ declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021 | Migration3030 | Migration3031 | Migration3038)[];
23
24
  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 GraphicalAbstractSectionAttrs {
19
19
  id: string;
20
+ category: string;
20
21
  }
21
22
  export interface GraphicalAbstractSectionNode extends ManuscriptNode {
22
- attrs: Attrs;
23
+ attrs: GraphicalAbstractSectionAttrs;
23
24
  }
24
25
  export declare const graphicalAbstractSection: NodeSpec;
25
26
  export declare const isGraphicalAbstractSectionNode: (node: ManuscriptNode) => node is GraphicalAbstractSectionNode;
26
- export {};
@@ -43,7 +43,7 @@ export type DataTrackedAttrs = {
43
43
  userID: string;
44
44
  createdAt: number;
45
45
  };
46
- export type SectionGroup = 'abstracts' | 'body' | 'backmatter';
46
+ export type SectionGroup = 'abstracts' | 'body' | 'backmatter' | 'abstracts-graphic';
47
47
  export type SectionCategory = {
48
48
  id: string;
49
49
  synonyms: string[];
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.40";
1
+ export declare const VERSION = "3.0.41-LEAN-4310.1";
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.40",
4
+ "version": "3.0.41-LEAN-4310.1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",