@manuscripts/transform 1.1.6 → 1.2.1-LEAN-2412

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.
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findParentNodeClosestToPos = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
18
+ exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
19
+ const bibliography_section_1 = require("../schema/nodes/bibliography_section");
19
20
  const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
20
21
  function* iterateChildren(node, recurse = false) {
21
22
  for (let i = 0; i < node.childCount; i++) {
@@ -50,6 +51,16 @@ const isInGraphicalAbstractSection = ($pos) => {
50
51
  return false;
51
52
  };
52
53
  exports.isInGraphicalAbstractSection = isInGraphicalAbstractSection;
54
+ const isInBibliographySection = ($pos) => {
55
+ for (let i = $pos.depth; i > 0; i--) {
56
+ const node = $pos.node(i);
57
+ if ((0, bibliography_section_1.isBibliographySectionNode)(node)) {
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ };
63
+ exports.isInBibliographySection = isInBibliographySection;
53
64
  const findParentNodeClosestToPos = ($pos, predicate) => {
54
65
  for (let i = $pos.depth; i > 0; i--) {
55
66
  const node = $pos.node(i);
@@ -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.updatedPageLayout = exports.getByPrototype = exports.fromPrototype = exports.loadBundledDependencies = exports.loadContributorRoles = exports.loadKeywords = exports.loadStyles = void 0;
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;
@@ -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 { isBibliographySectionNode } from '../schema/nodes/bibliography_section';
16
17
  import { isGraphicalAbstractSectionNode } from '../schema/nodes/graphical_abstract_section';
17
18
  export function* iterateChildren(node, recurse = false) {
18
19
  for (let i = 0; i < node.childCount; i++) {
@@ -44,6 +45,15 @@ export const isInGraphicalAbstractSection = ($pos) => {
44
45
  }
45
46
  return false;
46
47
  };
48
+ export const isInBibliographySection = ($pos) => {
49
+ for (let i = $pos.depth; i > 0; i--) {
50
+ const node = $pos.node(i);
51
+ if (isBibliographySectionNode(node)) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ };
47
57
  export const findParentNodeClosestToPos = ($pos, predicate) => {
48
58
  for (let i = $pos.depth; i > 0; i--) {
49
59
  const node = $pos.node(i);
@@ -32,6 +32,5 @@ export * from './object-types';
32
32
  export * from './project-bundle';
33
33
  export * from './section-category';
34
34
  export * from './serializer';
35
- export * from './shared-data';
36
35
  export * from './timestamp';
37
36
  export * from './update-identifiers';
@@ -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
- };
@@ -18,6 +18,7 @@ import { ManuscriptEditorState, ManuscriptNode } from '../schema';
18
18
  export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
19
19
  export declare const findNodePositions: (state: ManuscriptEditorState, predicate: (node: ManuscriptNode) => boolean) => number[];
20
20
  export declare const isInGraphicalAbstractSection: ($pos: ResolvedPos) => boolean;
21
+ export declare const isInBibliographySection: ($pos: ResolvedPos) => boolean;
21
22
  export declare const findParentNodeClosestToPos: ($pos: ResolvedPos, predicate: (node: ProsemirrorNode) => boolean) => {
22
23
  pos: number;
23
24
  start: number;
@@ -32,6 +32,5 @@ export * from './object-types';
32
32
  export * from './project-bundle';
33
33
  export * from './section-category';
34
34
  export * from './serializer';
35
- export * from './shared-data';
36
35
  export * from './timestamp';
37
36
  export * from './update-identifiers';
@@ -1,12 +1,4 @@
1
- import { AuxiliaryObjectReferenceStyle, BorderStyle, CaptionStyle, Color, ColorScheme, ContributorRole, FigureLayout, FigureStyle, Model, PageLayout, ParagraphStyle, TableStyle } from '@manuscripts/json-schema';
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.6",
4
+ "version": "1.2.1-LEAN-2412",
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": "^1.0.0",
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);
@@ -1,2 +0,0 @@
1
- import { Model } from '@manuscripts/json-schema';
2
- export declare const loadSharedData: <T extends Model>(file: string) => Promise<T[]>;