@manuscripts/body-editor 3.17.5 → 3.18.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.
- package/dist/cjs/components/references/ReferenceLine.js +14 -1
- package/dist/cjs/components/references/ReferencesModal.js +155 -131
- package/dist/cjs/icons.js +2 -2
- package/dist/cjs/lib/normalize.js +31 -1
- package/dist/cjs/lib/paste.js +0 -1
- package/dist/cjs/plugins/add-subtitle.js +1 -1
- package/dist/cjs/plugins/bibliography.js +7 -1
- package/dist/cjs/plugins/translations.js +1 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/bibliography_element.js +44 -2
- package/dist/cjs/views/figure_element.js +1 -1
- package/dist/cjs/views/headshot_grid.js +1 -1
- package/dist/es/components/references/ReferenceLine.js +14 -1
- package/dist/es/components/references/ReferencesModal.js +156 -132
- package/dist/es/icons.js +1 -1
- package/dist/es/lib/normalize.js +30 -1
- package/dist/es/lib/paste.js +0 -1
- package/dist/es/plugins/add-subtitle.js +2 -2
- package/dist/es/plugins/bibliography.js +7 -1
- package/dist/es/plugins/translations.js +2 -2
- package/dist/es/versions.js +1 -1
- package/dist/es/views/bibliography_element.js +45 -3
- package/dist/es/views/figure_element.js +2 -2
- package/dist/es/views/headshot_grid.js +2 -2
- package/dist/types/components/references/ReferenceLine.d.ts +1 -0
- package/dist/types/icons.d.ts +1 -1
- package/dist/types/lib/normalize.d.ts +30 -1
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/bibliography_element.d.ts +5 -1
- package/package.json +1 -1
- package/src/components/references/ReferenceLine.tsx +16 -1
- package/src/components/references/ReferencesModal.tsx +178 -140
- package/src/icons.ts +1 -1
- package/src/lib/normalize.ts +36 -1
- package/src/lib/paste.ts +0 -1
- package/src/plugins/add-subtitle.ts +2 -2
- package/src/plugins/bibliography.ts +10 -3
- package/src/plugins/translations.ts +2 -2
- package/src/versions.ts +1 -1
- package/src/views/bibliography_element.ts +61 -4
- package/src/views/figure_element.ts +2 -2
- package/src/views/headshot_grid.ts +2 -2
- package/styles/AdvancedEditor.css +29 -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 {
|
|
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
|
|
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
|
-
|
|
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,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 {
|
|
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:
|
|
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 {
|
|
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 =
|
|
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:
|
|
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;
|