@manuscripts/body-editor 3.17.5 → 3.18.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 (49) hide show
  1. package/dist/cjs/components/references/ReferenceLine.js +14 -1
  2. package/dist/cjs/components/references/ReferencesModal.js +155 -131
  3. package/dist/cjs/icons.js +2 -2
  4. package/dist/cjs/lib/normalize.js +31 -1
  5. package/dist/cjs/lib/paste.js +0 -1
  6. package/dist/cjs/plugins/add-subtitle.js +1 -1
  7. package/dist/cjs/plugins/bibliography.js +7 -1
  8. package/dist/cjs/plugins/translations.js +1 -1
  9. package/dist/cjs/versions.js +1 -1
  10. package/dist/cjs/views/bibliography_element.js +44 -2
  11. package/dist/cjs/views/cross_reference.js +4 -9
  12. package/dist/cjs/views/cross_reference_editable.js +1 -15
  13. package/dist/cjs/views/figure_element.js +1 -1
  14. package/dist/cjs/views/headshot_grid.js +1 -1
  15. package/dist/es/components/references/ReferenceLine.js +14 -1
  16. package/dist/es/components/references/ReferencesModal.js +156 -132
  17. package/dist/es/icons.js +1 -1
  18. package/dist/es/lib/normalize.js +30 -1
  19. package/dist/es/lib/paste.js +0 -1
  20. package/dist/es/plugins/add-subtitle.js +2 -2
  21. package/dist/es/plugins/bibliography.js +7 -1
  22. package/dist/es/plugins/translations.js +2 -2
  23. package/dist/es/versions.js +1 -1
  24. package/dist/es/views/bibliography_element.js +45 -3
  25. package/dist/es/views/cross_reference.js +4 -9
  26. package/dist/es/views/cross_reference_editable.js +1 -15
  27. package/dist/es/views/figure_element.js +2 -2
  28. package/dist/es/views/headshot_grid.js +2 -2
  29. package/dist/types/components/references/ReferenceLine.d.ts +1 -0
  30. package/dist/types/icons.d.ts +1 -1
  31. package/dist/types/lib/normalize.d.ts +30 -1
  32. package/dist/types/versions.d.ts +1 -1
  33. package/dist/types/views/bibliography_element.d.ts +5 -1
  34. package/package.json +2 -2
  35. package/src/components/references/ReferenceLine.tsx +16 -1
  36. package/src/components/references/ReferencesModal.tsx +178 -140
  37. package/src/icons.ts +1 -1
  38. package/src/lib/normalize.ts +36 -1
  39. package/src/lib/paste.ts +0 -1
  40. package/src/plugins/add-subtitle.ts +2 -2
  41. package/src/plugins/bibliography.ts +10 -3
  42. package/src/plugins/translations.ts +2 -2
  43. package/src/versions.ts +1 -1
  44. package/src/views/bibliography_element.ts +61 -4
  45. package/src/views/cross_reference.ts +4 -13
  46. package/src/views/cross_reference_editable.ts +2 -16
  47. package/src/views/figure_element.ts +2 -2
  48. package/src/views/headshot_grid.ts +2 -2
  49. package/styles/AdvancedEditor.css +29 -2
@@ -26,7 +26,7 @@ import { Decoration, DecorationSet } from 'prosemirror-view'
26
26
 
27
27
  import { insertTransAbstract, insertTransGraphicalAbstract } from '../commands'
28
28
  import { EditorProps } from '../configs/ManuscriptsEditor'
29
- import { addAuthorIcon, translateIcon } from '../icons'
29
+ import { addIcon, translateIcon } from '../icons'
30
30
  import { getLanguage, getLanguageLabel } from '../lib/languages'
31
31
  import {
32
32
  createKeyboardInteraction,
@@ -132,7 +132,7 @@ export default (props: EditorProps) =>
132
132
  $span.tabIndex = 0
133
133
  $span.className = 'add-trans-abstract'
134
134
  $span.title = 'Add translation'
135
- $span.innerHTML = `${addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`
135
+ $span.innerHTML = `${addIcon} <span class="add-trans-abstract-text">Add translation</span>`
136
136
 
137
137
  const handleActivate = (event: Event) => {
138
138
  event.preventDefault()
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.17.5';
2
+ export const VERSION = '3.18.1';
3
3
  export const MATHJAX_VERSION = '3.2.2';
@@ -19,6 +19,7 @@ import {
19
19
  BibliographyElementNode,
20
20
  BibliographyItemAttrs,
21
21
  BibliographyItemNode,
22
+ isCitationNode,
22
23
  } from '@manuscripts/transform'
23
24
  import { NodeSelection } from 'prosemirror-state'
24
25
 
@@ -32,7 +33,10 @@ import { findNodeByID } from '../lib/doc'
32
33
  import { sanitize } from '../lib/dompurify'
33
34
 
34
35
  import { deleteNode, findChildByID, saveBibliographyItem } from '../lib/view'
35
- import { getBibliographyPluginState } from '../plugins/bibliography'
36
+ import {
37
+ getBibliographyPluginState,
38
+ PluginState,
39
+ } from '../plugins/bibliography'
36
40
  import { commentsKey, setCommentSelection } from '../plugins/comments'
37
41
  import { selectedSuggestionKey } from '../plugins/selected-suggestion'
38
42
  import { Trackable } from '../types'
@@ -43,6 +47,7 @@ import {
43
47
  addTrackChangesAttributes,
44
48
  addTrackChangesClassNames,
45
49
  } from '@manuscripts/track-changes-plugin'
50
+ import { addIcon } from '../icons'
46
51
 
47
52
  export class BibliographyElementBlockView extends BlockView<
48
53
  Trackable<BibliographyElementNode>
@@ -52,7 +57,7 @@ export class BibliographyElementBlockView extends BlockView<
52
57
  private contextMenu: HTMLDivElement
53
58
  private version: string
54
59
 
55
- public showPopper(id: string) {
60
+ public showPopper(id?: string) {
56
61
  const bib = getBibliographyPluginState(this.view.state)
57
62
  if (!bib) {
58
63
  return
@@ -61,7 +66,7 @@ export class BibliographyElementBlockView extends BlockView<
61
66
  const componentProps: ReferencesEditorProps = {
62
67
  items: Array.from(bib.bibliographyItems.values()),
63
68
  citationCounts: bib.citationCounts,
64
- item: bib.bibliographyItems.get(id),
69
+ item: id ? bib.bibliographyItems.get(id) : undefined,
65
70
  onSave: this.handleSave,
66
71
  onDelete: this.handleDelete,
67
72
  }
@@ -187,7 +192,20 @@ export class BibliographyElementBlockView extends BlockView<
187
192
  }
188
193
  this.version = bib.version
189
194
 
195
+ this.renderBibs(bib)
196
+ this.createInlineModalButton()
197
+ this.updateSelections()
198
+ }
199
+
200
+ renderBibs(bib: PluginState) {
190
201
  const nodes: Map<string, BibliographyItemNode> = new Map()
202
+ const rids: string[] = []
203
+
204
+ this.view.state.doc.descendants((node) => {
205
+ if (isCitationNode(node)) {
206
+ rids.push(...node.attrs.rids)
207
+ }
208
+ })
191
209
 
192
210
  this.node.descendants((node) => {
193
211
  const id = node.attrs.id
@@ -239,6 +257,14 @@ export class BibliographyElementBlockView extends BlockView<
239
257
  const comment = createCommentMarker('div', id)
240
258
  element.prepend(comment)
241
259
 
260
+ if (!rids.includes(id)) {
261
+ // node is uncited if not reffed anywhere
262
+ const uncitedMarker = document.createElement('span')
263
+ uncitedMarker.innerHTML = 'UNCITED'
264
+ uncitedMarker.classList.add('uncited-reference-marker')
265
+ element.prepend(uncitedMarker)
266
+ }
267
+
242
268
  addTrackChangesAttributes(node.attrs, element)
243
269
  addTrackChangesClassNames(node.attrs, element)
244
270
 
@@ -257,7 +283,38 @@ export class BibliographyElementBlockView extends BlockView<
257
283
  } else {
258
284
  this.container.appendChild(wrapper)
259
285
  }
260
- this.updateSelections()
286
+ }
287
+
288
+ inlineModalButton: HTMLSpanElement | null
289
+ createInlineModalButton() {
290
+ const can = this.props.getCapabilities()
291
+
292
+ if (!can.editCitationsAndRefs) {
293
+ if (this.inlineModalButton) {
294
+ this.inlineModalButton.remove()
295
+ this.inlineModalButton = null
296
+ }
297
+ return
298
+ }
299
+
300
+ if (this.inlineModalButton) {
301
+ return
302
+ }
303
+
304
+ const $span = document.createElement('span')
305
+ $span.tabIndex = 0
306
+ $span.className = 'add-new-reference add-trans-abstract'
307
+ $span.title = 'Add New Reference'
308
+ $span.innerHTML = `${addIcon} <span type="button" tabindex="0" class="add-new-reference-text">Add new reference</span>`
309
+ $span.addEventListener('click', (e) => {
310
+ this.showPopper()
311
+ })
312
+ $span.addEventListener(
313
+ 'keydown',
314
+ handleEnterKey(() => this.showPopper())
315
+ )
316
+ this.inlineModalButton = $span
317
+ this.dom.appendChild($span)
261
318
  }
262
319
 
263
320
  public createElement = () => {
@@ -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
  }
@@ -18,7 +18,7 @@ import { schema } from '@manuscripts/transform'
18
18
  import { Node } from 'prosemirror-model'
19
19
  import { TextSelection } from 'prosemirror-state'
20
20
 
21
- import { addAuthorIcon } from '../icons'
21
+ import { addIcon } from '../icons'
22
22
  import { handleEnterKey } from '../lib/navigation-utils'
23
23
  import { createNodeView } from './creators'
24
24
  import { FigureEditableView } from './figure_editable'
@@ -59,7 +59,7 @@ export class FigureElementView extends ImageElementView {
59
59
  if (this.props.getCapabilities()?.editArticle) {
60
60
  this.addFigureBtn = Object.assign(document.createElement('button'), {
61
61
  className: 'add-button',
62
- innerHTML: addAuthorIcon,
62
+ innerHTML: addIcon,
63
63
  title: 'Add figure',
64
64
  })
65
65
  this.addFigureBtn.addEventListener('click', () => this.addFigure())
@@ -21,7 +21,7 @@ import {
21
21
  } from '@manuscripts/transform'
22
22
  import { TextSelection } from 'prosemirror-state'
23
23
 
24
- import { addAuthorIcon } from '../icons'
24
+ import { addIcon } from '../icons'
25
25
  import {
26
26
  createKeyboardInteraction,
27
27
  handleEnterKey,
@@ -61,7 +61,7 @@ export class HeadshotGridView extends BlockView<HeadshotGridNode> {
61
61
  this.addHeadshotButton.classList.add('add-headshot-element-button')
62
62
  this.addHeadshotButton.setAttribute('data-cy', 'headshot-add')
63
63
  this.addHeadshotButton.contentEditable = 'false'
64
- this.addHeadshotButton.innerHTML = addAuthorIcon
64
+ this.addHeadshotButton.innerHTML = addIcon
65
65
  const buttonText = document.createElement('span')
66
66
  buttonText.classList.add('add-headshot-element-text')
67
67
  buttonText.innerText = 'Add Headshot'
@@ -585,7 +585,7 @@ span.comment-marker {
585
585
  .bib-item {
586
586
  display: flex;
587
587
  margin-bottom: 12px;
588
- min-height: 80px;
588
+ min-height: 60px;
589
589
  }
590
590
  .bib-item:focus-visible {
591
591
  outline: 4px solid var(--focus-outline-color);
@@ -2126,6 +2126,7 @@ th:hover > .table-context-menu-button,
2126
2126
  padding-right: 150px;
2127
2127
  }
2128
2128
 
2129
+ .ProseMirror .add-new-reference,
2129
2130
  .ProseMirror .add-trans-abstract {
2130
2131
  display: flex;
2131
2132
  align-items: center;
@@ -2140,16 +2141,42 @@ th:hover > .table-context-menu-button,
2140
2141
  background: unset;
2141
2142
  border: none;
2142
2143
  }
2143
-
2144
+ .ProseMirror .add-new-reference {
2145
+ bottom: 100%;
2146
+ top: auto;
2147
+ }
2148
+ .ProseMirror .add-new-reference svg,
2144
2149
  .ProseMirror .add-trans-abstract svg {
2145
2150
  width: 16px;
2146
2151
  height: 16px;
2147
2152
  }
2148
2153
 
2154
+ .ProseMirror .add-new-reference svg rect,
2149
2155
  .ProseMirror .add-trans-abstract svg rect {
2150
2156
  fill: #6e6e6e !important;
2151
2157
  }
2152
2158
 
2159
+ .tracking-visible .ProseMirror .bib-item.inserted .uncited-reference-marker,
2160
+ .tracking-visible .ProseMirror .deleted.bib-item .uncited-reference-marker {
2161
+ text-decoration: none !important;
2162
+ }
2163
+ .tracking-visible .ProseMirror .bib-item.deleted {
2164
+ display: block;
2165
+ }
2166
+ .ProseMirror .uncited-reference-marker {
2167
+ padding: 1px 6px 0 6px;
2168
+ border-radius: 4px;
2169
+ left: calc(100% + 5px);
2170
+ position: absolute;
2171
+ top: 0;
2172
+ color: #353535;
2173
+ line-height: 13px;
2174
+ background-color: #f7b314;
2175
+ font-size: 10px;
2176
+ font-weight: 500;
2177
+ }
2178
+
2179
+ .ProseMirror .add-new-reference-text,
2153
2180
  .ProseMirror .add-trans-abstract-text {
2154
2181
  font-size: 14px;
2155
2182
  color: #353535;