@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.
Files changed (29) hide show
  1. package/dist/cjs/components/references/CitationEditor.js +8 -34
  2. package/dist/cjs/components/views/FigureDropdown.js +30 -39
  3. package/dist/cjs/components/views/FootnotesSelector.js +4 -5
  4. package/dist/cjs/components/views/LinkForm.js +5 -4
  5. package/dist/cjs/components/views/TableCellContextMenu.js +15 -15
  6. package/dist/cjs/versions.js +1 -1
  7. package/dist/cjs/views/ReactSubView.js +4 -2
  8. package/dist/cjs/views/cross_reference.js +4 -9
  9. package/dist/cjs/views/cross_reference_editable.js +1 -15
  10. package/dist/es/components/references/CitationEditor.js +9 -35
  11. package/dist/es/components/views/FigureDropdown.js +31 -40
  12. package/dist/es/components/views/FootnotesSelector.js +5 -6
  13. package/dist/es/components/views/LinkForm.js +6 -5
  14. package/dist/es/components/views/TableCellContextMenu.js +16 -16
  15. package/dist/es/versions.js +1 -1
  16. package/dist/es/views/ReactSubView.js +4 -2
  17. package/dist/es/views/cross_reference.js +4 -9
  18. package/dist/es/views/cross_reference_editable.js +1 -15
  19. package/dist/types/versions.d.ts +1 -1
  20. package/package.json +3 -3
  21. package/src/components/references/CitationEditor.tsx +14 -42
  22. package/src/components/views/FigureDropdown.tsx +48 -38
  23. package/src/components/views/FootnotesSelector.tsx +8 -9
  24. package/src/components/views/LinkForm.tsx +10 -7
  25. package/src/components/views/TableCellContextMenu.tsx +24 -10
  26. package/src/versions.ts +1 -1
  27. package/src/views/ReactSubView.tsx +13 -10
  28. package/src/views/cross_reference.ts +4 -13
  29. 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 onClick={() => runCommand(addRows('bottom'))}>
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 onClick={() => runCommand(mergeCells, true)}>
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 onClick={() => runCommand(splitCell, true)}>
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(IconTextButton)`
217
- padding: 8px 16px;
218
- justify-content: flex-start;
219
-
220
- &:hover {
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
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.18.0';
2
+ export const VERSION = '3.18.2';
3
3
  export const MATHJAX_VERSION = '3.2.2';
@@ -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
- <ThemeProvider theme={props.theme}>
96
- <Component
97
- nodeAttrs={node.attrs}
98
- setNodeAttrs={setNodeAttrs}
99
- viewProps={{ node, view, getPos }}
100
- container={container}
101
- {...props}
102
- {...componentProps}
103
- />
104
- </ThemeProvider>
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
- let derivedLabel = target?.label || ''
55
- if (target?.type === schema.nodes.supplement.name && target.href) {
56
- const found = findNodeByID(this.view.state.doc, target.id)
57
- if (found) {
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, SupplementNode, Target } from '@manuscripts/transform'
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
- // Prefer caption title, then URL / file name for supplements and weblinks.
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
  }