@manuscripts/body-editor 3.16.0 → 3.16.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.
- package/dist/cjs/commands.js +45 -10
- package/dist/cjs/components/form/FormFooter.js +2 -2
- package/dist/cjs/components/keyboard-shortcuts-modal/KeyboardShortcutsModal.js +4 -2
- package/dist/cjs/components/references/CitationEditor.js +13 -19
- package/dist/cjs/components/references/ImportBibliography.js +77 -0
- package/dist/cjs/components/references/ImportBibliographyForm.js +1 -1
- package/dist/cjs/components/references/ImportBibliographyModal.js +12 -81
- package/dist/cjs/components/references/ImportReferencesConfirmation.js +113 -0
- package/dist/cjs/components/references/ImportSuccessPlaceholder.js +56 -0
- package/dist/cjs/components/references/ReferenceSearch.js +2 -5
- package/dist/cjs/components/references/ReferencesEditor.js +18 -2
- package/dist/cjs/components/references/ReferencesModal.js +86 -33
- package/dist/cjs/components/views/CrossReferenceItems.js +139 -52
- package/dist/cjs/components/views/DeleteSupplementDialog.js +1 -1
- package/dist/cjs/lib/supplements.js +9 -1
- package/dist/cjs/lib/view.js +39 -1
- package/dist/cjs/menus.js +35 -0
- package/dist/cjs/plugins/objects.js +1 -1
- package/dist/cjs/toolbar.js +6 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/bibliography_element.js +1 -2
- package/dist/cjs/views/citation_editable.js +2 -29
- package/dist/cjs/views/cross_reference.js +12 -2
- package/dist/cjs/views/cross_reference_editable.js +95 -4
- package/dist/cjs/views/figure_editable.js +3 -0
- package/dist/es/commands.js +43 -9
- package/dist/es/components/form/FormFooter.js +2 -2
- package/dist/es/components/keyboard-shortcuts-modal/KeyboardShortcutsModal.js +4 -2
- package/dist/es/components/references/CitationEditor.js +13 -19
- package/dist/es/components/references/ImportBibliography.js +70 -0
- package/dist/es/components/references/ImportBibliographyForm.js +1 -1
- package/dist/es/components/references/ImportBibliographyModal.js +13 -79
- package/dist/es/components/references/ImportReferencesConfirmation.js +73 -0
- package/dist/es/components/references/ImportSuccessPlaceholder.js +49 -0
- package/dist/es/components/references/ReferenceSearch.js +3 -6
- package/dist/es/components/references/ReferencesEditor.js +19 -3
- package/dist/es/components/references/ReferencesModal.js +88 -35
- package/dist/es/components/views/CrossReferenceItems.js +141 -54
- package/dist/es/components/views/DeleteSupplementDialog.js +2 -2
- package/dist/es/lib/supplements.js +8 -1
- package/dist/es/lib/view.js +36 -0
- package/dist/es/menus.js +36 -1
- package/dist/es/plugins/objects.js +1 -1
- package/dist/es/toolbar.js +8 -2
- package/dist/es/versions.js +1 -1
- package/dist/es/views/bibliography_element.js +2 -3
- package/dist/es/views/citation_editable.js +3 -30
- package/dist/es/views/cross_reference.js +12 -2
- package/dist/es/views/cross_reference_editable.js +96 -5
- package/dist/es/views/figure_editable.js +3 -0
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/components/form/FormFooter.d.ts +2 -1
- package/dist/types/components/references/CitationEditor.d.ts +1 -1
- package/dist/types/components/references/ImportBibliography.d.ts +7 -0
- package/dist/types/components/references/ImportReferencesConfirmation.d.ts +8 -0
- package/dist/types/components/references/ImportSuccessPlaceholder.d.ts +5 -0
- package/dist/types/components/references/ReferenceSearch.d.ts +0 -1
- package/dist/types/components/references/ReferencesEditor.d.ts +4 -1
- package/dist/types/components/references/ReferencesModal.d.ts +1 -0
- package/dist/types/components/views/CrossReferenceItems.d.ts +3 -0
- package/dist/types/lib/supplements.d.ts +1 -0
- package/dist/types/lib/view.d.ts +3 -1
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/citation_editable.d.ts +0 -1
- package/dist/types/views/cross_reference_editable.d.ts +6 -0
- package/package.json +4 -4
- package/src/commands.ts +52 -10
- package/src/components/ChangeHandlingForm.tsx +4 -2
- package/src/components/form/FormFooter.tsx +3 -1
- package/src/components/keyboard-shortcuts-modal/KeyboardShortcutsModal.tsx +6 -7
- package/src/components/references/CitationEditor.tsx +16 -25
- package/src/components/references/ImportBibliography.tsx +119 -0
- package/src/components/references/ImportBibliographyForm.tsx +1 -1
- package/src/components/references/ImportBibliographyModal.tsx +34 -110
- package/src/components/references/ImportReferencesConfirmation.tsx +133 -0
- package/src/components/references/ImportSuccessPlaceholder.tsx +93 -0
- package/src/components/references/ReferenceSearch.tsx +0 -7
- package/src/components/references/ReferencesEditor.tsx +35 -6
- package/src/components/references/ReferencesModal.tsx +164 -78
- package/src/components/toolbar/InsertEmbedDialog.tsx +6 -2
- package/src/components/toolbar/type-selector/styles.ts +2 -1
- package/src/components/views/CrossReferenceItems.tsx +227 -100
- package/src/components/views/DeleteSupplementDialog.tsx +3 -6
- package/src/lib/footnotes.ts +3 -1
- package/src/lib/supplements.ts +13 -1
- package/src/lib/utils.ts +15 -4
- package/src/lib/view.ts +65 -0
- package/src/menus.tsx +39 -0
- package/src/plugins/add-subtitle.ts +18 -16
- package/src/plugins/objects.ts +2 -6
- package/src/toolbar.tsx +9 -0
- package/src/versions.ts +1 -1
- package/src/views/bibliography_element.ts +3 -4
- package/src/views/citation_editable.ts +5 -50
- package/src/views/cross_reference.ts +17 -3
- package/src/views/cross_reference_editable.ts +123 -11
- package/src/views/figure_editable.ts +4 -0
- package/src/views/supplement.ts +0 -1
- package/src/views/supplements.ts +2 -2
|
@@ -14,9 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { schema, } from '@manuscripts/transform';
|
|
17
|
-
import { findChildrenByType, findParentNodeClosestToPos } from 'prosemirror-utils';
|
|
17
|
+
import { findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
|
|
18
18
|
import { allowedHref } from './url';
|
|
19
|
+
export const getSupplementCaptionTitle = (node) => {
|
|
20
|
+
return node.firstChild?.textContent.trim() ?? '';
|
|
21
|
+
};
|
|
19
22
|
export const getSupplementDisplayLabel = (node, files) => {
|
|
23
|
+
const captionTitle = getSupplementCaptionTitle(node);
|
|
24
|
+
if (captionTitle) {
|
|
25
|
+
return captionTitle;
|
|
26
|
+
}
|
|
20
27
|
const href = node.attrs.href;
|
|
21
28
|
if (allowedHref(href)) {
|
|
22
29
|
return href;
|
package/dist/es/lib/view.js
CHANGED
|
@@ -64,3 +64,39 @@ export const deleteNode = (view, id) => {
|
|
|
64
64
|
view.dispatch(view.state.tr.delete(pos, pos + node.nodeSize));
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
+
const createBibliographySection = (nodes) => schema.nodes.bibliography_section.createAndFill({}, [
|
|
68
|
+
schema.nodes.section_title.create({}, schema.text('References')),
|
|
69
|
+
schema.nodes.bibliography_element.create({}, nodes),
|
|
70
|
+
]);
|
|
71
|
+
export const insertBibliographyItems = (view, items) => {
|
|
72
|
+
const { doc } = view.state;
|
|
73
|
+
let tr = view.state.tr;
|
|
74
|
+
const biblioSection = utils.findChildrenByType(doc, schema.nodes.bibliography_element, true);
|
|
75
|
+
if (biblioSection.length) {
|
|
76
|
+
let insertPos = biblioSection[0].pos + 1;
|
|
77
|
+
for (const attrs of items) {
|
|
78
|
+
const node = schema.nodes.bibliography_item.create(attrs);
|
|
79
|
+
tr = tr.insert(insertPos, node);
|
|
80
|
+
insertPos += node.nodeSize;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const backmatter = utils.findChildrenByType(doc, schema.nodes.backmatter, true);
|
|
85
|
+
const backmatterEnd = backmatter[0]
|
|
86
|
+
? backmatter[0].node.nodeSize + backmatter[0].pos
|
|
87
|
+
: 0;
|
|
88
|
+
const nodes = items.map((attrs) => schema.nodes.bibliography_item.create(attrs));
|
|
89
|
+
tr = tr.insert(backmatterEnd ? backmatterEnd - 1 : tr.doc.content.size, createBibliographySection(nodes));
|
|
90
|
+
}
|
|
91
|
+
view.dispatch(tr);
|
|
92
|
+
};
|
|
93
|
+
export const saveBibliographyItem = (view, attrs) => {
|
|
94
|
+
if (attrs.length === 1) {
|
|
95
|
+
const item = attrs[0];
|
|
96
|
+
if (findChildByID(view, item.id)) {
|
|
97
|
+
updateNodeAttrs(view, schema.nodes.bibliography_item, item);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
insertBibliographyItems(view, attrs);
|
|
102
|
+
};
|
package/dist/es/menus.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { getGroupCategories, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { toggleMark } from 'prosemirror-commands';
|
|
18
18
|
import { redo, undo } from 'prosemirror-history';
|
|
19
|
-
import { activateSearchReplace, addInlineComment, blockActive, canInsert, copySelection, insertAbstractSection, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertEmbed, insertGraphicalAbstract, insertHeadshotGrid, insertHeroImage, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, paste, } from './commands';
|
|
19
|
+
import { activateSearchReplace, addInlineComment, blockActive, canInsert, copySelection, insertAbstractSection, insertAffiliation, insertAward, insertBackmatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, canInsertCrossReference, insertEmbed, insertGraphicalAbstract, insertHeadshotGrid, insertHeroImage, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, paste, } from './commands';
|
|
20
20
|
import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
|
|
21
21
|
import { ListMenuItem } from './components/toolbar/ListMenuItem';
|
|
22
22
|
import { openInsertSpecialCharacterDialog } from './components/views/InsertSpecialCharacter';
|
|
@@ -330,6 +330,41 @@ export const getEditorMenus = (editor) => {
|
|
|
330
330
|
{
|
|
331
331
|
role: 'separator',
|
|
332
332
|
},
|
|
333
|
+
{
|
|
334
|
+
id: 'insert-citation',
|
|
335
|
+
label: 'Citation',
|
|
336
|
+
shortcut: {
|
|
337
|
+
mac: 'Option+CommandOrControl+C',
|
|
338
|
+
pc: 'CommandOrControl+Option+C',
|
|
339
|
+
},
|
|
340
|
+
isEnabled: isEditAllowed(state) &&
|
|
341
|
+
isCommandValid(canInsert(schema.nodes.citation)),
|
|
342
|
+
run: doCommand(insertInlineCitation),
|
|
343
|
+
isHidden: !templateAllows(state, schema.nodes.citation),
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
id: 'insert-cross-reference',
|
|
347
|
+
label: 'Cross-reference',
|
|
348
|
+
shortcut: {
|
|
349
|
+
mac: 'Option+CommandOrControl+R',
|
|
350
|
+
pc: 'CommandOrControl+Option+R',
|
|
351
|
+
},
|
|
352
|
+
isEnabled: isEditAllowed(state) && isCommandValid(canInsertCrossReference),
|
|
353
|
+
run: doCommand(insertCrossReference),
|
|
354
|
+
isHidden: !templateAllows(state, schema.nodes.cross_reference),
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
id: 'insert-footnote',
|
|
358
|
+
label: 'Footnote',
|
|
359
|
+
shortcut: {
|
|
360
|
+
mac: 'Option+CommandOrControl+F',
|
|
361
|
+
pc: 'CommandOrControl+Option+F',
|
|
362
|
+
},
|
|
363
|
+
isEnabled: isEditAllowed(state) &&
|
|
364
|
+
isCommandValid(canInsert(schema.nodes.inline_footnote)),
|
|
365
|
+
run: doCommand(insertInlineFootnote),
|
|
366
|
+
isHidden: !templateAllows(state, schema.nodes.inline_footnote),
|
|
367
|
+
},
|
|
333
368
|
{
|
|
334
369
|
id: 'insert-special-character',
|
|
335
370
|
label: 'Special Characters',
|
|
@@ -39,7 +39,7 @@ export default () => {
|
|
|
39
39
|
const { id } = node.attrs;
|
|
40
40
|
if (id) {
|
|
41
41
|
const target = targets.get(id);
|
|
42
|
-
if (target) {
|
|
42
|
+
if (target && target.label) {
|
|
43
43
|
const caption = findChildren(node, (node) => node.type === schema.nodes.caption ||
|
|
44
44
|
node.type === schema.nodes.caption_title, false)[0];
|
|
45
45
|
if (caption) {
|
package/dist/es/toolbar.js
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { AddCommentIcon, FileImageIcon, LinkIcon, OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlinePullQuoteIcon, ToolbarBoldIcon, ToolbarBoxedTextIcon, ToolbarCitationIcon, ToolbarEquationIcon, ToolbarFigureIcon, ToolbarIndentIcon, ToolbarItalicIcon, ToolbarOrderedListIcon, ToolbarSpecialCharactersIcon, ToolbarSubscriptIcon, ToolbarSuperscriptIcon, ToolbarTableIcon, ToolbarUnderlineIcon, ToolbarUnindentIcon, ToolbarUnorderedListIcon, } from '@manuscripts/style-guide';
|
|
16
|
+
import { AddCommentIcon, FileImageIcon, LinkIcon, OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlinePullQuoteIcon, ToolbarBoldIcon, ToolbarBoxedTextIcon, ToolbarCitationIcon, ToolbarCrossReferenceIcon, ToolbarEquationIcon, ToolbarFigureIcon, ToolbarIndentIcon, ToolbarItalicIcon, ToolbarOrderedListIcon, ToolbarSpecialCharactersIcon, ToolbarSubscriptIcon, ToolbarSuperscriptIcon, ToolbarTableIcon, ToolbarUnderlineIcon, ToolbarUnindentIcon, ToolbarUnorderedListIcon, } from '@manuscripts/style-guide';
|
|
17
17
|
import { schema } from '@manuscripts/transform';
|
|
18
18
|
import { toggleMark } from 'prosemirror-commands';
|
|
19
19
|
import React from 'react';
|
|
20
|
-
import { addInlineComment, blockActive, canInsert, insertBlock, insertBoxElement, insertEmbed, insertInlineCitation, insertLink, insertList, markActive, } from './commands';
|
|
20
|
+
import { addInlineComment, blockActive, canInsert, canInsertCrossReference, insertBlock, insertBoxElement, insertCrossReference, insertEmbed, insertInlineCitation, insertLink, insertList, markActive, } from './commands';
|
|
21
21
|
import { changeIndentation, isIndentationAllowed, } from './components/toolbar/helpers';
|
|
22
22
|
import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
|
|
23
23
|
import { openInsertSpecialCharacterDialog } from './components/views/InsertSpecialCharacter';
|
|
@@ -113,6 +113,12 @@ export const toolbar = {
|
|
|
113
113
|
isEnabled: isEnabled(canInsert(schema.nodes.highlight_marker)),
|
|
114
114
|
run: addInlineComment,
|
|
115
115
|
},
|
|
116
|
+
cross_reference: {
|
|
117
|
+
title: 'Insert cross-reference',
|
|
118
|
+
content: React.createElement(ToolbarCrossReferenceIcon, null),
|
|
119
|
+
isEnabled: isEnabled(canInsertCrossReference),
|
|
120
|
+
run: insertCrossReference,
|
|
121
|
+
},
|
|
116
122
|
citation: {
|
|
117
123
|
title: 'Insert citation',
|
|
118
124
|
content: React.createElement(ToolbarCitationIcon, null),
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.16.
|
|
1
|
+
export const VERSION = '3.16.2';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -14,14 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ContextMenu } from '@manuscripts/style-guide';
|
|
17
|
-
import { schema, } from '@manuscripts/transform';
|
|
18
17
|
import { NodeSelection } from 'prosemirror-state';
|
|
19
18
|
import { ReferencesEditor, } from '../components/references/ReferencesEditor';
|
|
20
19
|
import { createCommentMarker, handleComment } from '../lib/comments';
|
|
21
20
|
import { handleEnterKey } from '../lib/navigation-utils';
|
|
22
21
|
import { findNodeByID } from '../lib/doc';
|
|
23
22
|
import { sanitize } from '../lib/dompurify';
|
|
24
|
-
import { deleteNode, findChildByID,
|
|
23
|
+
import { deleteNode, findChildByID, saveBibliographyItem } from '../lib/view';
|
|
25
24
|
import { getBibliographyPluginState } from '../plugins/bibliography';
|
|
26
25
|
import { commentsKey, setCommentSelection } from '../plugins/comments';
|
|
27
26
|
import { selectedSuggestionKey } from '../plugins/selected-suggestion';
|
|
@@ -86,7 +85,7 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
86
85
|
this.dom.appendChild(this.container);
|
|
87
86
|
};
|
|
88
87
|
this.handleSave = (attrs) => {
|
|
89
|
-
|
|
88
|
+
saveBibliographyItem(this.view, attrs);
|
|
90
89
|
};
|
|
91
90
|
this.handleDelete = (item) => {
|
|
92
91
|
deleteNode(this.view, item.id);
|
|
@@ -15,23 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ContextMenu } from '@manuscripts/style-guide';
|
|
17
17
|
import { isDeleted } from '@manuscripts/track-changes-plugin';
|
|
18
|
-
import { schema, } from '@manuscripts/transform';
|
|
19
18
|
import { TextSelection } from 'prosemirror-state';
|
|
20
|
-
import { findChildrenByType } from 'prosemirror-utils';
|
|
21
19
|
import { CitationEditor, } from '../components/references/CitationEditor';
|
|
22
20
|
import { CitationViewer, } from '../components/references/CitationViewer';
|
|
23
21
|
import { handleComment } from '../lib/comments';
|
|
24
22
|
import { Crossref } from '../lib/crossref';
|
|
25
23
|
import { handleEnterKey } from '../lib/navigation-utils';
|
|
26
|
-
import { deleteNode,
|
|
24
|
+
import { deleteNode, saveBibliographyItem } from '../lib/view';
|
|
27
25
|
import { getBibliographyPluginState } from '../plugins/bibliography';
|
|
28
26
|
import { CitationView } from './citation';
|
|
29
27
|
import { createEditableNodeView } from './creators';
|
|
30
28
|
import ReactSubView from './ReactSubView';
|
|
31
|
-
const createBibliographySection = (node) => schema.nodes.bibliography_section.createAndFill({}, [
|
|
32
|
-
schema.nodes.section_title.create({}, schema.text('References')),
|
|
33
|
-
schema.nodes.bibliography_element.create({}, node ? [node] : []),
|
|
34
|
-
]);
|
|
35
29
|
export class CitationEditableView extends CitationView {
|
|
36
30
|
constructor() {
|
|
37
31
|
super(...arguments);
|
|
@@ -137,12 +131,7 @@ export class CitationEditableView extends CitationView {
|
|
|
137
131
|
this.props.popper.destroy();
|
|
138
132
|
};
|
|
139
133
|
this.handleSave = (attrs) => {
|
|
140
|
-
|
|
141
|
-
this.insertBibliographyNode(attrs);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
updateNodeAttrs(this.view, schema.nodes.bibliography_item, attrs);
|
|
145
|
-
}
|
|
134
|
+
saveBibliographyItem(this.view, attrs);
|
|
146
135
|
};
|
|
147
136
|
this.handleUncite = (id) => {
|
|
148
137
|
const attrs = this.node.attrs;
|
|
@@ -175,7 +164,7 @@ export class CitationEditableView extends CitationView {
|
|
|
175
164
|
item.id = existingItem.id;
|
|
176
165
|
}
|
|
177
166
|
else {
|
|
178
|
-
this.
|
|
167
|
+
saveBibliographyItem(this.view, [item]);
|
|
179
168
|
}
|
|
180
169
|
rids.push(item.id);
|
|
181
170
|
}
|
|
@@ -194,21 +183,5 @@ export class CitationEditableView extends CitationView {
|
|
|
194
183
|
this.dom.addEventListener('mouseup', () => this.handleClick(false));
|
|
195
184
|
this.dom.addEventListener('keydown', handleEnterKey(() => this.handleClick(true)));
|
|
196
185
|
}
|
|
197
|
-
insertBibliographyNode(attrs) {
|
|
198
|
-
const { doc, tr } = this.view.state;
|
|
199
|
-
const biblioSection = findChildrenByType(doc, schema.nodes.bibliography_element, true);
|
|
200
|
-
const backmatter = findChildrenByType(doc, schema.nodes.backmatter, true);
|
|
201
|
-
const backmatterEnd = backmatter[0]
|
|
202
|
-
? backmatter[0].node.nodeSize + backmatter[0].pos
|
|
203
|
-
: 0;
|
|
204
|
-
const node = schema.nodes.bibliography_item.create(attrs);
|
|
205
|
-
if (biblioSection.length) {
|
|
206
|
-
this.view.dispatch(tr.insert(biblioSection[0].pos + 1, node));
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
this.view.dispatch(tr.insert(backmatterEnd ? backmatterEnd - 1 : tr.doc.content.size, createBibliographySection(node)));
|
|
210
|
-
}
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
186
|
}
|
|
214
187
|
export default createEditableNodeView(CitationEditableView);
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { schema, } from '@manuscripts/transform';
|
|
17
|
+
import { findNodeByID } from '../lib/doc';
|
|
16
18
|
import { handleEnterKey } from '../lib/navigation-utils';
|
|
19
|
+
import { getSupplementDisplayLabel } from '../lib/supplements';
|
|
17
20
|
import { objectsKey } from '../plugins/objects';
|
|
18
21
|
import { BaseNodeView } from './base_node_view';
|
|
19
22
|
import { createNodeView } from './creators';
|
|
@@ -46,8 +49,15 @@ export class CrossReferenceView extends BaseNodeView {
|
|
|
46
49
|
super.updateContents();
|
|
47
50
|
const targets = objectsKey.getState(this.view.state);
|
|
48
51
|
const attrs = this.node.attrs;
|
|
49
|
-
const
|
|
50
|
-
|
|
52
|
+
const target = attrs.rids.length ? targets.get(attrs.rids[0]) : undefined;
|
|
53
|
+
let derivedLabel = target?.label || '';
|
|
54
|
+
if (target?.type === schema.nodes.supplement.name && target.href) {
|
|
55
|
+
const found = findNodeByID(this.view.state.doc, target.id);
|
|
56
|
+
if (found) {
|
|
57
|
+
derivedLabel = getSupplementDisplayLabel(found.node, this.props.getFiles());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
this.dom.textContent = attrs.label || derivedLabel;
|
|
51
61
|
this.dom.addEventListener('click', this.handleClick);
|
|
52
62
|
}
|
|
53
63
|
}
|
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { ContextMenu } from '@manuscripts/style-guide';
|
|
17
|
+
import { isDeleted, skipTracking } from '@manuscripts/track-changes-plugin';
|
|
17
18
|
import { schema } from '@manuscripts/transform';
|
|
18
19
|
import { TextSelection } from 'prosemirror-state';
|
|
19
20
|
import { CrossReferenceItems } from '../components/views/CrossReferenceItems';
|
|
21
|
+
import { handleComment } from '../lib/comments';
|
|
22
|
+
import { findNodeByID } from '../lib/doc';
|
|
23
|
+
import { getSupplementDisplayLabel } from '../lib/supplements';
|
|
20
24
|
import { objectsKey } from '../plugins/objects';
|
|
21
25
|
import { createEditableNodeView } from './creators';
|
|
22
26
|
import { CrossReferenceView } from './cross_reference';
|
|
@@ -31,14 +35,20 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
31
35
|
if (!can?.editArticle || rids.length) {
|
|
32
36
|
return;
|
|
33
37
|
}
|
|
38
|
+
this.showPicker();
|
|
39
|
+
};
|
|
40
|
+
this.showPicker = () => {
|
|
41
|
+
const rids = this.node.attrs.rids;
|
|
34
42
|
const componentProps = {
|
|
35
43
|
handleSelect: this.handleSelect,
|
|
36
44
|
targets: this.getTargets(),
|
|
45
|
+
files: this.props.getFiles(),
|
|
37
46
|
handleCancel: this.handleCancel,
|
|
38
47
|
currentTargetId: rids[0],
|
|
39
48
|
currentCustomLabel: this.node.attrs.label,
|
|
49
|
+
isEdit: rids.length > 0,
|
|
40
50
|
};
|
|
41
|
-
this.popperContainer = ReactSubView(this.props, CrossReferenceItems, componentProps, this.node, this.getPos, this.view
|
|
51
|
+
this.popperContainer = ReactSubView(this.props, CrossReferenceItems, componentProps, this.node, this.getPos, this.view);
|
|
42
52
|
this.popperContainer.setAttribute('tabindex', '0');
|
|
43
53
|
this.props.popper.show(this.dom, this.popperContainer, 'auto');
|
|
44
54
|
};
|
|
@@ -50,15 +60,39 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
50
60
|
this.handleCancel();
|
|
51
61
|
};
|
|
52
62
|
this.getTargets = () => {
|
|
53
|
-
const excludedTypes = [schema.nodes.image_element.name];
|
|
54
63
|
const targets = objectsKey.getState(this.view.state);
|
|
55
|
-
|
|
64
|
+
const files = this.props.getFiles();
|
|
65
|
+
const fileMap = new Map(files.map((f) => [f.id, f.name]));
|
|
66
|
+
const excludedTypes = [schema.nodes.image_element.name];
|
|
67
|
+
const supplement = schema.nodes.supplement.name;
|
|
68
|
+
return Array.from(targets.values()).reduce((acc, t) => {
|
|
69
|
+
if (excludedTypes.includes(t.type)) {
|
|
70
|
+
return acc;
|
|
71
|
+
}
|
|
72
|
+
if (t.type === supplement && t.href) {
|
|
73
|
+
const found = findNodeByID(this.view.state.doc, t.id);
|
|
74
|
+
const label = found
|
|
75
|
+
? getSupplementDisplayLabel(found.node, files)
|
|
76
|
+
: (fileMap.get(t.href) ?? t.href);
|
|
77
|
+
acc.push({ ...t, label, caption: '' });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
acc.push(t);
|
|
81
|
+
}
|
|
82
|
+
return acc;
|
|
83
|
+
}, []);
|
|
56
84
|
};
|
|
57
85
|
this.handleCancel = () => {
|
|
58
86
|
if (!this.node.attrs.rids.length) {
|
|
59
87
|
const { state } = this.view;
|
|
60
88
|
const pos = this.getPos();
|
|
61
|
-
|
|
89
|
+
if (pos === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const label = this.node.attrs.label;
|
|
93
|
+
const tr = label
|
|
94
|
+
? state.tr.replaceWith(pos, pos + this.node.nodeSize, state.schema.text(label))
|
|
95
|
+
: state.tr.delete(pos, pos + this.node.nodeSize);
|
|
62
96
|
tr.setSelection(TextSelection.create(tr.doc, pos));
|
|
63
97
|
skipTracking(tr);
|
|
64
98
|
this.view.dispatch(tr);
|
|
@@ -79,6 +113,63 @@ export class CrossReferenceEditableView extends CrossReferenceView {
|
|
|
79
113
|
this.view.dispatch(tr.setSelection(selection));
|
|
80
114
|
this.destroy();
|
|
81
115
|
};
|
|
116
|
+
this.handleClick = () => {
|
|
117
|
+
if (isDeleted(this.node)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!this.node.attrs.rids.length) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.showContextMenu();
|
|
124
|
+
};
|
|
125
|
+
this.showContextMenu = () => {
|
|
126
|
+
this.props.popper.destroy();
|
|
127
|
+
const can = this.props.getCapabilities();
|
|
128
|
+
const targets = objectsKey.getState(this.view.state);
|
|
129
|
+
const rid = this.node.attrs.rids[0];
|
|
130
|
+
const isOrphaned = !targets?.get(rid);
|
|
131
|
+
const actions = [
|
|
132
|
+
{
|
|
133
|
+
label: 'Comment',
|
|
134
|
+
icon: 'AddComment',
|
|
135
|
+
action: () => {
|
|
136
|
+
this.props.popper.destroy();
|
|
137
|
+
handleComment(this.node, this.view);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'Go to content',
|
|
142
|
+
icon: 'Scroll',
|
|
143
|
+
action: () => this.navigateToTarget(),
|
|
144
|
+
disabled: isOrphaned,
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
if (can?.editArticle) {
|
|
148
|
+
actions.unshift({
|
|
149
|
+
label: 'Edit',
|
|
150
|
+
icon: 'Edit',
|
|
151
|
+
action: () => this.handleEdit(),
|
|
152
|
+
disabled: isOrphaned,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
this.contextMenu = ReactSubView(this.props, ContextMenu, { actions }, this.node, this.getPos, this.view, ['context-menu']);
|
|
156
|
+
this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
|
|
157
|
+
};
|
|
158
|
+
this.navigateToTarget = () => {
|
|
159
|
+
this.props.popper.destroy();
|
|
160
|
+
const rids = this.node.attrs.rids;
|
|
161
|
+
if (!rids.length) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.props.navigate({
|
|
165
|
+
pathname: this.props.location.pathname,
|
|
166
|
+
hash: '#' + rids[0],
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
this.handleEdit = () => {
|
|
170
|
+
this.props.popper.destroy();
|
|
171
|
+
this.showPicker();
|
|
172
|
+
};
|
|
82
173
|
}
|
|
83
174
|
}
|
|
84
175
|
export default createEditableNodeView(CrossReferenceEditableView);
|
|
@@ -195,6 +195,9 @@ export class FigureEditableView extends FigureView {
|
|
|
195
195
|
this.addTools();
|
|
196
196
|
}
|
|
197
197
|
addTools() {
|
|
198
|
+
if (this.getPos() === undefined) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
198
201
|
this.manageReactTools();
|
|
199
202
|
const existingDragHandlers = this.container.querySelectorAll('.drag-handler');
|
|
200
203
|
existingDragHandlers.forEach((handler) => handler.remove());
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare const findPosBeforeFirstSubsection: ($pos: ManuscriptResolvedPos)
|
|
|
44
44
|
export declare const insertSectionLabel: (state: ManuscriptEditorState, dispatch?: Dispatch, currentTr?: Transaction) => boolean;
|
|
45
45
|
export declare const insertLink: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
46
46
|
export declare const insertInlineCitation: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
47
|
+
export declare const canInsertCrossReference: (state: ManuscriptEditorState) => boolean;
|
|
47
48
|
export declare const insertCrossReference: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
48
49
|
export declare const insertInlineEquation: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
49
50
|
export declare const insertTableElementFooter: (tr: Transaction, table: [ManuscriptNode, number]) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const FormFooter: ({ onCancel, primaryAction, }: {
|
|
2
|
+
declare const FormFooter: ({ onCancel, primaryAction, cancelLabel, }: {
|
|
3
3
|
onCancel: () => void;
|
|
4
4
|
primaryAction?: React.ReactNode;
|
|
5
|
+
cancelLabel?: string;
|
|
5
6
|
}) => React.JSX.Element;
|
|
6
7
|
export default FormFooter;
|
|
@@ -9,7 +9,7 @@ export interface CitationEditorProps {
|
|
|
9
9
|
sources: BibliographyItemSource[];
|
|
10
10
|
onCite: (items: BibliographyItemAttrs[]) => void;
|
|
11
11
|
onUncite: (id: string) => void;
|
|
12
|
-
onSave: (item: BibliographyItemAttrs) => void;
|
|
12
|
+
onSave: (item: BibliographyItemAttrs[]) => void;
|
|
13
13
|
onDelete: (item: BibliographyItemAttrs) => void;
|
|
14
14
|
onCancel: () => void;
|
|
15
15
|
canEdit: boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ImportBibliographyProps {
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
onContinue: (data: BibliographyItemAttrs[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ImportBibliography: React.FC<ImportBibliographyProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ImportReferencesConfirmationProps {
|
|
4
|
+
items: BibliographyItemAttrs[];
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
onConfirm: (items: BibliographyItemAttrs[]) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ImportReferencesConfirmation: React.FC<ImportReferencesConfirmationProps>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ReferencesModalProps } from './ReferencesModal';
|
|
3
|
-
export type ReferencesEditorProps = Omit<ReferencesModalProps, 'isOpen' | 'onCancel'
|
|
4
|
+
export type ReferencesEditorProps = Omit<ReferencesModalProps, 'isOpen' | 'onCancel' | 'handleImport' | 'onSave'> & {
|
|
5
|
+
onSave: (item: BibliographyItemAttrs[]) => void;
|
|
6
|
+
};
|
|
4
7
|
export declare const ReferencesEditor: React.FC<ReferencesEditorProps>;
|
|
@@ -8,5 +8,6 @@ export interface ReferencesModalProps {
|
|
|
8
8
|
citationCounts: Map<string, number>;
|
|
9
9
|
onSave: (item: BibliographyItemAttrs) => void;
|
|
10
10
|
onDelete: (item: BibliographyItemAttrs) => void;
|
|
11
|
+
handleImport: (data: BibliographyItemAttrs[]) => void;
|
|
11
12
|
}
|
|
12
13
|
export declare const ReferencesModal: React.FC<ReferencesModalProps>;
|
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Target } from '@manuscripts/transform';
|
|
17
17
|
import React from 'react';
|
|
18
|
+
import { FileAttachment } from '../../lib/files';
|
|
18
19
|
interface Props {
|
|
19
20
|
targets: Target[];
|
|
21
|
+
files: FileAttachment[];
|
|
20
22
|
handleSelect: (id: string, customLabel?: string) => void;
|
|
21
23
|
handleCancel: () => void;
|
|
22
24
|
currentTargetId?: string;
|
|
23
25
|
currentCustomLabel?: string;
|
|
26
|
+
isEdit?: boolean;
|
|
24
27
|
}
|
|
25
28
|
export declare const CrossReferenceItems: React.FC<Props>;
|
|
26
29
|
export {};
|
|
@@ -18,6 +18,7 @@ export type NodeWeblink = {
|
|
|
18
18
|
node: SupplementNode;
|
|
19
19
|
pos: number;
|
|
20
20
|
};
|
|
21
|
+
export declare const getSupplementCaptionTitle: (node: SupplementNode) => string;
|
|
21
22
|
export declare const getSupplementDisplayLabel: (node: SupplementNode, files: {
|
|
22
23
|
id: string;
|
|
23
24
|
name: string;
|
package/dist/types/lib/view.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ManuscriptEditorView, ManuscriptNodeType } from '@manuscripts/transform';
|
|
16
|
+
import { BibliographyItemAttrs, ManuscriptEditorView, ManuscriptNodeType } from '@manuscripts/transform';
|
|
17
17
|
import { Attrs } from 'prosemirror-model';
|
|
18
18
|
import * as utils from 'prosemirror-utils';
|
|
19
19
|
export declare const findChildByID: (view: ManuscriptEditorView, id: string) => utils.NodeWithPos | undefined;
|
|
@@ -22,3 +22,5 @@ export declare const findChildrenByType: (view: ManuscriptEditorView, type: Manu
|
|
|
22
22
|
export declare const findChildrenAttrsByType: <T extends Attrs>(view: ManuscriptEditorView, type: ManuscriptNodeType) => T[];
|
|
23
23
|
export declare const updateNodeAttrs: (view: ManuscriptEditorView, type: ManuscriptNodeType, attrs: Attrs) => boolean;
|
|
24
24
|
export declare const deleteNode: (view: ManuscriptEditorView, id: string) => void;
|
|
25
|
+
export declare const insertBibliographyItems: (view: ManuscriptEditorView, items: BibliographyItemAttrs[]) => void;
|
|
26
|
+
export declare const saveBibliographyItem: (view: ManuscriptEditorView, attrs: BibliographyItemAttrs[]) => void;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.16.
|
|
1
|
+
export declare const VERSION = "3.16.2";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
|
@@ -31,7 +31,6 @@ export declare class CitationEditableView extends CitationView {
|
|
|
31
31
|
private handleUncite;
|
|
32
32
|
private handleCite;
|
|
33
33
|
private handleDelete;
|
|
34
|
-
private insertBibliographyNode;
|
|
35
34
|
}
|
|
36
35
|
declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<CitationEditableView>;
|
|
37
36
|
export default _default;
|
|
@@ -17,12 +17,18 @@ import { Target } from '@manuscripts/transform';
|
|
|
17
17
|
import { CrossReferenceView } from './cross_reference';
|
|
18
18
|
export declare class CrossReferenceEditableView extends CrossReferenceView {
|
|
19
19
|
protected popperContainer: HTMLDivElement;
|
|
20
|
+
protected contextMenu: HTMLElement;
|
|
20
21
|
selectNode: () => void;
|
|
22
|
+
showPicker: () => void;
|
|
21
23
|
destroy: () => void;
|
|
22
24
|
deselectNode: () => void;
|
|
23
25
|
getTargets: () => Target[];
|
|
24
26
|
handleCancel: () => void;
|
|
25
27
|
handleSelect: (rid: string, label?: string) => Promise<void>;
|
|
28
|
+
handleClick: () => void;
|
|
29
|
+
showContextMenu: () => void;
|
|
30
|
+
private navigateToTarget;
|
|
31
|
+
private handleEdit;
|
|
26
32
|
}
|
|
27
33
|
declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<CrossReferenceEditableView>;
|
|
28
34
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/body-editor",
|
|
3
3
|
"description": "Prosemirror components for editing and viewing manuscripts",
|
|
4
|
-
"version": "3.16.
|
|
4
|
+
"version": "3.16.2",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@citation-js/plugin-pubmed": "0.3.0",
|
|
42
42
|
"@citation-js/plugin-ris": "0.7.18",
|
|
43
43
|
"@iarna/word-count": "1.1.2",
|
|
44
|
-
"@manuscripts/style-guide": "3.7.
|
|
44
|
+
"@manuscripts/style-guide": "3.7.1",
|
|
45
45
|
"@manuscripts/track-changes-plugin": "2.4.0",
|
|
46
|
-
"@manuscripts/transform": "4.5.
|
|
46
|
+
"@manuscripts/transform": "4.5.1",
|
|
47
47
|
"@popperjs/core": "2.11.8",
|
|
48
48
|
"citeproc": "2.4.63",
|
|
49
49
|
"codemirror": "5.65.19",
|
|
@@ -118,4 +118,4 @@
|
|
|
118
118
|
"engines": {
|
|
119
119
|
"node": ">=22"
|
|
120
120
|
}
|
|
121
|
-
}
|
|
121
|
+
}
|