@manuscripts/transform 4.1.0 → 4.1.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.
@@ -473,7 +473,7 @@ class JATSExporter {
473
473
  id: normalizeID(node.attrs.id),
474
474
  };
475
475
  if (node.attrs.lang) {
476
- attrs['xml:lang'] = node.attrs.lang;
476
+ attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
477
477
  }
478
478
  if (node.attrs.category) {
479
479
  attrs['sec-type'] = node.attrs.category;
@@ -902,13 +902,17 @@ class JATSExporter {
902
902
  };
903
903
  const createImage = (node) => {
904
904
  const graphicNode = node.content.firstChild;
905
- if (graphicNode) {
906
- const graphicElement = createGraphic(graphicNode);
907
- appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
908
- appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
909
- return graphicElement;
905
+ if (!graphicNode) {
906
+ return '';
907
+ }
908
+ const graphicElement = createGraphic(graphicNode);
909
+ if (node.attrs.extLink) {
910
+ const extLink = this.appendElement(graphicElement, 'ext-link');
911
+ extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
910
912
  }
911
- return '';
913
+ appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
914
+ appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
915
+ return graphicElement;
912
916
  };
913
917
  const createGraphic = (node) => {
914
918
  const graphic = this.createElement('graphic');
@@ -1523,7 +1527,7 @@ class JATSExporter {
1523
1527
  }
1524
1528
  createTransAbstractNode(transAbstract) {
1525
1529
  const transAbstractNode = this.createElement('trans-abstract');
1526
- transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttribute('xml:lang') ?? '');
1530
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
1527
1531
  this.setAbstractType(transAbstractNode, transAbstract);
1528
1532
  transAbstractNode.append(...transAbstract.childNodes);
1529
1533
  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.1.0";
4
+ exports.VERSION = "4.1.1";
@@ -443,7 +443,7 @@ export class JATSExporter {
443
443
  id: normalizeID(node.attrs.id),
444
444
  };
445
445
  if (node.attrs.lang) {
446
- attrs['xml:lang'] = node.attrs.lang;
446
+ attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
447
447
  }
448
448
  if (node.attrs.category) {
449
449
  attrs['sec-type'] = node.attrs.category;
@@ -872,13 +872,17 @@ export class JATSExporter {
872
872
  };
873
873
  const createImage = (node) => {
874
874
  const graphicNode = node.content.firstChild;
875
- if (graphicNode) {
876
- const graphicElement = createGraphic(graphicNode);
877
- appendChildNodeOfType(graphicElement, node, schema.nodes.alt_text);
878
- appendChildNodeOfType(graphicElement, node, schema.nodes.long_desc);
879
- return graphicElement;
875
+ if (!graphicNode) {
876
+ return '';
877
+ }
878
+ const graphicElement = createGraphic(graphicNode);
879
+ if (node.attrs.extLink) {
880
+ const extLink = this.appendElement(graphicElement, 'ext-link');
881
+ extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
880
882
  }
881
- return '';
883
+ appendChildNodeOfType(graphicElement, node, schema.nodes.alt_text);
884
+ appendChildNodeOfType(graphicElement, node, schema.nodes.long_desc);
885
+ return graphicElement;
882
886
  };
883
887
  const createGraphic = (node) => {
884
888
  const graphic = this.createElement('graphic');
@@ -1493,7 +1497,7 @@ export class JATSExporter {
1493
1497
  }
1494
1498
  createTransAbstractNode(transAbstract) {
1495
1499
  const transAbstractNode = this.createElement('trans-abstract');
1496
- transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttribute('xml:lang') ?? '');
1500
+ transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
1497
1501
  this.setAbstractType(transAbstractNode, transAbstract);
1498
1502
  transAbstractNode.append(...transAbstract.childNodes);
1499
1503
  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.1.0";
1
+ export const VERSION = "4.1.1";
@@ -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.1.0";
1
+ export declare const VERSION = "4.1.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": "4.1.0",
4
+ "version": "4.1.1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",