@manuscripts/transform 4.3.8 → 4.3.10

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.
@@ -486,7 +486,7 @@ class JATSDOMParser {
486
486
  {
487
487
  tag: 'caption',
488
488
  node: 'figcaption',
489
- context: 'figure_element/|table_element/|embed/|supplement/',
489
+ context: 'figure_element/|table_element/|embed/|supplement/|box_element/',
490
490
  getContent: (node, schema) => {
491
491
  const element = node;
492
492
  const content = [];
@@ -813,7 +813,7 @@ class JATSDOMParser {
813
813
  node: 'backmatter',
814
814
  },
815
815
  {
816
- tag: 'sec[sec-type="box-element"]',
816
+ tag: 'boxed-text',
817
817
  node: 'box_element',
818
818
  getAttrs: (node) => {
819
819
  const element = node;
@@ -890,10 +890,6 @@ class JATSDOMParser {
890
890
  context: 'keyword_group//',
891
891
  node: 'keyword',
892
892
  },
893
- {
894
- tag: 'boxed-text',
895
- ignore: true,
896
- },
897
893
  {
898
894
  tag: 'label',
899
895
  context: 'section/',
@@ -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.createAccessibilityItems = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveHeroImage = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.createTitles = exports.addMissingCaptions = void 0;
18
+ exports.fixTables = exports.createAttachments = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createAccessibilityItems = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.moveHeroImage = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.createTitles = exports.createBoxedElementSection = exports.addMissingCaptions = void 0;
19
19
  const deafults_1 = require("../../lib/deafults");
20
20
  const xml_1 = require("../../lib/xml");
21
21
  const jats_parser_utils_1 = require("./jats-parser-utils");
@@ -27,7 +27,7 @@ const createSectionGroup = (type, createElement) => {
27
27
  return sec;
28
28
  };
29
29
  const addMissingCaptions = (doc, createElement) => {
30
- const elements = doc.querySelectorAll('fig, table-wrap, media, supplementary-material');
30
+ const elements = doc.querySelectorAll('fig, table-wrap, media, supplementary-material, boxed-text');
31
31
  for (const element of elements) {
32
32
  let caption = element.querySelector('caption');
33
33
  if (!caption) {
@@ -39,12 +39,22 @@ const addMissingCaptions = (doc, createElement) => {
39
39
  if (!caption.querySelector('title')) {
40
40
  caption.prepend(createElement('title'));
41
41
  }
42
- if (!caption.querySelector('p')) {
42
+ if (!caption.querySelector('p') && element.nodeName !== 'boxed-text') {
43
43
  caption.appendChild(createElement('p'));
44
44
  }
45
45
  }
46
46
  };
47
47
  exports.addMissingCaptions = addMissingCaptions;
48
+ const createBoxedElementSection = (doc, createElement) => {
49
+ const boxedTexts = doc.querySelectorAll('boxed-text');
50
+ for (const boxedText of boxedTexts) {
51
+ const containerSec = createElement('sec');
52
+ const children = Array.from(boxedText.children).filter((child) => child.localName !== 'label' && child.localName !== 'caption');
53
+ containerSec.append(...children);
54
+ boxedText.appendChild(containerSec);
55
+ }
56
+ };
57
+ exports.createBoxedElementSection = createBoxedElementSection;
48
58
  const createTitles = (front, createElement) => {
49
59
  const titles = createElement('titles');
50
60
  let title = front.querySelector('article-meta > title-group > article-title');
@@ -126,30 +136,6 @@ const moveHeroImage = (doc) => {
126
136
  }
127
137
  };
128
138
  exports.moveHeroImage = moveHeroImage;
129
- const createBoxedElementSection = (body, createElement) => {
130
- const boxedTexts = body.querySelectorAll('boxed-text');
131
- for (const boxedText of boxedTexts) {
132
- const boxElementId = boxedText.getAttribute('id');
133
- const boxElementSec = createElement('sec');
134
- boxElementSec.setAttribute('sec-type', 'box-element');
135
- if (boxElementId) {
136
- boxElementSec.setAttribute('id', boxElementId);
137
- }
138
- const title = createElement('title');
139
- title.textContent = 'BoxElement';
140
- boxElementSec.append(title);
141
- for (const element of [...boxedText.children]) {
142
- if (element?.tagName === 'label' || element?.tagName === 'caption') {
143
- boxElementSec.append(element);
144
- }
145
- }
146
- const containerSection = createElement('sec');
147
- containerSection.append(...boxedText.children);
148
- boxElementSec.append(containerSection);
149
- boxedText.replaceWith(boxElementSec);
150
- }
151
- };
152
- exports.createBoxedElementSection = createBoxedElementSection;
153
139
  const createBody = (doc, body, createElement) => {
154
140
  const group = createSectionGroup('body', createElement);
155
141
  const elements = body.querySelectorAll(':scope > *:not(sec), :scope > sec:not([sec-type="backmatter"]), :scope > sec:not([sec-type])');
@@ -30,6 +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.createBoxedElementSection)(doc, createElement);
33
34
  (0, jats_transformations_1.createTitles)(front, createElement);
34
35
  (0, jats_transformations_1.moveContributors)(front, createElement);
35
36
  (0, jats_transformations_1.moveAffiliations)(front, createElement);
@@ -45,7 +46,6 @@ const processJATS = (doc, sectionCategories) => {
45
46
  article.append(body);
46
47
  }
47
48
  (0, jats_transformations_1.moveCaptionsToEnd)(body);
48
- (0, jats_transformations_1.createBoxedElementSection)(body, createElement);
49
49
  (0, jats_transformations_1.createBody)(doc, body, createElement);
50
50
  (0, jats_transformations_1.createAbstracts)(front, body, createElement);
51
51
  (0, jats_transformations_1.createBackmatter)(doc, body, sectionCategories, createElement);
@@ -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 = "4.3.8";
4
+ exports.VERSION = "4.3.10";
@@ -483,7 +483,7 @@ export class JATSDOMParser {
483
483
  {
484
484
  tag: 'caption',
485
485
  node: 'figcaption',
486
- context: 'figure_element/|table_element/|embed/|supplement/',
486
+ context: 'figure_element/|table_element/|embed/|supplement/|box_element/',
487
487
  getContent: (node, schema) => {
488
488
  const element = node;
489
489
  const content = [];
@@ -810,7 +810,7 @@ export class JATSDOMParser {
810
810
  node: 'backmatter',
811
811
  },
812
812
  {
813
- tag: 'sec[sec-type="box-element"]',
813
+ tag: 'boxed-text',
814
814
  node: 'box_element',
815
815
  getAttrs: (node) => {
816
816
  const element = node;
@@ -887,10 +887,6 @@ export class JATSDOMParser {
887
887
  context: 'keyword_group//',
888
888
  node: 'keyword',
889
889
  },
890
- {
891
- tag: 'boxed-text',
892
- ignore: true,
893
- },
894
890
  {
895
891
  tag: 'label',
896
892
  context: 'section/',
@@ -24,7 +24,7 @@ const createSectionGroup = (type, createElement) => {
24
24
  return sec;
25
25
  };
26
26
  export const addMissingCaptions = (doc, createElement) => {
27
- const elements = doc.querySelectorAll('fig, table-wrap, media, supplementary-material');
27
+ const elements = doc.querySelectorAll('fig, table-wrap, media, supplementary-material, boxed-text');
28
28
  for (const element of elements) {
29
29
  let caption = element.querySelector('caption');
30
30
  if (!caption) {
@@ -36,11 +36,20 @@ export const addMissingCaptions = (doc, createElement) => {
36
36
  if (!caption.querySelector('title')) {
37
37
  caption.prepend(createElement('title'));
38
38
  }
39
- if (!caption.querySelector('p')) {
39
+ if (!caption.querySelector('p') && element.nodeName !== 'boxed-text') {
40
40
  caption.appendChild(createElement('p'));
41
41
  }
42
42
  }
43
43
  };
44
+ export const createBoxedElementSection = (doc, createElement) => {
45
+ const boxedTexts = doc.querySelectorAll('boxed-text');
46
+ for (const boxedText of boxedTexts) {
47
+ const containerSec = createElement('sec');
48
+ const children = Array.from(boxedText.children).filter((child) => child.localName !== 'label' && child.localName !== 'caption');
49
+ containerSec.append(...children);
50
+ boxedText.appendChild(containerSec);
51
+ }
52
+ };
44
53
  export const createTitles = (front, createElement) => {
45
54
  const titles = createElement('titles');
46
55
  let title = front.querySelector('article-meta > title-group > article-title');
@@ -115,29 +124,6 @@ export const moveHeroImage = (doc) => {
115
124
  doc.documentElement.appendChild(heroImage);
116
125
  }
117
126
  };
118
- export const createBoxedElementSection = (body, createElement) => {
119
- const boxedTexts = body.querySelectorAll('boxed-text');
120
- for (const boxedText of boxedTexts) {
121
- const boxElementId = boxedText.getAttribute('id');
122
- const boxElementSec = createElement('sec');
123
- boxElementSec.setAttribute('sec-type', 'box-element');
124
- if (boxElementId) {
125
- boxElementSec.setAttribute('id', boxElementId);
126
- }
127
- const title = createElement('title');
128
- title.textContent = 'BoxElement';
129
- boxElementSec.append(title);
130
- for (const element of [...boxedText.children]) {
131
- if (element?.tagName === 'label' || element?.tagName === 'caption') {
132
- boxElementSec.append(element);
133
- }
134
- }
135
- const containerSection = createElement('sec');
136
- containerSection.append(...boxedText.children);
137
- boxElementSec.append(containerSection);
138
- boxedText.replaceWith(boxElementSec);
139
- }
140
- };
141
127
  export const createBody = (doc, body, createElement) => {
142
128
  const group = createSectionGroup('body', createElement);
143
129
  const elements = body.querySelectorAll(':scope > *:not(sec), :scope > sec:not([sec-type="backmatter"]), :scope > sec:not([sec-type])');
@@ -27,6 +27,7 @@ const processJATS = (doc, sectionCategories) => {
27
27
  return;
28
28
  }
29
29
  addMissingCaptions(doc, createElement);
30
+ createBoxedElementSection(doc, createElement);
30
31
  createTitles(front, createElement);
31
32
  moveContributors(front, createElement);
32
33
  moveAffiliations(front, createElement);
@@ -42,7 +43,6 @@ const processJATS = (doc, sectionCategories) => {
42
43
  article.append(body);
43
44
  }
44
45
  moveCaptionsToEnd(body);
45
- createBoxedElementSection(body, createElement);
46
46
  createBody(doc, body, createElement);
47
47
  createAbstracts(front, body, createElement);
48
48
  createBackmatter(doc, body, sectionCategories, createElement);
@@ -1 +1 @@
1
- export const VERSION = "4.3.8";
1
+ export const VERSION = "4.3.10";
@@ -16,6 +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 createBoxedElementSection: (doc: Document, createElement: CreateElement) => void;
19
20
  export declare const createTitles: (front: Element, createElement: CreateElement) => void;
20
21
  export declare const moveAuthorNotes: (front: Element, createElement: CreateElement) => void;
21
22
  export declare const moveAwards: (front: Element) => void;
@@ -23,7 +24,6 @@ export declare const moveContributors: (front: Element, createElement: CreateEle
23
24
  export declare const moveAffiliations: (front: Element, createElement: CreateElement) => void;
24
25
  export declare const moveAbstracts: (front: Element, group: Element, createElement: CreateElement) => void;
25
26
  export declare const moveHeroImage: (doc: Document) => void;
26
- export declare const createBoxedElementSection: (body: Element, createElement: (tagName: string) => HTMLElement) => void;
27
27
  export declare const createBody: (doc: Document, body: Element, createElement: CreateElement) => void;
28
28
  export declare const createAbstracts: (front: Element, body: Element, createElement: CreateElement) => void;
29
29
  export declare const createBackmatter: (doc: Document, body: Element, sectionCategories: SectionCategory[], createElement: CreateElement) => void;
@@ -1 +1 @@
1
- export declare const VERSION = "4.3.8";
1
+ export declare const VERSION = "4.3.10";
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": "4.3.8",
4
+ "version": "4.3.10",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -44,6 +44,8 @@
44
44
  "@babel/core": "7.23.7",
45
45
  "@babel/preset-env": "7.23.8",
46
46
  "@babel/preset-typescript": "7.23.3",
47
+ "@eslint/eslintrc": "3.3.1",
48
+ "@eslint/js": "9.39.1",
47
49
  "@jats4r/dtds": "0.0.10",
48
50
  "@manuscripts/eslint-config": "0.5.1",
49
51
  "@types/jest": "30.0.0",
@@ -53,29 +55,30 @@
53
55
  "@types/semver": "7.7.0",
54
56
  "@types/uuid": "9.0.8",
55
57
  "@types/w3c-xmlserializer": "2.0.4",
56
- "@typescript-eslint/eslint-plugin": "5.62.0",
57
- "@typescript-eslint/parser": "5.62.0",
58
+ "@typescript-eslint/eslint-plugin": "8.46.4",
59
+ "@typescript-eslint/parser": "8.46.4",
58
60
  "babel-jest": "30.0.5",
59
- "eslint": "8.57.1",
60
- "eslint-config-prettier": "8.10.0",
61
+ "eslint": "9.39.1",
62
+ "eslint-config-prettier": "10.1.8",
63
+ "eslint-plugin-diff": "2.0.3",
61
64
  "eslint-plugin-header": "3.1.1",
62
- "eslint-plugin-import": "2.31.0",
63
- "eslint-plugin-jest": "27.9.0",
65
+ "eslint-plugin-import": "2.32.0",
66
+ "eslint-plugin-jest": "29.1.0",
64
67
  "eslint-plugin-jsx-a11y": "6.10.2",
65
- "eslint-plugin-mdx": "2.3.4",
68
+ "eslint-plugin-mdx": "3.6.2",
66
69
  "eslint-plugin-node": "11.1.0",
67
- "eslint-plugin-prettier": "4.2.1",
68
- "eslint-plugin-promise": "6.6.0",
70
+ "eslint-plugin-prettier": "5.5.4",
71
+ "eslint-plugin-promise": "7.2.1",
69
72
  "eslint-plugin-react": "7.37.5",
70
- "eslint-plugin-react-hooks": "4.6.2",
71
- "eslint-plugin-simple-import-sort": "8.0.0",
73
+ "eslint-plugin-react-hooks": "7.0.1",
74
+ "eslint-plugin-simple-import-sort": "12.1.1",
72
75
  "husky": "8.0.3",
73
76
  "jest": "30.0.5",
74
77
  "jest-environment-jsdom": "30.0.5",
75
78
  "libxmljs2": "0.35.0",
76
79
  "migration-base": "npm:@manuscripts/transform@2.3.20",
77
80
  "npm-run-all": "4.1.5",
78
- "prettier": "2.8.8",
81
+ "prettier": "3.6.2",
79
82
  "prosemirror-state": "1.4.3",
80
83
  "prosemirror-view": "1.39.2",
81
84
  "rimraf": "6.0.1",