@manuscripts/transform 1.4.3 → 1.4.4-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/lib/utils.js +12 -1
- package/dist/cjs/schema/nodes/citation.js +10 -1
- 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/lib/utils.js +10 -0
- package/dist/es/schema/nodes/citation.js +10 -1
- package/dist/es/transformer/node-types.js +4 -0
- package/dist/types/lib/utils.d.ts +1 -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');
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
18
|
+
exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
19
19
|
const bibliography_section_1 = require("../schema/nodes/bibliography_section");
|
|
20
20
|
const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
|
|
21
21
|
function* iterateChildren(node, recurse = false) {
|
|
@@ -61,6 +61,17 @@ const isInBibliographySection = ($pos) => {
|
|
|
61
61
|
return false;
|
|
62
62
|
};
|
|
63
63
|
exports.isInBibliographySection = isInBibliographySection;
|
|
64
|
+
const isAbstractsSectionNode = (node) => node.attrs.category === 'MPSectionCategory:abstracts';
|
|
65
|
+
const isInAbstractsSection = ($pos) => {
|
|
66
|
+
for (let i = $pos.depth; i > 0; i--) {
|
|
67
|
+
const node = $pos.node(i);
|
|
68
|
+
if (isAbstractsSectionNode(node)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
};
|
|
74
|
+
exports.isInAbstractsSection = isInAbstractsSection;
|
|
64
75
|
const findParentNodeClosestToPos = ($pos, predicate) => {
|
|
65
76
|
for (let i = $pos.depth; i > 0; i--) {
|
|
66
77
|
const node = $pos.node(i);
|
|
@@ -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
|
},
|
|
@@ -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');
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -54,6 +54,16 @@ export const isInBibliographySection = ($pos) => {
|
|
|
54
54
|
}
|
|
55
55
|
return false;
|
|
56
56
|
};
|
|
57
|
+
const isAbstractsSectionNode = (node) => node.attrs.category === 'MPSectionCategory:abstracts';
|
|
58
|
+
export const isInAbstractsSection = ($pos) => {
|
|
59
|
+
for (let i = $pos.depth; i > 0; i--) {
|
|
60
|
+
const node = $pos.node(i);
|
|
61
|
+
if (isAbstractsSectionNode(node)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
57
67
|
export const findParentNodeClosestToPos = ($pos, predicate) => {
|
|
58
68
|
for (let i = $pos.depth; i > 0; i--) {
|
|
59
69
|
const node = $pos.node(i);
|
|
@@ -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
|
},
|
|
@@ -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;
|
|
@@ -19,6 +19,7 @@ export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean)
|
|
|
19
19
|
export declare const findNodePositions: (state: ManuscriptEditorState, predicate: (node: ManuscriptNode) => boolean) => number[];
|
|
20
20
|
export declare const isInGraphicalAbstractSection: ($pos: ResolvedPos) => boolean;
|
|
21
21
|
export declare const isInBibliographySection: ($pos: ResolvedPos) => boolean;
|
|
22
|
+
export declare const isInAbstractsSection: ($pos: ResolvedPos) => boolean;
|
|
22
23
|
export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate: (node: ProsemirrorNode) => boolean) => {
|
|
23
24
|
pos: number;
|
|
24
25
|
start: number;
|
|
@@ -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.4-LEAN-2737",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|