@manuscripts/transform 1.4.0 → 1.4.1-LEAN-2737
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/importer/jats-body-dom-parser.js +4 -0
- package/dist/cjs/jats/importer/jats-reference-parser.js +1 -0
- package/dist/cjs/schema/nodes/bibliography_element.js +1 -1
- package/dist/cjs/schema/nodes/citation.js +10 -1
- package/dist/cjs/transformer/decode.js +3 -0
- package/dist/cjs/transformer/node-types.js +6 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +4 -0
- package/dist/es/jats/importer/jats-reference-parser.js +1 -0
- package/dist/es/schema/nodes/bibliography_element.js +1 -1
- package/dist/es/schema/nodes/citation.js +10 -1
- package/dist/es/transformer/decode.js +3 -0
- package/dist/es/transformer/node-types.js +4 -0
- package/dist/types/schema/nodes/citation.d.ts +4 -0
- package/dist/types/transformer/node-types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -651,9 +651,13 @@ const nodes = [
|
|
|
651
651
|
getAttrs: (node) => {
|
|
652
652
|
var _a;
|
|
653
653
|
const element = node;
|
|
654
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
654
655
|
return {
|
|
655
656
|
rid: element.getAttribute('rid'),
|
|
656
657
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
658
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
659
|
+
? JSON.parse(embeddedCitationAttr)
|
|
660
|
+
: null,
|
|
657
661
|
};
|
|
658
662
|
},
|
|
659
663
|
},
|
|
@@ -158,6 +158,7 @@ exports.jatsReferenceParser = {
|
|
|
158
158
|
const citation = (0, builders_1.buildCitation)('', rids);
|
|
159
159
|
modelNodes.push(citation);
|
|
160
160
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
161
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems));
|
|
161
162
|
}
|
|
162
163
|
else {
|
|
163
164
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.bibliographyElement = void 0;
|
|
19
19
|
exports.bibliographyElement = {
|
|
20
|
-
content: '(bibliography_item | placeholder)
|
|
20
|
+
content: '(bibliography_item | placeholder)*',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
contents: { default: '' },
|
|
@@ -26,16 +26,22 @@ exports.citation = {
|
|
|
26
26
|
contents: { default: '' },
|
|
27
27
|
selectedText: { default: '' },
|
|
28
28
|
dataTracked: { default: null },
|
|
29
|
+
embeddedCitationItems: { default: null },
|
|
29
30
|
},
|
|
30
31
|
parseDOM: [
|
|
31
32
|
{
|
|
32
33
|
tag: 'span.citation[data-reference-id]',
|
|
33
34
|
getAttrs: (p) => {
|
|
34
35
|
const dom = p;
|
|
35
|
-
|
|
36
|
+
const attr = {
|
|
36
37
|
rid: dom.getAttribute('data-reference-id'),
|
|
37
38
|
contents: dom.innerHTML,
|
|
38
39
|
};
|
|
40
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
41
|
+
if (embeddedCitationAttr) {
|
|
42
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
43
|
+
}
|
|
44
|
+
return attr;
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
],
|
|
@@ -44,6 +50,9 @@ exports.citation = {
|
|
|
44
50
|
const dom = document.createElement('span');
|
|
45
51
|
dom.className = 'citation';
|
|
46
52
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
53
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
54
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
55
|
+
}
|
|
47
56
|
dom.innerHTML = citationNode.attrs.contents;
|
|
48
57
|
return dom;
|
|
49
58
|
},
|
|
@@ -151,6 +151,8 @@ class Decoder {
|
|
|
151
151
|
},
|
|
152
152
|
[json_schema_1.ObjectTypes.BibliographyItem]: (data) => {
|
|
153
153
|
const model = data;
|
|
154
|
+
const commentNodes = this.createCommentsNode(model);
|
|
155
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
154
156
|
return schema_1.schema.nodes.bibliography_item.create({
|
|
155
157
|
id: model._id,
|
|
156
158
|
type: model.type,
|
|
@@ -164,6 +166,7 @@ class Decoder {
|
|
|
164
166
|
page: model.page,
|
|
165
167
|
title: model.title,
|
|
166
168
|
literal: model.literal,
|
|
169
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
167
170
|
});
|
|
168
171
|
},
|
|
169
172
|
[object_types_1.ExtraObjectTypes.PlaceholderElement]: (data) => {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = exports.nodeTypesMap = void 0;
|
|
18
|
+
exports.isMetaNode = exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = exports.nodeTypesMap = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
exports.nodeTypesMap = new Map([
|
|
@@ -66,3 +66,8 @@ const isSectionNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_
|
|
|
66
66
|
exports.isSectionNodeType = isSectionNodeType;
|
|
67
67
|
const isNodeType = (node, type) => node.type === node.type.schema.nodes[type];
|
|
68
68
|
exports.isNodeType = isNodeType;
|
|
69
|
+
const isMetaNode = (nodeType) => nodeType === schema_1.schema.nodes.bibliography_item.name ||
|
|
70
|
+
nodeType === schema_1.schema.nodes.affiliation.name ||
|
|
71
|
+
nodeType === schema_1.schema.nodes.contributor.name ||
|
|
72
|
+
nodeType === schema_1.schema.nodes.manuscript.name;
|
|
73
|
+
exports.isMetaNode = isMetaNode;
|
|
@@ -645,9 +645,13 @@ const nodes = [
|
|
|
645
645
|
getAttrs: (node) => {
|
|
646
646
|
var _a;
|
|
647
647
|
const element = node;
|
|
648
|
+
const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
|
|
648
649
|
return {
|
|
649
650
|
rid: element.getAttribute('rid'),
|
|
650
651
|
contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
652
|
+
embeddedCitationItems: embeddedCitationAttr
|
|
653
|
+
? JSON.parse(embeddedCitationAttr)
|
|
654
|
+
: null,
|
|
651
655
|
};
|
|
652
656
|
},
|
|
653
657
|
},
|
|
@@ -155,6 +155,7 @@ export const jatsReferenceParser = {
|
|
|
155
155
|
const citation = buildCitation('', rids);
|
|
156
156
|
modelNodes.push(citation);
|
|
157
157
|
crossReferenceNode.setAttribute('rid', citation._id);
|
|
158
|
+
crossReferenceNode.setAttribute('data-reference-embedded-citation', JSON.stringify(citation.embeddedCitationItems));
|
|
158
159
|
}
|
|
159
160
|
else {
|
|
160
161
|
crossReferenceNode.removeAttribute('rid');
|
|
@@ -23,16 +23,22 @@ export const citation = {
|
|
|
23
23
|
contents: { default: '' },
|
|
24
24
|
selectedText: { default: '' },
|
|
25
25
|
dataTracked: { default: null },
|
|
26
|
+
embeddedCitationItems: { default: null },
|
|
26
27
|
},
|
|
27
28
|
parseDOM: [
|
|
28
29
|
{
|
|
29
30
|
tag: 'span.citation[data-reference-id]',
|
|
30
31
|
getAttrs: (p) => {
|
|
31
32
|
const dom = p;
|
|
32
|
-
|
|
33
|
+
const attr = {
|
|
33
34
|
rid: dom.getAttribute('data-reference-id'),
|
|
34
35
|
contents: dom.innerHTML,
|
|
35
36
|
};
|
|
37
|
+
const embeddedCitationAttr = dom.getAttribute('data-reference-embedded-citation');
|
|
38
|
+
if (embeddedCitationAttr) {
|
|
39
|
+
attr['embeddedCitationItems'] = JSON.parse(embeddedCitationAttr);
|
|
40
|
+
}
|
|
41
|
+
return attr;
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
44
|
],
|
|
@@ -41,6 +47,9 @@ export const citation = {
|
|
|
41
47
|
const dom = document.createElement('span');
|
|
42
48
|
dom.className = 'citation';
|
|
43
49
|
dom.setAttribute('data-reference-id', citationNode.attrs.rid);
|
|
50
|
+
if (citationNode.attrs.embeddedCitationItems) {
|
|
51
|
+
dom.setAttribute('data-reference-embedded-citation', JSON.stringify(citationNode.attrs.embeddedCitationItems));
|
|
52
|
+
}
|
|
44
53
|
dom.innerHTML = citationNode.attrs.contents;
|
|
45
54
|
return dom;
|
|
46
55
|
},
|
|
@@ -141,6 +141,8 @@ export class Decoder {
|
|
|
141
141
|
},
|
|
142
142
|
[ObjectTypes.BibliographyItem]: (data) => {
|
|
143
143
|
const model = data;
|
|
144
|
+
const commentNodes = this.createCommentsNode(model);
|
|
145
|
+
commentNodes.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
144
146
|
return schema.nodes.bibliography_item.create({
|
|
145
147
|
id: model._id,
|
|
146
148
|
type: model.type,
|
|
@@ -154,6 +156,7 @@ export class Decoder {
|
|
|
154
156
|
page: model.page,
|
|
155
157
|
title: model.title,
|
|
156
158
|
literal: model.literal,
|
|
159
|
+
comments: commentNodes.map((c) => c.attrs.id),
|
|
157
160
|
});
|
|
158
161
|
},
|
|
159
162
|
[ExtraObjectTypes.PlaceholderElement]: (data) => {
|
|
@@ -59,3 +59,7 @@ export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
|
59
59
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
60
60
|
export const isSectionNodeType = (type) => hasGroup(type, GROUP_SECTION);
|
|
61
61
|
export const isNodeType = (node, type) => node.type === node.type.schema.nodes[type];
|
|
62
|
+
export const isMetaNode = (nodeType) => nodeType === schema.nodes.bibliography_item.name ||
|
|
63
|
+
nodeType === schema.nodes.affiliation.name ||
|
|
64
|
+
nodeType === schema.nodes.contributor.name ||
|
|
65
|
+
nodeType === schema.nodes.manuscript.name;
|
|
@@ -18,6 +18,10 @@ import { ManuscriptNode } from '../types';
|
|
|
18
18
|
interface Attrs {
|
|
19
19
|
rid: string;
|
|
20
20
|
contents: string;
|
|
21
|
+
embeddedCitationItems: {
|
|
22
|
+
id: string;
|
|
23
|
+
bibliographyItem: string;
|
|
24
|
+
}[];
|
|
21
25
|
}
|
|
22
26
|
export interface CitationNode extends ManuscriptNode {
|
|
23
27
|
attrs: Attrs;
|
|
@@ -20,3 +20,4 @@ export declare const isExecutableNodeType: (type: ManuscriptNodeType) => boolean
|
|
|
20
20
|
export declare const isElementNodeType: (type: ManuscriptNodeType) => boolean;
|
|
21
21
|
export declare const isSectionNodeType: (type: ManuscriptNodeType) => boolean;
|
|
22
22
|
export declare const isNodeType: <T extends import("prosemirror-model").Node>(node: ManuscriptNode, type: Nodes) => node is T;
|
|
23
|
+
export declare const isMetaNode: (nodeType: string) => boolean;
|
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": "1.4.
|
|
4
|
+
"version": "1.4.1-LEAN-2737",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|