@manuscripts/body-editor 3.19.1 → 3.19.3
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/cross-ref-check-modal/CrossRefWarningModal.js +202 -52
- package/dist/cjs/components/cross-ref-check-modal/openModal.js +8 -2
- package/dist/cjs/lib/utils.js +12 -1
- package/dist/cjs/plugins/cross-references.js +37 -14
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/ReactSubView.js +1 -0
- package/dist/cjs/views/cross_reference.js +13 -2
- package/dist/cjs/views/cross_reference_editable.js +1 -4
- package/dist/es/components/cross-ref-check-modal/CrossRefWarningModal.js +202 -52
- package/dist/es/components/cross-ref-check-modal/openModal.js +9 -3
- package/dist/es/lib/utils.js +11 -1
- package/dist/es/plugins/cross-references.js +37 -15
- package/dist/es/versions.js +1 -1
- package/dist/es/views/ReactSubView.js +1 -0
- package/dist/es/views/cross_reference.js +13 -2
- package/dist/es/views/cross_reference_editable.js +1 -4
- package/dist/types/components/authors-affiliations/AuthorsAndAffiliationsModals.d.ts +1 -1
- package/dist/types/components/cross-ref-check-modal/CrossRefWarningModal.d.ts +4 -2
- package/dist/types/components/cross-ref-check-modal/openModal.d.ts +2 -2
- package/dist/types/lib/utils.d.ts +4 -0
- package/dist/types/plugins/cross-references.d.ts +2 -0
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/ReactSubView.d.ts +5 -2
- package/dist/types/views/cross_reference.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/cross-ref-check-modal/CrossRefWarningModal.tsx +315 -83
- package/src/components/cross-ref-check-modal/openModal.ts +14 -4
- package/src/lib/utils.ts +24 -0
- package/src/plugins/cross-references.ts +41 -13
- package/src/versions.ts +1 -1
- package/src/views/ReactSubView.tsx +6 -3
- package/src/views/cross_reference.ts +14 -2
- package/src/views/cross_reference_editable.ts +1 -4
- package/styles/Editor.css +12 -0
package/src/versions.ts
CHANGED
|
@@ -24,6 +24,8 @@ import { ThemeProvider } from 'styled-components'
|
|
|
24
24
|
import { EditorProps } from '../configs/ManuscriptsEditor'
|
|
25
25
|
import { Trackable } from '../types'
|
|
26
26
|
|
|
27
|
+
export type SubViewContainer = HTMLDivElement & { unmount: () => void }
|
|
28
|
+
|
|
27
29
|
export interface ReactViewComponentProps<NodeT extends ManuscriptNode> {
|
|
28
30
|
nodeAttrs: NodeT['attrs']
|
|
29
31
|
setNodeAttrs: (nextAttrs: Partial<NodeT['attrs']>) => void
|
|
@@ -32,7 +34,7 @@ export interface ReactViewComponentProps<NodeT extends ManuscriptNode> {
|
|
|
32
34
|
getPos: () => number
|
|
33
35
|
node: ManuscriptNode | Trackable<ManuscriptNode>
|
|
34
36
|
}
|
|
35
|
-
container:
|
|
37
|
+
container: SubViewContainer
|
|
36
38
|
}
|
|
37
39
|
/*
|
|
38
40
|
This is to render components that affect the Prosemirror Document indirectly. Such as dropdown buttons, inputs, advanced UX elements etc.
|
|
@@ -46,8 +48,9 @@ function createSubView<T extends Trackable<ManuscriptNode>>(
|
|
|
46
48
|
getPos: () => number,
|
|
47
49
|
view: ManuscriptEditorView,
|
|
48
50
|
classNames: string[] = []
|
|
49
|
-
):
|
|
50
|
-
const container = document.createElement('div')
|
|
51
|
+
): SubViewContainer {
|
|
52
|
+
const container = document.createElement('div') as SubViewContainer
|
|
53
|
+
container.unmount = () => root.unmount()
|
|
51
54
|
const Wrapped = createView<T>(
|
|
52
55
|
props,
|
|
53
56
|
Component,
|
|
@@ -50,11 +50,17 @@ export class CrossReferenceView
|
|
|
50
50
|
|
|
51
51
|
const isSupplement = target?.type === schema.nodes.supplement.name
|
|
52
52
|
const derivedLabel = isSupplement
|
|
53
|
-
? target?.caption || target?.label || ''
|
|
54
|
-
: target?.label || ''
|
|
53
|
+
? target?.caption || target?.label || '[cross-ref]'
|
|
54
|
+
: target?.label || '[cross-ref]'
|
|
55
55
|
|
|
56
56
|
this.dom.textContent = attrs.label || derivedLabel
|
|
57
57
|
this.dom.addEventListener('click', this.handleClick)
|
|
58
|
+
|
|
59
|
+
if (this.isOrphaned()) {
|
|
60
|
+
this.dom.classList.add('orphaned-cross-reference')
|
|
61
|
+
} else {
|
|
62
|
+
this.dom.classList.remove('orphaned-cross-reference')
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
public initialise = () => {
|
|
@@ -74,6 +80,12 @@ export class CrossReferenceView
|
|
|
74
80
|
handleEnterKey(() => this.handleClick())
|
|
75
81
|
)
|
|
76
82
|
}
|
|
83
|
+
|
|
84
|
+
protected isOrphaned() {
|
|
85
|
+
const targets = objectsKey.getState(this.view.state) as Map<string, Target>
|
|
86
|
+
const rid = this.node.attrs.rids[0]
|
|
87
|
+
return !targets?.get(rid)
|
|
88
|
+
}
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
export default createNodeView(CrossReferenceView)
|
|
@@ -147,9 +147,7 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
147
147
|
|
|
148
148
|
const can = this.props.getCapabilities()
|
|
149
149
|
|
|
150
|
-
const
|
|
151
|
-
const rid = this.node.attrs.rids[0]
|
|
152
|
-
const isOrphaned = !targets?.get(rid)
|
|
150
|
+
const isOrphaned = this.isOrphaned()
|
|
153
151
|
|
|
154
152
|
const actions: ContextMenuProps['actions'] = [
|
|
155
153
|
{
|
|
@@ -173,7 +171,6 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
173
171
|
label: 'Edit',
|
|
174
172
|
icon: 'Edit',
|
|
175
173
|
action: () => this.handleEdit(),
|
|
176
|
-
disabled: isOrphaned,
|
|
177
174
|
})
|
|
178
175
|
}
|
|
179
176
|
|
package/styles/Editor.css
CHANGED
|
@@ -300,12 +300,24 @@
|
|
|
300
300
|
color: inherit;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
.ProseMirror .orphaned-cross-reference {
|
|
304
|
+
text-decoration: underline dotted #f35143;
|
|
305
|
+
}
|
|
306
|
+
|
|
303
307
|
.ProseMirror .bib-item.ProseMirror-selectednode,
|
|
304
308
|
.ProseMirror .citation.ProseMirror-selectednode,
|
|
305
309
|
.ProseMirror .cross-reference.ProseMirror-selectednode {
|
|
306
310
|
background-color: #bce7f6;
|
|
307
311
|
}
|
|
308
312
|
|
|
313
|
+
.ProseMirror .cross-reference.selected-cross-reference {
|
|
314
|
+
border-radius: 4px;
|
|
315
|
+
outline: 2px solid #FE8F1F;
|
|
316
|
+
outline-offset: 1.5px;
|
|
317
|
+
background: #FFF9E5;
|
|
318
|
+
mix-blend-mode: darken;
|
|
319
|
+
}
|
|
320
|
+
|
|
309
321
|
.ProseMirror .block-table_element .block-gutter {
|
|
310
322
|
padding-top: 1em;
|
|
311
323
|
}
|