@manuscripts/body-editor 3.17.3 → 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/commands.js +13 -19
- package/dist/cjs/components/references/ReferenceLine.js +14 -1
- package/dist/cjs/components/references/ReferencesModal.js +155 -131
- package/dist/cjs/configs/editor-views.js +1 -0
- package/dist/cjs/icons.js +2 -2
- package/dist/cjs/lib/context-menu.js +4 -1
- package/dist/cjs/lib/normalize.js +31 -1
- package/dist/cjs/lib/paste.js +0 -1
- package/dist/cjs/menus.js +1 -1
- package/dist/cjs/node-type-icons.js +1 -0
- package/dist/cjs/plugins/add-subtitle.js +1 -1
- package/dist/cjs/plugins/bibliography.js +7 -1
- package/dist/cjs/plugins/section_category.js +5 -2
- package/dist/cjs/plugins/translations.js +9 -21
- 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/commands.js +13 -19
- package/dist/es/components/references/ReferenceLine.js +14 -1
- package/dist/es/components/references/ReferencesModal.js +156 -132
- package/dist/es/configs/editor-views.js +1 -0
- package/dist/es/icons.js +1 -1
- package/dist/es/lib/context-menu.js +4 -1
- package/dist/es/lib/normalize.js +30 -1
- package/dist/es/lib/paste.js +0 -1
- package/dist/es/menus.js +1 -1
- package/dist/es/node-type-icons.js +1 -0
- package/dist/es/plugins/add-subtitle.js +2 -2
- package/dist/es/plugins/bibliography.js +7 -1
- package/dist/es/plugins/section_category.js +6 -3
- package/dist/es/plugins/translations.js +11 -23
- 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/commands.d.ts +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 +2 -2
- package/src/commands.ts +22 -35
- package/src/components/references/ReferenceLine.tsx +16 -1
- package/src/components/references/ReferencesModal.tsx +178 -140
- package/src/configs/editor-views.ts +1 -0
- package/src/icons.ts +1 -1
- package/src/lib/context-menu.ts +4 -1
- package/src/lib/normalize.ts +36 -1
- package/src/lib/paste.ts +0 -1
- package/src/menus.tsx +1 -1
- package/src/node-type-icons.tsx +1 -0
- package/src/plugins/add-subtitle.ts +2 -2
- package/src/plugins/bibliography.ts +10 -3
- package/src/plugins/section_category.ts +7 -2
- package/src/plugins/translations.ts +18 -29
- 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
- package/styles/Editor.css +7 -0
|
@@ -14,20 +14,25 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import {
|
|
18
|
+
isAbstractNode,
|
|
19
|
+
isGraphicalAbstractSectionNode,
|
|
20
|
+
isTransAbstractNode,
|
|
21
|
+
isTransGraphicalAbstractNode,
|
|
22
|
+
schema,
|
|
23
|
+
} from '@manuscripts/transform'
|
|
19
24
|
import { Plugin } from 'prosemirror-state'
|
|
20
25
|
import { Decoration, DecorationSet } from 'prosemirror-view'
|
|
21
26
|
|
|
22
27
|
import { insertTransAbstract, insertTransGraphicalAbstract } from '../commands'
|
|
23
28
|
import { EditorProps } from '../configs/ManuscriptsEditor'
|
|
24
|
-
import {
|
|
29
|
+
import { addIcon, translateIcon } from '../icons'
|
|
25
30
|
import { getLanguage, getLanguageLabel } from '../lib/languages'
|
|
26
|
-
import { templateAllows } from '../lib/template'
|
|
27
31
|
import {
|
|
28
|
-
handleEnterKey,
|
|
29
32
|
createKeyboardInteraction,
|
|
33
|
+
handleEnterKey,
|
|
30
34
|
} from '../lib/navigation-utils'
|
|
35
|
+
import { templateAllows } from '../lib/template'
|
|
31
36
|
|
|
32
37
|
const createMenuItem = (
|
|
33
38
|
props: EditorProps,
|
|
@@ -90,11 +95,6 @@ const createLanguageMenu = (
|
|
|
90
95
|
return { menu, destroy }
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
const getInsertionPos = (doc: Node, nodePos: number): number | null => {
|
|
94
|
-
const node = doc.nodeAt(nodePos)
|
|
95
|
-
return node ? nodePos + node.nodeSize : null
|
|
96
|
-
}
|
|
97
|
-
|
|
98
98
|
export default (props: EditorProps) =>
|
|
99
99
|
new Plugin<null>({
|
|
100
100
|
props: {
|
|
@@ -110,19 +110,14 @@ export default (props: EditorProps) =>
|
|
|
110
110
|
|
|
111
111
|
const widgets: Decoration[] = []
|
|
112
112
|
|
|
113
|
-
state.doc.descendants((node, pos
|
|
113
|
+
state.doc.descendants((node, pos) => {
|
|
114
114
|
const isAbstractSection =
|
|
115
|
-
(node
|
|
116
|
-
node.type === schema.nodes.graphical_abstract_section) &&
|
|
117
|
-
parent?.type === schema.nodes.abstracts
|
|
115
|
+
isAbstractNode(node) || isGraphicalAbstractSectionNode(node)
|
|
118
116
|
|
|
119
117
|
// Show "Add translation" for abstract sections
|
|
120
118
|
if (isAbstractSection) {
|
|
121
|
-
const isGraphical =
|
|
122
|
-
node.type === schema.nodes.graphical_abstract_section
|
|
123
119
|
const category = props.sectionCategories.get(node.attrs.category)
|
|
124
|
-
|
|
125
|
-
const canEdit = isGraphical
|
|
120
|
+
const canEdit = isGraphicalAbstractSectionNode(node)
|
|
126
121
|
? canEditTransGraphicalAbstract &&
|
|
127
122
|
category &&
|
|
128
123
|
insertTransGraphicalAbstract(category)(state)
|
|
@@ -137,17 +132,13 @@ export default (props: EditorProps) =>
|
|
|
137
132
|
$span.tabIndex = 0
|
|
138
133
|
$span.className = 'add-trans-abstract'
|
|
139
134
|
$span.title = 'Add translation'
|
|
140
|
-
$span.innerHTML = `${
|
|
135
|
+
$span.innerHTML = `${addIcon} <span class="add-trans-abstract-text">Add translation</span>`
|
|
141
136
|
|
|
142
137
|
const handleActivate = (event: Event) => {
|
|
143
138
|
event.preventDefault()
|
|
144
139
|
event.stopPropagation()
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return
|
|
148
|
-
}
|
|
149
|
-
if (isGraphical && category) {
|
|
150
|
-
insertTransGraphicalAbstract(category, insertPos)(
|
|
140
|
+
if (isGraphicalAbstractSectionNode(node) && category) {
|
|
141
|
+
insertTransGraphicalAbstract(category)(
|
|
151
142
|
view.state,
|
|
152
143
|
view.dispatch,
|
|
153
144
|
view
|
|
@@ -156,8 +147,7 @@ export default (props: EditorProps) =>
|
|
|
156
147
|
insertTransAbstract(
|
|
157
148
|
view.state,
|
|
158
149
|
view.dispatch,
|
|
159
|
-
node.attrs.category
|
|
160
|
-
insertPos
|
|
150
|
+
node.attrs.category
|
|
161
151
|
)
|
|
162
152
|
}
|
|
163
153
|
}
|
|
@@ -177,8 +167,7 @@ export default (props: EditorProps) =>
|
|
|
177
167
|
|
|
178
168
|
// Language selector for trans_abstract and trans_graphical_abstract nodes
|
|
179
169
|
const isTransNode =
|
|
180
|
-
node
|
|
181
|
-
node.type === schema.nodes.trans_graphical_abstract
|
|
170
|
+
isTransAbstractNode(node) || isTransGraphicalAbstractNode(node)
|
|
182
171
|
|
|
183
172
|
if (isTransNode) {
|
|
184
173
|
const canEdit =
|
package/src/versions.ts
CHANGED
|
@@ -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;
|
package/styles/Editor.css
CHANGED
|
@@ -694,12 +694,14 @@
|
|
|
694
694
|
grid-template-columns: 52px auto 100px 28px;
|
|
695
695
|
}
|
|
696
696
|
.ProseMirror .block-container.block-section,
|
|
697
|
+
.ProseMirror .block-container.block-abstract,
|
|
697
698
|
.ProseMirror .block-container.block-graphical_abstract_section {
|
|
698
699
|
position: relative;
|
|
699
700
|
display: grid;
|
|
700
701
|
grid-template-columns: auto;
|
|
701
702
|
}
|
|
702
703
|
.ProseMirror .block-container.block-section section,
|
|
704
|
+
.ProseMirror .block-container.block-abstract section,
|
|
703
705
|
.ProseMirror .block-container.block-graphical_abstract_section section {
|
|
704
706
|
position: relative;
|
|
705
707
|
}
|
|
@@ -707,6 +709,7 @@
|
|
|
707
709
|
.ProseMirror
|
|
708
710
|
.block-container:not(
|
|
709
711
|
.block-section,
|
|
712
|
+
.block-abstract,
|
|
710
713
|
.block-graphical_abstract_section
|
|
711
714
|
):hover {
|
|
712
715
|
z-index: 2;
|
|
@@ -789,6 +792,7 @@
|
|
|
789
792
|
.block-container:not(
|
|
790
793
|
.block-section,
|
|
791
794
|
.block-box_element,
|
|
795
|
+
.block-abstract,
|
|
792
796
|
.block-graphical_abstract_section
|
|
793
797
|
):hover
|
|
794
798
|
.block-gutter,
|
|
@@ -796,6 +800,7 @@
|
|
|
796
800
|
.block-container:not(
|
|
797
801
|
.block-section,
|
|
798
802
|
.block-box_element,
|
|
803
|
+
.block-abstract,
|
|
799
804
|
.block-graphical_abstract_section
|
|
800
805
|
):focus-within
|
|
801
806
|
.block-gutter {
|
|
@@ -818,6 +823,7 @@
|
|
|
818
823
|
.block-container:not(
|
|
819
824
|
.block-section,
|
|
820
825
|
.block-box_element,
|
|
826
|
+
.block-abstract,
|
|
821
827
|
.block-graphical_abstract_section
|
|
822
828
|
):hover
|
|
823
829
|
.action-gutter,
|
|
@@ -825,6 +831,7 @@
|
|
|
825
831
|
.block-container:not(
|
|
826
832
|
.block-section,
|
|
827
833
|
.block-box_element,
|
|
834
|
+
.block-abstract,
|
|
828
835
|
.block-graphical_abstract_section
|
|
829
836
|
):focus-within
|
|
830
837
|
.action-gutter {
|