@manuscripts/body-editor 3.13.19 → 3.15.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 (52) hide show
  1. package/dist/cjs/commands.js +30 -2
  2. package/dist/cjs/components/authors-affiliations/AuthorsAndAffiliationsModals.js +1 -0
  3. package/dist/cjs/components/cross-ref-check-modal/CrossRefWarningModal.js +182 -0
  4. package/dist/cjs/components/cross-ref-check-modal/openModal.js +38 -0
  5. package/dist/cjs/components/views/DeleteSupplementDialog.js +75 -0
  6. package/dist/cjs/icons.js +2 -1
  7. package/dist/cjs/index.js +4 -1
  8. package/dist/cjs/lib/files.js +17 -5
  9. package/dist/cjs/lib/supplements.js +61 -0
  10. package/dist/cjs/plugins/cross-references.js +160 -0
  11. package/dist/cjs/versions.js +1 -1
  12. package/dist/cjs/views/caption_title.js +1 -0
  13. package/dist/cjs/views/supplement.js +21 -1
  14. package/dist/es/commands.js +26 -0
  15. package/dist/es/components/authors-affiliations/AuthorsAndAffiliationsModals.js +1 -0
  16. package/dist/es/components/cross-ref-check-modal/CrossRefWarningModal.js +142 -0
  17. package/dist/es/components/cross-ref-check-modal/openModal.js +31 -0
  18. package/dist/es/components/views/DeleteSupplementDialog.js +35 -0
  19. package/dist/es/icons.js +2 -1
  20. package/dist/es/index.js +2 -0
  21. package/dist/es/lib/files.js +17 -5
  22. package/dist/es/lib/supplements.js +55 -0
  23. package/dist/es/plugins/cross-references.js +162 -2
  24. package/dist/es/versions.js +1 -1
  25. package/dist/es/views/caption_title.js +1 -0
  26. package/dist/es/views/supplement.js +22 -2
  27. package/dist/types/commands.d.ts +2 -0
  28. package/dist/types/components/authors-affiliations/AuthorsAndAffiliationsModals.d.ts +1 -1
  29. package/dist/types/components/cross-ref-check-modal/CrossRefWarningModal.d.ts +29 -0
  30. package/dist/types/components/cross-ref-check-modal/openModal.d.ts +19 -0
  31. package/dist/types/components/views/DeleteSupplementDialog.d.ts +2 -0
  32. package/dist/types/icons.d.ts +1 -0
  33. package/dist/types/index.d.ts +2 -0
  34. package/dist/types/lib/files.d.ts +2 -0
  35. package/dist/types/lib/supplements.d.ts +30 -0
  36. package/dist/types/versions.d.ts +1 -1
  37. package/package.json +2 -2
  38. package/src/commands.ts +42 -0
  39. package/src/components/authors-affiliations/AuthorsAndAffiliationsModals.tsx +2 -0
  40. package/src/components/cross-ref-check-modal/CrossRefWarningModal.tsx +223 -0
  41. package/src/components/cross-ref-check-modal/openModal.ts +50 -0
  42. package/src/components/views/DeleteSupplementDialog.tsx +88 -0
  43. package/src/icons.ts +2 -0
  44. package/src/index.ts +2 -0
  45. package/src/lib/files.ts +20 -6
  46. package/src/lib/supplements.ts +97 -0
  47. package/src/plugins/cross-references.ts +232 -6
  48. package/src/versions.ts +1 -1
  49. package/src/views/caption_title.ts +2 -0
  50. package/src/views/supplement.ts +27 -2
  51. package/src/views/supplements.ts +2 -1
  52. package/styles/Editor.css +13 -0
@@ -26,4 +26,4 @@ export interface AuthorsAndAffiliationsModalsProps {
26
26
  addNewAffiliation?: boolean;
27
27
  }
28
28
  export declare const AuthorsAndAffiliationsModals: React.FC<AuthorsAndAffiliationsModalsProps>;
29
- export declare const openAuthorsAndAffiliationsModals: (pos: number, view: ManuscriptEditorView | EditorView | undefined, initialModal: "authors" | "affiliations") => void;
29
+ export declare const openAuthorsAndAffiliationsModals: (pos: number, view: ManuscriptEditorView | EditorView | undefined, initialModal: "authors" | "affiliations") => HTMLDivElement | undefined;
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * © 2026 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 { ManuscriptNode } from '@manuscripts/transform';
17
+ import React from 'react';
18
+ import { ResolvedPos } from 'prosemirror-model';
19
+ export type XrefGroup = {
20
+ referenced: ManuscriptNode;
21
+ label: string;
22
+ xrefs: [ManuscriptNode, ResolvedPos][];
23
+ };
24
+ export declare const CrossRefWarningModal: React.FC<{
25
+ onClose: () => void;
26
+ xrefs: XrefGroup[];
27
+ onConfirm: () => void;
28
+ selectAndScrollTo: ($pos: ResolvedPos) => void;
29
+ }>;
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * © 2026 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 { ManuscriptEditorView } from '@manuscripts/transform';
17
+ import { ResolvedPos } from 'prosemirror-model';
18
+ import { XrefGroup } from './CrossRefWarningModal';
19
+ export declare const openCrossRefWarningModal: (view: ManuscriptEditorView, xrefGroups: XrefGroup[], onConfirm: () => void, onClose: () => void, selectAndScrollTo: ($pos: ResolvedPos) => void) => HTMLDivElement;
@@ -0,0 +1,2 @@
1
+ import { ManuscriptEditorView } from '@manuscripts/transform';
2
+ export declare const openDeleteSupplementDialog: (view: ManuscriptEditorView, pos: number) => void;
@@ -24,3 +24,4 @@ export declare const leadingHalfLeftIcon: string;
24
24
  export declare const fileMainDocumentIcon: string;
25
25
  export declare const tickIcon: string;
26
26
  export declare const ORCIDIcon: string;
27
+ export declare const webLinkIcon: string;
@@ -29,6 +29,8 @@ export * from './lib/capabilities';
29
29
  export * from './lib/navigation-utils';
30
30
  export * from './lib/comments';
31
31
  export * from './lib/files';
32
+ export * from './lib/supplements';
33
+ export { allowedHref } from './lib/url';
32
34
  export * from './lib/footnotes';
33
35
  export * from './lib/template';
34
36
  export * from './lib/doc';
@@ -1,4 +1,5 @@
1
1
  import { ManuscriptNode } from '@manuscripts/transform';
2
+ import { NodeWeblink } from './supplements';
2
3
  export type FileAttachment = {
3
4
  id: string;
4
5
  name: string;
@@ -18,6 +19,7 @@ export type ElementFiles = {
18
19
  export type ManuscriptFiles = {
19
20
  figures: ElementFiles[];
20
21
  supplements: NodeFile[];
22
+ weblinks: NodeWeblink[];
21
23
  attachments: NodeFile[];
22
24
  linkedFiles: NodeFile[];
23
25
  others: FileAttachment[];
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * © 2026 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 { ManuscriptEditorView, ManuscriptNode, SupplementNode } from '@manuscripts/transform';
17
+ export type NodeWeblink = {
18
+ node: SupplementNode;
19
+ pos: number;
20
+ };
21
+ export declare const getSupplementDisplayLabel: (node: SupplementNode, files: {
22
+ id: string;
23
+ name: string;
24
+ }[]) => string;
25
+ export declare const performDeleteSupplement: (view: ManuscriptEditorView, pos: number) => boolean;
26
+ export declare const deleteSupplementAtPos: (doc: ManuscriptNode, from: number, to: number) => {
27
+ from: number;
28
+ to: number;
29
+ deleteWholeSection: boolean;
30
+ };
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.13.19";
1
+ export declare const VERSION = "3.15.0";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "3.13.19",
4
+ "version": "3.15.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -41,7 +41,7 @@
41
41
  "@citation-js/plugin-pubmed": "0.3.0",
42
42
  "@citation-js/plugin-ris": "0.7.18",
43
43
  "@iarna/word-count": "1.1.2",
44
- "@manuscripts/style-guide": "3.6.6",
44
+ "@manuscripts/style-guide": "3.7.0",
45
45
  "@manuscripts/track-changes-plugin": "2.4.0",
46
46
  "@manuscripts/transform": "4.4.6",
47
47
  "@popperjs/core": "2.11.8",
package/src/commands.ts CHANGED
@@ -517,6 +517,48 @@ export const insertSupplement = (
517
517
  return true
518
518
  }
519
519
 
520
+ export const insertSupplementWeblink = (
521
+ url: string,
522
+ title: string,
523
+ view: ManuscriptEditorView
524
+ ) => {
525
+ const supplement = schema.nodes.supplement.createAndFill(
526
+ {
527
+ id: generateNodeID(schema.nodes.supplement),
528
+ href: url
529
+ },
530
+ createAndFillCaption()
531
+ ) as SupplementNode
532
+
533
+ const tr = view.state.tr
534
+ const { pos } = upsertSupplementsSection(tr, supplement)
535
+ tr.setSelection(NodeSelection.create(tr.doc, pos))
536
+ view.focus()
537
+ view.dispatch(tr.scrollIntoView())
538
+
539
+ return true
540
+ }
541
+
542
+ export const updateSupplementWeblink = (
543
+ pos: number,
544
+ url: string,
545
+ title: string,
546
+ view: ManuscriptEditorView
547
+ ) => {
548
+ const node = view.state.doc.nodeAt(pos)
549
+ if (!node) {
550
+ return false
551
+ }
552
+ const tr = view.state.tr
553
+ tr.setNodeMarkup(pos, undefined, {
554
+ ...node.attrs,
555
+ href: url,
556
+ title: title,
557
+ })
558
+ view.dispatch(tr)
559
+ return true
560
+ }
561
+
520
562
  export const insertAttachment = (
521
563
  file: FileAttachment,
522
564
  state: ManuscriptEditorState,
@@ -167,4 +167,6 @@ export const openAuthorsAndAffiliationsModals = (
167
167
  )
168
168
  view.focus()
169
169
  document.body.appendChild(dialog)
170
+ // @TODO refactor to allow cleaning it up
171
+ return dialog
170
172
  }
@@ -0,0 +1,223 @@
1
+ /*!
2
+ * © 2026 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 { ManuscriptNode } from '@manuscripts/transform'
18
+ import React, { useState } from 'react'
19
+
20
+ import {
21
+ AttentionOrangeIcon,
22
+ CloseButton,
23
+ ModalContainer,
24
+ ModalHeader,
25
+ PrimaryButton,
26
+ StyledModal,
27
+ TertiaryButton,
28
+ TextButton,
29
+ } from '@manuscripts/style-guide'
30
+ import { ResolvedPos } from 'prosemirror-model'
31
+ import { startCase } from 'lodash'
32
+ import styled from 'styled-components'
33
+
34
+ export type XrefGroup = {
35
+ referenced: ManuscriptNode
36
+ label: string
37
+ xrefs: [ManuscriptNode, ResolvedPos][]
38
+ }
39
+
40
+ export const CrossRefWarningModal: React.FC<{
41
+ onClose: () => void
42
+ xrefs: XrefGroup[]
43
+ onConfirm: () => void
44
+ selectAndScrollTo: ($pos: ResolvedPos) => void
45
+ }> = ({ onClose, xrefs, onConfirm, selectAndScrollTo }) => {
46
+ const [isOpen, setIsOpen] = useState(true)
47
+ const handleClose = () => {
48
+ setIsOpen(false)
49
+ onClose()
50
+ }
51
+
52
+ return (
53
+ <Modal
54
+ isOpen={isOpen}
55
+ onRequestClose={() => handleClose()}
56
+ shouldCloseOnOverlayClick={false}
57
+ hideOverlay={true}
58
+ >
59
+ <Container data-cy="cross-reference-warning-modal">
60
+ <ModalHeader>
61
+ <CloseButton
62
+ onClick={() => handleClose()}
63
+ data-cy="modal-close-button"
64
+ />
65
+ </ModalHeader>
66
+ <Body>
67
+ <Title>
68
+ <AttentionOrangeIcon width={24} height={22} /> Delete referenced
69
+ content?
70
+ </Title>
71
+ <p>You are deleting content referenced elsewhere in the document:</p>
72
+ <ScrolableItems>
73
+ {xrefs.map((group, i) => (
74
+ <XrefGroupDisplay
75
+ key={i}
76
+ group={group}
77
+ selectAndScrollTo={selectAndScrollTo}
78
+ />
79
+ ))}
80
+ </ScrolableItems>
81
+ <Actions>
82
+ <TertiaryButton type="button" onClick={() => handleClose()}>
83
+ Cancel
84
+ </TertiaryButton>
85
+ <PrimaryButton
86
+ $danger={true}
87
+ type="button"
88
+ onClick={() => {
89
+ onConfirm()
90
+ setIsOpen(false)
91
+ }}
92
+ >
93
+ Delete & remove citation
94
+ </PrimaryButton>
95
+ </Actions>
96
+ </Body>
97
+ </Container>
98
+ </Modal>
99
+ )
100
+ }
101
+
102
+ const XrefGroupDisplay: React.FC<{
103
+ group: XrefGroup
104
+ selectAndScrollTo: ($pos: ResolvedPos) => void
105
+ }> = ({ group, selectAndScrollTo }) => {
106
+ return (
107
+ <div>
108
+ <h3>{group.label}</h3>
109
+ <ReferencesList>
110
+ {group.xrefs.map(([, pos], i) => {
111
+ return (
112
+ <li key={i}>
113
+ <TextButton onClick={() => selectAndScrollTo(pos)}>
114
+ {`${startCase(pos.parent.type.name)} - ${pos.parent.textContent}`}
115
+ </TextButton>
116
+ </li>
117
+ )
118
+ })}
119
+ </ReferencesList>
120
+ </div>
121
+ )
122
+ }
123
+
124
+ const Container = styled(ModalContainer)`
125
+ position: absolute;
126
+ top: 1rem;
127
+ left: 50%;
128
+ right: 0;
129
+ max-height: calc(50vh - 2rem);
130
+ min-height: 280px;
131
+ transform: translate(-50%, 0);
132
+ max-width: 480px;
133
+ transition:
134
+ top 0.2s,
135
+ transform 0.2s;
136
+ `
137
+
138
+ // since we need to scroll inside the editor when this dialog is active, we can't use dialog.showModal()
139
+ // so we recreate the appearance using classic position:fixed/after approach.
140
+ // While showModal doesn't block scrolling - it doesn't allow to focus on the editor and that kills the scrollIntoView
141
+ const Modal = styled(StyledModal)`
142
+ position: fixed;
143
+ top: 0;
144
+ left: 0;
145
+ width: 100%;
146
+ height: 100%;
147
+ z-index: 1100;
148
+ color: #6e6e6e;
149
+ margin: auto;
150
+
151
+ &.modal-bottom ${Container} {
152
+ top: calc(100% - 2rem);
153
+ transform: translate(-50%, -100%);
154
+ }
155
+
156
+ &:after {
157
+ content: '';
158
+ display: block;
159
+ position: fixed;
160
+ z-index: -1;
161
+ left: 0;
162
+ top: 0;
163
+ right: 0;
164
+ bottom: 0;
165
+ background: rgba(0, 0, 0, 0.2);
166
+ }
167
+ h3 {
168
+ font-size: 16px;
169
+ margin: 0.5em 0;
170
+ }
171
+ p {
172
+ margin: 0.5em 0;
173
+ }
174
+ `
175
+
176
+ const Body = styled.div`
177
+ margin: 1.5rem;
178
+ display: flex;
179
+ flex-flow: column;
180
+ `
181
+
182
+ const Title = styled.h2`
183
+ font-size: 18px;
184
+ font-weight: 700;
185
+ line-height: 1.5;
186
+ margin: 0;
187
+ color: #353535;
188
+ svg {
189
+ vertical-align: text-top;
190
+ }
191
+ `
192
+
193
+ const ReferencesList = styled.ul`
194
+ padding: 8px;
195
+ margin-left: 0;
196
+ list-style: none;
197
+ background: #f2f2f2;
198
+ border: 1px solid #e2e2e2;
199
+ border-radius: 3px;
200
+
201
+ ${TextButton} {
202
+ margin-left: 0;
203
+ text-decoration: underline;
204
+ &:hover {
205
+ text-decoration: none;
206
+ }
207
+ display: block;
208
+ max-width: 100%;
209
+ overflow: hidden;
210
+ color: #353535;
211
+ text-overflow: ellipsis;
212
+ }
213
+ `
214
+
215
+ const Actions = styled.footer`
216
+ text-align: right;
217
+ padding-top: 1rem;
218
+ `
219
+ const ScrolableItems = styled.div`
220
+ max-height: 16vh;
221
+ min-height: 100px;
222
+ overflow-y: auto;
223
+ `
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * © 2026 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 { ManuscriptEditorView } from '@manuscripts/transform'
18
+ import { ResolvedPos } from 'prosemirror-model'
19
+
20
+ import { getEditorProps } from '../../plugins/editor-props'
21
+ import ReactSubView from '../../views/ReactSubView'
22
+ import { CrossRefWarningModal, XrefGroup } from './CrossRefWarningModal'
23
+
24
+ export const openCrossRefWarningModal = (
25
+ view: ManuscriptEditorView,
26
+ xrefGroups: XrefGroup[],
27
+ onConfirm: () => void,
28
+ onClose: () => void,
29
+ selectAndScrollTo: ($pos: ResolvedPos) => void
30
+ ): HTMLDivElement => {
31
+ const { state } = view
32
+ const props = getEditorProps(state)
33
+ const componentProps = {
34
+ xrefs: xrefGroups,
35
+ onConfirm,
36
+ onClose,
37
+ selectAndScrollTo,
38
+ }
39
+
40
+ const dialog = ReactSubView(
41
+ props,
42
+ CrossRefWarningModal,
43
+ componentProps,
44
+ state.doc,
45
+ () => 0,
46
+ view
47
+ )
48
+ document.body.appendChild(dialog)
49
+ return dialog
50
+ }
@@ -0,0 +1,88 @@
1
+ /*!
2
+ * © 2026 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 {
17
+ Category,
18
+ Dialog,
19
+ } from '@manuscripts/style-guide'
20
+ import { ManuscriptEditorView, SupplementNode } from '@manuscripts/transform'
21
+ import React, { useState } from 'react'
22
+
23
+ import {
24
+ getSupplementDisplayLabel,
25
+ performDeleteSupplement,
26
+ } from '../../lib/supplements'
27
+ import { getEditorProps } from '../../plugins/editor-props'
28
+ import ReactSubView from '../../views/ReactSubView'
29
+
30
+ const DeleteSupplementDialog: React.FC<{
31
+ label: string
32
+ onDelete: () => void
33
+ }> = ({ label, onDelete }) => {
34
+ const [isOpen, setOpen] = useState(true)
35
+
36
+ return (
37
+ <Dialog
38
+ isOpen={isOpen}
39
+ category={Category.confirmation}
40
+ header='Delete supplement'
41
+ message='Are you sure you want to delete &ldquo;{label}&rdquo;?'
42
+ actions={{
43
+ primary: {
44
+ action: () => {
45
+ onDelete()
46
+ setOpen(false)
47
+ },
48
+ title: 'Delete',
49
+ },
50
+ secondary: {
51
+ action: () => setOpen(false),
52
+ title: 'Cancel',
53
+ },
54
+ }}
55
+ />
56
+ )
57
+ }
58
+
59
+ export const openDeleteSupplementDialog = (
60
+ view: ManuscriptEditorView,
61
+ pos: number
62
+ ) => {
63
+ const node = view.state.doc.nodeAt(pos)
64
+ if (!node || node.type.name !== 'supplement') {
65
+ return
66
+ }
67
+
68
+ const { state } = view
69
+ const props = getEditorProps(state)
70
+ const label = getSupplementDisplayLabel(
71
+ node as SupplementNode,
72
+ props.getFiles()
73
+ )
74
+
75
+ const dialog = ReactSubView(
76
+ props,
77
+ DeleteSupplementDialog,
78
+ {
79
+ label,
80
+ onDelete: () => performDeleteSupplement(view, pos),
81
+ },
82
+ state.doc,
83
+ () => 0,
84
+ view
85
+ )
86
+
87
+ document.body.appendChild(dialog)
88
+ }
package/src/icons.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  SectionCategoryIcon,
41
41
  TickIcon,
42
42
  TranslateIcon,
43
+ WebLinkIcon,
43
44
  } from '@manuscripts/style-guide'
44
45
  import React, { createElement } from 'react'
45
46
  import { renderToStaticMarkup } from 'react-dom/server'
@@ -72,3 +73,4 @@ export const leadingHalfLeftIcon = renderIcon(LeadingHalfLeftIcon)
72
73
  export const fileMainDocumentIcon = renderIcon(FileMainDocumentIcon)
73
74
  export const tickIcon = renderIcon(TickIcon)
74
75
  export const ORCIDIcon = renderIcon(ORCID)
76
+ export const webLinkIcon = renderIcon(WebLinkIcon)
package/src/index.ts CHANGED
@@ -33,6 +33,8 @@ export * from './lib/capabilities'
33
33
  export * from './lib/navigation-utils'
34
34
  export * from './lib/comments'
35
35
  export * from './lib/files'
36
+ export * from './lib/supplements'
37
+ export { allowedHref } from './lib/url'
36
38
  export * from './lib/footnotes'
37
39
  export * from './lib/template'
38
40
  export * from './lib/doc'
package/src/lib/files.ts CHANGED
@@ -13,11 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ManuscriptNode, schema } from '@manuscripts/transform'
16
+ import { ManuscriptNode, schema, SupplementNode } from '@manuscripts/transform'
17
17
  import { findChildrenByType } from 'prosemirror-utils'
18
18
 
19
19
  import { isHidden } from './track-changes-utils'
20
20
 
21
+ import { NodeWeblink } from './supplements'
22
+ import { allowedHref } from './url'
23
+
21
24
  export type FileAttachment = {
22
25
  id: string
23
26
  name: string
@@ -40,6 +43,7 @@ export type ElementFiles = {
40
43
  export type ManuscriptFiles = {
41
44
  figures: ElementFiles[]
42
45
  supplements: NodeFile[]
46
+ weblinks: NodeWeblink[]
43
47
  attachments: NodeFile[]
44
48
  linkedFiles: NodeFile[]
45
49
  others: FileAttachment[]
@@ -95,6 +99,7 @@ export const groupFiles = (
95
99
  const fileMap = new Map(files.map((f) => [f.id, f]))
96
100
  const figures: ElementFiles[] = []
97
101
  const supplements: NodeFile[] = []
102
+ const weblinks: NodeWeblink[] = []
98
103
  const linkedFiles: NodeFile[] = []
99
104
  const attachments: NodeFile[] = []
100
105
 
@@ -161,11 +166,19 @@ export const groupFiles = (
161
166
  }
162
167
  }
163
168
  if (node.type === schema.nodes.supplement) {
164
- supplements.push({
165
- node,
166
- pos,
167
- file: getFile(node.attrs.href),
168
- })
169
+ const href = node.attrs.href as string
170
+ if (allowedHref(href)) {
171
+ weblinks.push({
172
+ node: node as SupplementNode,
173
+ pos,
174
+ })
175
+ } else {
176
+ supplements.push({
177
+ node,
178
+ pos,
179
+ file: getFile(href),
180
+ })
181
+ }
169
182
  }
170
183
  if (node.type === schema.nodes.attachment) {
171
184
  attachments.push({
@@ -179,6 +192,7 @@ export const groupFiles = (
179
192
  return {
180
193
  figures,
181
194
  supplements,
195
+ weblinks,
182
196
  attachments,
183
197
  linkedFiles,
184
198
  others: [...fileMap.values()],