@manuscripts/transform 3.0.24-LEAN-4192.0 → 3.0.25

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.
@@ -872,12 +872,7 @@ class JATSExporter {
872
872
  return element;
873
873
  };
874
874
  const appendLabels = (element, node) => {
875
- if (node.attrs.label) {
876
- const label = this.document.createElement('label');
877
- label.textContent = node.attrs.label;
878
- element.appendChild(label);
879
- }
880
- else if (this.labelTargets) {
875
+ if (this.labelTargets) {
881
876
  const target = this.labelTargets.get(node.attrs.id);
882
877
  if (target) {
883
878
  const label = this.document.createElement('label');
@@ -443,7 +443,7 @@ class JATSDOMParser {
443
443
  {
444
444
  tag: 'caption',
445
445
  node: 'figcaption',
446
- context: 'figure_element/',
446
+ context: 'figure_element/|table_element/',
447
447
  getContent: (node, schema) => {
448
448
  const element = node;
449
449
  const content = [];
@@ -462,11 +462,6 @@ class JATSDOMParser {
462
462
  return prosemirror_model_1.Fragment.from(content);
463
463
  },
464
464
  },
465
- {
466
- tag: 'caption',
467
- node: 'figcaption',
468
- context: 'table_element/',
469
- },
470
465
  {
471
466
  tag: 'caption',
472
467
  node: 'figcaption',
@@ -504,11 +499,9 @@ class JATSDOMParser {
504
499
  tag: 'disp-formula',
505
500
  node: 'equation_element',
506
501
  getAttrs: (node) => {
507
- var _a;
508
502
  const element = node;
509
503
  return {
510
504
  id: element.getAttribute('id'),
511
- label: (_a = (0, utils_1.getTrimmedTextContent)(element, 'label')) !== null && _a !== void 0 ? _a : '',
512
505
  };
513
506
  },
514
507
  getContent: (node, schema) => {
@@ -614,12 +607,8 @@ class JATSDOMParser {
614
607
  tag: 'fig',
615
608
  node: 'figure_element',
616
609
  getAttrs: (node) => {
617
- var _a, _b;
610
+ var _a;
618
611
  const element = node;
619
- const labelNode = element.querySelector('label');
620
- if (labelNode) {
621
- element.removeChild(labelNode);
622
- }
623
612
  const attrib = element.querySelector('attrib');
624
613
  const attribution = attrib
625
614
  ? {
@@ -628,7 +617,6 @@ class JATSDOMParser {
628
617
  : undefined;
629
618
  return {
630
619
  id: element.getAttribute('id'),
631
- label: (_b = (0, utils_1.getTrimmedTextContent)(labelNode)) !== null && _b !== void 0 ? _b : '',
632
620
  attribution,
633
621
  type: element.getAttribute('fig-type'),
634
622
  };
@@ -775,7 +763,6 @@ class JATSDOMParser {
775
763
  const element = node;
776
764
  return {
777
765
  id: element.getAttribute('id'),
778
- label: (0, utils_1.getTrimmedTextContent)(element, 'label'),
779
766
  };
780
767
  },
781
768
  },
@@ -831,11 +818,6 @@ class JATSDOMParser {
831
818
  context: 'keyword_group//',
832
819
  node: 'keyword',
833
820
  },
834
- {
835
- tag: 'label',
836
- context: 'box_element/',
837
- ignore: true,
838
- },
839
821
  {
840
822
  tag: 'boxed-text',
841
823
  ignore: true,
@@ -845,16 +827,6 @@ class JATSDOMParser {
845
827
  context: 'section/',
846
828
  node: 'section_label',
847
829
  },
848
- {
849
- tag: 'label',
850
- context: 'table_element/',
851
- ignore: true,
852
- },
853
- {
854
- tag: 'label',
855
- context: 'figure/',
856
- ignore: true,
857
- },
858
830
  {
859
831
  tag: 'table',
860
832
  node: 'table',
@@ -954,10 +926,13 @@ class JATSDOMParser {
954
926
  const element = node;
955
927
  return {
956
928
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
957
- label: (0, utils_1.getTrimmedTextContent)(element),
958
929
  };
959
930
  },
960
931
  },
932
+ {
933
+ tag: 'label',
934
+ ignore: true,
935
+ },
961
936
  ];
962
937
  this.marks = [
963
938
  {
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.fixTables = 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 = void 0;
18
+ exports.fixTables = 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;
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);
@@ -25,6 +25,25 @@ const createSectionGroup = (type, createElement) => {
25
25
  sec.setAttribute('sec-type', type);
26
26
  return sec;
27
27
  };
28
+ const addMissingCaptions = (doc, createElement) => {
29
+ const elements = doc.querySelectorAll('fig, table-wrap');
30
+ for (const element of elements) {
31
+ let caption = element.querySelector('caption');
32
+ if (!caption) {
33
+ caption = createElement('caption');
34
+ element.nodeName === 'fig'
35
+ ? element.appendChild(caption)
36
+ : element.prepend(caption);
37
+ }
38
+ if (!caption.querySelector('title')) {
39
+ caption.prepend(createElement('title'));
40
+ }
41
+ if (!caption.querySelector('p')) {
42
+ caption.appendChild(createElement('p'));
43
+ }
44
+ }
45
+ };
46
+ exports.addMissingCaptions = addMissingCaptions;
28
47
  const moveTitle = (front, createElement) => {
29
48
  var _a, _b;
30
49
  let title = front.querySelector('article-meta > title-group > article-title');
@@ -29,6 +29,7 @@ const processJATS = (doc, sectionCategories) => {
29
29
  if (!front) {
30
30
  return;
31
31
  }
32
+ (0, jats_transformations_1.addMissingCaptions)(doc, createElement);
32
33
  (0, jats_transformations_1.moveTitle)(front, createElement);
33
34
  (0, jats_transformations_1.moveContributors)(front, createElement);
34
35
  (0, jats_transformations_1.moveAffiliations)(front, createElement);
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.abstracts = void 0;
19
19
  exports.abstracts = {
20
20
  content: 'sections*',
21
+ atom: true,
21
22
  attrs: {
22
23
  id: { default: '' },
23
24
  },
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.body = void 0;
19
19
  exports.body = {
20
20
  content: 'element* sections*',
21
+ atom: true,
21
22
  attrs: {
22
23
  id: { default: '' },
23
24
  },
@@ -20,7 +20,6 @@ exports.box_element = {
20
20
  content: 'figcaption? section?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- label: { default: '' },
24
23
  dataTracked: { default: null },
25
24
  },
26
25
  group: 'block element',
@@ -32,7 +31,6 @@ exports.box_element = {
32
31
  const dom = p;
33
32
  const attrs = {
34
33
  id: dom.getAttribute('id') || undefined,
35
- label: dom.getAttribute('label') || undefined,
36
34
  };
37
35
  return attrs;
38
36
  },
@@ -44,9 +42,6 @@ exports.box_element = {
44
42
  if (boxElementNode.attrs.id) {
45
43
  attrs.id = boxElementNode.attrs.id;
46
44
  }
47
- if (boxElementNode.attrs.label) {
48
- attrs.label = boxElementNode.attrs.label;
49
- }
50
45
  return [
51
46
  'div',
52
47
  Object.assign({ class: 'boxed-text' }, attrs),
@@ -20,7 +20,6 @@ exports.tableElement = {
20
20
  content: ' figcaption? (table | placeholder) table_colgroup? table_element_footer? (listing | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- label: { default: '' },
24
23
  dataTracked: { default: null },
25
24
  },
26
25
  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.24-LEAN-4192.0";
4
+ exports.VERSION = "3.0.25";
@@ -864,12 +864,7 @@ export class JATSExporter {
864
864
  return element;
865
865
  };
866
866
  const appendLabels = (element, node) => {
867
- if (node.attrs.label) {
868
- const label = this.document.createElement('label');
869
- label.textContent = node.attrs.label;
870
- element.appendChild(label);
871
- }
872
- else if (this.labelTargets) {
867
+ if (this.labelTargets) {
873
868
  const target = this.labelTargets.get(node.attrs.id);
874
869
  if (target) {
875
870
  const label = this.document.createElement('label');
@@ -437,7 +437,7 @@ export class JATSDOMParser {
437
437
  {
438
438
  tag: 'caption',
439
439
  node: 'figcaption',
440
- context: 'figure_element/',
440
+ context: 'figure_element/|table_element/',
441
441
  getContent: (node, schema) => {
442
442
  const element = node;
443
443
  const content = [];
@@ -456,11 +456,6 @@ export class JATSDOMParser {
456
456
  return Fragment.from(content);
457
457
  },
458
458
  },
459
- {
460
- tag: 'caption',
461
- node: 'figcaption',
462
- context: 'table_element/',
463
- },
464
459
  {
465
460
  tag: 'caption',
466
461
  node: 'figcaption',
@@ -498,11 +493,9 @@ export class JATSDOMParser {
498
493
  tag: 'disp-formula',
499
494
  node: 'equation_element',
500
495
  getAttrs: (node) => {
501
- var _a;
502
496
  const element = node;
503
497
  return {
504
498
  id: element.getAttribute('id'),
505
- label: (_a = getTrimmedTextContent(element, 'label')) !== null && _a !== void 0 ? _a : '',
506
499
  };
507
500
  },
508
501
  getContent: (node, schema) => {
@@ -608,12 +601,8 @@ export class JATSDOMParser {
608
601
  tag: 'fig',
609
602
  node: 'figure_element',
610
603
  getAttrs: (node) => {
611
- var _a, _b;
604
+ var _a;
612
605
  const element = node;
613
- const labelNode = element.querySelector('label');
614
- if (labelNode) {
615
- element.removeChild(labelNode);
616
- }
617
606
  const attrib = element.querySelector('attrib');
618
607
  const attribution = attrib
619
608
  ? {
@@ -622,7 +611,6 @@ export class JATSDOMParser {
622
611
  : undefined;
623
612
  return {
624
613
  id: element.getAttribute('id'),
625
- label: (_b = getTrimmedTextContent(labelNode)) !== null && _b !== void 0 ? _b : '',
626
614
  attribution,
627
615
  type: element.getAttribute('fig-type'),
628
616
  };
@@ -769,7 +757,6 @@ export class JATSDOMParser {
769
757
  const element = node;
770
758
  return {
771
759
  id: element.getAttribute('id'),
772
- label: getTrimmedTextContent(element, 'label'),
773
760
  };
774
761
  },
775
762
  },
@@ -825,11 +812,6 @@ export class JATSDOMParser {
825
812
  context: 'keyword_group//',
826
813
  node: 'keyword',
827
814
  },
828
- {
829
- tag: 'label',
830
- context: 'box_element/',
831
- ignore: true,
832
- },
833
815
  {
834
816
  tag: 'boxed-text',
835
817
  ignore: true,
@@ -839,16 +821,6 @@ export class JATSDOMParser {
839
821
  context: 'section/',
840
822
  node: 'section_label',
841
823
  },
842
- {
843
- tag: 'label',
844
- context: 'table_element/',
845
- ignore: true,
846
- },
847
- {
848
- tag: 'label',
849
- context: 'figure/',
850
- ignore: true,
851
- },
852
824
  {
853
825
  tag: 'table',
854
826
  node: 'table',
@@ -948,10 +920,13 @@ export class JATSDOMParser {
948
920
  const element = node;
949
921
  return {
950
922
  rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
951
- label: getTrimmedTextContent(element),
952
923
  };
953
924
  },
954
925
  },
926
+ {
927
+ tag: 'label',
928
+ ignore: true,
929
+ },
955
930
  ];
956
931
  this.marks = [
957
932
  {
@@ -22,6 +22,24 @@ const createSectionGroup = (type, createElement) => {
22
22
  sec.setAttribute('sec-type', type);
23
23
  return sec;
24
24
  };
25
+ export const addMissingCaptions = (doc, createElement) => {
26
+ const elements = doc.querySelectorAll('fig, table-wrap');
27
+ for (const element of elements) {
28
+ let caption = element.querySelector('caption');
29
+ if (!caption) {
30
+ caption = createElement('caption');
31
+ element.nodeName === 'fig'
32
+ ? element.appendChild(caption)
33
+ : element.prepend(caption);
34
+ }
35
+ if (!caption.querySelector('title')) {
36
+ caption.prepend(createElement('title'));
37
+ }
38
+ if (!caption.querySelector('p')) {
39
+ caption.appendChild(createElement('p'));
40
+ }
41
+ }
42
+ };
25
43
  export const moveTitle = (front, createElement) => {
26
44
  var _a, _b;
27
45
  let title = front.querySelector('article-meta > title-group > article-title');
@@ -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 { createAbstracts, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
21
+ import { addMissingCaptions, createAbstracts, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
22
22
  const processJATS = (doc, sectionCategories) => {
23
23
  const createElement = createElementFn(doc);
24
24
  markComments(doc);
@@ -26,6 +26,7 @@ const processJATS = (doc, sectionCategories) => {
26
26
  if (!front) {
27
27
  return;
28
28
  }
29
+ addMissingCaptions(doc, createElement);
29
30
  moveTitle(front, createElement);
30
31
  moveContributors(front, createElement);
31
32
  moveAffiliations(front, createElement);
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export const abstracts = {
17
17
  content: 'sections*',
18
+ atom: true,
18
19
  attrs: {
19
20
  id: { default: '' },
20
21
  },
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export const body = {
17
17
  content: 'element* sections*',
18
+ atom: true,
18
19
  attrs: {
19
20
  id: { default: '' },
20
21
  },
@@ -17,7 +17,6 @@ export const box_element = {
17
17
  content: 'figcaption? section?',
18
18
  attrs: {
19
19
  id: { default: '' },
20
- label: { default: '' },
21
20
  dataTracked: { default: null },
22
21
  },
23
22
  group: 'block element',
@@ -29,7 +28,6 @@ export const box_element = {
29
28
  const dom = p;
30
29
  const attrs = {
31
30
  id: dom.getAttribute('id') || undefined,
32
- label: dom.getAttribute('label') || undefined,
33
31
  };
34
32
  return attrs;
35
33
  },
@@ -41,9 +39,6 @@ export const box_element = {
41
39
  if (boxElementNode.attrs.id) {
42
40
  attrs.id = boxElementNode.attrs.id;
43
41
  }
44
- if (boxElementNode.attrs.label) {
45
- attrs.label = boxElementNode.attrs.label;
46
- }
47
42
  return [
48
43
  'div',
49
44
  Object.assign({ class: 'boxed-text' }, attrs),
@@ -17,7 +17,6 @@ export const tableElement = {
17
17
  content: ' figcaption? (table | placeholder) table_colgroup? table_element_footer? (listing | placeholder)',
18
18
  attrs: {
19
19
  id: { default: '' },
20
- label: { default: '' },
21
20
  dataTracked: { default: null },
22
21
  },
23
22
  selectable: false,
@@ -1 +1 @@
1
- export const VERSION = "3.0.24-LEAN-4192.0";
1
+ export const VERSION = "3.0.25";
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { SectionCategory } from '../../schema';
17
17
  export type CreateElement = (tagName: string) => HTMLElement;
18
+ export declare const addMissingCaptions: (doc: Document, createElement: CreateElement) => void;
18
19
  export declare const moveTitle: (front: Element, createElement: CreateElement) => void;
19
20
  export declare const moveAuthorNotes: (front: Element, createElement: CreateElement) => void;
20
21
  export declare const moveAwards: (front: Element) => void;
@@ -17,7 +17,6 @@ import { NodeSpec } from 'prosemirror-model';
17
17
  import { ManuscriptNode } from '../types';
18
18
  interface Attrs {
19
19
  id: string;
20
- label: string;
21
20
  }
22
21
  export interface BoxElementNode extends ManuscriptNode {
23
22
  attrs: Attrs;
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.24-LEAN-4192.0";
1
+ export declare const VERSION = "3.0.25";
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.24-LEAN-4192.0",
4
+ "version": "3.0.25",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",