@manuscripts/transform 1.5.0-LEAN-3014-B-0 → 1.5.0-LIT-528106
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 +0 -2
- package/dist/cjs/lib/utils.js +14 -1
- package/dist/cjs/schema/index.js +0 -4
- package/dist/cjs/transformer/encode.js +10 -3
- package/dist/es/jats/jats-exporter.js +0 -2
- package/dist/es/lib/utils.js +12 -0
- package/dist/es/schema/index.js +0 -4
- package/dist/es/transformer/encode.js +11 -4
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/encode.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/schema/nodes/affiliation_list.js +0 -10
- package/dist/cjs/schema/nodes/contributor_list.js +0 -10
- package/dist/es/schema/nodes/affiliation_list.js +0 -7
- package/dist/es/schema/nodes/contributor_list.js +0 -7
- package/dist/types/schema/nodes/affiliation_list.d.ts +0 -10
- package/dist/types/schema/nodes/contributor_list.d.ts +0 -10
|
@@ -598,8 +598,6 @@ class JATSExporter {
|
|
|
598
598
|
this.createSerializer = () => {
|
|
599
599
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
600
600
|
const nodes = {
|
|
601
|
-
affiliation_list: () => '',
|
|
602
|
-
contributor_list: () => '',
|
|
603
601
|
affiliations_section: () => '',
|
|
604
602
|
contributors_section: () => '',
|
|
605
603
|
table_element_footer: () => ['table-wrap-foot', 0],
|
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.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
18
|
+
exports.modelsEqual = 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) {
|
|
@@ -94,3 +94,16 @@ const getTrimmedTextContent = (node, querySelector) => {
|
|
|
94
94
|
return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
95
95
|
};
|
|
96
96
|
exports.getTrimmedTextContent = getTrimmedTextContent;
|
|
97
|
+
function modelsEqual(model, model2) {
|
|
98
|
+
for (const v in model) {
|
|
99
|
+
for (const v2 in model2) {
|
|
100
|
+
const prepV = typeof v == 'object' ? JSON.stringify(v) : v;
|
|
101
|
+
const prepV2 = typeof v2 == 'object' ? JSON.stringify(v2) : v2;
|
|
102
|
+
if (prepV !== prepV2) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
exports.modelsEqual = modelsEqual;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -33,7 +33,6 @@ exports.schema = void 0;
|
|
|
33
33
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
34
34
|
const marks_1 = require("./marks");
|
|
35
35
|
const affiliation_1 = require("./nodes/affiliation");
|
|
36
|
-
const affiliation_list_1 = require("./nodes/affiliation_list");
|
|
37
36
|
const affiliations_section_1 = require("./nodes/affiliations_section");
|
|
38
37
|
const attribution_1 = require("./nodes/attribution");
|
|
39
38
|
const bibliography_element_1 = require("./nodes/bibliography_element");
|
|
@@ -46,7 +45,6 @@ const citation_1 = require("./nodes/citation");
|
|
|
46
45
|
const comment_1 = require("./nodes/comment");
|
|
47
46
|
const comment_list_1 = require("./nodes/comment_list");
|
|
48
47
|
const contributor_1 = require("./nodes/contributor");
|
|
49
|
-
const contributor_list_1 = require("./nodes/contributor_list");
|
|
50
48
|
const contributors_section_1 = require("./nodes/contributors_section");
|
|
51
49
|
const cross_reference_1 = require("./nodes/cross_reference");
|
|
52
50
|
const doc_1 = require("./nodes/doc");
|
|
@@ -220,7 +218,5 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
220
218
|
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
221
219
|
affiliations_section: affiliations_section_1.affiliationsSection,
|
|
222
220
|
contributors_section: contributors_section_1.contributorsSection,
|
|
223
|
-
affiliation_list: affiliation_list_1.affiliationList,
|
|
224
|
-
contributor_list: contributor_list_1.contributorList,
|
|
225
221
|
},
|
|
226
222
|
});
|
|
@@ -25,6 +25,7 @@ const utils_1 = require("../lib/utils");
|
|
|
25
25
|
const schema_1 = require("../schema");
|
|
26
26
|
const builders_1 = require("./builders");
|
|
27
27
|
const highlight_markers_1 = require("./highlight-markers");
|
|
28
|
+
const id_1 = require("./id");
|
|
28
29
|
const node_types_1 = require("./node-types");
|
|
29
30
|
const section_category_1 = require("./section-category");
|
|
30
31
|
const serializer = prosemirror_model_1.DOMSerializer.fromSchema(schema_1.schema);
|
|
@@ -570,7 +571,7 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
570
571
|
return { model, commentAnnotationsMap };
|
|
571
572
|
};
|
|
572
573
|
exports.modelFromNode = modelFromNode;
|
|
573
|
-
const encode = (node) => {
|
|
574
|
+
const encode = (node, preserveWithRepeatedID = false) => {
|
|
574
575
|
const models = new Map();
|
|
575
576
|
const priority = {
|
|
576
577
|
value: 1,
|
|
@@ -590,8 +591,14 @@ const encode = (node) => {
|
|
|
590
591
|
return;
|
|
591
592
|
}
|
|
592
593
|
const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
593
|
-
|
|
594
|
-
|
|
594
|
+
const existingModel = models.get(model._id);
|
|
595
|
+
if (existingModel) {
|
|
596
|
+
if (preserveWithRepeatedID && !(0, utils_1.modelsEqual)(model, existingModel)) {
|
|
597
|
+
model._id = (0, id_1.generateID)(model.objectType);
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
|
|
601
|
+
}
|
|
595
602
|
}
|
|
596
603
|
models.set(model._id, model);
|
|
597
604
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
@@ -591,8 +591,6 @@ export class JATSExporter {
|
|
|
591
591
|
this.createSerializer = () => {
|
|
592
592
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
593
593
|
const nodes = {
|
|
594
|
-
affiliation_list: () => '',
|
|
595
|
-
contributor_list: () => '',
|
|
596
594
|
affiliations_section: () => '',
|
|
597
595
|
contributors_section: () => '',
|
|
598
596
|
table_element_footer: () => ['table-wrap-foot', 0],
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -84,3 +84,15 @@ export const getTrimmedTextContent = (node, querySelector) => {
|
|
|
84
84
|
}
|
|
85
85
|
return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
86
86
|
};
|
|
87
|
+
export function modelsEqual(model, model2) {
|
|
88
|
+
for (const v in model) {
|
|
89
|
+
for (const v2 in model2) {
|
|
90
|
+
const prepV = typeof v == 'object' ? JSON.stringify(v) : v;
|
|
91
|
+
const prepV2 = typeof v2 == 'object' ? JSON.stringify(v2) : v2;
|
|
92
|
+
if (prepV !== prepV2) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
package/dist/es/schema/index.js
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
import { Schema } from 'prosemirror-model';
|
|
17
17
|
import { bold, code, italic, smallcaps, strikethrough, styled, subscript, superscript, tracked_delete, tracked_insert, underline, } from './marks';
|
|
18
18
|
import { affiliation } from './nodes/affiliation';
|
|
19
|
-
import { affiliationList } from './nodes/affiliation_list';
|
|
20
19
|
import { affiliationsSection } from './nodes/affiliations_section';
|
|
21
20
|
import { attribution } from './nodes/attribution';
|
|
22
21
|
import { bibliographyElement } from './nodes/bibliography_element';
|
|
@@ -29,7 +28,6 @@ import { citation } from './nodes/citation';
|
|
|
29
28
|
import { comment } from './nodes/comment';
|
|
30
29
|
import { commentList } from './nodes/comment_list';
|
|
31
30
|
import { contributor } from './nodes/contributor';
|
|
32
|
-
import { contributorList } from './nodes/contributor_list';
|
|
33
31
|
import { contributorsSection } from './nodes/contributors_section';
|
|
34
32
|
import { crossReference } from './nodes/cross_reference';
|
|
35
33
|
import { doc } from './nodes/doc';
|
|
@@ -203,7 +201,5 @@ export const schema = new Schema({
|
|
|
203
201
|
table_element_footer: tableElementFooter,
|
|
204
202
|
affiliations_section: affiliationsSection,
|
|
205
203
|
contributors_section: contributorsSection,
|
|
206
|
-
affiliation_list: affiliationList,
|
|
207
|
-
contributor_list: contributorList,
|
|
208
204
|
},
|
|
209
205
|
});
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DOMSerializer } from 'prosemirror-model';
|
|
17
17
|
import serializeToXML from 'w3c-xmlserializer';
|
|
18
|
-
import { iterateChildren } from '../lib/utils';
|
|
18
|
+
import { iterateChildren, modelsEqual } from '../lib/utils';
|
|
19
19
|
import { hasGroup, isHighlightMarkerNode, isSectionNode, schema, } from '../schema';
|
|
20
20
|
import { buildAttribution } from './builders';
|
|
21
21
|
import { extractHighlightMarkers, isHighlightableModel, } from './highlight-markers';
|
|
22
|
+
import { generateID } from './id';
|
|
22
23
|
import { nodeTypesMap } from './node-types';
|
|
23
24
|
import { buildSectionCategory } from './section-category';
|
|
24
25
|
const serializer = DOMSerializer.fromSchema(schema);
|
|
@@ -561,7 +562,7 @@ export const modelFromNode = (node, parent, path, priority) => {
|
|
|
561
562
|
}
|
|
562
563
|
return { model, commentAnnotationsMap };
|
|
563
564
|
};
|
|
564
|
-
export const encode = (node) => {
|
|
565
|
+
export const encode = (node, preserveWithRepeatedID = false) => {
|
|
565
566
|
const models = new Map();
|
|
566
567
|
const priority = {
|
|
567
568
|
value: 1,
|
|
@@ -581,8 +582,14 @@ export const encode = (node) => {
|
|
|
581
582
|
return;
|
|
582
583
|
}
|
|
583
584
|
const { model } = modelFromNode(child, parent, path, priority);
|
|
584
|
-
|
|
585
|
-
|
|
585
|
+
const existingModel = models.get(model._id);
|
|
586
|
+
if (existingModel) {
|
|
587
|
+
if (preserveWithRepeatedID && !modelsEqual(model, existingModel)) {
|
|
588
|
+
model._id = generateID(model.objectType);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
|
|
592
|
+
}
|
|
586
593
|
}
|
|
587
594
|
models.set(model._id, model);
|
|
588
595
|
child.forEach(addModel(path.concat(child.attrs.id), child));
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
16
17
|
import { Node as ProsemirrorNode, ResolvedPos } from 'prosemirror-model';
|
|
17
18
|
import { ManuscriptEditorState, ManuscriptNode } from '../schema';
|
|
18
19
|
export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
|
|
@@ -27,3 +28,4 @@ export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate:
|
|
|
27
28
|
node: ProsemirrorNode;
|
|
28
29
|
} | undefined;
|
|
29
30
|
export declare const getTrimmedTextContent: (node: Element | Document, querySelector: string) => string | null | undefined;
|
|
31
|
+
export declare function modelsEqual(model: Model, model2: Model): boolean;
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'contributor' | 'table_element_footer' | 'affiliations_section' | 'contributors_section'
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comment_list' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keywords_group' | 'keywords_section' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_body' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'meta_section' | 'contributor' | 'table_element_footer' | 'affiliations_section' | 'contributors_section';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -25,5 +25,5 @@ export declare const modelFromNode: (node: ManuscriptNode, parent: ManuscriptNod
|
|
|
25
25
|
interface PrioritizedValue {
|
|
26
26
|
value: number;
|
|
27
27
|
}
|
|
28
|
-
export declare const encode: (node: ManuscriptNode) => Map<string, Model>;
|
|
28
|
+
export declare const encode: (node: ManuscriptNode, preserveWithRepeatedID?: boolean) => Map<string, Model>;
|
|
29
29
|
export {};
|
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.5.0-
|
|
4
|
+
"version": "1.5.0-LIT-528106",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.affiliationList = void 0;
|
|
4
|
-
exports.affiliationList = {
|
|
5
|
-
content: 'affiliation*',
|
|
6
|
-
attrs: {
|
|
7
|
-
id: { default: 'AFFILIATION_LIST' },
|
|
8
|
-
},
|
|
9
|
-
toDOM: () => ['section', 0],
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contributorList = void 0;
|
|
4
|
-
exports.contributorList = {
|
|
5
|
-
content: 'contributor*',
|
|
6
|
-
attrs: {
|
|
7
|
-
id: { default: 'CONTRIBUTOR_LIST' },
|
|
8
|
-
},
|
|
9
|
-
toDOM: () => ['section', 0],
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NodeSpec } from 'prosemirror-model';
|
|
2
|
-
import { ManuscriptNode } from '../types';
|
|
3
|
-
interface Attrs {
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
export interface AffiliationListNode extends ManuscriptNode {
|
|
7
|
-
attrs: Attrs;
|
|
8
|
-
}
|
|
9
|
-
export declare const affiliationList: NodeSpec;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NodeSpec } from 'prosemirror-model';
|
|
2
|
-
import { ManuscriptNode } from '../types';
|
|
3
|
-
interface Attrs {
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ContributorListNode extends ManuscriptNode {
|
|
7
|
-
attrs: Attrs;
|
|
8
|
-
}
|
|
9
|
-
export declare const contributorList: NodeSpec;
|
|
10
|
-
export {};
|