@manuscripts/transform 1.1.6 → 1.2.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.
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/transformer/manuscript-dependencies.js +1 -54
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/transformer/manuscript-dependencies.js +0 -47
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/transformer/manuscript-dependencies.d.ts +1 -9
- package/package.json +2 -4
- package/dist/cjs/transformer/shared-data.js +0 -31
- package/dist/es/transformer/shared-data.js +0 -1
- package/dist/types/transformer/shared-data.d.ts +0 -2
|
@@ -48,6 +48,5 @@ __exportStar(require("./object-types"), exports);
|
|
|
48
48
|
__exportStar(require("./project-bundle"), exports);
|
|
49
49
|
__exportStar(require("./section-category"), exports);
|
|
50
50
|
__exportStar(require("./serializer"), exports);
|
|
51
|
-
__exportStar(require("./shared-data"), exports);
|
|
52
51
|
__exportStar(require("./timestamp"), exports);
|
|
53
52
|
__exportStar(require("./update-identifiers"), exports);
|
|
@@ -11,64 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
15
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
14
|
+
exports.fromPrototype = void 0;
|
|
16
15
|
const id_1 = require("./id");
|
|
17
|
-
const object_types_1 = require("./object-types");
|
|
18
|
-
const shared_data_1 = require("./shared-data");
|
|
19
|
-
const isStatusLabel = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.StatusLabel);
|
|
20
|
-
const isBundledModel = (model) => model.bundled === true;
|
|
21
|
-
const loadBundledData = async (file) => {
|
|
22
|
-
const models = await (0, shared_data_1.loadSharedData)(file);
|
|
23
|
-
return models.filter(isBundledModel);
|
|
24
|
-
};
|
|
25
|
-
const loadStyles = () => loadBundledData('styles');
|
|
26
|
-
exports.loadStyles = loadStyles;
|
|
27
|
-
const loadKeywords = () => loadBundledData('keywords');
|
|
28
|
-
exports.loadKeywords = loadKeywords;
|
|
29
|
-
const loadContributorRoles = () => loadBundledData('contributor-roles');
|
|
30
|
-
exports.loadContributorRoles = loadContributorRoles;
|
|
31
|
-
const loadBundledDependencies = async () => {
|
|
32
|
-
const contributorRoles = await (0, exports.loadContributorRoles)();
|
|
33
|
-
const keywords = await (0, exports.loadKeywords)();
|
|
34
|
-
const styles = await (0, exports.loadStyles)();
|
|
35
|
-
return [...contributorRoles, ...keywords.filter(isStatusLabel), ...styles];
|
|
36
|
-
};
|
|
37
|
-
exports.loadBundledDependencies = loadBundledDependencies;
|
|
38
16
|
const fromPrototype = (model) => {
|
|
39
17
|
const { _id, _rev } = model, data = __rest(model, ["_id", "_rev"]);
|
|
40
18
|
const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: (0, id_1.generateID)(model.objectType) });
|
|
41
19
|
return output;
|
|
42
20
|
};
|
|
43
21
|
exports.fromPrototype = fromPrototype;
|
|
44
|
-
const getByPrototype = (modelMap, prototype) => {
|
|
45
|
-
for (const model of modelMap.values()) {
|
|
46
|
-
if (model.prototype === prototype) {
|
|
47
|
-
return model;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.getByPrototype = getByPrototype;
|
|
52
|
-
const isParagraphStyle = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphStyle);
|
|
53
|
-
const chooseNewDefaultParagraphStyle = (styles) => {
|
|
54
|
-
for (const style of styles.values()) {
|
|
55
|
-
if (isParagraphStyle(style)) {
|
|
56
|
-
if (style.title === 'Body Text') {
|
|
57
|
-
return style;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const updatedPageLayout = (styleMap, pageLayoutID) => {
|
|
63
|
-
const newPageLayout = (0, exports.getByPrototype)(styleMap, pageLayoutID);
|
|
64
|
-
if (!newPageLayout) {
|
|
65
|
-
throw new Error('Page layout not found');
|
|
66
|
-
}
|
|
67
|
-
const newDefaultParagraphStyle = (0, exports.getByPrototype)(styleMap, newPageLayout.defaultParagraphStyle) || chooseNewDefaultParagraphStyle(styleMap);
|
|
68
|
-
if (!newDefaultParagraphStyle) {
|
|
69
|
-
throw new Error('Default paragraph style not found');
|
|
70
|
-
}
|
|
71
|
-
newPageLayout.defaultParagraphStyle = newDefaultParagraphStyle._id;
|
|
72
|
-
return newPageLayout;
|
|
73
|
-
};
|
|
74
|
-
exports.updatedPageLayout = updatedPageLayout;
|
|
@@ -9,56 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
13
12
|
import { generateID } from './id';
|
|
14
|
-
import { hasObjectType } from './object-types';
|
|
15
|
-
import { loadSharedData } from './shared-data';
|
|
16
|
-
const isStatusLabel = hasObjectType(ObjectTypes.StatusLabel);
|
|
17
|
-
const isBundledModel = (model) => model.bundled === true;
|
|
18
|
-
const loadBundledData = async (file) => {
|
|
19
|
-
const models = await loadSharedData(file);
|
|
20
|
-
return models.filter(isBundledModel);
|
|
21
|
-
};
|
|
22
|
-
export const loadStyles = () => loadBundledData('styles');
|
|
23
|
-
export const loadKeywords = () => loadBundledData('keywords');
|
|
24
|
-
export const loadContributorRoles = () => loadBundledData('contributor-roles');
|
|
25
|
-
export const loadBundledDependencies = async () => {
|
|
26
|
-
const contributorRoles = await loadContributorRoles();
|
|
27
|
-
const keywords = await loadKeywords();
|
|
28
|
-
const styles = await loadStyles();
|
|
29
|
-
return [...contributorRoles, ...keywords.filter(isStatusLabel), ...styles];
|
|
30
|
-
};
|
|
31
13
|
export const fromPrototype = (model) => {
|
|
32
14
|
const { _id, _rev } = model, data = __rest(model, ["_id", "_rev"]);
|
|
33
15
|
const output = Object.assign(Object.assign({}, data), { prototype: _id, _id: generateID(model.objectType) });
|
|
34
16
|
return output;
|
|
35
17
|
};
|
|
36
|
-
export const getByPrototype = (modelMap, prototype) => {
|
|
37
|
-
for (const model of modelMap.values()) {
|
|
38
|
-
if (model.prototype === prototype) {
|
|
39
|
-
return model;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const isParagraphStyle = hasObjectType(ObjectTypes.ParagraphStyle);
|
|
44
|
-
const chooseNewDefaultParagraphStyle = (styles) => {
|
|
45
|
-
for (const style of styles.values()) {
|
|
46
|
-
if (isParagraphStyle(style)) {
|
|
47
|
-
if (style.title === 'Body Text') {
|
|
48
|
-
return style;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
export const updatedPageLayout = (styleMap, pageLayoutID) => {
|
|
54
|
-
const newPageLayout = getByPrototype(styleMap, pageLayoutID);
|
|
55
|
-
if (!newPageLayout) {
|
|
56
|
-
throw new Error('Page layout not found');
|
|
57
|
-
}
|
|
58
|
-
const newDefaultParagraphStyle = getByPrototype(styleMap, newPageLayout.defaultParagraphStyle) || chooseNewDefaultParagraphStyle(styleMap);
|
|
59
|
-
if (!newDefaultParagraphStyle) {
|
|
60
|
-
throw new Error('Default paragraph style not found');
|
|
61
|
-
}
|
|
62
|
-
newPageLayout.defaultParagraphStyle = newDefaultParagraphStyle._id;
|
|
63
|
-
return newPageLayout;
|
|
64
|
-
};
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ContainedModel } from './models';
|
|
3
|
-
export type StyleObject = AuxiliaryObjectReferenceStyle | BorderStyle | CaptionStyle | Color | ColorScheme | FigureLayout | FigureStyle | PageLayout | ParagraphStyle | TableStyle;
|
|
4
|
-
export declare const loadStyles: () => Promise<StyleObject[]>;
|
|
5
|
-
export declare const loadKeywords: () => Promise<Model[]>;
|
|
6
|
-
export declare const loadContributorRoles: () => Promise<ContributorRole[]>;
|
|
7
|
-
export declare const loadBundledDependencies: () => Promise<ContainedModel[]>;
|
|
1
|
+
import { Model } from '@manuscripts/json-schema';
|
|
8
2
|
export declare const fromPrototype: <T extends Model>(model: T) => T & {
|
|
9
3
|
prototype: string;
|
|
10
4
|
};
|
|
11
|
-
export declare const getByPrototype: <T extends Model>(modelMap: Map<string, Model>, prototype: string) => T | undefined;
|
|
12
|
-
export declare const updatedPageLayout: (styleMap: Map<string, StyleObject>, pageLayoutID: string) => PageLayout;
|
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.1
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "^
|
|
32
|
+
"@manuscripts/json-schema": "^2.0.0",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@manuscripts/data": "^0.1.12",
|
|
47
47
|
"@manuscripts/eslint-config": "^0.5.1",
|
|
48
48
|
"@manuscripts/examples": "^0.1.0",
|
|
49
|
-
"@manuscripts/json-schema": "^1.1.0",
|
|
50
49
|
"@types/debug": "^4.1.7",
|
|
51
50
|
"@types/jest": "^29.2.4",
|
|
52
51
|
"@types/lodash.pickby": "^4.6.7",
|
|
@@ -82,7 +81,6 @@
|
|
|
82
81
|
},
|
|
83
82
|
"peerDependencies": {
|
|
84
83
|
"@manuscripts/data": "^0.1.12",
|
|
85
|
-
"@manuscripts/json-schema": "^1.0.0",
|
|
86
84
|
"prosemirror-model": "^1.18.3",
|
|
87
85
|
"prosemirror-state": "^1.4.2",
|
|
88
86
|
"prosemirror-view": "^1.29.1"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.loadSharedData = void 0;
|
|
27
|
-
const loadSharedData = (file) => {
|
|
28
|
-
var _a;
|
|
29
|
-
return (_a = `@manuscripts/data/dist/shared/${file}.json`, Promise.resolve().then(() => __importStar(require(_a)))).then((module) => module.default);
|
|
30
|
-
};
|
|
31
|
-
exports.loadSharedData = loadSharedData;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const loadSharedData = (file) => import(`@manuscripts/data/dist/shared/${file}.json`).then((module) => module.default);
|