@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,134 @@
|
|
|
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
|
+
|
|
18
|
+
import { ManuscriptNode } from '../types'
|
|
19
|
+
|
|
20
|
+
export type ListStyleType =
|
|
21
|
+
| 'simple'
|
|
22
|
+
| 'bullet'
|
|
23
|
+
| 'order'
|
|
24
|
+
| 'alpha-lower'
|
|
25
|
+
| 'alpha-upper'
|
|
26
|
+
| 'roman-lower'
|
|
27
|
+
| 'roman-upper'
|
|
28
|
+
|
|
29
|
+
export interface ListAttrs {
|
|
30
|
+
id: string
|
|
31
|
+
listStyleType: ListStyleType
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ListNode extends ManuscriptNode {
|
|
35
|
+
attrs: ListAttrs
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const list: NodeSpec = {
|
|
39
|
+
content: 'list_item+',
|
|
40
|
+
group: 'block list element',
|
|
41
|
+
attrs: {
|
|
42
|
+
id: { default: '' },
|
|
43
|
+
listStyleType: { default: null },
|
|
44
|
+
dataTracked: { default: null },
|
|
45
|
+
},
|
|
46
|
+
parseDOM: [
|
|
47
|
+
{
|
|
48
|
+
tag: 'ul',
|
|
49
|
+
getAttrs: (p) => {
|
|
50
|
+
const dom = p as HTMLUListElement
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
id: dom.getAttribute('id'),
|
|
54
|
+
listStyleType: dom.getAttribute('list-type'),
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tag: 'ol',
|
|
60
|
+
getAttrs: (p) => {
|
|
61
|
+
const dom = p as HTMLOListElement
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
id: dom.getAttribute('id'),
|
|
65
|
+
listStyleType: dom.getAttribute('list-type'),
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
toDOM: (node) => {
|
|
71
|
+
const list = node as ListNode
|
|
72
|
+
return [
|
|
73
|
+
'ul',
|
|
74
|
+
{
|
|
75
|
+
id: list.attrs.id,
|
|
76
|
+
'list-type': list.attrs.listStyleType,
|
|
77
|
+
},
|
|
78
|
+
0,
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ListItemNode extends ManuscriptNode {
|
|
84
|
+
attrs: {
|
|
85
|
+
placeholder: string
|
|
86
|
+
id: string
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const listItem: NodeSpec = {
|
|
91
|
+
// NOTE: can't mix inline (text) and block content (list)
|
|
92
|
+
// content: 'paragraph list+',
|
|
93
|
+
content: 'paragraph? (paragraph | list)+',
|
|
94
|
+
group: 'block',
|
|
95
|
+
defining: true,
|
|
96
|
+
attrs: {
|
|
97
|
+
placeholder: { default: 'List item' },
|
|
98
|
+
id: { default: '' },
|
|
99
|
+
dataTracked: { default: null },
|
|
100
|
+
},
|
|
101
|
+
parseDOM: [
|
|
102
|
+
{
|
|
103
|
+
tag: 'li',
|
|
104
|
+
getAttrs: (p) => {
|
|
105
|
+
const dom = p as HTMLLIElement
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
109
|
+
id: dom.getAttribute('id') || '',
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
toDOM: (node) => {
|
|
115
|
+
const listItemNode = node as ListItemNode
|
|
116
|
+
|
|
117
|
+
const attrs: { [key: string]: string } = {}
|
|
118
|
+
|
|
119
|
+
if (listItemNode.attrs.placeholder) {
|
|
120
|
+
attrs['data-placeholder-text'] = listItemNode.attrs.placeholder
|
|
121
|
+
}
|
|
122
|
+
if (listItemNode.attrs.id) {
|
|
123
|
+
attrs['id'] = listItemNode.attrs.id
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return ['li', attrs, 0]
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const isListNode = (node: ManuscriptNode): node is ListNode => {
|
|
131
|
+
const { nodes } = node.type.schema
|
|
132
|
+
|
|
133
|
+
return node.type === nodes.list
|
|
134
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
contents: string
|
|
24
|
+
language: string
|
|
25
|
+
languageKey: string
|
|
26
|
+
isExpanded: boolean
|
|
27
|
+
isExecuting: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ListingNode extends ManuscriptNode {
|
|
31
|
+
attrs: Attrs
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const listing: NodeSpec = {
|
|
35
|
+
attrs: {
|
|
36
|
+
id: { default: '' },
|
|
37
|
+
contents: { default: '' },
|
|
38
|
+
language: { default: '' },
|
|
39
|
+
languageKey: { default: 'null' },
|
|
40
|
+
isExpanded: { default: false },
|
|
41
|
+
isExecuting: { default: false },
|
|
42
|
+
// placeholder: { default: 'Click to edit listing' },
|
|
43
|
+
dataTracked: { default: null },
|
|
44
|
+
},
|
|
45
|
+
draggable: false,
|
|
46
|
+
selectable: false,
|
|
47
|
+
group: 'block',
|
|
48
|
+
parseDOM: [
|
|
49
|
+
{
|
|
50
|
+
tag: 'pre.MPListing',
|
|
51
|
+
preserveWhitespace: 'full',
|
|
52
|
+
getAttrs: (p) => {
|
|
53
|
+
const node = p as HTMLPreElement
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
contents: node.textContent, // TODO: innerText?
|
|
57
|
+
language: node.getAttribute('language'),
|
|
58
|
+
languageKey: node.getAttribute('languageKey'),
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
priority: 100,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
tag: 'pre',
|
|
65
|
+
preserveWhitespace: 'full',
|
|
66
|
+
getAttrs: (p) => {
|
|
67
|
+
const node = p as HTMLPreElement
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
contents: node.getAttribute('code') || node.textContent,
|
|
71
|
+
languageKey: node.getAttribute('language'),
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
priority: 90,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
toDOM: (node) => {
|
|
78
|
+
const listingNode = node as ListingNode
|
|
79
|
+
|
|
80
|
+
const dom = document.createElement('div')
|
|
81
|
+
dom.setAttribute('id', listingNode.attrs.id)
|
|
82
|
+
dom.setAttribute('data-language', listingNode.attrs.language)
|
|
83
|
+
dom.setAttribute('data-languageKey', listingNode.attrs.languageKey)
|
|
84
|
+
dom.textContent = listingNode.attrs.contents
|
|
85
|
+
|
|
86
|
+
return dom
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const isListingNode = (node: ManuscriptNode): node is ListingNode =>
|
|
91
|
+
node.type === node.type.schema.nodes.listing
|
|
@@ -0,0 +1,61 @@
|
|
|
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 ListingElementNode extends ManuscriptNode {
|
|
26
|
+
attrs: Attrs
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const listingElement: NodeSpec = {
|
|
30
|
+
content: '(listing | placeholder) caption_title caption',
|
|
31
|
+
attrs: {
|
|
32
|
+
id: { default: '' },
|
|
33
|
+
dataTracked: { default: null },
|
|
34
|
+
},
|
|
35
|
+
group: 'block element',
|
|
36
|
+
selectable: false,
|
|
37
|
+
parseDOM: [
|
|
38
|
+
{
|
|
39
|
+
tag: 'figure.listing',
|
|
40
|
+
getAttrs: (p) => {
|
|
41
|
+
const dom = p as HTMLElement
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
id: dom.getAttribute('id'),
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
toDOM: (node) => {
|
|
50
|
+
const listingElementNode = node as ListingElementNode
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
'figure',
|
|
54
|
+
{
|
|
55
|
+
class: 'listing', // TODO: suppress-caption?
|
|
56
|
+
id: listingElementNode.attrs.id,
|
|
57
|
+
},
|
|
58
|
+
0,
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 type { NodeSpec } from 'prosemirror-model'
|
|
18
|
+
|
|
19
|
+
import type { ManuscriptNode } from '../types'
|
|
20
|
+
|
|
21
|
+
export interface LongDescAttrs {
|
|
22
|
+
id: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LongDescNode extends ManuscriptNode {
|
|
26
|
+
attrs: LongDescAttrs
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const longDesc: NodeSpec = {
|
|
30
|
+
content: 'text*',
|
|
31
|
+
attrs: {
|
|
32
|
+
id: { default: '' },
|
|
33
|
+
},
|
|
34
|
+
parseDOM: [{ tag: 'div' }],
|
|
35
|
+
toDOM: () => ['div', 0],
|
|
36
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 ActualManuscriptNode extends ManuscriptNode {
|
|
22
|
+
attrs: ManuscriptAttrs
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ManuscriptAttrs {
|
|
26
|
+
id: string
|
|
27
|
+
doi: string
|
|
28
|
+
articleType: string
|
|
29
|
+
prototype: string
|
|
30
|
+
primaryLanguageCode: string
|
|
31
|
+
acceptanceDate?: number
|
|
32
|
+
correctionDate?: number
|
|
33
|
+
retractionDate?: number
|
|
34
|
+
revisionRequestDate?: number
|
|
35
|
+
revisionReceiveDate?: number
|
|
36
|
+
receiveDate?: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The direct children of this node do not have a json-schema representation
|
|
40
|
+
// They exist for the purpose of styling in the UI
|
|
41
|
+
|
|
42
|
+
export const manuscript: NodeSpec = {
|
|
43
|
+
content:
|
|
44
|
+
'title subtitles? alt_titles? contributors? affiliations? author_notes? awards? keywords? abstracts body backmatter supplements? hero_image? comments attachments?',
|
|
45
|
+
attrs: {
|
|
46
|
+
id: { default: '' },
|
|
47
|
+
doi: { default: '' },
|
|
48
|
+
prototype: { default: '' },
|
|
49
|
+
primaryLanguageCode: { default: '' },
|
|
50
|
+
articleType: { default: '' },
|
|
51
|
+
acceptanceDate: { default: undefined },
|
|
52
|
+
correctionDate: { default: undefined },
|
|
53
|
+
retractionDate: { default: undefined },
|
|
54
|
+
revisionRequestDate: { default: undefined },
|
|
55
|
+
revisionReceiveDate: { default: undefined },
|
|
56
|
+
receiveDate: { default: undefined },
|
|
57
|
+
},
|
|
58
|
+
group: 'block',
|
|
59
|
+
parseDOM: [
|
|
60
|
+
{
|
|
61
|
+
tag: 'article',
|
|
62
|
+
getAttrs: (p) => {
|
|
63
|
+
const dom = p as HTMLElement
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
id: dom.getAttribute('id'),
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
toDOM: (node) => {
|
|
72
|
+
const manuscriptNode = node as ActualManuscriptNode
|
|
73
|
+
|
|
74
|
+
return [
|
|
75
|
+
'article',
|
|
76
|
+
{
|
|
77
|
+
id: manuscriptNode.attrs.id,
|
|
78
|
+
},
|
|
79
|
+
0,
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const isManuscriptNode = (
|
|
85
|
+
node: ManuscriptNode
|
|
86
|
+
): node is ManuscriptNode => node.type === node.type.schema.nodes.manuscript
|
|
@@ -0,0 +1,59 @@
|
|
|
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 MissingFigureNode extends ManuscriptNode {
|
|
22
|
+
attrs: {
|
|
23
|
+
id: string
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const missingFigure: NodeSpec = {
|
|
28
|
+
attrs: {
|
|
29
|
+
id: { default: '' },
|
|
30
|
+
dataTracked: { default: null },
|
|
31
|
+
},
|
|
32
|
+
selectable: false,
|
|
33
|
+
group: 'block',
|
|
34
|
+
parseDOM: [
|
|
35
|
+
{
|
|
36
|
+
tag: 'figure',
|
|
37
|
+
context: 'figure_element/',
|
|
38
|
+
getAttrs: (dom) => {
|
|
39
|
+
const element = dom as HTMLElement
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
id: element.getAttribute('id'),
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
toDOM: (node) => {
|
|
48
|
+
const missingFigureNode = node as MissingFigureNode
|
|
49
|
+
|
|
50
|
+
return [
|
|
51
|
+
'figure',
|
|
52
|
+
{
|
|
53
|
+
class: 'figure',
|
|
54
|
+
id: missingFigureNode.attrs.id,
|
|
55
|
+
},
|
|
56
|
+
0,
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
placeholder: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ParagraphNode extends ManuscriptNode {
|
|
27
|
+
attrs: Attrs
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const paragraph: NodeSpec = {
|
|
31
|
+
content: 'inline*',
|
|
32
|
+
attrs: {
|
|
33
|
+
id: { default: '' },
|
|
34
|
+
placeholder: { default: '' }, // TODO: 'List item' if inside a list
|
|
35
|
+
dataTracked: { default: null },
|
|
36
|
+
},
|
|
37
|
+
group: 'block element',
|
|
38
|
+
selectable: false,
|
|
39
|
+
parseDOM: [
|
|
40
|
+
{
|
|
41
|
+
tag: 'p',
|
|
42
|
+
getAttrs: (p) => {
|
|
43
|
+
const dom = p as HTMLParagraphElement
|
|
44
|
+
|
|
45
|
+
const attrs: Partial<Attrs> = {
|
|
46
|
+
id: dom.getAttribute('id') || undefined,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const placeholder = dom.getAttribute('data-placeholder-text')
|
|
50
|
+
|
|
51
|
+
if (placeholder) {
|
|
52
|
+
attrs.placeholder = placeholder
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return attrs
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
toDOM: (node) => {
|
|
60
|
+
const paragraphNode = node as ParagraphNode
|
|
61
|
+
|
|
62
|
+
const attrs: { [key: string]: string } = {}
|
|
63
|
+
|
|
64
|
+
if (paragraphNode.attrs.id) {
|
|
65
|
+
attrs.id = paragraphNode.attrs.id
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (paragraphNode.attrs.placeholder) {
|
|
69
|
+
attrs['data-placeholder-text'] = paragraphNode.attrs.placeholder
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return ['p', attrs, 0]
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const isParagraphNode = (node: ManuscriptNode): node is ParagraphNode =>
|
|
77
|
+
node.type === node.type.schema.nodes.paragraph
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
label: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PlaceholderNode extends ManuscriptNode {
|
|
27
|
+
attrs: Attrs
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const placeholder: NodeSpec = {
|
|
31
|
+
atom: true,
|
|
32
|
+
selectable: false,
|
|
33
|
+
attrs: {
|
|
34
|
+
id: { default: '' },
|
|
35
|
+
label: { default: '' },
|
|
36
|
+
dataTracked: { default: null },
|
|
37
|
+
},
|
|
38
|
+
group: 'block',
|
|
39
|
+
parseDOM: [
|
|
40
|
+
{
|
|
41
|
+
tag: 'div.placeholder',
|
|
42
|
+
getAttrs: (p) => {
|
|
43
|
+
const dom = p as HTMLDivElement
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
id: dom.getAttribute('id'),
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
toDOM: (node) => {
|
|
52
|
+
const placeholderNode = node as PlaceholderNode
|
|
53
|
+
|
|
54
|
+
return [
|
|
55
|
+
'div',
|
|
56
|
+
{
|
|
57
|
+
class: 'placeholder-item',
|
|
58
|
+
id: placeholderNode.attrs.id,
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 PlaceholderElementNode extends ManuscriptNode {
|
|
26
|
+
attrs: Attrs
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const placeholderElement: NodeSpec = {
|
|
30
|
+
atom: true,
|
|
31
|
+
selectable: false,
|
|
32
|
+
attrs: {
|
|
33
|
+
id: { default: '' },
|
|
34
|
+
dataTracked: { default: null },
|
|
35
|
+
},
|
|
36
|
+
group: 'block element',
|
|
37
|
+
parseDOM: [
|
|
38
|
+
{
|
|
39
|
+
tag: 'div.placeholder-element',
|
|
40
|
+
getAttrs: (p) => {
|
|
41
|
+
const dom = p as HTMLDivElement
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
id: dom.getAttribute('id'),
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
toDOM: (node) => {
|
|
50
|
+
const placeholderElementNode = node as PlaceholderElementNode
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
'div',
|
|
54
|
+
{
|
|
55
|
+
class: 'placeholder-element',
|
|
56
|
+
id: placeholderElementNode.attrs.id,
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
}
|