@manuscripts/transform 4.0.0 → 4.0.1-LEAN-4573.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.
@@ -467,7 +467,7 @@ class JATSExporter {
467
467
  id: normalizeID(node.attrs.id),
468
468
  };
469
469
  if (node.attrs.lang) {
470
- attrs['xml:lang'] = node.attrs.lang;
470
+ attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
471
471
  }
472
472
  if (node.attrs.category) {
473
473
  attrs['sec-type'] = node.attrs.category;
@@ -894,13 +894,17 @@ class JATSExporter {
894
894
  };
895
895
  const createImage = (node) => {
896
896
  const graphicNode = node.content.firstChild;
897
- if (graphicNode) {
898
- const graphicElement = createGraphic(graphicNode);
899
- appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
900
- appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
901
- return graphicElement;
897
+ if (!graphicNode) {
898
+ return '';
899
+ }
900
+ const graphicElement = createGraphic(graphicNode);
901
+ if (node.attrs.extLink) {
902
+ const extLink = this.appendElement(graphicElement, 'ext-link');
903
+ extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
902
904
  }
903
- return '';
905
+ appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
906
+ appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
907
+ return graphicElement;
904
908
  };
905
909
  const createGraphic = (node) => {
906
910
  const graphic = this.createElement('graphic');
@@ -1515,7 +1519,7 @@ class JATSExporter {
1515
1519
  }
1516
1520
  createTransAbstractNode(transAbstract) {
1517
1521
  const transAbstractNode = this.createElement('trans-abstract');
1518
- transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttribute('xml:lang') ?? '');
1522
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
1519
1523
  this.setAbstractType(transAbstractNode, transAbstract);
1520
1524
  transAbstractNode.append(...transAbstract.childNodes);
1521
1525
  return transAbstractNode;
@@ -97,8 +97,9 @@ class JATSDOMParser {
97
97
  };
98
98
  }
99
99
  };
100
- this.getFigureAttrs = (node) => {
100
+ this.getFigAttrs = (node) => {
101
101
  const element = node;
102
+ const extLink = element.querySelector('ext-link');
102
103
  const parentElement = element.parentElement;
103
104
  return {
104
105
  id: element.getAttribute('id'),
@@ -106,6 +107,7 @@ class JATSDOMParser {
106
107
  element.getAttribute('content-type') ??
107
108
  '',
108
109
  src: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
110
+ extLink: extLink?.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
109
111
  };
110
112
  };
111
113
  this.getInstitutionDetails = (element) => {
@@ -151,9 +153,7 @@ class JATSDOMParser {
151
153
  };
152
154
  this.getFigContent = (node) => {
153
155
  const element = node;
154
- const content = [
155
- this.schema.nodes.figure.create(this.getFigureAttrs(element)),
156
- ];
156
+ const content = [this.schema.nodes.figure.create(this.getFigAttrs(element))];
157
157
  const altText = element.querySelector('alt-text');
158
158
  if (altText) {
159
159
  const altTextNode = this.schema.nodes.alt_text.create();
@@ -568,7 +568,7 @@ class JATSDOMParser {
568
568
  tag: 'graphic',
569
569
  node: 'quote_image',
570
570
  context: 'pullquote_element/',
571
- getAttrs: this.getFigureAttrs,
571
+ getAttrs: this.getFigAttrs,
572
572
  },
573
573
  {
574
574
  tag: 'ext-link',
@@ -633,12 +633,13 @@ class JATSDOMParser {
633
633
  tag: 'graphic',
634
634
  node: 'figure',
635
635
  context: 'figure_element/',
636
- getAttrs: this.getFigureAttrs,
636
+ getAttrs: this.getFigAttrs,
637
637
  },
638
638
  {
639
639
  tag: 'graphic',
640
640
  node: 'image_element',
641
641
  getContent: this.getFigContent,
642
+ getAttrs: this.getFigAttrs,
642
643
  },
643
644
  {
644
645
  tag: 'fig',
@@ -5,6 +5,7 @@ exports.imageElement = {
5
5
  content: 'figure? alt_text long_desc',
6
6
  attrs: {
7
7
  id: { default: '' },
8
+ extLink: { default: '' },
8
9
  dataTracked: { default: null },
9
10
  },
10
11
  group: 'block element',
@@ -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.0.0";
4
+ exports.VERSION = "4.0.1-LEAN-4573.0";
@@ -437,7 +437,7 @@ export class JATSExporter {
437
437
  id: normalizeID(node.attrs.id),
438
438
  };
439
439
  if (node.attrs.lang) {
440
- attrs['xml:lang'] = node.attrs.lang;
440
+ attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
441
441
  }
442
442
  if (node.attrs.category) {
443
443
  attrs['sec-type'] = node.attrs.category;
@@ -864,13 +864,17 @@ export class JATSExporter {
864
864
  };
865
865
  const createImage = (node) => {
866
866
  const graphicNode = node.content.firstChild;
867
- if (graphicNode) {
868
- const graphicElement = createGraphic(graphicNode);
869
- appendChildNodeOfType(graphicElement, node, schema.nodes.alt_text);
870
- appendChildNodeOfType(graphicElement, node, schema.nodes.long_desc);
871
- return graphicElement;
867
+ if (!graphicNode) {
868
+ return '';
869
+ }
870
+ const graphicElement = createGraphic(graphicNode);
871
+ if (node.attrs.extLink) {
872
+ const extLink = this.appendElement(graphicElement, 'ext-link');
873
+ extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
872
874
  }
873
- return '';
875
+ appendChildNodeOfType(graphicElement, node, schema.nodes.alt_text);
876
+ appendChildNodeOfType(graphicElement, node, schema.nodes.long_desc);
877
+ return graphicElement;
874
878
  };
875
879
  const createGraphic = (node) => {
876
880
  const graphic = this.createElement('graphic');
@@ -1485,7 +1489,7 @@ export class JATSExporter {
1485
1489
  }
1486
1490
  createTransAbstractNode(transAbstract) {
1487
1491
  const transAbstractNode = this.createElement('trans-abstract');
1488
- transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttribute('xml:lang') ?? '');
1492
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
1489
1493
  this.setAbstractType(transAbstractNode, transAbstract);
1490
1494
  transAbstractNode.append(...transAbstract.childNodes);
1491
1495
  return transAbstractNode;
@@ -94,8 +94,9 @@ export class JATSDOMParser {
94
94
  };
95
95
  }
96
96
  };
97
- this.getFigureAttrs = (node) => {
97
+ this.getFigAttrs = (node) => {
98
98
  const element = node;
99
+ const extLink = element.querySelector('ext-link');
99
100
  const parentElement = element.parentElement;
100
101
  return {
101
102
  id: element.getAttribute('id'),
@@ -103,6 +104,7 @@ export class JATSDOMParser {
103
104
  element.getAttribute('content-type') ??
104
105
  '',
105
106
  src: element.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
107
+ extLink: extLink?.getAttributeNS(this.XLINK_NAMESPACE, 'href'),
106
108
  };
107
109
  };
108
110
  this.getInstitutionDetails = (element) => {
@@ -148,9 +150,7 @@ export class JATSDOMParser {
148
150
  };
149
151
  this.getFigContent = (node) => {
150
152
  const element = node;
151
- const content = [
152
- this.schema.nodes.figure.create(this.getFigureAttrs(element)),
153
- ];
153
+ const content = [this.schema.nodes.figure.create(this.getFigAttrs(element))];
154
154
  const altText = element.querySelector('alt-text');
155
155
  if (altText) {
156
156
  const altTextNode = this.schema.nodes.alt_text.create();
@@ -565,7 +565,7 @@ export class JATSDOMParser {
565
565
  tag: 'graphic',
566
566
  node: 'quote_image',
567
567
  context: 'pullquote_element/',
568
- getAttrs: this.getFigureAttrs,
568
+ getAttrs: this.getFigAttrs,
569
569
  },
570
570
  {
571
571
  tag: 'ext-link',
@@ -630,12 +630,13 @@ export class JATSDOMParser {
630
630
  tag: 'graphic',
631
631
  node: 'figure',
632
632
  context: 'figure_element/',
633
- getAttrs: this.getFigureAttrs,
633
+ getAttrs: this.getFigAttrs,
634
634
  },
635
635
  {
636
636
  tag: 'graphic',
637
637
  node: 'image_element',
638
638
  getContent: this.getFigContent,
639
+ getAttrs: this.getFigAttrs,
639
640
  },
640
641
  {
641
642
  tag: 'fig',
@@ -2,6 +2,7 @@ export const imageElement = {
2
2
  content: 'figure? alt_text long_desc',
3
3
  attrs: {
4
4
  id: { default: '' },
5
+ extLink: { default: '' },
5
6
  dataTracked: { default: null },
6
7
  },
7
8
  group: 'block element',
@@ -1 +1 @@
1
- export const VERSION = "4.0.0";
1
+ export const VERSION = "4.0.1-LEAN-4573.0";
@@ -28,7 +28,7 @@ export declare class JATSDOMParser {
28
28
  private getEquationContent;
29
29
  private parseHistoryDates;
30
30
  private getEmail;
31
- private getFigureAttrs;
31
+ private getFigAttrs;
32
32
  private getInstitutionDetails;
33
33
  private getAddressLine;
34
34
  private getRefType;
@@ -3,6 +3,7 @@ import { ManuscriptNode } from '../types';
3
3
  export interface ImageElementNode extends ManuscriptNode {
4
4
  attrs: {
5
5
  id: string;
6
+ extLink?: string;
6
7
  };
7
8
  }
8
9
  export declare const imageElement: NodeSpec;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0";
1
+ export declare const VERSION = "4.0.1-LEAN-4573.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": "4.0.0",
4
+ "version": "4.0.1-LEAN-4573.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",