@manuscripts/body-editor 3.18.0 → 3.18.2
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/components/references/CitationEditor.js +8 -34
- package/dist/cjs/components/views/FigureDropdown.js +30 -39
- package/dist/cjs/components/views/FootnotesSelector.js +4 -5
- package/dist/cjs/components/views/LinkForm.js +5 -4
- package/dist/cjs/components/views/TableCellContextMenu.js +15 -15
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/ReactSubView.js +4 -2
- package/dist/cjs/views/cross_reference.js +4 -9
- package/dist/cjs/views/cross_reference_editable.js +1 -15
- package/dist/es/components/references/CitationEditor.js +9 -35
- package/dist/es/components/views/FigureDropdown.js +31 -40
- package/dist/es/components/views/FootnotesSelector.js +5 -6
- package/dist/es/components/views/LinkForm.js +6 -5
- package/dist/es/components/views/TableCellContextMenu.js +16 -16
- package/dist/es/versions.js +1 -1
- package/dist/es/views/ReactSubView.js +4 -2
- package/dist/es/views/cross_reference.js +4 -9
- package/dist/es/views/cross_reference_editable.js +1 -15
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/references/CitationEditor.tsx +14 -42
- package/src/components/views/FigureDropdown.tsx +48 -38
- package/src/components/views/FootnotesSelector.tsx +8 -9
- package/src/components/views/LinkForm.tsx +10 -7
- package/src/components/views/TableCellContextMenu.tsx +24 -10
- package/src/versions.ts +1 -1
- package/src/views/ReactSubView.tsx +13 -10
- package/src/views/cross_reference.ts +4 -13
- package/src/views/cross_reference_editable.ts +2 -16
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
Category,
|
|
18
18
|
DeleteIcon,
|
|
19
19
|
Dialog,
|
|
20
|
-
IconTextButton,
|
|
21
20
|
PlusIcon,
|
|
22
21
|
} from '@manuscripts/style-guide'
|
|
22
|
+
import { Button } from '@manuscripts/style-guide/mui'
|
|
23
23
|
import { skipTracking } from '@manuscripts/track-changes-plugin'
|
|
24
24
|
import { schema } from '@manuscripts/transform'
|
|
25
25
|
import { Command, EditorState } from 'prosemirror-state'
|
|
@@ -125,15 +125,20 @@ export const ContextMenu: React.FC<{
|
|
|
125
125
|
return (
|
|
126
126
|
<MenuDropdownList className={'table-ctx'}>
|
|
127
127
|
<ActionButton
|
|
128
|
+
variant="tertiary"
|
|
128
129
|
disabled={isHeaderCellSelected(view.state)}
|
|
129
130
|
onClick={() => runCommand(addRows('top'))}
|
|
130
131
|
>
|
|
131
132
|
<PlusIcon /> Insert {rows} above
|
|
132
133
|
</ActionButton>
|
|
133
|
-
<ActionButton
|
|
134
|
+
<ActionButton
|
|
135
|
+
variant="tertiary"
|
|
136
|
+
onClick={() => runCommand(addRows('bottom'))}
|
|
137
|
+
>
|
|
134
138
|
<PlusIcon /> Insert {rows} below
|
|
135
139
|
</ActionButton>
|
|
136
140
|
<ActionButton
|
|
141
|
+
variant="tertiary"
|
|
137
142
|
onClick={() =>
|
|
138
143
|
showWarningForTCPlugin(setColumnAction, () => addColumns('left'))
|
|
139
144
|
}
|
|
@@ -141,6 +146,7 @@ export const ContextMenu: React.FC<{
|
|
|
141
146
|
<PlusIcon /> Insert {columns} to the left
|
|
142
147
|
</ActionButton>
|
|
143
148
|
<ActionButton
|
|
149
|
+
variant="tertiary"
|
|
144
150
|
onClick={() =>
|
|
145
151
|
showWarningForTCPlugin(setColumnAction, () => addColumns('right'))
|
|
146
152
|
}
|
|
@@ -149,6 +155,7 @@ export const ContextMenu: React.FC<{
|
|
|
149
155
|
</ActionButton>
|
|
150
156
|
<Separator />
|
|
151
157
|
<ActionButton
|
|
158
|
+
variant="tertiary"
|
|
152
159
|
disabled={count.rows !== 1}
|
|
153
160
|
onClick={() => runCommand(addHeaderRow(headerPosition))}
|
|
154
161
|
>
|
|
@@ -156,6 +163,7 @@ export const ContextMenu: React.FC<{
|
|
|
156
163
|
</ActionButton>
|
|
157
164
|
<Separator />
|
|
158
165
|
<ActionButton
|
|
166
|
+
variant="tertiary"
|
|
159
167
|
onClick={() =>
|
|
160
168
|
showWarningForTCPlugin(setRowDeleteAction, () => deleteRow)
|
|
161
169
|
}
|
|
@@ -164,6 +172,7 @@ export const ContextMenu: React.FC<{
|
|
|
164
172
|
{isHeaderCellSelected(view.state) ? ' header ' : ''} {rows}
|
|
165
173
|
</ActionButton>
|
|
166
174
|
<ActionButton
|
|
175
|
+
variant="tertiary"
|
|
167
176
|
onClick={() =>
|
|
168
177
|
showWarningForTCPlugin(setColumnAction, () => deleteColumn)
|
|
169
178
|
}
|
|
@@ -172,12 +181,18 @@ export const ContextMenu: React.FC<{
|
|
|
172
181
|
</ActionButton>
|
|
173
182
|
{(isCellSelectionMerged || isCellSelectionSplittable) && <Separator />}
|
|
174
183
|
{isCellSelectionMerged && (
|
|
175
|
-
<ActionButton
|
|
184
|
+
<ActionButton
|
|
185
|
+
variant="tertiary"
|
|
186
|
+
onClick={() => runCommand(mergeCells, true)}
|
|
187
|
+
>
|
|
176
188
|
Merge cells
|
|
177
189
|
</ActionButton>
|
|
178
190
|
)}
|
|
179
191
|
{isCellSelectionSplittable && (
|
|
180
|
-
<ActionButton
|
|
192
|
+
<ActionButton
|
|
193
|
+
variant="tertiary"
|
|
194
|
+
onClick={() => runCommand(splitCell, true)}
|
|
195
|
+
>
|
|
181
196
|
Split cells
|
|
182
197
|
</ActionButton>
|
|
183
198
|
)}
|
|
@@ -213,12 +228,11 @@ const MenuDropdownList = styled.div`
|
|
|
213
228
|
flex-direction: column;
|
|
214
229
|
`
|
|
215
230
|
|
|
216
|
-
const ActionButton = styled(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
background: #f2fbfc;
|
|
231
|
+
const ActionButton = styled(Button)`
|
|
232
|
+
&& {
|
|
233
|
+
padding: 8px 16px;
|
|
234
|
+
justify-content: flex-start;
|
|
235
|
+
width: 100%;
|
|
222
236
|
}
|
|
223
237
|
&:disabled {
|
|
224
238
|
color: #353535;
|
package/src/versions.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { MuiThemeProvider, muiTheme } from '@manuscripts/style-guide/mui'
|
|
17
18
|
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform'
|
|
18
19
|
import React from 'react'
|
|
19
20
|
import { flushSync } from 'react-dom'
|
|
@@ -92,16 +93,18 @@ function createView<T extends Trackable<ManuscriptNode>>(
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
return (
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
<MuiThemeProvider theme={muiTheme}>
|
|
97
|
+
<ThemeProvider theme={props.theme}>
|
|
98
|
+
<Component
|
|
99
|
+
nodeAttrs={node.attrs}
|
|
100
|
+
setNodeAttrs={setNodeAttrs}
|
|
101
|
+
viewProps={{ node, view, getPos }}
|
|
102
|
+
container={container}
|
|
103
|
+
{...props}
|
|
104
|
+
{...componentProps}
|
|
105
|
+
/>
|
|
106
|
+
</ThemeProvider>
|
|
107
|
+
</MuiThemeProvider>
|
|
105
108
|
)
|
|
106
109
|
}
|
|
107
110
|
return Wrapped
|
|
@@ -18,13 +18,10 @@ import {
|
|
|
18
18
|
CrossReferenceNode,
|
|
19
19
|
ManuscriptNodeView,
|
|
20
20
|
schema,
|
|
21
|
-
SupplementNode,
|
|
22
21
|
Target,
|
|
23
22
|
} from '@manuscripts/transform'
|
|
24
23
|
|
|
25
|
-
import { findNodeByID } from '../lib/doc'
|
|
26
24
|
import { handleEnterKey } from '../lib/navigation-utils'
|
|
27
|
-
import { getSupplementDisplayLabel } from '../lib/supplements'
|
|
28
25
|
import { objectsKey } from '../plugins/objects'
|
|
29
26
|
import { Trackable } from '../types'
|
|
30
27
|
import { BaseNodeView } from './base_node_view'
|
|
@@ -51,16 +48,10 @@ export class CrossReferenceView
|
|
|
51
48
|
const attrs = this.node.attrs
|
|
52
49
|
const target = attrs.rids.length ? targets.get(attrs.rids[0]) : undefined
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
derivedLabel = getSupplementDisplayLabel(
|
|
59
|
-
found.node as SupplementNode,
|
|
60
|
-
this.props.getFiles()
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
51
|
+
const isSupplement = target?.type === schema.nodes.supplement.name
|
|
52
|
+
const derivedLabel = isSupplement
|
|
53
|
+
? target?.caption || target?.label || ''
|
|
54
|
+
: target?.label || ''
|
|
64
55
|
|
|
65
56
|
this.dom.textContent = attrs.label || derivedLabel
|
|
66
57
|
this.dom.addEventListener('click', this.handleClick)
|
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
import { ContextMenu, ContextMenuProps } from '@manuscripts/style-guide'
|
|
18
18
|
import { isDeleted, skipTracking } from '@manuscripts/track-changes-plugin'
|
|
19
|
-
import { schema,
|
|
19
|
+
import { schema, Target } from '@manuscripts/transform'
|
|
20
20
|
import { TextSelection } from 'prosemirror-state'
|
|
21
21
|
|
|
22
22
|
import { CrossReferenceItems } from '../components/views/CrossReferenceItems'
|
|
23
23
|
import { handleComment } from '../lib/comments'
|
|
24
|
-
import { findNodeByID } from '../lib/doc'
|
|
25
|
-
import { getSupplementDisplayLabel } from '../lib/supplements'
|
|
26
24
|
import { objectsKey } from '../plugins/objects'
|
|
27
25
|
import { createEditableNodeView } from './creators'
|
|
28
26
|
import { CrossReferenceView } from './cross_reference'
|
|
@@ -81,25 +79,13 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
81
79
|
|
|
82
80
|
public getTargets = () => {
|
|
83
81
|
const targets = objectsKey.getState(this.view.state) as Map<string, Target>
|
|
84
|
-
const files = this.props.getFiles()
|
|
85
|
-
const fileMap = new Map(files.map((f) => [f.id, f.name]))
|
|
86
82
|
const excludedTypes = [schema.nodes.image_element.name]
|
|
87
|
-
const supplement = schema.nodes.supplement.name
|
|
88
83
|
|
|
89
84
|
return Array.from(targets.values()).reduce<Target[]>((acc, t) => {
|
|
90
85
|
if (excludedTypes.includes(t.type)) {
|
|
91
86
|
return acc
|
|
92
87
|
}
|
|
93
|
-
|
|
94
|
-
if (t.type === supplement && t.href) {
|
|
95
|
-
const found = findNodeByID(this.view.state.doc, t.id)
|
|
96
|
-
const label = found
|
|
97
|
-
? getSupplementDisplayLabel(found.node as SupplementNode, files)
|
|
98
|
-
: (fileMap.get(t.href) ?? t.href)
|
|
99
|
-
acc.push({ ...t, label, caption: '' })
|
|
100
|
-
} else {
|
|
101
|
-
acc.push(t)
|
|
102
|
-
}
|
|
88
|
+
acc.push(t)
|
|
103
89
|
return acc
|
|
104
90
|
}, [])
|
|
105
91
|
}
|