@manuscripts/transform 3.0.21-LEAN-4076.1 → 3.0.21
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/index.js +1 -2
- package/dist/cjs/jats/exporter/jats-exporter.js +7 -7
- package/dist/cjs/jats/importer/jats-dom-parser.js +972 -948
- package/dist/cjs/jats/importer/jats-transformations.js +9 -14
- package/dist/cjs/jats/importer/parse-jats-article.js +7 -5
- package/dist/cjs/lib/{section-group-type.js → section-categories.js} +4 -14
- package/dist/cjs/schema/index.js +0 -2
- package/dist/cjs/schema/migration/migration-scripts/3.0.21.js +25 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/index.js +1 -2
- package/dist/es/jats/exporter/jats-exporter.js +8 -8
- package/dist/es/jats/importer/jats-dom-parser.js +970 -947
- package/dist/es/jats/importer/jats-transformations.js +9 -14
- package/dist/es/jats/importer/parse-jats-article.js +8 -6
- package/dist/es/lib/{section-group-type.js → section-categories.js} +2 -13
- package/dist/es/schema/index.js +0 -2
- package/dist/es/schema/migration/migration-scripts/3.0.21.js +23 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/jats/importer/jats-dom-parser.d.ts +24 -9
- package/dist/types/jats/importer/jats-transformations.d.ts +2 -1
- package/dist/types/jats/importer/parse-jats-article.d.ts +2 -2
- package/dist/types/lib/{section-group-type.d.ts → section-categories.d.ts} +3 -9
- package/dist/types/schema/index.d.ts +0 -2
- package/dist/types/schema/migration/migration-scripts/3.0.21.d.ts +9 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/types.d.ts +21 -1
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/lib/table-cell-styles.js +0 -52
- package/dist/cjs/transformer/section-category.js +0 -263
- package/dist/es/lib/table-cell-styles.js +0 -47
- package/dist/es/transformer/section-category.js +0 -249
- package/dist/types/lib/table-cell-styles.d.ts +0 -27
- package/dist/types/transformer/section-category.d.ts +0 -31
|
@@ -14,17 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { defaultTitle } from '../../lib/deafults';
|
|
17
|
-
import { abstractsType, backmatterType, bodyType, } from '../../lib/section-group-type';
|
|
18
|
-
import { chooseSectionCategoryByType, chooseSecType } from '../../transformer';
|
|
19
17
|
import { htmlFromJatsNode } from './jats-parser-utils';
|
|
20
18
|
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
21
19
|
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
22
20
|
const createSectionGroup = (type, createElement) => {
|
|
23
21
|
const sec = createElement('sec');
|
|
24
|
-
sec.setAttribute('sec-type', type
|
|
25
|
-
const title = createElement('title');
|
|
26
|
-
title.textContent = type.title;
|
|
27
|
-
sec.appendChild(title);
|
|
22
|
+
sec.setAttribute('sec-type', type);
|
|
28
23
|
return sec;
|
|
29
24
|
};
|
|
30
25
|
export const moveTitle = (front, createElement) => {
|
|
@@ -105,7 +100,7 @@ export const createBoxedElementSection = (body, createElement) => {
|
|
|
105
100
|
}
|
|
106
101
|
};
|
|
107
102
|
export const createBody = (doc, body, createElement) => {
|
|
108
|
-
const group = createSectionGroup(
|
|
103
|
+
const group = createSectionGroup('body', createElement);
|
|
109
104
|
const paragraphs = doc.querySelectorAll('body > p');
|
|
110
105
|
group.append(...paragraphs);
|
|
111
106
|
const sections = doc.querySelectorAll('body > sec:not([sec-type="backmatter"]), body > sec:not([sec-type])');
|
|
@@ -117,15 +112,15 @@ export const createBody = (doc, body, createElement) => {
|
|
|
117
112
|
body.append(group);
|
|
118
113
|
};
|
|
119
114
|
export const createAbstracts = (doc, body, createElement) => {
|
|
120
|
-
const group = createSectionGroup(
|
|
115
|
+
const group = createSectionGroup('abstracts', createElement);
|
|
121
116
|
moveAbstracts(doc, group, createElement);
|
|
122
117
|
body.insertBefore(group, body.lastElementChild);
|
|
123
118
|
};
|
|
124
|
-
export const createBackmatter = (doc, body, createElement) => {
|
|
125
|
-
const group = createSectionGroup(
|
|
119
|
+
export const createBackmatter = (doc, body, sectionCategories, createElement) => {
|
|
120
|
+
const group = createSectionGroup('backmatter', createElement);
|
|
126
121
|
moveBackSections(doc, group);
|
|
127
122
|
moveAppendices(doc, group, createElement);
|
|
128
|
-
moveSpecialFootnotes(doc, group, createElement);
|
|
123
|
+
moveSpecialFootnotes(doc, group, sectionCategories, createElement);
|
|
129
124
|
moveFootnotes(doc, group, createElement);
|
|
130
125
|
moveAcknowledgments(doc, group, createElement);
|
|
131
126
|
body.append(group);
|
|
@@ -149,12 +144,12 @@ const moveFootnotes = (doc, group, createElement) => {
|
|
|
149
144
|
group.insertBefore(section, ((_a = group.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling) || group.firstChild);
|
|
150
145
|
}
|
|
151
146
|
};
|
|
152
|
-
const moveSpecialFootnotes = (doc, group, createElement) => {
|
|
147
|
+
const moveSpecialFootnotes = (doc, group, sectionCategories, createElement) => {
|
|
153
148
|
var _a;
|
|
154
149
|
const fns = [...doc.querySelectorAll('fn[fn-type]')];
|
|
155
150
|
for (const fn of fns) {
|
|
156
151
|
const type = fn.getAttribute('fn-type') || '';
|
|
157
|
-
const category =
|
|
152
|
+
const category = sectionCategories.find((category) => category.synonyms.includes(type));
|
|
158
153
|
if (category) {
|
|
159
154
|
const section = createElement('sec');
|
|
160
155
|
const fnTitle = fn.querySelector('p[content-type="fn-title"]');
|
|
@@ -169,7 +164,7 @@ const moveSpecialFootnotes = (doc, group, createElement) => {
|
|
|
169
164
|
}
|
|
170
165
|
section.append(...fn.children);
|
|
171
166
|
removeNodeFromParent(fn);
|
|
172
|
-
section.setAttribute('sec-type',
|
|
167
|
+
section.setAttribute('sec-type', category.id);
|
|
173
168
|
group.append(section);
|
|
174
169
|
}
|
|
175
170
|
}
|
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { schema } from '../../schema';
|
|
16
17
|
import { markComments } from './jats-comments';
|
|
17
|
-
import {
|
|
18
|
+
import { JATSDOMParser } from './jats-dom-parser';
|
|
18
19
|
import { parseJournal } from './jats-journal-meta-parser';
|
|
19
20
|
import { updateDocumentIDs } from './jats-parser-utils';
|
|
20
21
|
import { createAbstracts, createBackmatter, createBody, createBoxedElementSection, createKeywordsSection, createSupplementaryMaterialsSection, fixTables, moveAffiliations, moveAuthorNotes, moveAwards, moveCaptionsToEnd, moveContributors, moveReferencesToBackmatter, moveTitle, orderTableFootnote, } from './jats-transformations';
|
|
21
|
-
const processJATS = (doc) => {
|
|
22
|
+
const processJATS = (doc, sectionCategories) => {
|
|
22
23
|
const createElement = createElementFn(doc);
|
|
23
24
|
markComments(doc);
|
|
24
25
|
const front = doc.querySelector('front');
|
|
@@ -38,7 +39,7 @@ const processJATS = (doc) => {
|
|
|
38
39
|
createBoxedElementSection(body, createElement);
|
|
39
40
|
createBody(doc, body, createElement);
|
|
40
41
|
createAbstracts(doc, body, createElement);
|
|
41
|
-
createBackmatter(doc, body, createElement);
|
|
42
|
+
createBackmatter(doc, body, sectionCategories, createElement);
|
|
42
43
|
createSupplementaryMaterialsSection(doc, body, createElement);
|
|
43
44
|
createKeywordsSection(doc, body, createElement);
|
|
44
45
|
fixTables(doc, body, createElement);
|
|
@@ -50,10 +51,11 @@ const processJATS = (doc) => {
|
|
|
50
51
|
moveReferencesToBackmatter(body, back, createElement);
|
|
51
52
|
};
|
|
52
53
|
const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
|
|
53
|
-
export const parseJATSArticle = (doc, template) => {
|
|
54
|
+
export const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
54
55
|
const journal = parseJournal(doc);
|
|
55
|
-
processJATS(doc);
|
|
56
|
-
const node =
|
|
56
|
+
processJATS(doc, sectionCategories);
|
|
57
|
+
const node = new JATSDOMParser(sectionCategories, schema).parse(doc)
|
|
58
|
+
.firstChild;
|
|
57
59
|
if (!node) {
|
|
58
60
|
throw new Error('No content was parsed from the JATS article body');
|
|
59
61
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2024 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,15 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
17
|
-
_id: 'abstracts',
|
|
18
|
-
title: 'Abstracts',
|
|
19
|
-
};
|
|
20
|
-
export const bodyType = {
|
|
21
|
-
_id: 'body',
|
|
22
|
-
title: 'Body',
|
|
23
|
-
};
|
|
24
|
-
export const backmatterType = {
|
|
25
|
-
_id: 'backmatter',
|
|
26
|
-
title: 'Backmatter',
|
|
27
|
-
};
|
|
16
|
+
export const getGroupCateogries = (sectionsMap, group) => Array.from(sectionsMap.values()).filter((section) => section.group === group);
|
package/dist/es/schema/index.js
CHANGED
|
@@ -137,8 +137,6 @@ export * from './nodes/supplement';
|
|
|
137
137
|
export * from './nodes/supplements';
|
|
138
138
|
export * from './nodes/corresp';
|
|
139
139
|
export * from './nodes/author_notes';
|
|
140
|
-
export * from './nodes/award';
|
|
141
|
-
export * from './nodes/awards';
|
|
142
140
|
export const schema = new Schema({
|
|
143
141
|
marks: {
|
|
144
142
|
bold,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Migration3021 {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.fromVersion = '3.0.20';
|
|
4
|
+
this.toVersion = '3.0.21';
|
|
5
|
+
this.suffixMap = new Map([
|
|
6
|
+
['competing-interests', 'coi-statement'],
|
|
7
|
+
['acknowledgement', 'acknowledgements'],
|
|
8
|
+
['introduction', 'intro'],
|
|
9
|
+
['materials-method', 'methods'],
|
|
10
|
+
['subsection', ''],
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
migrateNode(node) {
|
|
14
|
+
if (node.type === 'section' &&
|
|
15
|
+
node.attrs.category.startsWith('MPSectionCategory:')) {
|
|
16
|
+
const [, suffix] = node.attrs.category.split(':', 2);
|
|
17
|
+
const newCategory = this.suffixMap.get(suffix) || suffix;
|
|
18
|
+
return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { category: newCategory }) });
|
|
19
|
+
}
|
|
20
|
+
return node;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default Migration3021;
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
import Migration125 from './1.2.5';
|
|
17
17
|
import Migration2322 from './2.3.22';
|
|
18
18
|
import { Migration3012 } from './3.0.12';
|
|
19
|
+
import Migration3021 from './3.0.21';
|
|
19
20
|
const migrations = [
|
|
20
21
|
new Migration125(),
|
|
21
22
|
new Migration2322(),
|
|
22
23
|
new Migration3012(),
|
|
24
|
+
new Migration3021(),
|
|
23
25
|
];
|
|
24
26
|
export default migrations;
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.21
|
|
1
|
+
export const VERSION = "3.0.21";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ export * from './errors';
|
|
|
2
2
|
export { getVersion } from './getVersion';
|
|
3
3
|
export * from './jats';
|
|
4
4
|
export * from './jats/types';
|
|
5
|
-
export * from './lib/section-group-type';
|
|
6
|
-
export * from './lib/table-cell-styles';
|
|
7
5
|
export * from './lib/footnotes';
|
|
8
6
|
export * from './lib/utils';
|
|
7
|
+
export * from './lib/section-categories';
|
|
9
8
|
export * from './schema';
|
|
10
9
|
export { JSONNode, migrateFor } from './schema/migration/migrate';
|
|
11
10
|
export { isSectionLabelNode } from './schema/nodes/section_label';
|
|
@@ -13,12 +13,27 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
import { ParseOptions, Schema } from 'prosemirror-model';
|
|
17
|
+
import { SectionCategory } from '../../schema';
|
|
18
|
+
export declare class JATSDOMParser {
|
|
19
|
+
private sectionCategories;
|
|
20
|
+
private schema;
|
|
21
|
+
private XLINK_NAMESPACE;
|
|
22
|
+
private parser;
|
|
23
|
+
constructor(sectionCategories: SectionCategory[], schema: Schema);
|
|
24
|
+
parse(doc: Node, options?: ParseOptions): import("prosemirror-model").Node;
|
|
25
|
+
private isMatchingCategory;
|
|
26
|
+
private chooseSectionCategory;
|
|
27
|
+
private chooseContentType;
|
|
28
|
+
private parsePriority;
|
|
29
|
+
private getEquationContent;
|
|
30
|
+
private parseDates;
|
|
31
|
+
private getEmail;
|
|
32
|
+
private getInstitutionDetails;
|
|
33
|
+
private getAddressLine;
|
|
34
|
+
private getHTMLContent;
|
|
35
|
+
private chooseBibliographyItemType;
|
|
36
|
+
private parseRef;
|
|
37
|
+
private nodes;
|
|
38
|
+
private marks;
|
|
39
|
+
}
|
|
@@ -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 { SectionCategory } from '../../schema';
|
|
16
17
|
export type CreateElement = (tagName: string) => HTMLElement;
|
|
17
18
|
export declare const moveTitle: (front: Element, createElement: CreateElement) => void;
|
|
18
19
|
export declare const moveAuthorNotes: (front: Element, createElement: CreateElement) => void;
|
|
@@ -23,7 +24,7 @@ export declare const moveAbstracts: (doc: Document, group: Element, createElemen
|
|
|
23
24
|
export declare const createBoxedElementSection: (body: Element, createElement: (tagName: string) => HTMLElement) => void;
|
|
24
25
|
export declare const createBody: (doc: Document, body: Element, createElement: CreateElement) => void;
|
|
25
26
|
export declare const createAbstracts: (doc: Document, body: Element, createElement: CreateElement) => void;
|
|
26
|
-
export declare const createBackmatter: (doc: Document, body: Element, createElement: CreateElement) => void;
|
|
27
|
+
export declare const createBackmatter: (doc: Document, body: Element, sectionCategories: SectionCategory[], createElement: CreateElement) => void;
|
|
27
28
|
export declare const moveCaptionsToEnd: (body: Element) => void;
|
|
28
29
|
export declare const createKeywordsSection: (document: Document, body: Element, createElement: CreateElement) => void;
|
|
29
30
|
export declare const createSupplementaryMaterialsSection: (document: Document, body: Element, createElement: CreateElement) => void;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ActualManuscriptNode } from '../../schema';
|
|
17
|
-
export declare const parseJATSArticle: (doc: Document, template?: string) => {
|
|
16
|
+
import { ActualManuscriptNode, SectionCategory } from '../../schema';
|
|
17
|
+
export declare const parseJATSArticle: (doc: Document, sectionCategories: SectionCategory[], template?: string) => {
|
|
18
18
|
node: ActualManuscriptNode;
|
|
19
19
|
journal: {
|
|
20
20
|
objectType: import("@manuscripts/json-schema/dist/types").ObjectTypes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2024 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,11 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
_id: SectionGroupTypeID;
|
|
19
|
-
title: string;
|
|
20
|
-
};
|
|
21
|
-
export declare const abstractsType: SectionGroupType;
|
|
22
|
-
export declare const bodyType: SectionGroupType;
|
|
23
|
-
export declare const backmatterType: SectionGroupType;
|
|
16
|
+
import { SectionCategory, SectionGroup } from '../schema';
|
|
17
|
+
export declare const getGroupCateogries: (sectionsMap: Map<string, SectionCategory>, group: SectionGroup) => SectionCategory[];
|
|
@@ -74,6 +74,4 @@ export * from './nodes/supplement';
|
|
|
74
74
|
export * from './nodes/supplements';
|
|
75
75
|
export * from './nodes/corresp';
|
|
76
76
|
export * from './nodes/author_notes';
|
|
77
|
-
export * from './nodes/award';
|
|
78
|
-
export * from './nodes/awards';
|
|
79
77
|
export declare const schema: Schema<Nodes, Marks>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JSONNode } from '../migrate';
|
|
2
|
+
import { MigrationScript } from '../migration-script';
|
|
3
|
+
declare class Migration3021 implements MigrationScript {
|
|
4
|
+
fromVersion: string;
|
|
5
|
+
toVersion: string;
|
|
6
|
+
private suffixMap;
|
|
7
|
+
migrateNode(node: JSONNode): JSONNode;
|
|
8
|
+
}
|
|
9
|
+
export default Migration3021;
|
|
@@ -16,5 +16,6 @@
|
|
|
16
16
|
import Migration125 from './1.2.5';
|
|
17
17
|
import Migration2322 from './2.3.22';
|
|
18
18
|
import { Migration3012 } from './3.0.12';
|
|
19
|
-
|
|
19
|
+
import Migration3021 from './3.0.21';
|
|
20
|
+
declare const migrations: (Migration125 | Migration2322 | Migration3012 | Migration3021)[];
|
|
20
21
|
export default migrations;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, NodeSpec, NodeType, ResolvedPos, Schema, Slice } from 'prosemirror-model';
|
|
16
|
+
import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, NodeSpec, NodeType, ParseRule, ResolvedPos, Schema, Slice } from 'prosemirror-model';
|
|
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';
|
|
@@ -43,3 +43,23 @@ export type DataTrackedAttrs = {
|
|
|
43
43
|
userID: string;
|
|
44
44
|
createdAt: number;
|
|
45
45
|
};
|
|
46
|
+
export type SectionGroup = 'abstracts' | 'body' | 'backmatter';
|
|
47
|
+
export type SectionCategory = {
|
|
48
|
+
id: string;
|
|
49
|
+
synonyms: string[];
|
|
50
|
+
titles: [string, ...string[]];
|
|
51
|
+
group?: SectionGroup;
|
|
52
|
+
isUnique: boolean;
|
|
53
|
+
};
|
|
54
|
+
export type ManuscriptTemplate = {
|
|
55
|
+
_id: string;
|
|
56
|
+
bundle: string;
|
|
57
|
+
title: string;
|
|
58
|
+
sectionCategories: SectionCategory[];
|
|
59
|
+
};
|
|
60
|
+
export type MarkRule = ParseRule & {
|
|
61
|
+
mark: Marks | null;
|
|
62
|
+
};
|
|
63
|
+
export type NodeRule = ParseRule & {
|
|
64
|
+
node?: Nodes | null;
|
|
65
|
+
};
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.21
|
|
1
|
+
export declare const VERSION = "3.0.21";
|
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": "3.0.21
|
|
4
|
+
"version": "3.0.21",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getTableCellStyles = exports.serializeTableCellStyles = exports.TABLE_CELL_STYLES = void 0;
|
|
19
|
-
exports.TABLE_CELL_STYLES = [
|
|
20
|
-
'backgroundColor',
|
|
21
|
-
'border-top',
|
|
22
|
-
'border-right',
|
|
23
|
-
'border-bottom',
|
|
24
|
-
'border-left',
|
|
25
|
-
'verticalAlign',
|
|
26
|
-
'textAlign',
|
|
27
|
-
];
|
|
28
|
-
const dashify = (str) => {
|
|
29
|
-
return str
|
|
30
|
-
.trim()
|
|
31
|
-
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
32
|
-
.replace(/\W/g, (m) => (/[À-ž]/.test(m) ? m : '-'))
|
|
33
|
-
.replace(/^-+|-+$/g, '')
|
|
34
|
-
.toLowerCase();
|
|
35
|
-
};
|
|
36
|
-
const serializeTableCellStyles = (styles) => {
|
|
37
|
-
return Object.keys(styles)
|
|
38
|
-
.map((key) => styles[key] && `${dashify(key)}: ${styles[key]}`)
|
|
39
|
-
.filter(Boolean)
|
|
40
|
-
.join('; ');
|
|
41
|
-
};
|
|
42
|
-
exports.serializeTableCellStyles = serializeTableCellStyles;
|
|
43
|
-
const isStyleKey = (key) => exports.TABLE_CELL_STYLES.includes(key);
|
|
44
|
-
const getTableCellStyles = (styles) => {
|
|
45
|
-
return Object.entries(styles).reduce((acc, [key, value]) => {
|
|
46
|
-
if (isStyleKey(key)) {
|
|
47
|
-
acc[key] = value;
|
|
48
|
-
}
|
|
49
|
-
return acc;
|
|
50
|
-
}, {});
|
|
51
|
-
};
|
|
52
|
-
exports.getTableCellStyles = getTableCellStyles;
|