@manuscripts/transform 2.2.2-LEAN-2746.0 → 2.3.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.
- package/dist/cjs/jats/jats-exporter.js +18 -42
- package/dist/cjs/schema/nodes/title.js +2 -1
- package/dist/cjs/transformer/decode.js +1 -3
- package/dist/es/jats/jats-exporter.js +18 -42
- package/dist/es/schema/nodes/title.js +2 -1
- package/dist/es/transformer/decode.js +1 -3
- package/dist/types/jats/jats-exporter.d.ts +2 -3
- package/package.json +1 -1
|
@@ -160,7 +160,6 @@ class JATSExporter {
|
|
|
160
160
|
if (mediaPathGenerator) {
|
|
161
161
|
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
162
162
|
}
|
|
163
|
-
this.rewriteCrossReferenceTypes();
|
|
164
163
|
return (0, w3c_xmlserializer_1.default)(this.document);
|
|
165
164
|
};
|
|
166
165
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -173,66 +172,44 @@ class JATSExporter {
|
|
|
173
172
|
template.innerHTML = JATSFragment;
|
|
174
173
|
return template.firstChild;
|
|
175
174
|
};
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
if (!figRefs.length) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
for (const xref of figRefs) {
|
|
183
|
-
const rid = xref.getAttribute('rid');
|
|
184
|
-
if (rid) {
|
|
185
|
-
const nodeName = (_a = this.document.getElementById(rid)) === null || _a === void 0 ? void 0 : _a.nodeName;
|
|
186
|
-
if (nodeName) {
|
|
187
|
-
switch (nodeName) {
|
|
188
|
-
case 'table-wrap-group':
|
|
189
|
-
case 'table-wrap':
|
|
190
|
-
case 'table':
|
|
191
|
-
xref.setAttribute('ref-type', 'table');
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
this.rewriteMediaPaths = async (mediaPathGenerator) => {
|
|
199
|
-
for (const fig of this.document.querySelectorAll('fig')) {
|
|
200
|
-
const parentID = fig.getAttribute('id');
|
|
175
|
+
this.rewriteMediaPaths = async (generator) => {
|
|
176
|
+
const doc = this.document;
|
|
177
|
+
for (const fig of doc.querySelectorAll('fig')) {
|
|
201
178
|
for (const graphic of fig.querySelectorAll('graphic')) {
|
|
202
|
-
const newHref = await
|
|
179
|
+
const newHref = await generator(graphic, fig.id);
|
|
203
180
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
204
181
|
}
|
|
205
182
|
}
|
|
206
|
-
for (const
|
|
207
|
-
const newHref = await
|
|
208
|
-
|
|
183
|
+
for (const suppl of doc.querySelectorAll('supplementary-material')) {
|
|
184
|
+
const newHref = await generator(suppl, suppl.id);
|
|
185
|
+
suppl.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
209
186
|
}
|
|
210
187
|
};
|
|
211
|
-
this.rewriteIDs = async (
|
|
212
|
-
const
|
|
188
|
+
this.rewriteIDs = async (generator = createDefaultIdGenerator()) => {
|
|
189
|
+
const ids = new Map();
|
|
213
190
|
for (const element of this.document.querySelectorAll('[id]')) {
|
|
214
|
-
const
|
|
215
|
-
const newID = await
|
|
191
|
+
const oldID = element.getAttribute('id');
|
|
192
|
+
const newID = await generator(element);
|
|
216
193
|
if (newID) {
|
|
217
194
|
element.setAttribute('id', newID);
|
|
218
195
|
}
|
|
219
196
|
else {
|
|
220
197
|
element.removeAttribute('id');
|
|
221
198
|
}
|
|
222
|
-
if (
|
|
223
|
-
|
|
199
|
+
if (oldID) {
|
|
200
|
+
ids.set(oldID, newID);
|
|
224
201
|
}
|
|
225
202
|
}
|
|
226
203
|
for (const node of this.document.querySelectorAll('[rid]')) {
|
|
227
204
|
const rids = node.getAttribute('rid');
|
|
228
205
|
if (rids) {
|
|
229
|
-
const
|
|
206
|
+
const newRids = rids
|
|
230
207
|
.split(/\s+/)
|
|
231
208
|
.filter(Boolean)
|
|
232
|
-
.map((
|
|
209
|
+
.map((rid) => ids.get(rid))
|
|
233
210
|
.filter(Boolean);
|
|
234
|
-
if (
|
|
235
|
-
node.setAttribute('rid',
|
|
211
|
+
if (newRids.length) {
|
|
212
|
+
node.setAttribute('rid', newRids.join(' '));
|
|
236
213
|
}
|
|
237
214
|
}
|
|
238
215
|
}
|
|
@@ -719,8 +696,7 @@ class JATSExporter {
|
|
|
719
696
|
},
|
|
720
697
|
figure: (node) => {
|
|
721
698
|
const graphic = this.document.createElement('graphic');
|
|
722
|
-
|
|
723
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', `graphic/${filename}`);
|
|
699
|
+
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
|
|
724
700
|
if (node.attrs.contentType) {
|
|
725
701
|
const [mimeType, mimeSubType] = node.attrs.contentType.split('/');
|
|
726
702
|
if (mimeType) {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.title = void 0;
|
|
19
19
|
exports.title = {
|
|
20
|
-
content: '
|
|
20
|
+
content: 'text*',
|
|
21
|
+
marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
|
|
21
22
|
attrs: {
|
|
22
23
|
id: { default: '' },
|
|
23
24
|
dataTracked: { default: null },
|
|
@@ -169,9 +169,7 @@ class Decoder {
|
|
|
169
169
|
this.creators = {
|
|
170
170
|
[json_schema_1.ObjectTypes.Titles]: (data) => {
|
|
171
171
|
const model = data;
|
|
172
|
-
|
|
173
|
-
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
174
|
-
return this.parseContents(model.title, 'div', this.getComments(model), {
|
|
172
|
+
return this.parseContents(model.title, 'div', undefined, {
|
|
175
173
|
topNode: schema_1.schema.nodes.title.create({
|
|
176
174
|
id: model._id,
|
|
177
175
|
}),
|
|
@@ -152,7 +152,6 @@ export class JATSExporter {
|
|
|
152
152
|
if (mediaPathGenerator) {
|
|
153
153
|
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
154
154
|
}
|
|
155
|
-
this.rewriteCrossReferenceTypes();
|
|
156
155
|
return serializeToXML(this.document);
|
|
157
156
|
};
|
|
158
157
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -165,66 +164,44 @@ export class JATSExporter {
|
|
|
165
164
|
template.innerHTML = JATSFragment;
|
|
166
165
|
return template.firstChild;
|
|
167
166
|
};
|
|
168
|
-
this.
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
if (!figRefs.length) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
for (const xref of figRefs) {
|
|
175
|
-
const rid = xref.getAttribute('rid');
|
|
176
|
-
if (rid) {
|
|
177
|
-
const nodeName = (_a = this.document.getElementById(rid)) === null || _a === void 0 ? void 0 : _a.nodeName;
|
|
178
|
-
if (nodeName) {
|
|
179
|
-
switch (nodeName) {
|
|
180
|
-
case 'table-wrap-group':
|
|
181
|
-
case 'table-wrap':
|
|
182
|
-
case 'table':
|
|
183
|
-
xref.setAttribute('ref-type', 'table');
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
this.rewriteMediaPaths = async (mediaPathGenerator) => {
|
|
191
|
-
for (const fig of this.document.querySelectorAll('fig')) {
|
|
192
|
-
const parentID = fig.getAttribute('id');
|
|
167
|
+
this.rewriteMediaPaths = async (generator) => {
|
|
168
|
+
const doc = this.document;
|
|
169
|
+
for (const fig of doc.querySelectorAll('fig')) {
|
|
193
170
|
for (const graphic of fig.querySelectorAll('graphic')) {
|
|
194
|
-
const newHref = await
|
|
171
|
+
const newHref = await generator(graphic, fig.id);
|
|
195
172
|
graphic.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
196
173
|
}
|
|
197
174
|
}
|
|
198
|
-
for (const
|
|
199
|
-
const newHref = await
|
|
200
|
-
|
|
175
|
+
for (const suppl of doc.querySelectorAll('supplementary-material')) {
|
|
176
|
+
const newHref = await generator(suppl, suppl.id);
|
|
177
|
+
suppl.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
201
178
|
}
|
|
202
179
|
};
|
|
203
|
-
this.rewriteIDs = async (
|
|
204
|
-
const
|
|
180
|
+
this.rewriteIDs = async (generator = createDefaultIdGenerator()) => {
|
|
181
|
+
const ids = new Map();
|
|
205
182
|
for (const element of this.document.querySelectorAll('[id]')) {
|
|
206
|
-
const
|
|
207
|
-
const newID = await
|
|
183
|
+
const oldID = element.getAttribute('id');
|
|
184
|
+
const newID = await generator(element);
|
|
208
185
|
if (newID) {
|
|
209
186
|
element.setAttribute('id', newID);
|
|
210
187
|
}
|
|
211
188
|
else {
|
|
212
189
|
element.removeAttribute('id');
|
|
213
190
|
}
|
|
214
|
-
if (
|
|
215
|
-
|
|
191
|
+
if (oldID) {
|
|
192
|
+
ids.set(oldID, newID);
|
|
216
193
|
}
|
|
217
194
|
}
|
|
218
195
|
for (const node of this.document.querySelectorAll('[rid]')) {
|
|
219
196
|
const rids = node.getAttribute('rid');
|
|
220
197
|
if (rids) {
|
|
221
|
-
const
|
|
198
|
+
const newRids = rids
|
|
222
199
|
.split(/\s+/)
|
|
223
200
|
.filter(Boolean)
|
|
224
|
-
.map((
|
|
201
|
+
.map((rid) => ids.get(rid))
|
|
225
202
|
.filter(Boolean);
|
|
226
|
-
if (
|
|
227
|
-
node.setAttribute('rid',
|
|
203
|
+
if (newRids.length) {
|
|
204
|
+
node.setAttribute('rid', newRids.join(' '));
|
|
228
205
|
}
|
|
229
206
|
}
|
|
230
207
|
}
|
|
@@ -711,8 +688,7 @@ export class JATSExporter {
|
|
|
711
688
|
},
|
|
712
689
|
figure: (node) => {
|
|
713
690
|
const graphic = this.document.createElement('graphic');
|
|
714
|
-
|
|
715
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', `graphic/${filename}`);
|
|
691
|
+
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
|
|
716
692
|
if (node.attrs.contentType) {
|
|
717
693
|
const [mimeType, mimeSubType] = node.attrs.contentType.split('/');
|
|
718
694
|
if (mimeType) {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const title = {
|
|
17
|
-
content: '
|
|
17
|
+
content: 'text*',
|
|
18
|
+
marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
|
|
18
19
|
attrs: {
|
|
19
20
|
id: { default: '' },
|
|
20
21
|
dataTracked: { default: null },
|
|
@@ -160,9 +160,7 @@ export class Decoder {
|
|
|
160
160
|
this.creators = {
|
|
161
161
|
[ObjectTypes.Titles]: (data) => {
|
|
162
162
|
const model = data;
|
|
163
|
-
|
|
164
|
-
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
165
|
-
return this.parseContents(model.title, 'div', this.getComments(model), {
|
|
163
|
+
return this.parseContents(model.title, 'div', undefined, {
|
|
166
164
|
topNode: schema.nodes.title.create({
|
|
167
165
|
id: model._id,
|
|
168
166
|
}),
|
|
@@ -72,9 +72,8 @@ export declare class JATSExporter {
|
|
|
72
72
|
protected generateCitationTexts(fragment: ManuscriptFragment, csl: CSLOptions): void;
|
|
73
73
|
serializeToJATS: (fragment: ManuscriptFragment, modelMap: Map<string, Model>, manuscriptID: string, options: JATSExporterOptions) => Promise<string>;
|
|
74
74
|
private nodeFromJATS;
|
|
75
|
-
protected
|
|
76
|
-
protected
|
|
77
|
-
protected rewriteIDs: (idGenerator?: IDGenerator) => Promise<void>;
|
|
75
|
+
protected rewriteMediaPaths: (generator: MediaPathGenerator) => Promise<void>;
|
|
76
|
+
protected rewriteIDs: (generator?: IDGenerator) => Promise<void>;
|
|
78
77
|
protected setTitleContent: (element: HTMLElement, title: string) => void;
|
|
79
78
|
protected buildFront: (doi?: string, id?: string, links?: Links) => HTMLElement;
|
|
80
79
|
protected buildDateElement: (timestamp: number, type: string) => HTMLElement;
|
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": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|