@manuscripts/transform 1.5.3 → 1.5.4-3019-v1
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/parse-jats-article.js +11 -2
- package/dist/cjs/jats/jats-exporter.js +8 -6
- package/dist/cjs/schema/index.js +3 -0
- package/dist/cjs/schema/nodes/affiliation.js +22 -1
- package/dist/cjs/schema/nodes/affiliations_section.js +23 -2
- package/dist/cjs/schema/nodes/contributor.js +13 -1
- package/dist/cjs/schema/nodes/contributors_element.js +49 -0
- package/dist/cjs/schema/nodes/contributors_section.js +23 -2
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/schema/nodes/title.js +29 -0
- package/dist/cjs/transformer/builders.js +8 -3
- package/dist/cjs/transformer/decode.js +22 -3
- package/dist/cjs/transformer/encode.js +6 -0
- package/dist/cjs/transformer/html.js +6 -5
- package/dist/cjs/transformer/node-title.js +6 -4
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/cjs/transformer/project-bundle.js +22 -1
- package/dist/es/jats/importer/parse-jats-article.js +11 -2
- package/dist/es/jats/jats-exporter.js +9 -7
- package/dist/es/schema/index.js +3 -0
- package/dist/es/schema/nodes/affiliation.js +22 -1
- package/dist/es/schema/nodes/affiliations_section.js +23 -2
- package/dist/es/schema/nodes/contributor.js +13 -1
- package/dist/es/schema/nodes/contributors_element.js +46 -0
- package/dist/es/schema/nodes/contributors_section.js +23 -2
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/schema/nodes/title.js +26 -0
- package/dist/es/transformer/builders.js +6 -2
- package/dist/es/transformer/decode.js +22 -3
- package/dist/es/transformer/encode.js +6 -0
- package/dist/es/transformer/html.js +7 -6
- package/dist/es/transformer/node-title.js +7 -5
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/es/transformer/project-bundle.js +20 -0
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/contributors_element.d.ts +27 -0
- package/dist/types/schema/nodes/contributors_section.d.ts +1 -0
- package/dist/types/schema/nodes/title.d.ts +28 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +3 -2
- package/dist/types/transformer/decode.d.ts +1 -0
- package/dist/types/transformer/project-bundle.d.ts +2 -1
- package/package.json +2 -2
package/dist/es/schema/index.js
CHANGED
|
@@ -68,6 +68,7 @@ import { tableElement } from './nodes/table_element';
|
|
|
68
68
|
import { tableElementFooter } from './nodes/table_element_footer';
|
|
69
69
|
import { tableCell, tableRow } from './nodes/table_row';
|
|
70
70
|
import { text } from './nodes/text';
|
|
71
|
+
import { title } from './nodes/title';
|
|
71
72
|
import { tocElement } from './nodes/toc_element';
|
|
72
73
|
import { tocSection } from './nodes/toc_section';
|
|
73
74
|
export * from './groups';
|
|
@@ -123,6 +124,7 @@ export * from './nodes/affiliation';
|
|
|
123
124
|
export * from './nodes/meta_section';
|
|
124
125
|
export * from './nodes/contributor';
|
|
125
126
|
export * from './nodes/table_element_footer';
|
|
127
|
+
export * from './nodes/title';
|
|
126
128
|
export * from './nodes/affiliations_section';
|
|
127
129
|
export * from './nodes/contributors_section';
|
|
128
130
|
export const schema = new Schema({
|
|
@@ -199,6 +201,7 @@ export const schema = new Schema({
|
|
|
199
201
|
meta_section: metaSection,
|
|
200
202
|
contributor: contributor,
|
|
201
203
|
table_element_footer: tableElementFooter,
|
|
204
|
+
title: title,
|
|
202
205
|
affiliations_section: affiliationsSection,
|
|
203
206
|
contributors_section: contributorsSection,
|
|
204
207
|
},
|
|
@@ -15,8 +15,29 @@ export const affiliation = {
|
|
|
15
15
|
text: undefined,
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
+
dataTracked: { default: null },
|
|
18
19
|
},
|
|
19
20
|
group: 'block element',
|
|
20
|
-
|
|
21
|
+
parseDOM: [
|
|
22
|
+
{
|
|
23
|
+
tag: 'div.affiliation',
|
|
24
|
+
getAttrs: (node) => {
|
|
25
|
+
const dom = node;
|
|
26
|
+
return {
|
|
27
|
+
id: dom.getAttribute('id'),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
toDOM: (node) => {
|
|
33
|
+
const affiliationNode = node;
|
|
34
|
+
return [
|
|
35
|
+
'div',
|
|
36
|
+
{
|
|
37
|
+
class: 'affiliation',
|
|
38
|
+
id: affiliationNode.attrs.id,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
},
|
|
21
42
|
};
|
|
22
43
|
export const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
export const affiliationsSection = {
|
|
2
2
|
content: 'section_title? affiliation*',
|
|
3
3
|
attrs: {
|
|
4
|
-
id: { default: '' },
|
|
4
|
+
id: { default: 'META_SECTION_AFFILLIATIONS' },
|
|
5
5
|
dataTracked: { default: null },
|
|
6
6
|
},
|
|
7
7
|
group: 'block sections',
|
|
8
8
|
selectable: false,
|
|
9
|
-
|
|
9
|
+
parseDOM: [
|
|
10
|
+
{
|
|
11
|
+
tag: 'section.affiliations',
|
|
12
|
+
getAttrs: (section) => {
|
|
13
|
+
const dom = section;
|
|
14
|
+
return {
|
|
15
|
+
contents: dom.innerHTML,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
toDOM: (node) => {
|
|
21
|
+
const affiliationsSectionNode = node;
|
|
22
|
+
return [
|
|
23
|
+
'section',
|
|
24
|
+
{
|
|
25
|
+
class: 'affiliations',
|
|
26
|
+
id: affiliationsSectionNode.attrs.id,
|
|
27
|
+
},
|
|
28
|
+
0
|
|
29
|
+
];
|
|
30
|
+
},
|
|
10
31
|
};
|
|
11
32
|
export const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const contributor = {
|
|
2
|
+
content: 'inline*',
|
|
2
3
|
attrs: {
|
|
3
4
|
id: { default: '' },
|
|
4
5
|
role: { default: '' },
|
|
@@ -11,8 +12,19 @@ export const contributor = {
|
|
|
11
12
|
isCorresponding: { default: undefined },
|
|
12
13
|
ORCIDIdentifier: { default: undefined },
|
|
13
14
|
priority: { default: undefined },
|
|
15
|
+
dataTracked: { default: null },
|
|
16
|
+
contents: { default: '' },
|
|
14
17
|
},
|
|
15
18
|
group: 'block element',
|
|
16
|
-
toDOM: () =>
|
|
19
|
+
toDOM: (node) => {
|
|
20
|
+
const contributorNode = node;
|
|
21
|
+
return [
|
|
22
|
+
'div',
|
|
23
|
+
{
|
|
24
|
+
class: 'contributor',
|
|
25
|
+
id: contributorNode.attrs.id,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
},
|
|
17
29
|
};
|
|
18
30
|
export const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const contributorsElement = {
|
|
17
|
+
content: 'contributor*',
|
|
18
|
+
attrs: {
|
|
19
|
+
id: { default: '' },
|
|
20
|
+
contents: { default: '' },
|
|
21
|
+
dataTracked: { default: null },
|
|
22
|
+
},
|
|
23
|
+
group: 'block element',
|
|
24
|
+
selectable: false,
|
|
25
|
+
parseDOM: [
|
|
26
|
+
{
|
|
27
|
+
tag: 'div.manuscript-contributors',
|
|
28
|
+
getAttrs: () => {
|
|
29
|
+
return {
|
|
30
|
+
contents: '',
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
toDOM: (node) => {
|
|
36
|
+
const contributorsElementNode = node;
|
|
37
|
+
return [
|
|
38
|
+
'div',
|
|
39
|
+
{
|
|
40
|
+
class: 'manuscript-contributors',
|
|
41
|
+
id: contributorsElementNode.attrs.id,
|
|
42
|
+
},
|
|
43
|
+
0,
|
|
44
|
+
];
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
export const contributorsSection = {
|
|
2
2
|
content: 'section_title? contributor*',
|
|
3
3
|
attrs: {
|
|
4
|
-
id: { default: '' },
|
|
4
|
+
id: { default: 'META_SECTION_CONTRIBUTORS' },
|
|
5
5
|
dataTracked: { default: null },
|
|
6
|
+
contents: { default: '' },
|
|
6
7
|
},
|
|
7
8
|
group: 'block sections',
|
|
8
9
|
selectable: false,
|
|
9
|
-
|
|
10
|
+
parseDOM: [
|
|
11
|
+
{
|
|
12
|
+
tag: 'section.contributors',
|
|
13
|
+
getAttrs: () => {
|
|
14
|
+
return {
|
|
15
|
+
contents: '',
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
toDOM: (node) => {
|
|
21
|
+
const contributorsSectionNode = node;
|
|
22
|
+
return [
|
|
23
|
+
'section',
|
|
24
|
+
{
|
|
25
|
+
class: 'contributors',
|
|
26
|
+
id: contributorsSectionNode.attrs.id,
|
|
27
|
+
},
|
|
28
|
+
0,
|
|
29
|
+
];
|
|
30
|
+
},
|
|
10
31
|
};
|
|
11
32
|
export const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const title = {
|
|
17
|
+
content: 'text*',
|
|
18
|
+
marks: 'italic smallcaps subscript superscript tracked_insert tracked_delete',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: { default: '' },
|
|
21
|
+
dataTracked: { default: null },
|
|
22
|
+
},
|
|
23
|
+
group: 'block element',
|
|
24
|
+
parseDOM: [{ tag: 'div' }],
|
|
25
|
+
toDOM: () => ['div', 0],
|
|
26
|
+
};
|
|
@@ -28,10 +28,9 @@ export const buildProject = (owner) => ({
|
|
|
28
28
|
viewers: [],
|
|
29
29
|
title: '',
|
|
30
30
|
});
|
|
31
|
-
export const buildManuscript = (
|
|
31
|
+
export const buildManuscript = () => ({
|
|
32
32
|
_id: generateID(ObjectTypes.Manuscript),
|
|
33
33
|
objectType: ObjectTypes.Manuscript,
|
|
34
|
-
title,
|
|
35
34
|
});
|
|
36
35
|
export const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
|
|
37
36
|
_id: generateID(ObjectTypes.Contributor),
|
|
@@ -249,3 +248,8 @@ export const buildElementsOrder = (elementType) => ({
|
|
|
249
248
|
elementType: elementType,
|
|
250
249
|
elements: [],
|
|
251
250
|
});
|
|
251
|
+
export const buildTitles = (title) => ({
|
|
252
|
+
_id: generateID(ObjectTypes.Titles),
|
|
253
|
+
objectType: ObjectTypes.Titles,
|
|
254
|
+
title: title || '',
|
|
255
|
+
});
|
|
@@ -29,6 +29,7 @@ import debug from 'debug';
|
|
|
29
29
|
import { DOMParser } from 'prosemirror-model';
|
|
30
30
|
import { MissingElement } from '../errors';
|
|
31
31
|
import { schema, } from '../schema';
|
|
32
|
+
import { buildTitles } from './builders';
|
|
32
33
|
import { insertHighlightMarkers } from './highlight-markers';
|
|
33
34
|
import { generateNodeID } from './id';
|
|
34
35
|
import { ExtraObjectTypes, hasObjectType, isCommentAnnotation, isManuscript, } from './object-types';
|
|
@@ -105,6 +106,11 @@ export class Decoder {
|
|
|
105
106
|
rootSectionNodes.unshift(node);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
109
|
+
createTitleNode() {
|
|
110
|
+
const titles = getModelsByType(this.modelMap, ObjectTypes.Titles)[0] ||
|
|
111
|
+
buildTitles();
|
|
112
|
+
return this.decode(titles);
|
|
113
|
+
}
|
|
108
114
|
createRootSectionNodes() {
|
|
109
115
|
let rootSections = getSections(this.modelMap).filter((section) => !section.path || section.path.length <= 1);
|
|
110
116
|
rootSections = this.addGeneratedLabels(rootSections);
|
|
@@ -137,6 +143,14 @@ export class Decoder {
|
|
|
137
143
|
constructor(modelMap, allowMissingElements = false) {
|
|
138
144
|
this.comments = new Map();
|
|
139
145
|
this.creators = {
|
|
146
|
+
[ObjectTypes.Titles]: (data) => {
|
|
147
|
+
const model = data;
|
|
148
|
+
return this.parseContents(model.title, 'div', undefined, {
|
|
149
|
+
topNode: schema.nodes.title.create({
|
|
150
|
+
id: model._id,
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
},
|
|
140
154
|
[ObjectTypes.BibliographyElement]: (data) => {
|
|
141
155
|
var _a;
|
|
142
156
|
const model = data;
|
|
@@ -593,7 +607,7 @@ export class Decoder {
|
|
|
593
607
|
email: model.email,
|
|
594
608
|
department: model.department,
|
|
595
609
|
priority: model.priority,
|
|
596
|
-
});
|
|
610
|
+
}, schema.text('_'));
|
|
597
611
|
},
|
|
598
612
|
[ObjectTypes.Contributor]: (data) => {
|
|
599
613
|
const model = data;
|
|
@@ -609,7 +623,7 @@ export class Decoder {
|
|
|
609
623
|
footnote: model.footnote,
|
|
610
624
|
corresp: model.corresp,
|
|
611
625
|
priority: model.priority,
|
|
612
|
-
});
|
|
626
|
+
}, schema.text('_'));
|
|
613
627
|
},
|
|
614
628
|
};
|
|
615
629
|
this.decode = (model) => {
|
|
@@ -621,9 +635,14 @@ export class Decoder {
|
|
|
621
635
|
};
|
|
622
636
|
this.getModel = (id) => this.modelMap.get(id);
|
|
623
637
|
this.createArticleNode = (manuscriptID) => {
|
|
638
|
+
const titlesNode = this.createTitleNode();
|
|
624
639
|
const rootSectionNodes = this.createRootSectionNodes();
|
|
625
640
|
const metaSectionNode = this.createMetaSectionNode();
|
|
626
|
-
const contents = [
|
|
641
|
+
const contents = [
|
|
642
|
+
titlesNode,
|
|
643
|
+
...rootSectionNodes,
|
|
644
|
+
metaSectionNode,
|
|
645
|
+
];
|
|
627
646
|
return schema.nodes.manuscript.create({
|
|
628
647
|
id: manuscriptID || this.getManuscriptID(),
|
|
629
648
|
}, contents);
|
|
@@ -255,6 +255,12 @@ function figureElementEncoder(node) {
|
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
257
|
const encoders = {
|
|
258
|
+
title: (node) => ({
|
|
259
|
+
title: inlineContents(node),
|
|
260
|
+
subtitle: node.attrs.subtitle,
|
|
261
|
+
runningTitle: node.attrs.runningTitle,
|
|
262
|
+
_id: node.attrs._id,
|
|
263
|
+
}),
|
|
258
264
|
bibliography_element: (node) => ({
|
|
259
265
|
elementType: 'div',
|
|
260
266
|
contents: '',
|
|
@@ -23,7 +23,7 @@ import { generateAttachmentFilename } from './filename';
|
|
|
23
23
|
import { buildTargets } from './labels';
|
|
24
24
|
import { isNodeType } from './node-types';
|
|
25
25
|
import { hasObjectType } from './object-types';
|
|
26
|
-
import { findJournal, findManuscript } from './project-bundle';
|
|
26
|
+
import { findJournal, findManuscript, findTitles } from './project-bundle';
|
|
27
27
|
import { chooseSecType } from './section-category';
|
|
28
28
|
const chooseNodeName = (element) => {
|
|
29
29
|
const nodeName = element.nodeName.toLowerCase();
|
|
@@ -146,6 +146,7 @@ export class HTMLTransformer {
|
|
|
146
146
|
this.buildFront = () => {
|
|
147
147
|
const manuscript = findManuscript(this.modelMap);
|
|
148
148
|
const journal = findJournal(this.modelMap);
|
|
149
|
+
const titles = findTitles(this.modelMap);
|
|
149
150
|
if (!manuscript) {
|
|
150
151
|
throw new Error('Manuscript not found in project modelMap');
|
|
151
152
|
}
|
|
@@ -164,14 +165,14 @@ export class HTMLTransformer {
|
|
|
164
165
|
}
|
|
165
166
|
const articleMeta = this.document.createElement('div');
|
|
166
167
|
front.appendChild(articleMeta);
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
|
|
168
|
+
const title = this.document.createElement('h1');
|
|
169
|
+
if (titles.title) {
|
|
170
|
+
title.innerHTML = titles.title;
|
|
170
171
|
}
|
|
171
172
|
if (journal === null || journal === void 0 ? void 0 : journal.title) {
|
|
172
|
-
|
|
173
|
+
title.setAttribute('data-journal', journal.title);
|
|
173
174
|
}
|
|
174
|
-
articleMeta.appendChild(
|
|
175
|
+
articleMeta.appendChild(title);
|
|
175
176
|
if (manuscript.DOI) {
|
|
176
177
|
const articleID = this.document.createElement('article-id');
|
|
177
178
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { iterateChildren } from '../lib/utils';
|
|
17
|
-
import { isHighlightMarkerNode } from '../schema';
|
|
17
|
+
import { isHighlightMarkerNode, schema } from '../schema';
|
|
18
18
|
import { nodeNames } from './node-names';
|
|
19
19
|
const textSnippet = (node, max = 100) => {
|
|
20
20
|
let text = '';
|
|
@@ -29,7 +29,7 @@ const textSnippet = (node, max = 100) => {
|
|
|
29
29
|
text += ' ';
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
return text.
|
|
32
|
+
return text.substring(0, max);
|
|
33
33
|
};
|
|
34
34
|
const snippetOfNodeType = (node, nodeType) => {
|
|
35
35
|
for (const child of iterateChildren(node, true)) {
|
|
@@ -40,8 +40,10 @@ const snippetOfNodeType = (node, nodeType) => {
|
|
|
40
40
|
return null;
|
|
41
41
|
};
|
|
42
42
|
export const nodeTitle = (node) => {
|
|
43
|
-
const nodes =
|
|
43
|
+
const nodes = schema.nodes;
|
|
44
44
|
switch (node.type) {
|
|
45
|
+
case nodes.manuscript:
|
|
46
|
+
return snippetOfNodeType(node, nodes.title);
|
|
45
47
|
case nodes.section:
|
|
46
48
|
case nodes.bibliography_section:
|
|
47
49
|
case nodes.footnotes_section:
|
|
@@ -68,9 +70,9 @@ export const nodeTitle = (node) => {
|
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
export const nodeTitlePlaceholder = (nodeType) => {
|
|
71
|
-
const nodes =
|
|
73
|
+
const nodes = schema.nodes;
|
|
72
74
|
switch (nodeType) {
|
|
73
|
-
case nodes.
|
|
75
|
+
case nodes.manuscript:
|
|
74
76
|
return 'Untitled Manuscript';
|
|
75
77
|
case nodes.section:
|
|
76
78
|
return 'Untitled Section';
|
|
@@ -54,6 +54,7 @@ export const nodeTypesMap = new Map([
|
|
|
54
54
|
[schema.nodes.affiliation, ObjectTypes.Affiliation],
|
|
55
55
|
[schema.nodes.contributor, ObjectTypes.Contributor],
|
|
56
56
|
[schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
|
|
57
|
+
[schema.nodes.title, ObjectTypes.Titles],
|
|
57
58
|
[schema.nodes.contributors_section, ObjectTypes.Section],
|
|
58
59
|
[schema.nodes.affiliations_section, ObjectTypes.Section],
|
|
59
60
|
]);
|
|
@@ -63,3 +63,23 @@ export const findManuscriptById = (modelMap, manuscriptID) => {
|
|
|
63
63
|
}
|
|
64
64
|
throw new Error(`There is no manuscript found for the following _id (${manuscriptID})`);
|
|
65
65
|
};
|
|
66
|
+
const isTitle = hasObjectType(ObjectTypes.Titles);
|
|
67
|
+
export const findTitles = (modelMap) => {
|
|
68
|
+
for (const model of modelMap.values()) {
|
|
69
|
+
if (isTitle(model)) {
|
|
70
|
+
return model;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const defaultTitle = {
|
|
74
|
+
_id: 'MPTitles:8EB79C14-9F61-483A-902F-A0B8EF5973C1',
|
|
75
|
+
createdAt: 1538472121.690101,
|
|
76
|
+
updatedAt: 1538472121.690101,
|
|
77
|
+
objectType: 'MPTitles',
|
|
78
|
+
title: 'main title',
|
|
79
|
+
subtitle: 'subtitle',
|
|
80
|
+
runningTitle: 'running title',
|
|
81
|
+
manuscriptID: 'MPManuscript:E3830344-E77B-42BA-BD77-3E95489712A0',
|
|
82
|
+
containerID: 'MPProject:1',
|
|
83
|
+
};
|
|
84
|
+
return defaultTitle;
|
|
85
|
+
};
|
|
@@ -68,6 +68,7 @@ export * from './nodes/affiliation';
|
|
|
68
68
|
export * from './nodes/meta_section';
|
|
69
69
|
export * from './nodes/contributor';
|
|
70
70
|
export * from './nodes/table_element_footer';
|
|
71
|
+
export * from './nodes/title';
|
|
71
72
|
export * from './nodes/affiliations_section';
|
|
72
73
|
export * from './nodes/contributors_section';
|
|
73
74
|
export declare const schema: Schema<Nodes, Marks>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { ManuscriptNode } from '../types';
|
|
18
|
+
interface Attrs {
|
|
19
|
+
contents: string;
|
|
20
|
+
id: string;
|
|
21
|
+
paragraphStyle?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ContributorsElementNode extends ManuscriptNode {
|
|
24
|
+
attrs: Attrs;
|
|
25
|
+
}
|
|
26
|
+
export declare const contributorsElement: NodeSpec;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
import { ManuscriptNode } from '../types';
|
|
18
|
+
interface Attrs {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
subtitle: string;
|
|
22
|
+
runningTitle: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TitleNode extends ManuscriptNode {
|
|
25
|
+
attrs: Attrs;
|
|
26
|
+
}
|
|
27
|
+
export declare const title: NodeSpec;
|
|
28
|
+
export {};
|
|
@@ -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' | 'title' | 'affiliations_section' | 'contributors_section';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -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 { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Supplement, UserProfileAffiliation } from '@manuscripts/json-schema';
|
|
16
|
+
import { Affiliation, Attribution, AuxiliaryObjectReference, BibliographicDate, BibliographicName, BibliographyItem, Citation, CitationItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Highlight, HighlightMarker, InlineMathFragment, InlineStyle, Journal, Keyword, KeywordGroup, LibraryCollection, Manuscript, ManuscriptKeyword, ManuscriptNote, ObjectTypes, ParagraphElement, Project, RequirementsValidation, RequirementsValidationData, Section, StatusLabel, Supplement, Titles, UserProfileAffiliation } from '@manuscripts/json-schema';
|
|
17
17
|
import { FootnotesOrderIndexList } from './footnotes-order';
|
|
18
18
|
import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
|
|
19
19
|
export declare const DEFAULT_BUNDLE = "MPBundle:www-zotero-org-styles-nature";
|
|
@@ -28,7 +28,7 @@ export type BuildEmbedded<T extends EmbeddedModel, O> = Pick<T, Exclude<keyof T,
|
|
|
28
28
|
objectType: O;
|
|
29
29
|
};
|
|
30
30
|
export declare const buildProject: (owner: string) => Build<Project>;
|
|
31
|
-
export declare const buildManuscript: (
|
|
31
|
+
export declare const buildManuscript: () => Build<Manuscript>;
|
|
32
32
|
export type ContributorRoleType = 'author';
|
|
33
33
|
export declare const buildContributor: (bibliographicName: BibliographicName, role?: ContributorRoleType, priority?: number, userID?: string, invitationID?: string) => Build<Contributor>;
|
|
34
34
|
export declare const buildBibliographyItem: (data: Partial<Build<BibliographyItem>>) => Build<BibliographyItem>;
|
|
@@ -70,3 +70,4 @@ export declare const buildStatusLabel: (name: string) => Build<StatusLabel>;
|
|
|
70
70
|
export type AuxiliaryObjects = 'MPFigureElement' | 'MPTableElement' | 'MPListingElement' | 'MPEquationElement';
|
|
71
71
|
export declare const auxiliaryObjectTypes: Set<import("prosemirror-model").NodeType>;
|
|
72
72
|
export declare const buildElementsOrder: (elementType: AuxiliaryObjects) => Build<ElementsOrder>;
|
|
73
|
+
export declare const buildTitles: (title?: string) => Build<Titles>;
|
|
@@ -30,6 +30,7 @@ export declare class Decoder {
|
|
|
30
30
|
private handleMissingRootSectionNodes;
|
|
31
31
|
private createAffiliationSectionNode;
|
|
32
32
|
private createContributorSectionNode;
|
|
33
|
+
private createTitleNode;
|
|
33
34
|
private createRootSectionNodes;
|
|
34
35
|
private createCommentsNode;
|
|
35
36
|
private getComments;
|
|
@@ -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 { Journal, Manuscript, Model, ObjectTypes } from '@manuscripts/json-schema';
|
|
16
|
+
import { Journal, Manuscript, Model, ObjectTypes, Titles } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptModel } from './models';
|
|
18
18
|
export interface ProjectBundle {
|
|
19
19
|
version: string;
|
|
@@ -27,3 +27,4 @@ export declare const findManuscript: (modelMap: Map<string, Model>) => Manuscrip
|
|
|
27
27
|
export declare const findJournal: (modelMap: Map<string, Model>) => Journal | null;
|
|
28
28
|
export declare const findManuscriptModelByType: <T extends ManuscriptModel>(modelMap: Map<string, Model>, manuscript: Manuscript, objectType: ObjectTypes) => T | undefined;
|
|
29
29
|
export declare const findManuscriptById: (modelMap: Map<string, Model>, manuscriptID: string) => Manuscript;
|
|
30
|
+
export declare const findTitles: (modelMap: Map<string, Model>) => Titles;
|
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.
|
|
4
|
+
"version": "1.5.4-3019-v1",
|
|
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.2.1",
|
|
33
33
|
"debug": "^4.3.4",
|
|
34
34
|
"jszip": "^3.10.1",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|