@manuscripts/transform 4.3.53 → 4.4.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/jats/__tests__/jats-roundtrip.test.js +3 -3
- package/dist/cjs/jats/exporter/jats-exporter.js +3 -0
- package/dist/cjs/jats/importer/jats-dom-parser.js +41 -1
- package/dist/cjs/schema/index.js +9 -0
- package/dist/cjs/schema/nodes/headshot_element.js +38 -0
- package/dist/cjs/schema/nodes/headshot_grid.js +37 -0
- package/dist/cjs/schema/nodes/headshot_image.js +51 -0
- package/dist/cjs/transformer/node-names.js +2 -0
- package/dist/cjs/transformer/node-title.js +6 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-roundtrip.test.js +3 -3
- package/dist/es/jats/exporter/jats-exporter.js +3 -0
- package/dist/es/jats/importer/jats-dom-parser.js +41 -1
- package/dist/es/schema/index.js +9 -0
- package/dist/es/schema/nodes/headshot_element.js +34 -0
- package/dist/es/schema/nodes/headshot_grid.js +33 -0
- package/dist/es/schema/nodes/headshot_image.js +48 -0
- package/dist/es/transformer/node-names.js +2 -0
- package/dist/es/transformer/node-title.js +6 -0
- package/dist/es/version.js +1 -1
- package/dist/types/jats/__tests__/utils.d.ts +1 -1
- package/dist/types/schema/index.d.ts +3 -0
- package/dist/types/schema/nodes/headshot_element.d.ts +25 -0
- package/dist/types/schema/nodes/headshot_grid.d.ts +24 -0
- package/dist/types/schema/nodes/headshot_image.d.ts +26 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +22 -21
- package/src/errors.ts +28 -0
- package/src/getVersion.ts +21 -0
- package/src/index.ts +28 -0
- package/src/jats/__tests__/__fixtures__/debug-example.xml +136 -0
- package/src/jats/__tests__/__fixtures__/jats-abstract-no-body.xml +163 -0
- package/src/jats/__tests__/__fixtures__/jats-citations.xml +472 -0
- package/src/jats/__tests__/__fixtures__/jats-comments.xml +46 -0
- package/src/jats/__tests__/__fixtures__/jats-document.xml +134 -0
- package/src/jats/__tests__/__fixtures__/jats-example-doc.xml +1235 -0
- package/src/jats/__tests__/__fixtures__/jats-example-front-only.xml +26 -0
- package/src/jats/__tests__/__fixtures__/jats-example-full.xml +209 -0
- package/src/jats/__tests__/__fixtures__/jats-example-no-back.xml +156 -0
- package/src/jats/__tests__/__fixtures__/jats-example-no-body.xml +91 -0
- package/src/jats/__tests__/__fixtures__/jats-example.xml +221 -0
- package/src/jats/__tests__/__fixtures__/jats-fn-group.xml +60 -0
- package/src/jats/__tests__/__fixtures__/jats-import-no-refs.xml +1077 -0
- package/src/jats/__tests__/__fixtures__/jats-import.xml +1578 -0
- package/src/jats/__tests__/__fixtures__/jats-roundtrip.xml +133 -0
- package/src/jats/__tests__/__fixtures__/jats-tables-example.xml +2043 -0
- package/src/jats/__tests__/__fixtures__/math-fragment.xml +12 -0
- package/src/jats/__tests__/__snapshots__/citeproc.test.ts.snap +57 -0
- package/src/jats/__tests__/__snapshots__/create-article-node.test.ts.snap +65 -0
- package/src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap +7 -0
- package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +59796 -0
- package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +18 -0
- package/src/jats/__tests__/citations.ts +25 -0
- package/src/jats/__tests__/citeproc.test.ts +195 -0
- package/src/jats/__tests__/create-article-node.test.ts +29 -0
- package/src/jats/__tests__/data/section-categories.ts +212 -0
- package/src/jats/__tests__/files.ts +24 -0
- package/src/jats/__tests__/jats-exporter.test.ts +223 -0
- package/src/jats/__tests__/jats-importer.test.ts +567 -0
- package/src/jats/__tests__/jats-roundtrip.test.ts +66 -0
- package/src/jats/__tests__/utils.ts +90 -0
- package/src/jats/exporter/citeproc.ts +265 -0
- package/src/jats/exporter/jats-exporter.ts +2093 -0
- package/src/jats/exporter/jats-versions.ts +50 -0
- package/src/jats/exporter/labels.ts +101 -0
- package/src/jats/importer/create-article-node.ts +52 -0
- package/src/jats/importer/jats-comments.ts +111 -0
- package/src/jats/importer/jats-dom-parser.ts +1306 -0
- package/src/jats/importer/jats-parser-utils.ts +234 -0
- package/src/jats/importer/jats-transformations.ts +591 -0
- package/src/jats/importer/parse-jats-article.ts +106 -0
- package/src/jats/index.ts +21 -0
- package/src/jats/types.ts +16 -0
- package/src/lib/__tests__/footnotes.test.ts +36 -0
- package/src/lib/citeproc.ts +30 -0
- package/src/lib/credit-roles.ts +91 -0
- package/src/lib/deafults.ts +17 -0
- package/src/lib/footnotes.ts +85 -0
- package/src/lib/html.ts +56 -0
- package/src/lib/section-categories.ts +27 -0
- package/src/lib/utils.ts +145 -0
- package/src/lib/xml.ts +28 -0
- package/src/schema/__tests__/docs.ts +1911 -0
- package/src/schema/__tests__/groups.test.ts +61 -0
- package/src/schema/__tests__/migration.test.ts +23 -0
- package/src/schema/groups.ts +36 -0
- package/src/schema/index.ts +295 -0
- package/src/schema/marks.ts +254 -0
- package/src/schema/migration/migrate.ts +77 -0
- package/src/schema/migration/migration-script.ts +26 -0
- package/src/schema/migration/migration-scripts/1.2.5.ts +44 -0
- package/src/schema/migration/migration-scripts/2.3.22.ts +52 -0
- package/src/schema/migration/migration-scripts/3.0.12.ts +33 -0
- package/src/schema/migration/migration-scripts/3.0.21.ts +50 -0
- package/src/schema/migration/migration-scripts/3.0.30.ts +65 -0
- package/src/schema/migration/migration-scripts/3.0.31.ts +40 -0
- package/src/schema/migration/migration-scripts/3.0.41.ts +37 -0
- package/src/schema/migration/migration-scripts/3.0.55.ts +42 -0
- package/src/schema/migration/migration-scripts/3.0.56.ts +114 -0
- package/src/schema/migration/migration-scripts/4.2.13.ts +37 -0
- package/src/schema/migration/migration-scripts/4.2.15.ts +48 -0
- package/src/schema/migration/migration-scripts/4.3.23.ts +55 -0
- package/src/schema/migration/migration-scripts/4.3.34.ts +132 -0
- package/src/schema/migration/migration-scripts/4.3.35.ts +41 -0
- package/src/schema/migration/migration-scripts/index.ts +49 -0
- package/src/schema/nodes/abstracts.ts +29 -0
- package/src/schema/nodes/affiliation.ts +88 -0
- package/src/schema/nodes/affiliations.ts +30 -0
- package/src/schema/nodes/alt_text.ts +36 -0
- package/src/schema/nodes/alt_title.ts +40 -0
- package/src/schema/nodes/alt_titles_section.ts +58 -0
- package/src/schema/nodes/attachment.ts +46 -0
- package/src/schema/nodes/attachments.ts +45 -0
- package/src/schema/nodes/attribution.ts +38 -0
- package/src/schema/nodes/author_notes.ts +44 -0
- package/src/schema/nodes/award.ts +52 -0
- package/src/schema/nodes/awards.ts +45 -0
- package/src/schema/nodes/backmatter.ts +31 -0
- package/src/schema/nodes/bibliography_element.ts +58 -0
- package/src/schema/nodes/bibliography_item.ts +108 -0
- package/src/schema/nodes/bibliography_section.ts +60 -0
- package/src/schema/nodes/blockquote_element.ts +79 -0
- package/src/schema/nodes/body.ts +29 -0
- package/src/schema/nodes/box_element.ts +67 -0
- package/src/schema/nodes/caption.ts +67 -0
- package/src/schema/nodes/caption_title.ts +67 -0
- package/src/schema/nodes/citation.ts +70 -0
- package/src/schema/nodes/comment.ts +50 -0
- package/src/schema/nodes/comments.ts +28 -0
- package/src/schema/nodes/contributor.ts +87 -0
- package/src/schema/nodes/contributors.ts +40 -0
- package/src/schema/nodes/core_section.ts +27 -0
- package/src/schema/nodes/corresp.ts +49 -0
- package/src/schema/nodes/cross_reference.ts +64 -0
- package/src/schema/nodes/doc.ts +21 -0
- package/src/schema/nodes/embed.ts +55 -0
- package/src/schema/nodes/equation.ts +65 -0
- package/src/schema/nodes/equation_element.ts +61 -0
- package/src/schema/nodes/figure.ts +65 -0
- package/src/schema/nodes/figure_element.ts +73 -0
- package/src/schema/nodes/footnote.ts +95 -0
- package/src/schema/nodes/footnotes_element.ts +69 -0
- package/src/schema/nodes/footnotes_section.ts +61 -0
- package/src/schema/nodes/general_table_footnote.ts +42 -0
- package/src/schema/nodes/graphical_abstract_section.ts +62 -0
- package/src/schema/nodes/hard_break.ts +36 -0
- package/src/schema/nodes/headshot_element.ts +48 -0
- package/src/schema/nodes/headshot_grid.ts +46 -0
- package/src/schema/nodes/headshot_image.ts +65 -0
- package/src/schema/nodes/hero_image.ts +46 -0
- package/src/schema/nodes/highlight_marker.ts +68 -0
- package/src/schema/nodes/image_element.ts +49 -0
- package/src/schema/nodes/inline_equation.ts +68 -0
- package/src/schema/nodes/inline_footnote.ts +66 -0
- package/src/schema/nodes/keyword.ts +61 -0
- package/src/schema/nodes/keyword_group.ts +63 -0
- package/src/schema/nodes/keywords.ts +59 -0
- package/src/schema/nodes/keywords_element.ts +64 -0
- package/src/schema/nodes/link.ts +79 -0
- package/src/schema/nodes/list.ts +134 -0
- package/src/schema/nodes/listing.ts +91 -0
- package/src/schema/nodes/listing_element.ts +61 -0
- package/src/schema/nodes/long_desc.ts +36 -0
- package/src/schema/nodes/manuscript.ts +86 -0
- package/src/schema/nodes/missing_figure.ts +59 -0
- package/src/schema/nodes/paragraph.ts +77 -0
- package/src/schema/nodes/placeholder.ts +62 -0
- package/src/schema/nodes/placeholder_element.ts +60 -0
- package/src/schema/nodes/pullquote_element.ts +81 -0
- package/src/schema/nodes/quote_image.ts +64 -0
- package/src/schema/nodes/section.ts +69 -0
- package/src/schema/nodes/section_label.ts +39 -0
- package/src/schema/nodes/section_title.ts +58 -0
- package/src/schema/nodes/subtitle.ts +40 -0
- package/src/schema/nodes/subtitles.ts +51 -0
- package/src/schema/nodes/supplement.ts +77 -0
- package/src/schema/nodes/supplements.ts +60 -0
- package/src/schema/nodes/table.ts +144 -0
- package/src/schema/nodes/table_col.ts +76 -0
- package/src/schema/nodes/table_element.ts +67 -0
- package/src/schema/nodes/table_element_footer.ts +42 -0
- package/src/schema/nodes/text.ts +31 -0
- package/src/schema/nodes/title.ts +43 -0
- package/src/schema/nodes/trans_abstract.ts +58 -0
- package/src/schema/nodes/trans_graphical_abstract.ts +67 -0
- package/src/schema/types.ts +243 -0
- package/src/tests.ts +33 -0
- package/src/transformer/id.ts +23 -0
- package/src/transformer/index.ts +21 -0
- package/src/transformer/node-names.ts +75 -0
- package/src/transformer/node-title.ts +116 -0
- package/src/transformer/node-types.ts +39 -0
- package/src/transformer/node-validator.ts +82 -0
- package/src/types.ts +25 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
|
|
17
|
+
// adapted from 'prosemirror-tables'
|
|
18
|
+
|
|
19
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
20
|
+
|
|
21
|
+
import { ManuscriptNode } from '../types'
|
|
22
|
+
|
|
23
|
+
export interface TableColNode extends ManuscriptNode {
|
|
24
|
+
attrs: {
|
|
25
|
+
width: string
|
|
26
|
+
id: string
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const tableColGroup: NodeSpec = {
|
|
31
|
+
content: 'table_col+',
|
|
32
|
+
group: 'block',
|
|
33
|
+
parseDOM: [
|
|
34
|
+
{
|
|
35
|
+
tag: 'colgroup',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
toDOM() {
|
|
39
|
+
return ['colgroup', 0]
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const tableCol: NodeSpec = {
|
|
44
|
+
attrs: {
|
|
45
|
+
width: { default: '' },
|
|
46
|
+
id: { default: '' },
|
|
47
|
+
},
|
|
48
|
+
group: 'block',
|
|
49
|
+
parseDOM: [
|
|
50
|
+
{
|
|
51
|
+
tag: 'col',
|
|
52
|
+
getAttrs: (p) => {
|
|
53
|
+
const dom = p as HTMLTableColElement
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
width: dom.getAttribute('width'),
|
|
57
|
+
id: dom.getAttribute('id'),
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
toDOM: (node) => {
|
|
63
|
+
const tableColNode = node as TableColNode
|
|
64
|
+
|
|
65
|
+
const attrs: { [key: string]: string } = {}
|
|
66
|
+
|
|
67
|
+
if (tableColNode.attrs.width) {
|
|
68
|
+
attrs['width'] = tableColNode.attrs.width
|
|
69
|
+
}
|
|
70
|
+
if (tableColNode.attrs.id) {
|
|
71
|
+
attrs['id'] = tableColNode.attrs.id
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return ['col', attrs]
|
|
75
|
+
},
|
|
76
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { ManuscriptNode } from '../types'
|
|
20
|
+
|
|
21
|
+
export interface TableAttrs {
|
|
22
|
+
id: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TableElementNode extends ManuscriptNode {
|
|
26
|
+
attrs: TableAttrs
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const tableElement: NodeSpec = {
|
|
30
|
+
content:
|
|
31
|
+
'caption_title (table | placeholder) table_colgroup? table_element_footer? alt_text long_desc (listing | placeholder)',
|
|
32
|
+
attrs: {
|
|
33
|
+
id: { default: '' },
|
|
34
|
+
dataTracked: { default: null },
|
|
35
|
+
},
|
|
36
|
+
selectable: false,
|
|
37
|
+
group: 'block element executable',
|
|
38
|
+
parseDOM: [
|
|
39
|
+
{
|
|
40
|
+
tag: 'figure.table',
|
|
41
|
+
getAttrs: (dom) => {
|
|
42
|
+
const element = dom as HTMLTableElement
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
id: element.getAttribute('id'),
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
toDOM: (node) => {
|
|
51
|
+
const tableElementNode = node as TableElementNode
|
|
52
|
+
|
|
53
|
+
return [
|
|
54
|
+
'figure',
|
|
55
|
+
{
|
|
56
|
+
class: 'table', // TODO: suppress-header, suppress-footer?
|
|
57
|
+
id: tableElementNode.attrs.id,
|
|
58
|
+
},
|
|
59
|
+
0,
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const isTableElementNode = (
|
|
65
|
+
node: ManuscriptNode
|
|
66
|
+
): node is TableElementNode =>
|
|
67
|
+
node.type === node.type.schema.nodes.table_element
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { ManuscriptNode } from '../types'
|
|
20
|
+
|
|
21
|
+
interface Attrs {
|
|
22
|
+
id: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TableElementFooterNode extends ManuscriptNode {
|
|
26
|
+
attrs: Attrs
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const tableElementFooter: NodeSpec = {
|
|
30
|
+
attrs: {
|
|
31
|
+
id: { default: '' },
|
|
32
|
+
dataTracked: { default: null },
|
|
33
|
+
},
|
|
34
|
+
content: 'general_table_footnote? footnotes_element?',
|
|
35
|
+
group: 'block element',
|
|
36
|
+
toDOM: () => ['table-wrap-foot', 0],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const isTableElementFooter = (
|
|
40
|
+
node: ManuscriptNode
|
|
41
|
+
): node is TableElementFooterNode =>
|
|
42
|
+
node.type === node.type.schema.nodes.table_element_footer
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { paragraph } from './paragraph'
|
|
20
|
+
|
|
21
|
+
export const text: NodeSpec = {
|
|
22
|
+
group: 'inline',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const textBlock: NodeSpec = {
|
|
26
|
+
...paragraph,
|
|
27
|
+
attrs: {
|
|
28
|
+
dataTracked: { default: null },
|
|
29
|
+
},
|
|
30
|
+
group: 'block',
|
|
31
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { ManuscriptNode } from '../types'
|
|
20
|
+
|
|
21
|
+
export interface TitleAttrs {
|
|
22
|
+
id: string
|
|
23
|
+
placeholder: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TitleNode extends ManuscriptNode {
|
|
27
|
+
attrs: TitleAttrs
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const title: NodeSpec = {
|
|
31
|
+
content: '(text | highlight_marker)*',
|
|
32
|
+
attrs: {
|
|
33
|
+
id: { default: '' },
|
|
34
|
+
placeholder: { default: 'Insert title here...' },
|
|
35
|
+
dataTracked: { default: null },
|
|
36
|
+
},
|
|
37
|
+
group: 'block element',
|
|
38
|
+
parseDOM: [{ tag: 'div' }],
|
|
39
|
+
toDOM: () => ['div', 0],
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const isTitleNode = (node: ManuscriptNode): node is TitleNode =>
|
|
43
|
+
node.type === node.type.schema.nodes.title
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2025 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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { schema } from '../index'
|
|
20
|
+
import type { ManuscriptNode } from '../types'
|
|
21
|
+
|
|
22
|
+
export interface TransAbstractAttrs {
|
|
23
|
+
id: string
|
|
24
|
+
lang: string
|
|
25
|
+
category: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TransAbstractNode extends ManuscriptNode {
|
|
29
|
+
attrs: TransAbstractAttrs
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const transAbstract: NodeSpec = {
|
|
33
|
+
content: 'section_title (paragraph | element)* sections*',
|
|
34
|
+
attrs: {
|
|
35
|
+
id: { default: '' },
|
|
36
|
+
lang: { default: '' },
|
|
37
|
+
category: { default: '' },
|
|
38
|
+
dataTracked: { default: null },
|
|
39
|
+
},
|
|
40
|
+
group: 'block sections',
|
|
41
|
+
selectable: false,
|
|
42
|
+
toDOM: (node) => {
|
|
43
|
+
const { id, lang } = node.attrs
|
|
44
|
+
return [
|
|
45
|
+
'section',
|
|
46
|
+
{
|
|
47
|
+
id,
|
|
48
|
+
lang,
|
|
49
|
+
class: 'trans-abstract',
|
|
50
|
+
},
|
|
51
|
+
0,
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const isTransAbstractNode = (
|
|
57
|
+
node: ManuscriptNode
|
|
58
|
+
): node is TransAbstractNode => node.type === schema.nodes.trans_abstract
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2025 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
|
+
|
|
17
|
+
import { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import { schema } from '../index'
|
|
20
|
+
import type { ManuscriptNode } from '../types'
|
|
21
|
+
|
|
22
|
+
export interface TransGraphicalAbstractAttrs {
|
|
23
|
+
id: string
|
|
24
|
+
lang: string
|
|
25
|
+
category: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TransGraphicalAbstractNode extends ManuscriptNode {
|
|
29
|
+
attrs: TransGraphicalAbstractAttrs
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const transGraphicalAbstract: NodeSpec = {
|
|
33
|
+
content: 'section_title (figure_element | placeholder)',
|
|
34
|
+
attrs: {
|
|
35
|
+
id: { default: '' },
|
|
36
|
+
lang: { default: '' },
|
|
37
|
+
category: { default: '' },
|
|
38
|
+
dataTracked: { default: null },
|
|
39
|
+
},
|
|
40
|
+
group: 'block sections',
|
|
41
|
+
selectable: false,
|
|
42
|
+
parseDOM: [
|
|
43
|
+
{
|
|
44
|
+
tag: 'section.trans-graphical-abstract',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
toDOM: (node) => {
|
|
48
|
+
const transGraphicalAbstractNode = node as TransGraphicalAbstractNode
|
|
49
|
+
const { id, lang } = transGraphicalAbstractNode.attrs
|
|
50
|
+
|
|
51
|
+
return [
|
|
52
|
+
'section',
|
|
53
|
+
{
|
|
54
|
+
id,
|
|
55
|
+
lang,
|
|
56
|
+
class: 'trans-graphical-abstract',
|
|
57
|
+
spellcheck: 'false',
|
|
58
|
+
},
|
|
59
|
+
0,
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const isTransGraphicalAbstractNode = (
|
|
65
|
+
node: ManuscriptNode
|
|
66
|
+
): node is TransGraphicalAbstractNode =>
|
|
67
|
+
node.type === schema.nodes.trans_graphical_abstract
|
|
@@ -0,0 +1,243 @@
|
|
|
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
|
+
|
|
17
|
+
import {
|
|
18
|
+
Fragment,
|
|
19
|
+
Mark as ProsemirrorMark,
|
|
20
|
+
MarkType,
|
|
21
|
+
Node as ProsemirrorNode,
|
|
22
|
+
NodeSpec,
|
|
23
|
+
NodeType,
|
|
24
|
+
ParseRule,
|
|
25
|
+
ResolvedPos,
|
|
26
|
+
Schema,
|
|
27
|
+
Slice,
|
|
28
|
+
} from 'prosemirror-model'
|
|
29
|
+
import {
|
|
30
|
+
EditorState,
|
|
31
|
+
NodeSelection,
|
|
32
|
+
Plugin,
|
|
33
|
+
TextSelection,
|
|
34
|
+
Transaction,
|
|
35
|
+
} from 'prosemirror-state'
|
|
36
|
+
import { EditorView, NodeView } from 'prosemirror-view'
|
|
37
|
+
|
|
38
|
+
export type Marks =
|
|
39
|
+
| 'bold'
|
|
40
|
+
| 'code'
|
|
41
|
+
| 'italic'
|
|
42
|
+
| 'smallcaps'
|
|
43
|
+
| 'strikethrough'
|
|
44
|
+
| 'styled'
|
|
45
|
+
| 'subscript'
|
|
46
|
+
| 'superscript'
|
|
47
|
+
| 'underline'
|
|
48
|
+
| 'tracked_insert'
|
|
49
|
+
| 'tracked_delete'
|
|
50
|
+
|
|
51
|
+
export type Nodes =
|
|
52
|
+
| 'attribution'
|
|
53
|
+
| 'bibliography_item'
|
|
54
|
+
| 'bibliography_element'
|
|
55
|
+
| 'bibliography_section'
|
|
56
|
+
| 'blockquote_element'
|
|
57
|
+
| 'quote_image'
|
|
58
|
+
| 'list'
|
|
59
|
+
| 'caption'
|
|
60
|
+
| 'caption_title'
|
|
61
|
+
| 'comment'
|
|
62
|
+
| 'comments'
|
|
63
|
+
| 'citation'
|
|
64
|
+
| 'cross_reference'
|
|
65
|
+
| 'doc'
|
|
66
|
+
| 'equation'
|
|
67
|
+
| 'equation_element'
|
|
68
|
+
| 'figure'
|
|
69
|
+
| 'graphical_abstract_section'
|
|
70
|
+
| 'figure_element'
|
|
71
|
+
| 'footnote'
|
|
72
|
+
| 'footnotes_element'
|
|
73
|
+
| 'footnotes_section'
|
|
74
|
+
| 'hard_break'
|
|
75
|
+
| 'highlight_marker'
|
|
76
|
+
| 'inline_equation'
|
|
77
|
+
| 'inline_footnote'
|
|
78
|
+
| 'keyword'
|
|
79
|
+
| 'keywords_element'
|
|
80
|
+
| 'keyword_group'
|
|
81
|
+
| 'keywords'
|
|
82
|
+
| 'link'
|
|
83
|
+
| 'list_item'
|
|
84
|
+
| 'listing'
|
|
85
|
+
| 'listing_element'
|
|
86
|
+
| 'manuscript'
|
|
87
|
+
| 'abstracts'
|
|
88
|
+
| 'body'
|
|
89
|
+
| 'backmatter'
|
|
90
|
+
| 'missing_figure'
|
|
91
|
+
| 'paragraph'
|
|
92
|
+
| 'placeholder'
|
|
93
|
+
| 'placeholder_element'
|
|
94
|
+
| 'pullquote_element'
|
|
95
|
+
| 'section'
|
|
96
|
+
| 'section_label'
|
|
97
|
+
| 'section_title'
|
|
98
|
+
| 'section_title_plain'
|
|
99
|
+
| 'table'
|
|
100
|
+
| 'table_cell'
|
|
101
|
+
| 'table_element'
|
|
102
|
+
| 'table_row'
|
|
103
|
+
| 'table_colgroup'
|
|
104
|
+
| 'table_col'
|
|
105
|
+
| 'table_header'
|
|
106
|
+
| 'text'
|
|
107
|
+
| 'text_block'
|
|
108
|
+
| 'affiliation'
|
|
109
|
+
| 'contributor'
|
|
110
|
+
| 'table_element_footer'
|
|
111
|
+
| 'title'
|
|
112
|
+
| 'affiliations'
|
|
113
|
+
| 'contributors'
|
|
114
|
+
| 'supplements'
|
|
115
|
+
| 'supplement'
|
|
116
|
+
| 'author_notes'
|
|
117
|
+
| 'corresp'
|
|
118
|
+
| 'general_table_footnote'
|
|
119
|
+
| 'box_element'
|
|
120
|
+
| 'awards'
|
|
121
|
+
| 'award'
|
|
122
|
+
| 'embed'
|
|
123
|
+
| 'image_element'
|
|
124
|
+
| 'attachment'
|
|
125
|
+
| 'attachments'
|
|
126
|
+
| 'alt_title'
|
|
127
|
+
| 'alt_text'
|
|
128
|
+
| 'alt_titles'
|
|
129
|
+
| 'long_desc'
|
|
130
|
+
| 'hero_image'
|
|
131
|
+
| 'headshot_grid'
|
|
132
|
+
| 'headshot_element'
|
|
133
|
+
| 'headshot_image'
|
|
134
|
+
| 'trans_abstract'
|
|
135
|
+
| 'trans_graphical_abstract'
|
|
136
|
+
| 'subtitle'
|
|
137
|
+
| 'subtitles'
|
|
138
|
+
|
|
139
|
+
export type ManuscriptSchema = Schema<Nodes, Marks>
|
|
140
|
+
|
|
141
|
+
export type ManuscriptEditorState = EditorState
|
|
142
|
+
export type ManuscriptEditorView = EditorView
|
|
143
|
+
export type ManuscriptFragment = Fragment
|
|
144
|
+
export type ManuscriptMark = ProsemirrorMark
|
|
145
|
+
export type ManuscriptNode = ProsemirrorNode
|
|
146
|
+
export type ManuscriptNodeSelection = NodeSelection
|
|
147
|
+
export type ManuscriptTextSelection = TextSelection
|
|
148
|
+
export type ManuscriptMarkType = MarkType
|
|
149
|
+
export type ManuscriptNodeType = NodeType
|
|
150
|
+
export type ManuscriptNodeView = NodeView
|
|
151
|
+
export type ManuscriptResolvedPos = ResolvedPos
|
|
152
|
+
export type ManuscriptPlugin = Plugin
|
|
153
|
+
export type ManuscriptSlice = Slice
|
|
154
|
+
export type ManuscriptTransaction = Transaction
|
|
155
|
+
|
|
156
|
+
export interface TableNodeSpec extends NodeSpec {
|
|
157
|
+
tableRole: string
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type DataTrackedAttrs = {
|
|
161
|
+
id: string
|
|
162
|
+
status: string
|
|
163
|
+
operation: string
|
|
164
|
+
userID: string
|
|
165
|
+
createdAt: number
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type SectionGroup =
|
|
169
|
+
| 'abstracts'
|
|
170
|
+
| 'body'
|
|
171
|
+
| 'backmatter'
|
|
172
|
+
| 'abstracts-graphic'
|
|
173
|
+
|
|
174
|
+
export type SectionCategory = {
|
|
175
|
+
id: string
|
|
176
|
+
synonyms: string[]
|
|
177
|
+
label?: string // for display menu purposes, if not provided, the first title will be used
|
|
178
|
+
titles: [string, ...string[]]
|
|
179
|
+
group?: SectionGroup
|
|
180
|
+
isUnique: boolean
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type ManuscriptTemplate = {
|
|
184
|
+
_id: string
|
|
185
|
+
bundle: string
|
|
186
|
+
title: string
|
|
187
|
+
sectionCategories: SectionCategory[]
|
|
188
|
+
articleType: string
|
|
189
|
+
hiddenNodeTypes?: string[]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface UserProfile {
|
|
193
|
+
_id: string
|
|
194
|
+
userID: string
|
|
195
|
+
given?: string
|
|
196
|
+
family?: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface Project {
|
|
200
|
+
_id: string
|
|
201
|
+
owners: string[]
|
|
202
|
+
writers: string[]
|
|
203
|
+
editors?: string[]
|
|
204
|
+
annotators?: string[]
|
|
205
|
+
proofers?: string[]
|
|
206
|
+
viewers: string[]
|
|
207
|
+
updatedAt: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface Bundle {
|
|
211
|
+
_id: string
|
|
212
|
+
csl: {
|
|
213
|
+
_id: string
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export enum ManuscriptActions {
|
|
218
|
+
handleSuggestion = 'handleSuggestion',
|
|
219
|
+
rejectOwnSuggestion = 'rejectOwnSuggestion',
|
|
220
|
+
handleOwnComments = 'handleOwnComments',
|
|
221
|
+
handleOthersComments = 'handleOthersComments',
|
|
222
|
+
resolveOwnComment = 'resolveOwnComment',
|
|
223
|
+
resolveOthersComment = 'resolveOthersComment',
|
|
224
|
+
createComment = 'createComment',
|
|
225
|
+
canEditFiles = 'canEditFiles',
|
|
226
|
+
editArticle = 'editArticle',
|
|
227
|
+
formatArticle = 'formatArticle',
|
|
228
|
+
editMetadata = 'editMetadata',
|
|
229
|
+
editCitationsAndRefs = 'editCitationsAndRefs',
|
|
230
|
+
seeEditorToolbar = 'seeEditorToolbar',
|
|
231
|
+
seeReferencesButtons = 'seeReferencesButtons',
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export type MarkRule = ParseRule & { mark: Marks | null }
|
|
235
|
+
|
|
236
|
+
export type NodeRule = ParseRule & { node?: Nodes | null }
|
|
237
|
+
|
|
238
|
+
export function isNodeOfType<T extends ManuscriptNode>(
|
|
239
|
+
node: ManuscriptNode,
|
|
240
|
+
type: NodeType
|
|
241
|
+
): node is T {
|
|
242
|
+
return node.type === type
|
|
243
|
+
}
|
package/src/tests.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
|
|
17
|
+
import { v4 as uuid } from 'uuid'
|
|
18
|
+
|
|
19
|
+
const supportedCommands: string[] = []
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(document, 'queryCommandSupported', {
|
|
22
|
+
value: (cmd: string) => supportedCommands.includes(cmd),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(document, 'execCommand', {
|
|
26
|
+
value: (cmd: string) => supportedCommands.includes(cmd),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (!window.URL.createObjectURL) {
|
|
30
|
+
Object.defineProperty(window.URL, 'createObjectURL', {
|
|
31
|
+
value: vi.fn(() => 'blob:https://localhost/' + uuid()),
|
|
32
|
+
})
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
17
|
+
import { v4 as uuid } from 'uuid'
|
|
18
|
+
|
|
19
|
+
import { ManuscriptNodeType } from '../schema'
|
|
20
|
+
import { typeName } from './node-names'
|
|
21
|
+
|
|
22
|
+
export const generateNodeID = (type: ManuscriptNodeType) =>
|
|
23
|
+
`MP${typeName(type)}:${uuid()}`
|