@manuscripts/transform 4.3.53 → 4.4.0

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.
Files changed (172) hide show
  1. package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +3 -3
  2. package/dist/cjs/version.js +1 -1
  3. package/dist/es/jats/__tests__/jats-roundtrip.test.js +3 -3
  4. package/dist/es/version.js +1 -1
  5. package/dist/types/jats/__tests__/utils.d.ts +1 -1
  6. package/dist/types/version.d.ts +1 -1
  7. package/package.json +22 -21
  8. package/src/errors.ts +28 -0
  9. package/src/getVersion.ts +21 -0
  10. package/src/index.ts +28 -0
  11. package/src/jats/__tests__/__fixtures__/debug-example.xml +136 -0
  12. package/src/jats/__tests__/__fixtures__/jats-abstract-no-body.xml +163 -0
  13. package/src/jats/__tests__/__fixtures__/jats-citations.xml +472 -0
  14. package/src/jats/__tests__/__fixtures__/jats-comments.xml +46 -0
  15. package/src/jats/__tests__/__fixtures__/jats-document.xml +134 -0
  16. package/src/jats/__tests__/__fixtures__/jats-example-doc.xml +1235 -0
  17. package/src/jats/__tests__/__fixtures__/jats-example-front-only.xml +26 -0
  18. package/src/jats/__tests__/__fixtures__/jats-example-full.xml +209 -0
  19. package/src/jats/__tests__/__fixtures__/jats-example-no-back.xml +156 -0
  20. package/src/jats/__tests__/__fixtures__/jats-example-no-body.xml +91 -0
  21. package/src/jats/__tests__/__fixtures__/jats-example.xml +221 -0
  22. package/src/jats/__tests__/__fixtures__/jats-fn-group.xml +60 -0
  23. package/src/jats/__tests__/__fixtures__/jats-import-no-refs.xml +1077 -0
  24. package/src/jats/__tests__/__fixtures__/jats-import.xml +1561 -0
  25. package/src/jats/__tests__/__fixtures__/jats-roundtrip.xml +133 -0
  26. package/src/jats/__tests__/__fixtures__/jats-tables-example.xml +2043 -0
  27. package/src/jats/__tests__/__fixtures__/math-fragment.xml +12 -0
  28. package/src/jats/__tests__/__snapshots__/citeproc.test.ts.snap +57 -0
  29. package/src/jats/__tests__/__snapshots__/create-article-node.test.ts.snap +65 -0
  30. package/src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap +7 -0
  31. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +59605 -0
  32. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +18 -0
  33. package/src/jats/__tests__/citations.ts +25 -0
  34. package/src/jats/__tests__/citeproc.test.ts +195 -0
  35. package/src/jats/__tests__/create-article-node.test.ts +29 -0
  36. package/src/jats/__tests__/data/section-categories.ts +212 -0
  37. package/src/jats/__tests__/files.ts +24 -0
  38. package/src/jats/__tests__/jats-exporter.test.ts +223 -0
  39. package/src/jats/__tests__/jats-importer.test.ts +567 -0
  40. package/src/jats/__tests__/jats-roundtrip.test.ts +66 -0
  41. package/src/jats/__tests__/utils.ts +90 -0
  42. package/src/jats/exporter/citeproc.ts +265 -0
  43. package/src/jats/exporter/jats-exporter.ts +2090 -0
  44. package/src/jats/exporter/jats-versions.ts +50 -0
  45. package/src/jats/exporter/labels.ts +101 -0
  46. package/src/jats/importer/create-article-node.ts +52 -0
  47. package/src/jats/importer/jats-comments.ts +111 -0
  48. package/src/jats/importer/jats-dom-parser.ts +1260 -0
  49. package/src/jats/importer/jats-parser-utils.ts +234 -0
  50. package/src/jats/importer/jats-transformations.ts +591 -0
  51. package/src/jats/importer/parse-jats-article.ts +106 -0
  52. package/src/jats/index.ts +21 -0
  53. package/src/jats/types.ts +16 -0
  54. package/src/lib/__tests__/footnotes.test.ts +36 -0
  55. package/src/lib/citeproc.ts +30 -0
  56. package/src/lib/credit-roles.ts +91 -0
  57. package/src/lib/deafults.ts +17 -0
  58. package/src/lib/footnotes.ts +85 -0
  59. package/src/lib/html.ts +56 -0
  60. package/src/lib/section-categories.ts +27 -0
  61. package/src/lib/utils.ts +145 -0
  62. package/src/lib/xml.ts +28 -0
  63. package/src/schema/__tests__/docs.ts +1911 -0
  64. package/src/schema/__tests__/groups.test.ts +61 -0
  65. package/src/schema/__tests__/migration.test.ts +23 -0
  66. package/src/schema/groups.ts +36 -0
  67. package/src/schema/index.ts +286 -0
  68. package/src/schema/marks.ts +254 -0
  69. package/src/schema/migration/migrate.ts +77 -0
  70. package/src/schema/migration/migration-script.ts +26 -0
  71. package/src/schema/migration/migration-scripts/1.2.5.ts +44 -0
  72. package/src/schema/migration/migration-scripts/2.3.22.ts +52 -0
  73. package/src/schema/migration/migration-scripts/3.0.12.ts +33 -0
  74. package/src/schema/migration/migration-scripts/3.0.21.ts +50 -0
  75. package/src/schema/migration/migration-scripts/3.0.30.ts +65 -0
  76. package/src/schema/migration/migration-scripts/3.0.31.ts +40 -0
  77. package/src/schema/migration/migration-scripts/3.0.41.ts +37 -0
  78. package/src/schema/migration/migration-scripts/3.0.55.ts +42 -0
  79. package/src/schema/migration/migration-scripts/3.0.56.ts +114 -0
  80. package/src/schema/migration/migration-scripts/4.2.13.ts +37 -0
  81. package/src/schema/migration/migration-scripts/4.2.15.ts +48 -0
  82. package/src/schema/migration/migration-scripts/4.3.23.ts +55 -0
  83. package/src/schema/migration/migration-scripts/4.3.34.ts +132 -0
  84. package/src/schema/migration/migration-scripts/4.3.35.ts +41 -0
  85. package/src/schema/migration/migration-scripts/index.ts +49 -0
  86. package/src/schema/nodes/abstracts.ts +29 -0
  87. package/src/schema/nodes/affiliation.ts +88 -0
  88. package/src/schema/nodes/affiliations.ts +30 -0
  89. package/src/schema/nodes/alt_text.ts +36 -0
  90. package/src/schema/nodes/alt_title.ts +40 -0
  91. package/src/schema/nodes/alt_titles_section.ts +58 -0
  92. package/src/schema/nodes/attachment.ts +46 -0
  93. package/src/schema/nodes/attachments.ts +45 -0
  94. package/src/schema/nodes/attribution.ts +38 -0
  95. package/src/schema/nodes/author_notes.ts +44 -0
  96. package/src/schema/nodes/award.ts +52 -0
  97. package/src/schema/nodes/awards.ts +45 -0
  98. package/src/schema/nodes/backmatter.ts +31 -0
  99. package/src/schema/nodes/bibliography_element.ts +58 -0
  100. package/src/schema/nodes/bibliography_item.ts +108 -0
  101. package/src/schema/nodes/bibliography_section.ts +60 -0
  102. package/src/schema/nodes/blockquote_element.ts +79 -0
  103. package/src/schema/nodes/body.ts +29 -0
  104. package/src/schema/nodes/box_element.ts +67 -0
  105. package/src/schema/nodes/caption.ts +67 -0
  106. package/src/schema/nodes/caption_title.ts +67 -0
  107. package/src/schema/nodes/citation.ts +70 -0
  108. package/src/schema/nodes/comment.ts +50 -0
  109. package/src/schema/nodes/comments.ts +28 -0
  110. package/src/schema/nodes/contributor.ts +87 -0
  111. package/src/schema/nodes/contributors.ts +40 -0
  112. package/src/schema/nodes/core_section.ts +27 -0
  113. package/src/schema/nodes/corresp.ts +49 -0
  114. package/src/schema/nodes/cross_reference.ts +64 -0
  115. package/src/schema/nodes/doc.ts +21 -0
  116. package/src/schema/nodes/embed.ts +55 -0
  117. package/src/schema/nodes/equation.ts +65 -0
  118. package/src/schema/nodes/equation_element.ts +61 -0
  119. package/src/schema/nodes/figure.ts +65 -0
  120. package/src/schema/nodes/figure_element.ts +73 -0
  121. package/src/schema/nodes/footnote.ts +95 -0
  122. package/src/schema/nodes/footnotes_element.ts +69 -0
  123. package/src/schema/nodes/footnotes_section.ts +61 -0
  124. package/src/schema/nodes/general_table_footnote.ts +42 -0
  125. package/src/schema/nodes/graphical_abstract_section.ts +62 -0
  126. package/src/schema/nodes/hard_break.ts +36 -0
  127. package/src/schema/nodes/hero_image.ts +46 -0
  128. package/src/schema/nodes/highlight_marker.ts +68 -0
  129. package/src/schema/nodes/image_element.ts +49 -0
  130. package/src/schema/nodes/inline_equation.ts +68 -0
  131. package/src/schema/nodes/inline_footnote.ts +66 -0
  132. package/src/schema/nodes/keyword.ts +61 -0
  133. package/src/schema/nodes/keyword_group.ts +63 -0
  134. package/src/schema/nodes/keywords.ts +59 -0
  135. package/src/schema/nodes/keywords_element.ts +64 -0
  136. package/src/schema/nodes/link.ts +79 -0
  137. package/src/schema/nodes/list.ts +134 -0
  138. package/src/schema/nodes/listing.ts +91 -0
  139. package/src/schema/nodes/listing_element.ts +61 -0
  140. package/src/schema/nodes/long_desc.ts +36 -0
  141. package/src/schema/nodes/manuscript.ts +86 -0
  142. package/src/schema/nodes/missing_figure.ts +59 -0
  143. package/src/schema/nodes/paragraph.ts +77 -0
  144. package/src/schema/nodes/placeholder.ts +62 -0
  145. package/src/schema/nodes/placeholder_element.ts +60 -0
  146. package/src/schema/nodes/pullquote_element.ts +81 -0
  147. package/src/schema/nodes/quote_image.ts +64 -0
  148. package/src/schema/nodes/section.ts +69 -0
  149. package/src/schema/nodes/section_label.ts +39 -0
  150. package/src/schema/nodes/section_title.ts +58 -0
  151. package/src/schema/nodes/subtitle.ts +40 -0
  152. package/src/schema/nodes/subtitles.ts +51 -0
  153. package/src/schema/nodes/supplement.ts +77 -0
  154. package/src/schema/nodes/supplements.ts +60 -0
  155. package/src/schema/nodes/table.ts +144 -0
  156. package/src/schema/nodes/table_col.ts +76 -0
  157. package/src/schema/nodes/table_element.ts +67 -0
  158. package/src/schema/nodes/table_element_footer.ts +42 -0
  159. package/src/schema/nodes/text.ts +31 -0
  160. package/src/schema/nodes/title.ts +43 -0
  161. package/src/schema/nodes/trans_abstract.ts +58 -0
  162. package/src/schema/nodes/trans_graphical_abstract.ts +67 -0
  163. package/src/schema/types.ts +240 -0
  164. package/src/tests.ts +33 -0
  165. package/src/transformer/id.ts +23 -0
  166. package/src/transformer/index.ts +21 -0
  167. package/src/transformer/node-names.ts +73 -0
  168. package/src/transformer/node-title.ts +111 -0
  169. package/src/transformer/node-types.ts +39 -0
  170. package/src/transformer/node-validator.ts +82 -0
  171. package/src/types.ts +25 -0
  172. package/src/version.ts +1 -0
@@ -0,0 +1,65 @@
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 FigureAttrs {
22
+ id: string
23
+ src: string
24
+ type: string
25
+ }
26
+
27
+ export interface FigureNode extends ManuscriptNode {
28
+ attrs: FigureAttrs
29
+ }
30
+
31
+ export const figure: NodeSpec = {
32
+ attrs: {
33
+ id: { default: '' },
34
+ src: { default: '' },
35
+ type: { default: '' },
36
+ dataTracked: { default: null },
37
+ },
38
+ selectable: false,
39
+ group: 'block',
40
+ parseDOM: [
41
+ {
42
+ tag: 'figure',
43
+ context: 'figure_element/',
44
+ getAttrs: (dom) => {
45
+ const element = dom as HTMLElement
46
+
47
+ return {
48
+ id: element.getAttribute('id'),
49
+ src: element.getAttribute('src'),
50
+ }
51
+ },
52
+ },
53
+ ],
54
+ toDOM: (node) => {
55
+ const figureNode = node as FigureNode
56
+
57
+ return [
58
+ 'figure',
59
+ {
60
+ class: 'figure',
61
+ id: figureNode.attrs.id,
62
+ },
63
+ ]
64
+ },
65
+ }
@@ -0,0 +1,73 @@
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
+ import { AttributionNode } from './attribution'
21
+
22
+ export interface FigureElementAttrs {
23
+ id: string
24
+ attribution?: AttributionNode
25
+ }
26
+
27
+ export interface FigureElementNode extends ManuscriptNode {
28
+ attrs: FigureElementAttrs
29
+ }
30
+
31
+ export const figureElement: NodeSpec = {
32
+ content:
33
+ '(paragraph | figure | missing_figure | placeholder)+ attribution* caption alt_text long_desc (listing | placeholder)',
34
+ attrs: {
35
+ id: { default: '' },
36
+ attribution: { default: undefined },
37
+ dataTracked: { default: null },
38
+ },
39
+ selectable: false,
40
+ group: 'block element executable',
41
+ parseDOM: [
42
+ {
43
+ tag: 'figure.figure-group',
44
+ getAttrs: (p) => {
45
+ const dom = p as HTMLElement
46
+
47
+ return {
48
+ id: dom.getAttribute('id'),
49
+ }
50
+ },
51
+ },
52
+ ],
53
+ toDOM: (node) => {
54
+ const figureElementNode = node as FigureElementNode
55
+
56
+ const { id } = figureElementNode.attrs
57
+
58
+ const attrs: { [key: string]: string } = {}
59
+
60
+ const classes: string[] = ['figure-group']
61
+
62
+ attrs.class = classes.join(' ')
63
+
64
+ attrs.id = id
65
+
66
+ return ['figure', attrs, 0]
67
+ },
68
+ }
69
+
70
+ export const isFigureElementNode = (
71
+ node: ManuscriptNode
72
+ ): node is FigureElementNode =>
73
+ node.type === node.type.schema.nodes.figure_element
@@ -0,0 +1,95 @@
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
+ type Kind = 'footnote' | 'endnote'
22
+
23
+ // const placeholderText: { [key in Kind]: string } = {
24
+ // endnote: 'Endnote',
25
+ // footnote: 'Footnote',
26
+ // }
27
+
28
+ interface Attrs {
29
+ id: string
30
+ kind: Kind
31
+ placeholder?: string
32
+ }
33
+
34
+ export interface FootnoteNode extends ManuscriptNode {
35
+ attrs: Attrs
36
+ }
37
+
38
+ export const footnote: NodeSpec = {
39
+ group: 'block',
40
+ content: 'paragraph+',
41
+ attrs: {
42
+ id: { default: '' },
43
+ kind: { default: 'footnote' },
44
+ placeholder: { default: '' },
45
+ dataTracked: { default: null },
46
+ },
47
+ parseDOM: [
48
+ {
49
+ tag: 'div.footnote-text', // TODO: footnote-contents wrapper?
50
+ getAttrs: (p) => {
51
+ const dom = p as HTMLDivElement
52
+
53
+ const attrs: Partial<Attrs> = {
54
+ id: dom.getAttribute('id') || undefined,
55
+ kind: (dom.getAttribute('data-kind') || 'footnote') as Kind,
56
+ }
57
+
58
+ const placeholder = dom.getAttribute('data-placeholder-text')
59
+
60
+ if (placeholder) {
61
+ attrs.placeholder = placeholder
62
+ }
63
+
64
+ return attrs
65
+ },
66
+ },
67
+ ],
68
+ toDOM: (node) => {
69
+ const footnoteNode = node as FootnoteNode
70
+
71
+ // TODO: footnote-contents wrapper?
72
+
73
+ // TODO: default kind
74
+ const { kind, placeholder, id } = footnoteNode.attrs
75
+
76
+ const attrs: Record<string, string> = { class: 'footnote-text', id: '' }
77
+
78
+ if (kind) {
79
+ attrs['data-kind'] = kind
80
+ }
81
+
82
+ if (id) {
83
+ attrs.id = id
84
+ }
85
+
86
+ if (placeholder) {
87
+ attrs['data-placeholder-text'] = placeholder
88
+ }
89
+
90
+ return ['div', attrs, 0]
91
+ },
92
+ }
93
+
94
+ export const isFootnoteNode = (node: ManuscriptNode): node is FootnoteNode =>
95
+ node.type === node.type.schema.nodes.footnote
@@ -0,0 +1,69 @@
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
+ kind?: string
24
+ }
25
+
26
+ export interface FootnotesElementNode extends ManuscriptNode {
27
+ attrs: Attrs
28
+ }
29
+
30
+ export const footnotesElement: NodeSpec = {
31
+ attrs: {
32
+ id: { default: '' },
33
+ kind: { default: 'footnote' },
34
+ dataTracked: { default: null },
35
+ },
36
+ content: 'footnote*',
37
+ group: 'block element',
38
+ selectable: false,
39
+ parseDOM: [
40
+ {
41
+ tag: 'div.footnotes', // TODO: endnotes?
42
+ getAttrs: (p) => {
43
+ const dom = p as HTMLDivElement
44
+
45
+ return {
46
+ kind: dom.getAttribute('data-kind') || 'footnote',
47
+ }
48
+ },
49
+ },
50
+ ],
51
+ toDOM: (node) => {
52
+ const footnotesElementNode = node as FootnotesElementNode
53
+
54
+ const { id, kind } = footnotesElementNode.attrs
55
+
56
+ const attrs: Record<string, string> = { class: 'footnotes', id }
57
+
58
+ if (kind) {
59
+ attrs['data-kind'] = kind
60
+ }
61
+
62
+ return ['div', attrs, 0]
63
+ },
64
+ }
65
+
66
+ export const isFootnotesElementNode = (
67
+ node: ManuscriptNode
68
+ ): node is FootnotesElementNode =>
69
+ node.type === node.type.schema.nodes.footnotes_element
@@ -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
+ // TODO: endnotes section?
26
+
27
+ export interface FootnotesSectionNode extends ManuscriptNode {
28
+ attrs: Attrs
29
+ }
30
+
31
+ export const footnotesSection: NodeSpec = {
32
+ content: 'section_title footnotes_element?',
33
+ attrs: {
34
+ id: { default: '' },
35
+ dataTracked: { default: null },
36
+ },
37
+ group: 'block sections',
38
+ selectable: false,
39
+ parseDOM: [
40
+ {
41
+ tag: 'section.footnotes',
42
+ },
43
+ ],
44
+ toDOM: (node) => {
45
+ const footnotesSectionNode = node as FootnotesSectionNode
46
+
47
+ return [
48
+ 'section',
49
+ {
50
+ id: footnotesSectionNode.attrs.id,
51
+ class: 'footnotes',
52
+ },
53
+ 0,
54
+ ]
55
+ },
56
+ }
57
+
58
+ export const isFootnotesSectionNode = (
59
+ node: ManuscriptNode
60
+ ): node is FootnotesSectionNode =>
61
+ node.type === node.type.schema.nodes.footnotes_section
@@ -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 GeneralTableFootnoteNode extends ManuscriptNode {
26
+ attrs: Attrs
27
+ }
28
+
29
+ export const generalTableFootnote: NodeSpec = {
30
+ content: 'paragraph*',
31
+ attrs: {
32
+ id: { default: '' },
33
+ dataTracked: { default: null },
34
+ },
35
+ group: 'block',
36
+ toDOM: () => ['div', { class: 'general-table-footnote' }, 0],
37
+ }
38
+
39
+ export const isGeneralTableFootnoteNode = (
40
+ node: ManuscriptNode
41
+ ): node is GeneralTableFootnoteNode =>
42
+ node.type === node.type.schema.nodes.general_table_footnote
@@ -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
+ export interface GraphicalAbstractSectionAttrs {
22
+ id: string
23
+ category: string
24
+ }
25
+
26
+ export interface GraphicalAbstractSectionNode extends ManuscriptNode {
27
+ attrs: GraphicalAbstractSectionAttrs
28
+ }
29
+
30
+ export const graphicalAbstractSection: NodeSpec = {
31
+ content: 'section_title (figure_element | placeholder)', // does it need perhaps a special view that limits the figure content? Ask Nick?
32
+ attrs: {
33
+ id: { default: '' },
34
+ dataTracked: { default: null },
35
+ category: { default: '' },
36
+ },
37
+ group: 'block sections',
38
+ selectable: false,
39
+ parseDOM: [
40
+ {
41
+ tag: 'section.graphical-abstract',
42
+ },
43
+ ],
44
+ toDOM: (node) => {
45
+ const graphicalAbstractSectionNode = node as GraphicalAbstractSectionNode
46
+
47
+ return [
48
+ 'section',
49
+ {
50
+ id: graphicalAbstractSectionNode.attrs.id,
51
+ class: 'graphical-abstract',
52
+ spellcheck: 'false',
53
+ },
54
+ 0,
55
+ ]
56
+ },
57
+ }
58
+
59
+ export const isGraphicalAbstractSectionNode = (
60
+ node: ManuscriptNode
61
+ ): node is GraphicalAbstractSectionNode =>
62
+ node.type === node.type.schema.nodes.graphical_abstract_section
@@ -0,0 +1,36 @@
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 HardBreakNode extends ManuscriptNode {
22
+ attrs: Record<string, unknown>
23
+ }
24
+
25
+ export const hardBreak: NodeSpec = {
26
+ inline: true,
27
+ group: 'inline',
28
+ selectable: false,
29
+ attrs: {
30
+ dataTracked: { default: null },
31
+ },
32
+ parseDOM: [{ tag: 'br' }],
33
+ toDOM() {
34
+ return ['br']
35
+ },
36
+ }
@@ -0,0 +1,46 @@
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 { ManuscriptNode } from '../types'
20
+
21
+ export interface HeroImageNode extends ManuscriptNode {
22
+ attrs: {
23
+ id: string
24
+ }
25
+ }
26
+
27
+ export const heroImage: NodeSpec = {
28
+ content: 'figure? alt_text long_desc',
29
+ attrs: {
30
+ id: { default: '' },
31
+ dataTracked: { default: null },
32
+ },
33
+ group: 'block element',
34
+ toDOM: (node) => {
35
+ return [
36
+ 'div',
37
+ {
38
+ class: 'hero_image',
39
+ id: node.attrs.id,
40
+ },
41
+ ]
42
+ },
43
+ }
44
+
45
+ export const isHeroImageNode = (node: ManuscriptNode): node is HeroImageNode =>
46
+ node.type === node.type.schema.nodes.hero_image
@@ -0,0 +1,68 @@
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
+ //TODO rename to rid
23
+ id: string
24
+ position: string
25
+ }
26
+
27
+ export interface HighlightMarkerNode extends ManuscriptNode {
28
+ attrs: Attrs
29
+ }
30
+
31
+ export const highlightMarker: NodeSpec = {
32
+ inline: true,
33
+ group: 'inline',
34
+ // draggable: true,
35
+ atom: true,
36
+ attrs: {
37
+ id: { default: '' },
38
+ position: { default: '' },
39
+ },
40
+ parseDOM: [
41
+ {
42
+ tag: 'span.highlight-marker',
43
+ getAttrs: (p) => {
44
+ const dom = p as HTMLSpanElement
45
+
46
+ return {
47
+ id: dom.getAttribute('id'),
48
+ position: dom.getAttribute('data-position'),
49
+ }
50
+ },
51
+ },
52
+ ],
53
+ toDOM: (node) => {
54
+ const highlightMarkerNode = node as HighlightMarkerNode
55
+
56
+ const dom = document.createElement('span')
57
+ dom.className = 'highlight-marker'
58
+ dom.setAttribute('id', highlightMarkerNode.attrs.id)
59
+ dom.setAttribute('data-position', highlightMarkerNode.attrs.position)
60
+
61
+ return dom
62
+ },
63
+ }
64
+
65
+ export const isHighlightMarkerNode = (
66
+ node: ManuscriptNode
67
+ ): node is HighlightMarkerNode =>
68
+ node.type === node.type.schema.nodes.highlight_marker
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * © 2024 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 interface ImageElementNode extends ManuscriptNode {
21
+ attrs: {
22
+ id: string
23
+ extLink?: string
24
+ }
25
+ }
26
+
27
+ export const imageElement: NodeSpec = {
28
+ content: 'figure? caption alt_text long_desc',
29
+ attrs: {
30
+ id: { default: '' },
31
+ extLink: { default: '' },
32
+ dataTracked: { default: null },
33
+ },
34
+ group: 'block element',
35
+ toDOM: (node) => {
36
+ return [
37
+ 'div',
38
+ {
39
+ class: 'image_element',
40
+ id: node.attrs.id,
41
+ },
42
+ ]
43
+ },
44
+ }
45
+
46
+ export const isImageElementNode = (
47
+ node: ManuscriptNode
48
+ ): node is ImageElementNode =>
49
+ node.type === node.type.schema.nodes.image_element