@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.
Files changed (196) hide show
  1. package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +3 -3
  2. package/dist/cjs/jats/exporter/jats-exporter.js +3 -0
  3. package/dist/cjs/jats/importer/jats-dom-parser.js +41 -1
  4. package/dist/cjs/schema/index.js +9 -0
  5. package/dist/cjs/schema/nodes/headshot_element.js +38 -0
  6. package/dist/cjs/schema/nodes/headshot_grid.js +37 -0
  7. package/dist/cjs/schema/nodes/headshot_image.js +51 -0
  8. package/dist/cjs/transformer/node-names.js +2 -0
  9. package/dist/cjs/transformer/node-title.js +6 -0
  10. package/dist/cjs/version.js +1 -1
  11. package/dist/es/jats/__tests__/jats-roundtrip.test.js +3 -3
  12. package/dist/es/jats/exporter/jats-exporter.js +3 -0
  13. package/dist/es/jats/importer/jats-dom-parser.js +41 -1
  14. package/dist/es/schema/index.js +9 -0
  15. package/dist/es/schema/nodes/headshot_element.js +34 -0
  16. package/dist/es/schema/nodes/headshot_grid.js +33 -0
  17. package/dist/es/schema/nodes/headshot_image.js +48 -0
  18. package/dist/es/transformer/node-names.js +2 -0
  19. package/dist/es/transformer/node-title.js +6 -0
  20. package/dist/es/version.js +1 -1
  21. package/dist/types/jats/__tests__/utils.d.ts +1 -1
  22. package/dist/types/schema/index.d.ts +3 -0
  23. package/dist/types/schema/nodes/headshot_element.d.ts +25 -0
  24. package/dist/types/schema/nodes/headshot_grid.d.ts +24 -0
  25. package/dist/types/schema/nodes/headshot_image.d.ts +26 -0
  26. package/dist/types/schema/types.d.ts +1 -1
  27. package/dist/types/version.d.ts +1 -1
  28. package/package.json +22 -21
  29. package/src/errors.ts +28 -0
  30. package/src/getVersion.ts +21 -0
  31. package/src/index.ts +28 -0
  32. package/src/jats/__tests__/__fixtures__/debug-example.xml +136 -0
  33. package/src/jats/__tests__/__fixtures__/jats-abstract-no-body.xml +163 -0
  34. package/src/jats/__tests__/__fixtures__/jats-citations.xml +472 -0
  35. package/src/jats/__tests__/__fixtures__/jats-comments.xml +46 -0
  36. package/src/jats/__tests__/__fixtures__/jats-document.xml +134 -0
  37. package/src/jats/__tests__/__fixtures__/jats-example-doc.xml +1235 -0
  38. package/src/jats/__tests__/__fixtures__/jats-example-front-only.xml +26 -0
  39. package/src/jats/__tests__/__fixtures__/jats-example-full.xml +209 -0
  40. package/src/jats/__tests__/__fixtures__/jats-example-no-back.xml +156 -0
  41. package/src/jats/__tests__/__fixtures__/jats-example-no-body.xml +91 -0
  42. package/src/jats/__tests__/__fixtures__/jats-example.xml +221 -0
  43. package/src/jats/__tests__/__fixtures__/jats-fn-group.xml +60 -0
  44. package/src/jats/__tests__/__fixtures__/jats-import-no-refs.xml +1077 -0
  45. package/src/jats/__tests__/__fixtures__/jats-import.xml +1578 -0
  46. package/src/jats/__tests__/__fixtures__/jats-roundtrip.xml +133 -0
  47. package/src/jats/__tests__/__fixtures__/jats-tables-example.xml +2043 -0
  48. package/src/jats/__tests__/__fixtures__/math-fragment.xml +12 -0
  49. package/src/jats/__tests__/__snapshots__/citeproc.test.ts.snap +57 -0
  50. package/src/jats/__tests__/__snapshots__/create-article-node.test.ts.snap +65 -0
  51. package/src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap +7 -0
  52. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +59796 -0
  53. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +18 -0
  54. package/src/jats/__tests__/citations.ts +25 -0
  55. package/src/jats/__tests__/citeproc.test.ts +195 -0
  56. package/src/jats/__tests__/create-article-node.test.ts +29 -0
  57. package/src/jats/__tests__/data/section-categories.ts +212 -0
  58. package/src/jats/__tests__/files.ts +24 -0
  59. package/src/jats/__tests__/jats-exporter.test.ts +223 -0
  60. package/src/jats/__tests__/jats-importer.test.ts +567 -0
  61. package/src/jats/__tests__/jats-roundtrip.test.ts +66 -0
  62. package/src/jats/__tests__/utils.ts +90 -0
  63. package/src/jats/exporter/citeproc.ts +265 -0
  64. package/src/jats/exporter/jats-exporter.ts +2093 -0
  65. package/src/jats/exporter/jats-versions.ts +50 -0
  66. package/src/jats/exporter/labels.ts +101 -0
  67. package/src/jats/importer/create-article-node.ts +52 -0
  68. package/src/jats/importer/jats-comments.ts +111 -0
  69. package/src/jats/importer/jats-dom-parser.ts +1306 -0
  70. package/src/jats/importer/jats-parser-utils.ts +234 -0
  71. package/src/jats/importer/jats-transformations.ts +591 -0
  72. package/src/jats/importer/parse-jats-article.ts +106 -0
  73. package/src/jats/index.ts +21 -0
  74. package/src/jats/types.ts +16 -0
  75. package/src/lib/__tests__/footnotes.test.ts +36 -0
  76. package/src/lib/citeproc.ts +30 -0
  77. package/src/lib/credit-roles.ts +91 -0
  78. package/src/lib/deafults.ts +17 -0
  79. package/src/lib/footnotes.ts +85 -0
  80. package/src/lib/html.ts +56 -0
  81. package/src/lib/section-categories.ts +27 -0
  82. package/src/lib/utils.ts +145 -0
  83. package/src/lib/xml.ts +28 -0
  84. package/src/schema/__tests__/docs.ts +1911 -0
  85. package/src/schema/__tests__/groups.test.ts +61 -0
  86. package/src/schema/__tests__/migration.test.ts +23 -0
  87. package/src/schema/groups.ts +36 -0
  88. package/src/schema/index.ts +295 -0
  89. package/src/schema/marks.ts +254 -0
  90. package/src/schema/migration/migrate.ts +77 -0
  91. package/src/schema/migration/migration-script.ts +26 -0
  92. package/src/schema/migration/migration-scripts/1.2.5.ts +44 -0
  93. package/src/schema/migration/migration-scripts/2.3.22.ts +52 -0
  94. package/src/schema/migration/migration-scripts/3.0.12.ts +33 -0
  95. package/src/schema/migration/migration-scripts/3.0.21.ts +50 -0
  96. package/src/schema/migration/migration-scripts/3.0.30.ts +65 -0
  97. package/src/schema/migration/migration-scripts/3.0.31.ts +40 -0
  98. package/src/schema/migration/migration-scripts/3.0.41.ts +37 -0
  99. package/src/schema/migration/migration-scripts/3.0.55.ts +42 -0
  100. package/src/schema/migration/migration-scripts/3.0.56.ts +114 -0
  101. package/src/schema/migration/migration-scripts/4.2.13.ts +37 -0
  102. package/src/schema/migration/migration-scripts/4.2.15.ts +48 -0
  103. package/src/schema/migration/migration-scripts/4.3.23.ts +55 -0
  104. package/src/schema/migration/migration-scripts/4.3.34.ts +132 -0
  105. package/src/schema/migration/migration-scripts/4.3.35.ts +41 -0
  106. package/src/schema/migration/migration-scripts/index.ts +49 -0
  107. package/src/schema/nodes/abstracts.ts +29 -0
  108. package/src/schema/nodes/affiliation.ts +88 -0
  109. package/src/schema/nodes/affiliations.ts +30 -0
  110. package/src/schema/nodes/alt_text.ts +36 -0
  111. package/src/schema/nodes/alt_title.ts +40 -0
  112. package/src/schema/nodes/alt_titles_section.ts +58 -0
  113. package/src/schema/nodes/attachment.ts +46 -0
  114. package/src/schema/nodes/attachments.ts +45 -0
  115. package/src/schema/nodes/attribution.ts +38 -0
  116. package/src/schema/nodes/author_notes.ts +44 -0
  117. package/src/schema/nodes/award.ts +52 -0
  118. package/src/schema/nodes/awards.ts +45 -0
  119. package/src/schema/nodes/backmatter.ts +31 -0
  120. package/src/schema/nodes/bibliography_element.ts +58 -0
  121. package/src/schema/nodes/bibliography_item.ts +108 -0
  122. package/src/schema/nodes/bibliography_section.ts +60 -0
  123. package/src/schema/nodes/blockquote_element.ts +79 -0
  124. package/src/schema/nodes/body.ts +29 -0
  125. package/src/schema/nodes/box_element.ts +67 -0
  126. package/src/schema/nodes/caption.ts +67 -0
  127. package/src/schema/nodes/caption_title.ts +67 -0
  128. package/src/schema/nodes/citation.ts +70 -0
  129. package/src/schema/nodes/comment.ts +50 -0
  130. package/src/schema/nodes/comments.ts +28 -0
  131. package/src/schema/nodes/contributor.ts +87 -0
  132. package/src/schema/nodes/contributors.ts +40 -0
  133. package/src/schema/nodes/core_section.ts +27 -0
  134. package/src/schema/nodes/corresp.ts +49 -0
  135. package/src/schema/nodes/cross_reference.ts +64 -0
  136. package/src/schema/nodes/doc.ts +21 -0
  137. package/src/schema/nodes/embed.ts +55 -0
  138. package/src/schema/nodes/equation.ts +65 -0
  139. package/src/schema/nodes/equation_element.ts +61 -0
  140. package/src/schema/nodes/figure.ts +65 -0
  141. package/src/schema/nodes/figure_element.ts +73 -0
  142. package/src/schema/nodes/footnote.ts +95 -0
  143. package/src/schema/nodes/footnotes_element.ts +69 -0
  144. package/src/schema/nodes/footnotes_section.ts +61 -0
  145. package/src/schema/nodes/general_table_footnote.ts +42 -0
  146. package/src/schema/nodes/graphical_abstract_section.ts +62 -0
  147. package/src/schema/nodes/hard_break.ts +36 -0
  148. package/src/schema/nodes/headshot_element.ts +48 -0
  149. package/src/schema/nodes/headshot_grid.ts +46 -0
  150. package/src/schema/nodes/headshot_image.ts +65 -0
  151. package/src/schema/nodes/hero_image.ts +46 -0
  152. package/src/schema/nodes/highlight_marker.ts +68 -0
  153. package/src/schema/nodes/image_element.ts +49 -0
  154. package/src/schema/nodes/inline_equation.ts +68 -0
  155. package/src/schema/nodes/inline_footnote.ts +66 -0
  156. package/src/schema/nodes/keyword.ts +61 -0
  157. package/src/schema/nodes/keyword_group.ts +63 -0
  158. package/src/schema/nodes/keywords.ts +59 -0
  159. package/src/schema/nodes/keywords_element.ts +64 -0
  160. package/src/schema/nodes/link.ts +79 -0
  161. package/src/schema/nodes/list.ts +134 -0
  162. package/src/schema/nodes/listing.ts +91 -0
  163. package/src/schema/nodes/listing_element.ts +61 -0
  164. package/src/schema/nodes/long_desc.ts +36 -0
  165. package/src/schema/nodes/manuscript.ts +86 -0
  166. package/src/schema/nodes/missing_figure.ts +59 -0
  167. package/src/schema/nodes/paragraph.ts +77 -0
  168. package/src/schema/nodes/placeholder.ts +62 -0
  169. package/src/schema/nodes/placeholder_element.ts +60 -0
  170. package/src/schema/nodes/pullquote_element.ts +81 -0
  171. package/src/schema/nodes/quote_image.ts +64 -0
  172. package/src/schema/nodes/section.ts +69 -0
  173. package/src/schema/nodes/section_label.ts +39 -0
  174. package/src/schema/nodes/section_title.ts +58 -0
  175. package/src/schema/nodes/subtitle.ts +40 -0
  176. package/src/schema/nodes/subtitles.ts +51 -0
  177. package/src/schema/nodes/supplement.ts +77 -0
  178. package/src/schema/nodes/supplements.ts +60 -0
  179. package/src/schema/nodes/table.ts +144 -0
  180. package/src/schema/nodes/table_col.ts +76 -0
  181. package/src/schema/nodes/table_element.ts +67 -0
  182. package/src/schema/nodes/table_element_footer.ts +42 -0
  183. package/src/schema/nodes/text.ts +31 -0
  184. package/src/schema/nodes/title.ts +43 -0
  185. package/src/schema/nodes/trans_abstract.ts +58 -0
  186. package/src/schema/nodes/trans_graphical_abstract.ts +67 -0
  187. package/src/schema/types.ts +243 -0
  188. package/src/tests.ts +33 -0
  189. package/src/transformer/id.ts +23 -0
  190. package/src/transformer/index.ts +21 -0
  191. package/src/transformer/node-names.ts +75 -0
  192. package/src/transformer/node-title.ts +116 -0
  193. package/src/transformer/node-types.ts +39 -0
  194. package/src/transformer/node-validator.ts +82 -0
  195. package/src/types.ts +25 -0
  196. package/src/version.ts +1 -0
@@ -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
+ interface Attrs {
22
+ placeholder: string
23
+ }
24
+
25
+ export interface CaptionTitleNode extends ManuscriptNode {
26
+ attrs: Attrs
27
+ }
28
+
29
+ export const captionTitle: NodeSpec = {
30
+ content: 'inline*',
31
+ group: 'block',
32
+ selectable: false,
33
+ isolating: true,
34
+ attrs: {
35
+ placeholder: { default: 'Title...' },
36
+ dataTracked: { default: null },
37
+ },
38
+ parseDOM: [
39
+ {
40
+ tag: 'label',
41
+ getAttrs: (node) => {
42
+ const dom = node as HTMLSpanElement
43
+
44
+ return {
45
+ placeholder: dom.getAttribute('data-placeholder-text'),
46
+ }
47
+ },
48
+ },
49
+ ],
50
+ toDOM: (node) => {
51
+ const captionTitleNode = node as CaptionTitleNode
52
+
53
+ const attrs: { [key: string]: string } = {}
54
+
55
+ attrs.class = 'caption-title'
56
+
57
+ if (captionTitleNode.attrs.placeholder) {
58
+ attrs['data-placeholder-text'] = captionTitleNode.attrs.placeholder
59
+ }
60
+
61
+ if (!captionTitleNode.textContent) {
62
+ attrs.class = `${attrs.class} placeholder`
63
+ }
64
+
65
+ return ['label', attrs, 0]
66
+ },
67
+ }
@@ -0,0 +1,70 @@
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 CitationAttrs {
22
+ id: string
23
+ rids: string[]
24
+ selectedText?: string
25
+ }
26
+
27
+ export interface CitationNode extends ManuscriptNode {
28
+ attrs: CitationAttrs
29
+ }
30
+
31
+ export const citation: NodeSpec = {
32
+ inline: true,
33
+ group: 'inline',
34
+ draggable: true,
35
+ atom: true,
36
+ attrs: {
37
+ id: { default: '' },
38
+ rids: { default: [] },
39
+ selectedText: { default: '' },
40
+ dataTracked: { default: null },
41
+ },
42
+ parseDOM: [
43
+ {
44
+ tag: 'span.citation[data-reference-id]',
45
+ getAttrs: (p) => {
46
+ const dom = p as HTMLSpanElement
47
+
48
+ return {
49
+ id: dom.getAttribute('data-id'),
50
+ rids: dom.getAttribute('data-reference-id')?.split(/\s+/) || [],
51
+ }
52
+ },
53
+ },
54
+ ],
55
+ toDOM: (node) => {
56
+ const citation = node as CitationNode
57
+
58
+ const dom = document.createElement('span')
59
+ dom.className = 'citation'
60
+ dom.setAttribute('data-id', citation.attrs.id)
61
+ dom.setAttribute('data-reference-id', citation.attrs.rids.join(' '))
62
+
63
+ dom.innerHTML = node.attrs.contents
64
+
65
+ return dom
66
+ },
67
+ }
68
+
69
+ export const isCitationNode = (node: ManuscriptNode): node is CitationNode =>
70
+ node.type === node.type.schema.nodes.citation
@@ -0,0 +1,50 @@
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 CommentAttrs {
22
+ id: string
23
+ contents: string
24
+ target: string
25
+ selector: { from: number; to: number }
26
+ resolved?: boolean
27
+ userID: string
28
+ timestamp: number
29
+ originalText?: string
30
+ }
31
+
32
+ export interface CommentNode extends ManuscriptNode {
33
+ attrs: CommentAttrs
34
+ }
35
+
36
+ export const comment: NodeSpec = {
37
+ attrs: {
38
+ id: { default: '' },
39
+ contents: { default: '' },
40
+ target: { default: '' },
41
+ selector: { default: undefined },
42
+ resolved: { default: false },
43
+ userID: { default: '' },
44
+ timestamp: { default: 0 },
45
+ originalText: { default: '' },
46
+ },
47
+ }
48
+
49
+ export const isCommentNode = (node: ManuscriptNode): node is CommentNode =>
50
+ node.type === node.type.schema.nodes.comment
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { NodeSpec } from 'prosemirror-model'
18
+
19
+ // This node has no representation in json-schema
20
+ // It exists for the purpose of styling in the UI
21
+
22
+ export const comments: NodeSpec = {
23
+ content: 'comment*',
24
+ attrs: {
25
+ id: { default: '' },
26
+ },
27
+ toDOM: () => ['div', { class: 'comments' }, 0],
28
+ }
@@ -0,0 +1,87 @@
1
+ /*!
2
+ * © 2023 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 { CreditVocabTerm } from '../../lib/credit-roles'
19
+ import { ManuscriptNode } from '../types'
20
+
21
+ export type CreditRole = {
22
+ vocabTerm: CreditVocabTerm
23
+ }
24
+
25
+ export interface ContributorAttrs {
26
+ id: string
27
+ role: string
28
+ correspIDs: string[]
29
+ affiliationIDs: string[]
30
+ footnoteIDs: string[]
31
+ given?: string
32
+ family?: string
33
+ prefix?: string
34
+ suffix?: string
35
+ email?: string
36
+ ORCID?: string
37
+ degrees: string[]
38
+ isAuthenticated?: boolean
39
+ isCorresponding: boolean
40
+ priority: number
41
+ isJointContributor: boolean
42
+ creditRoles?: CreditRole[]
43
+ }
44
+
45
+ export interface ContributorNode extends ManuscriptNode {
46
+ attrs: ContributorAttrs
47
+ }
48
+
49
+ export const contributor: NodeSpec = {
50
+ content: 'inline*',
51
+ atom: true,
52
+ attrs: {
53
+ id: { default: '' },
54
+ role: { default: '' },
55
+ correspIDs: { default: [] },
56
+ affiliationIDs: { default: [] },
57
+ footnoteIDs: { default: [] },
58
+ given: { default: undefined },
59
+ family: { default: undefined },
60
+ prefix: { default: undefined },
61
+ suffix: { default: undefined },
62
+ degrees: { default: [] },
63
+ email: { default: undefined },
64
+ ORCID: { default: undefined },
65
+ isAuthenticated: { default: false },
66
+ isCorresponding: { default: false },
67
+ isJointContributor: { default: false },
68
+ priority: { default: undefined },
69
+ creditRoles: { default: [] },
70
+ dataTracked: { default: null },
71
+ contents: { default: '' },
72
+ },
73
+ group: 'block',
74
+ toDOM: (node) => {
75
+ const contributorNode = node as ContributorNode
76
+ return [
77
+ 'div',
78
+ {
79
+ class: 'contributor',
80
+ id: contributorNode.attrs.id,
81
+ },
82
+ ]
83
+ },
84
+ }
85
+ export const isContributorNode = (
86
+ node: ManuscriptNode
87
+ ): node is ContributorNode => node.type === node.type.schema.nodes.contributor
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * © 2023 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
+ // This node has no representation in json-schema
22
+ // It exists for the purpose of styling in the UI
23
+
24
+ interface Attrs {
25
+ id: string
26
+ }
27
+
28
+ export interface ContributorsNode extends ManuscriptNode {
29
+ attrs: Attrs
30
+ }
31
+
32
+ export const contributors: NodeSpec = {
33
+ content: 'contributor*',
34
+ attrs: {
35
+ id: { default: '' },
36
+ },
37
+ group: 'block',
38
+ selectable: false,
39
+ toDOM: () => ['div', { class: 'contributors' }, 0],
40
+ }
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { NodeSpec } from 'prosemirror-model'
18
+
19
+ export const coreSection: NodeSpec = {
20
+ content: 'sections*',
21
+ atom: true,
22
+ attrs: {
23
+ id: { default: '' },
24
+ },
25
+ group: 'block',
26
+ toDOM: () => ['section', 0],
27
+ }
@@ -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
+ interface Attrs {
21
+ id: string
22
+ label?: string
23
+ }
24
+
25
+ export interface CorrespNode extends ManuscriptNode {
26
+ attrs: Attrs
27
+ }
28
+
29
+ export const corresp: NodeSpec = {
30
+ content: 'inline*',
31
+ attrs: {
32
+ id: { default: '' },
33
+ label: { default: undefined },
34
+ dataTracked: { default: null },
35
+ },
36
+ group: 'block',
37
+ toDOM: (node) => {
38
+ return [
39
+ 'div',
40
+ {
41
+ class: 'corresp',
42
+ id: node.attrs.id,
43
+ },
44
+ 0,
45
+ ]
46
+ },
47
+ }
48
+ export const isCorrespNode = (node: ManuscriptNode): node is CorrespNode =>
49
+ node.type === node.type.schema.nodes.corresp
@@ -0,0 +1,64 @@
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
+ rids: string[]
23
+ label: string
24
+ }
25
+
26
+ export interface CrossReferenceNode extends ManuscriptNode {
27
+ attrs: Attrs
28
+ }
29
+
30
+ export const crossReference: NodeSpec = {
31
+ inline: true,
32
+ group: 'inline',
33
+ draggable: true,
34
+ atom: true,
35
+ attrs: {
36
+ rids: { default: [] },
37
+ label: { default: '' },
38
+ dataTracked: { default: null },
39
+ },
40
+ parseDOM: [
41
+ {
42
+ tag: 'span.cross-reference',
43
+ getAttrs: (p) => {
44
+ const dom = p as HTMLSpanElement
45
+
46
+ return {
47
+ rids: dom.getAttribute('data-reference-id')?.split(/\s+/) || [],
48
+ }
49
+ },
50
+ },
51
+ ],
52
+ toDOM: (node) => {
53
+ const crossReferenceNode = node as CrossReferenceNode
54
+
55
+ return [
56
+ 'span',
57
+ {
58
+ class: 'cross-reference',
59
+ 'data-reference-id': crossReferenceNode.attrs.rids.join(' '),
60
+ },
61
+ crossReferenceNode.attrs.label,
62
+ ]
63
+ },
64
+ }
@@ -0,0 +1,21 @@
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
+ export const doc: NodeSpec = {
20
+ content: 'manuscript',
21
+ }
@@ -0,0 +1,55 @@
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
+
17
+ import { NodeSpec } from 'prosemirror-model'
18
+
19
+ import { ManuscriptNode } from '../types'
20
+
21
+ export interface EmbedAttrs {
22
+ id: string
23
+ href: string
24
+ mimetype: string
25
+ mimeSubtype: string
26
+ }
27
+
28
+ export interface EmbedNode extends ManuscriptNode {
29
+ attrs: EmbedAttrs
30
+ }
31
+
32
+ export const embed: NodeSpec = {
33
+ content: 'caption_title caption alt_text long_desc',
34
+ attrs: {
35
+ id: { default: '' },
36
+ dataTracked: { default: null },
37
+ href: { default: undefined },
38
+ mimetype: { default: undefined },
39
+ mimeSubtype: { default: undefined },
40
+ longDesc: { default: '' },
41
+ },
42
+ group: 'block element',
43
+ toDOM: (node) => {
44
+ return [
45
+ 'div',
46
+ {
47
+ class: 'embed',
48
+ id: node.attrs.id,
49
+ },
50
+ ]
51
+ },
52
+ }
53
+
54
+ export const isEmbedNode = (node: ManuscriptNode): node is EmbedNode =>
55
+ node.type === node.type.schema.nodes.embed
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * © 2023 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
+ format: string
24
+ contents: string
25
+ }
26
+
27
+ export interface EquationNode extends ManuscriptNode {
28
+ attrs: Attrs
29
+ }
30
+
31
+ export const equation: NodeSpec = {
32
+ attrs: {
33
+ id: { default: '' },
34
+ contents: { default: '' },
35
+ format: { default: '' },
36
+ dataTracked: { default: null },
37
+ },
38
+ group: 'block',
39
+ parseDOM: [
40
+ {
41
+ tag: `div.MPEquation`,
42
+ getAttrs: (p) => {
43
+ const htmlEl = p as HTMLElement
44
+ return {
45
+ id: htmlEl.getAttribute('id'),
46
+ format: htmlEl.getAttribute('data-equation-format'),
47
+ contents: htmlEl.innerHTML,
48
+ }
49
+ },
50
+ },
51
+ ],
52
+ toDOM: (node: ManuscriptNode) => {
53
+ const equationNode = node as EquationNode
54
+ const { id, contents, format } = equationNode.attrs
55
+
56
+ const dom = document.createElement('div')
57
+ dom.setAttribute('id', id)
58
+ if (format) {
59
+ dom.setAttribute('data-equation-format', format)
60
+ }
61
+ dom.innerHTML = contents
62
+
63
+ return dom
64
+ },
65
+ }
@@ -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 EquationElementNode extends ManuscriptNode {
26
+ attrs: Attrs
27
+ }
28
+
29
+ export const equationElement: NodeSpec = {
30
+ content: '(equation | placeholder)',
31
+ attrs: {
32
+ id: { default: '' },
33
+ dataTracked: { default: null },
34
+ },
35
+ selectable: false,
36
+ group: 'block element',
37
+ parseDOM: [
38
+ {
39
+ tag: 'div.equation',
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 equationElementNode = node as EquationElementNode
51
+
52
+ return [
53
+ 'div',
54
+ {
55
+ class: 'equation',
56
+ id: equationElementNode.attrs.id,
57
+ },
58
+ 0,
59
+ ]
60
+ },
61
+ }