@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
package/dist/cjs/commands.js
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
exports.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = void 0;
|
|
18
|
+
exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTransGraphicalAbstract = exports.insertTransAbstract = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertHeadshotGrid = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.canInsertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertAttachment = exports.updateSupplementWeblink = exports.insertSupplementWeblink = exports.insertSupplement = exports.insertTable = exports.insertEmbed = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
|
|
19
|
+
exports.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = void 0;
|
|
20
20
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
21
21
|
const transform_1 = require("@manuscripts/transform");
|
|
22
22
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
@@ -315,7 +315,7 @@ exports.insertSupplement = insertSupplement;
|
|
|
315
315
|
const insertSupplementWeblink = (url, title, view) => {
|
|
316
316
|
const supplement = transform_1.schema.nodes.supplement.createAndFill({
|
|
317
317
|
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.supplement),
|
|
318
|
-
href: url
|
|
318
|
+
href: url,
|
|
319
319
|
}, createAndFillCaption());
|
|
320
320
|
const tr = view.state.tr;
|
|
321
321
|
const { pos } = (0, doc_1.upsertSupplementsSection)(tr, supplement);
|
|
@@ -493,15 +493,53 @@ const insertInlineCitation = (state, dispatch) => {
|
|
|
493
493
|
return true;
|
|
494
494
|
};
|
|
495
495
|
exports.insertInlineCitation = insertInlineCitation;
|
|
496
|
+
const canInsertCrossReference = (state) => {
|
|
497
|
+
if (!(0, exports.canInsert)(transform_1.schema.nodes.cross_reference)(state)) {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
const { from, to, empty, $from, $to } = state.selection;
|
|
501
|
+
if (empty) {
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
if (!$from.sameParent($to)) {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
let overlaps = false;
|
|
508
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
509
|
+
if (node.isAtom && !node.isText) {
|
|
510
|
+
overlaps = true;
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
return !overlaps;
|
|
514
|
+
});
|
|
515
|
+
return !overlaps;
|
|
516
|
+
};
|
|
517
|
+
exports.canInsertCrossReference = canInsertCrossReference;
|
|
496
518
|
const insertCrossReference = (state, dispatch) => {
|
|
519
|
+
if (!(0, exports.canInsertCrossReference)(state)) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
const text = selectedText();
|
|
497
523
|
const node = state.schema.nodes.cross_reference.create({
|
|
524
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.cross_reference),
|
|
498
525
|
rids: [],
|
|
526
|
+
label: text,
|
|
499
527
|
});
|
|
500
|
-
const
|
|
501
|
-
|
|
528
|
+
const { tr } = state;
|
|
529
|
+
let pos;
|
|
530
|
+
const isWrap = !state.selection.empty;
|
|
531
|
+
if (isWrap) {
|
|
532
|
+
pos = state.selection.from;
|
|
533
|
+
tr.replaceSelectionWith(node);
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
pos = state.selection.to;
|
|
537
|
+
tr.insert(pos, node);
|
|
538
|
+
}
|
|
502
539
|
if (dispatch) {
|
|
503
540
|
const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
|
|
504
|
-
|
|
541
|
+
tr.setSelection(selection).scrollIntoView();
|
|
542
|
+
dispatch(isWrap ? (0, track_changes_plugin_1.skipTracking)(tr) : tr);
|
|
505
543
|
}
|
|
506
544
|
return true;
|
|
507
545
|
};
|
|
@@ -1009,10 +1047,7 @@ const insertTransGraphicalAbstract = (category, insertAfterPos) => (state, dispa
|
|
|
1009
1047
|
const node = transform_1.schema.nodes.trans_graphical_abstract.createAndFill({
|
|
1010
1048
|
lang,
|
|
1011
1049
|
category: category.id,
|
|
1012
|
-
}, [
|
|
1013
|
-
transform_1.schema.nodes.section_title.create(),
|
|
1014
|
-
createAndFillFigureElement(state),
|
|
1015
|
-
]);
|
|
1050
|
+
}, [transform_1.schema.nodes.section_title.create(), createAndFillFigureElement(state)]);
|
|
1016
1051
|
const tr = state.tr.insert(pos, node);
|
|
1017
1052
|
if (node.lastChild) {
|
|
1018
1053
|
(0, accessibility_element_1.expandAccessibilitySection)(tr, node.lastChild);
|
|
@@ -21,9 +21,9 @@ const Footer = styled_components_1.default.div `
|
|
|
21
21
|
const StyledIconTextButton = (0, styled_components_1.default)(style_guide_1.IconTextButton) `
|
|
22
22
|
color: ${(props) => props.theme.colors.brand.default};
|
|
23
23
|
`;
|
|
24
|
-
const FormFooter = ({ onCancel, primaryAction, }) => {
|
|
24
|
+
const FormFooter = ({ onCancel, primaryAction, cancelLabel = 'Close', }) => {
|
|
25
25
|
return (react_1.default.createElement(Footer, null,
|
|
26
|
-
react_1.default.createElement(StyledIconTextButton, { color: "secondary", onClick: onCancel },
|
|
26
|
+
react_1.default.createElement(StyledIconTextButton, { color: "secondary", onClick: onCancel }, cancelLabel),
|
|
27
27
|
primaryAction));
|
|
28
28
|
};
|
|
29
29
|
exports.default = FormFooter;
|
|
@@ -79,7 +79,8 @@ const ShortcutTabs = (0, styled_components_1.default)(style_guide_1.InspectorTab
|
|
|
79
79
|
min-height: 0;
|
|
80
80
|
`;
|
|
81
81
|
const ModalTabsWrapper = (0, styled_components_1.default)('div') `
|
|
82
|
-
margin: 0 ${(props) => props.theme.grid.unit * 8}px
|
|
82
|
+
margin: 0 ${(props) => props.theme.grid.unit * 8}px
|
|
83
|
+
${(props) => props.theme.grid.unit * 3}px;
|
|
83
84
|
`;
|
|
84
85
|
const ShortcutTabPanel = (0, styled_components_1.default)(style_guide_1.InspectorTabPanel).attrs({
|
|
85
86
|
tabIndex: -1,
|
|
@@ -130,7 +131,8 @@ const Section = styled_components_1.default.section `
|
|
|
130
131
|
}
|
|
131
132
|
`;
|
|
132
133
|
const SectionTitle = styled_components_1.default.h3 `
|
|
133
|
-
margin: 0 ${(props) => props.theme.grid.unit * 8}px
|
|
134
|
+
margin: 0 ${(props) => props.theme.grid.unit * 8}px
|
|
135
|
+
${(props) => props.theme.grid.unit * 2}px;
|
|
134
136
|
font-size: ${(props) => props.theme.font.size.large};
|
|
135
137
|
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
136
138
|
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
@@ -44,7 +44,6 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
44
44
|
const array_reducer_1 = require("../../lib/array-reducer");
|
|
45
45
|
const utils_1 = require("../../lib/utils");
|
|
46
46
|
const CitationViewer_1 = require("./CitationViewer");
|
|
47
|
-
const ImportBibliographyModal_1 = require("./ImportBibliographyModal");
|
|
48
47
|
const ReferenceLine_1 = require("./ReferenceLine");
|
|
49
48
|
const ReferenceSearch_1 = require("./ReferenceSearch");
|
|
50
49
|
const ReferencesModal_1 = require("./ReferencesModal");
|
|
@@ -94,7 +93,7 @@ const CitationEditor = ({ query, rids: $rids, items: $items, citationCounts, sou
|
|
|
94
93
|
const [rids, dispatchRids] = (0, react_1.useReducer)(ridsReducer, $rids);
|
|
95
94
|
const handleSave = (item) => {
|
|
96
95
|
const cleanedItem = (0, utils_1.cleanItemValues)(item);
|
|
97
|
-
onSave(cleanedItem);
|
|
96
|
+
onSave([cleanedItem]);
|
|
98
97
|
dispatchItems({
|
|
99
98
|
type: 'update',
|
|
100
99
|
items: [cleanedItem],
|
|
@@ -129,7 +128,6 @@ const CitationEditor = ({ query, rids: $rids, items: $items, citationCounts, sou
|
|
|
129
128
|
show: false,
|
|
130
129
|
});
|
|
131
130
|
const [searching, setSearching] = (0, react_1.useState)(false);
|
|
132
|
-
const [importing, setImporting] = (0, react_1.useState)(false);
|
|
133
131
|
const handleAdd = () => {
|
|
134
132
|
setSearching(false);
|
|
135
133
|
const item = {
|
|
@@ -142,35 +140,31 @@ const CitationEditor = ({ query, rids: $rids, items: $items, citationCounts, sou
|
|
|
142
140
|
});
|
|
143
141
|
setEditingForm({ show: true, item: item });
|
|
144
142
|
};
|
|
145
|
-
const handleImport = () => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
handleCite([newItem]);
|
|
143
|
+
const handleImport = (data) => {
|
|
144
|
+
const newItems = data.map((item) => (0, utils_1.cleanItemValues)({
|
|
145
|
+
...item,
|
|
146
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.bibliography_item),
|
|
147
|
+
}));
|
|
148
|
+
onSave(newItems);
|
|
149
|
+
dispatchItems({
|
|
150
|
+
type: 'set',
|
|
151
|
+
state: [...items, ...newItems],
|
|
155
152
|
});
|
|
156
153
|
};
|
|
157
154
|
const cited = (0, react_1.useMemo)(() => {
|
|
158
155
|
return rids.flatMap((rid) => items.filter((i) => i.id === rid));
|
|
159
156
|
}, [rids, items]);
|
|
160
157
|
if (editingForm.show) {
|
|
161
|
-
return (react_1.default.createElement(ReferencesModal_1.ReferencesModal, { isOpen: editingForm.show, onCancel: () => setEditingForm({ show: false }), items: items, citationCounts: citationCounts, item: editingForm.item, onSave: handleSave, onDelete: handleDelete }));
|
|
162
|
-
}
|
|
163
|
-
if (importing) {
|
|
164
|
-
return (react_1.default.createElement(ImportBibliographyModal_1.ImportBibliographyModal, { onCancel: () => setImporting(false), onSave: handleSaveImport }));
|
|
158
|
+
return (react_1.default.createElement(ReferencesModal_1.ReferencesModal, { isOpen: editingForm.show, onCancel: () => setEditingForm({ show: false }), items: items, citationCounts: citationCounts, item: editingForm.item, onSave: handleSave, onDelete: handleDelete, handleImport: handleImport }));
|
|
165
159
|
}
|
|
166
160
|
if (searching) {
|
|
167
|
-
return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd,
|
|
161
|
+
return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onCite: (items) => {
|
|
168
162
|
setSearching(false);
|
|
169
163
|
handleCite(items);
|
|
170
164
|
}, onCancel: () => setSearching(false) }));
|
|
171
165
|
}
|
|
172
166
|
if (!rids.length) {
|
|
173
|
-
return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd,
|
|
167
|
+
return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onCite: handleCite, onCancel: onCancel }));
|
|
174
168
|
}
|
|
175
169
|
return (react_1.default.createElement(Container, null,
|
|
176
170
|
react_1.default.createElement(style_guide_1.Dialog, { isOpen: deleteDialog.show, category: style_guide_1.Category.confirmation, header: "Remove cited item", message: "Are you sure you want to remove this cited item? It will still exist in the reference list.", actions: {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ImportBibliography = void 0;
|
|
7
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const ImportBibliographyForm_1 = require("./ImportBibliographyForm");
|
|
11
|
+
const exampleBibtex = `@book{abramowitz+stegun,
|
|
12
|
+
author = "Milton {Abramowitz} and Irene A. {Stegun}",
|
|
13
|
+
title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables",
|
|
14
|
+
publisher = "Dover",
|
|
15
|
+
year = 1964,
|
|
16
|
+
address = "New York City",
|
|
17
|
+
edition = "ninth Dover printing, tenth GPO printing"
|
|
18
|
+
}`;
|
|
19
|
+
const examplePubmed = `Example Identifiers:
|
|
20
|
+
pmid:17170128
|
|
21
|
+
PMC1852221`;
|
|
22
|
+
const exampleRis = `TY - JOUR
|
|
23
|
+
AU - Shannon, Claude E.
|
|
24
|
+
PY - 1948
|
|
25
|
+
DA - July
|
|
26
|
+
TI - A Mathematical Theory of Communication
|
|
27
|
+
T2 - Bell System Technical Journal
|
|
28
|
+
SP - 379
|
|
29
|
+
EP - 423
|
|
30
|
+
VL - 27
|
|
31
|
+
ER - `;
|
|
32
|
+
const exampleEnw = `%0 Journal Article
|
|
33
|
+
%D 2018
|
|
34
|
+
%@ 0903-4641
|
|
35
|
+
%A Abbassi-Daloii, Tooba
|
|
36
|
+
%A Yousefi, Soheil
|
|
37
|
+
%A Sekhavati, Mohammad Hadi
|
|
38
|
+
%A Tahmoorespur, Mojtaba
|
|
39
|
+
%J APMIS
|
|
40
|
+
%N 1
|
|
41
|
+
%P 65-75
|
|
42
|
+
%T Impact of heat shock protein 60KD in combination with outer membrane proteins on immune response against Brucella melitensis
|
|
43
|
+
%R https://doi.org/10.1111/apm.12778
|
|
44
|
+
%U https://onlinelibrary.wiley.com/doi/abs/10.1111/apm.12778
|
|
45
|
+
%V 126
|
|
46
|
+
%X Lorem ipsum dolor sit amet`;
|
|
47
|
+
const exampleDoi = `Example DOI Identifiers:
|
|
48
|
+
10.1080/15588742.2015.1017684
|
|
49
|
+
http://dx.doi.org/10.1080/15588742.2015.1017684`;
|
|
50
|
+
const supportedFormats = [
|
|
51
|
+
{ label: 'BibTex', example: exampleBibtex },
|
|
52
|
+
{ label: 'PubMed', example: examplePubmed },
|
|
53
|
+
{ label: 'RIS', example: exampleRis },
|
|
54
|
+
{ label: 'ENW', example: exampleEnw },
|
|
55
|
+
{ label: 'DOI', example: exampleDoi },
|
|
56
|
+
];
|
|
57
|
+
const ImportBibliography = ({ onCancel, onContinue, }) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
58
|
+
react_1.default.createElement(style_guide_1.ModalTitle, null, "Import Bibliography"),
|
|
59
|
+
react_1.default.createElement("p", null,
|
|
60
|
+
supportedFormats.map(({ label, example }, index) => (react_1.default.createElement(react_1.default.Fragment, { key: label },
|
|
61
|
+
index > 0 &&
|
|
62
|
+
(index === supportedFormats.length - 1 ? ' and ' : ', '),
|
|
63
|
+
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": example }, label)))),
|
|
64
|
+
' ',
|
|
65
|
+
"formats are supported"),
|
|
66
|
+
react_1.default.createElement(ImportBibliographyForm_1.ImportBibliographyForm, { onCancel: onCancel, onSave: onContinue }),
|
|
67
|
+
react_1.default.createElement(Example, { id: "import-example-tooltip", place: "bottom", render: (s) => react_1.default.createElement("pre", null, s.content) })));
|
|
68
|
+
exports.ImportBibliography = ImportBibliography;
|
|
69
|
+
const SpanWithExample = styled_components_1.default.span `
|
|
70
|
+
text-decoration: underline dotted;
|
|
71
|
+
text-underline-offset: 4px;
|
|
72
|
+
`;
|
|
73
|
+
const Example = (0, styled_components_1.default)(style_guide_1.Tooltip) `
|
|
74
|
+
text-align: left !important;
|
|
75
|
+
max-width: 480px !important;
|
|
76
|
+
overflow: hidden !important;
|
|
77
|
+
`;
|
|
@@ -142,7 +142,7 @@ const ImportBibliographyForm = ({ onCancel, onSave, }) => {
|
|
|
142
142
|
formik.values.data.map((item) => (react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item, key: item.id })))),
|
|
143
143
|
react_1.default.createElement(style_guide_1.FormActionsBar, null,
|
|
144
144
|
react_1.default.createElement(style_guide_1.SecondaryButton, { type: "reset" }, "Cancel"),
|
|
145
|
-
react_1.default.createElement(style_guide_1.PrimaryButton, { type: "submit", disabled: !formik.dirty || formik.isSubmitting || !formik.values.data.length }, "
|
|
145
|
+
react_1.default.createElement(style_guide_1.PrimaryButton, { type: "submit", disabled: !formik.dirty || formik.isSubmitting || !formik.values.data.length }, "Import References"))));
|
|
146
146
|
};
|
|
147
147
|
exports.ImportBibliographyForm = ImportBibliographyForm;
|
|
148
148
|
const Preview = styled_components_1.default.div `
|
|
@@ -32,97 +32,28 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.ImportBibliographyModal = void 0;
|
|
40
37
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
41
38
|
const react_1 = __importStar(require("react"));
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const exampleBibtex = `@book{abramowitz+stegun,
|
|
45
|
-
author = "Milton {Abramowitz} and Irene A. {Stegun}",
|
|
46
|
-
title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables",
|
|
47
|
-
publisher = "Dover",
|
|
48
|
-
year = 1964,
|
|
49
|
-
address = "New York City",
|
|
50
|
-
edition = "ninth Dover printing, tenth GPO printing"
|
|
51
|
-
}`;
|
|
52
|
-
const examplePubmed = `Example Identifiers:
|
|
53
|
-
pmid:17170128
|
|
54
|
-
PMC1852221`;
|
|
55
|
-
const exampleRis = `TY - JOUR
|
|
56
|
-
AU - Shannon, Claude E.
|
|
57
|
-
PY - 1948
|
|
58
|
-
DA - July
|
|
59
|
-
TI - A Mathematical Theory of Communication
|
|
60
|
-
T2 - Bell System Technical Journal
|
|
61
|
-
SP - 379
|
|
62
|
-
EP - 423
|
|
63
|
-
VL - 27
|
|
64
|
-
ER - `;
|
|
65
|
-
const exampleEnw = `%0 Journal Article
|
|
66
|
-
%D 2018
|
|
67
|
-
%@ 0903-4641
|
|
68
|
-
%A Abbassi-Daloii, Tooba
|
|
69
|
-
%A Yousefi, Soheil
|
|
70
|
-
%A Sekhavati, Mohammad Hadi
|
|
71
|
-
%A Tahmoorespur, Mojtaba
|
|
72
|
-
%J APMIS
|
|
73
|
-
%N 1
|
|
74
|
-
%P 65-75
|
|
75
|
-
%T Impact of heat shock protein 60KD in combination with outer membrane proteins on immune response against Brucella melitensis
|
|
76
|
-
%R https://doi.org/10.1111/apm.12778
|
|
77
|
-
%U https://onlinelibrary.wiley.com/doi/abs/10.1111/apm.12778
|
|
78
|
-
%V 126
|
|
79
|
-
%X Lorem ipsum dolor sit amet`;
|
|
80
|
-
const exampleDoi = `Example DOI Identifiers:
|
|
81
|
-
10.1080/15588742.2015.1017684
|
|
82
|
-
http://dx.doi.org/10.1080/15588742.2015.1017684`;
|
|
39
|
+
const ImportBibliography_1 = require("./ImportBibliography");
|
|
40
|
+
const ImportReferencesConfirmation_1 = require("./ImportReferencesConfirmation");
|
|
83
41
|
const ImportBibliographyModal = ({ onCancel, onSave }) => {
|
|
84
42
|
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
};
|
|
43
|
+
const [pendingItems, setPendingItems] = (0, react_1.useState)(null);
|
|
44
|
+
const isConfirming = pendingItems !== null;
|
|
88
45
|
const handleClose = () => setOpen(false);
|
|
89
|
-
const
|
|
90
|
-
|
|
46
|
+
const handleBack = () => setPendingItems(null);
|
|
47
|
+
const handleConfirm = (items) => {
|
|
48
|
+
onSave(items);
|
|
91
49
|
handleClose();
|
|
92
50
|
};
|
|
93
51
|
return (react_1.default.createElement(style_guide_1.StyledModal, { isOpen: isOpen, onRequestClose: onCancel },
|
|
94
|
-
react_1.default.createElement(style_guide_1.ModalContainer, { "data-cy":
|
|
52
|
+
react_1.default.createElement(style_guide_1.ModalContainer, { "data-cy": isConfirming
|
|
53
|
+
? 'import-confirmation-modal'
|
|
54
|
+
: 'import-bibliography-modal' },
|
|
95
55
|
react_1.default.createElement(style_guide_1.ModalHeader, null,
|
|
96
|
-
react_1.default.createElement(style_guide_1.CloseButton, { onClick: onCancel, "data-cy": "modal-close-button" })),
|
|
97
|
-
react_1.default.createElement(style_guide_1.ModalCardBody, { "$width":
|
|
98
|
-
react_1.default.createElement(style_guide_1.ModalTitle, null, "Import Bibliography"),
|
|
99
|
-
react_1.default.createElement("p", null,
|
|
100
|
-
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": exampleBibtex }, "BibTex"),
|
|
101
|
-
",",
|
|
102
|
-
' ',
|
|
103
|
-
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": examplePubmed }, "PubMed"),
|
|
104
|
-
",",
|
|
105
|
-
' ',
|
|
106
|
-
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": exampleRis }, "RIS"),
|
|
107
|
-
",",
|
|
108
|
-
' ',
|
|
109
|
-
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": exampleEnw }, "ENW"),
|
|
110
|
-
' ',
|
|
111
|
-
"and",
|
|
112
|
-
' ',
|
|
113
|
-
react_1.default.createElement(SpanWithExample, { "data-tooltip-id": "import-example-tooltip", "data-tooltip-content": exampleDoi }, "DOI"),
|
|
114
|
-
' ',
|
|
115
|
-
"formats are supported"),
|
|
116
|
-
react_1.default.createElement(ImportBibliographyForm_1.ImportBibliographyForm, { onCancel: handleCancel, onSave: handleSave }),
|
|
117
|
-
react_1.default.createElement(Example, { id: "import-example-tooltip", place: "bottom", render: (s) => react_1.default.createElement("pre", null, s.content) })))));
|
|
56
|
+
react_1.default.createElement(style_guide_1.CloseButton, { onClick: isConfirming ? handleBack : onCancel, "data-cy": "modal-close-button" })),
|
|
57
|
+
react_1.default.createElement(style_guide_1.ModalCardBody, { "$width": 724 }, pendingItems ? (react_1.default.createElement(ImportReferencesConfirmation_1.ImportReferencesConfirmation, { items: pendingItems, onCancel: handleBack, onConfirm: handleConfirm })) : (react_1.default.createElement(ImportBibliography_1.ImportBibliography, { onCancel: onCancel, onContinue: setPendingItems }))))));
|
|
118
58
|
};
|
|
119
59
|
exports.ImportBibliographyModal = ImportBibliographyModal;
|
|
120
|
-
const SpanWithExample = styled_components_1.default.span `
|
|
121
|
-
text-decoration: underline dotted;
|
|
122
|
-
text-underline-offset: 4px;
|
|
123
|
-
`;
|
|
124
|
-
const Example = (0, styled_components_1.default)(style_guide_1.Tooltip) `
|
|
125
|
-
text-align: left !important;
|
|
126
|
-
max-width: 480px !important;
|
|
127
|
-
overflow: hidden !important;
|
|
128
|
-
`;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ImportReferencesConfirmation = void 0;
|
|
40
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
43
|
+
const ReferenceLine_1 = require("./ReferenceLine");
|
|
44
|
+
const ImportReferencesConfirmation = ({ items, onCancel, onConfirm }) => {
|
|
45
|
+
const [selected, setSelected] = (0, react_1.useState)(() => items.map(() => true));
|
|
46
|
+
const selectedCount = selected.filter(Boolean).length;
|
|
47
|
+
const countLabel = selectedCount === 1 ? 'reference' : 'references';
|
|
48
|
+
const toggleItem = (index) => {
|
|
49
|
+
setSelected((current) => current.map((value, i) => (i === index ? !value : value)));
|
|
50
|
+
};
|
|
51
|
+
const handleConfirm = () => {
|
|
52
|
+
onConfirm(items.filter((_, index) => selected[index]));
|
|
53
|
+
};
|
|
54
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
|
+
react_1.default.createElement(Title, null, "Import References"),
|
|
56
|
+
react_1.default.createElement(Subtitle, null,
|
|
57
|
+
"Importing ",
|
|
58
|
+
selectedCount,
|
|
59
|
+
" ",
|
|
60
|
+
countLabel),
|
|
61
|
+
react_1.default.createElement(List, null, items.map((item, index) => (react_1.default.createElement(ListItem, { key: index },
|
|
62
|
+
react_1.default.createElement(ItemCheckbox, null,
|
|
63
|
+
react_1.default.createElement(style_guide_1.CheckboxField, { checked: selected[index], "aria-label": `Select reference ${index + 1}`, onChange: () => toggleItem(index) }),
|
|
64
|
+
react_1.default.createElement("div", null)),
|
|
65
|
+
react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item }))))),
|
|
66
|
+
react_1.default.createElement(style_guide_1.FormActionsBar, null,
|
|
67
|
+
react_1.default.createElement(style_guide_1.SecondaryButton, { type: "button", onClick: onCancel }, "Cancel"),
|
|
68
|
+
react_1.default.createElement(style_guide_1.PrimaryButton, { type: "button", disabled: selectedCount === 0, onClick: handleConfirm },
|
|
69
|
+
"Import ",
|
|
70
|
+
selectedCount,
|
|
71
|
+
" ",
|
|
72
|
+
countLabel))));
|
|
73
|
+
};
|
|
74
|
+
exports.ImportReferencesConfirmation = ImportReferencesConfirmation;
|
|
75
|
+
const Title = (0, styled_components_1.default)(style_guide_1.ModalTitle) `
|
|
76
|
+
border-bottom: 1px solid ${(props) => props.theme.colors.border.secondary};
|
|
77
|
+
margin: 0 -${(props) => 6 * props.theme.grid.unit}px 20px;
|
|
78
|
+
padding: 0 ${(props) => 6 * props.theme.grid.unit}px
|
|
79
|
+
${(props) => props.theme.grid.unit * 4}px;
|
|
80
|
+
`;
|
|
81
|
+
const Subtitle = styled_components_1.default.p `
|
|
82
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
83
|
+
font-weight: ${(props) => props.theme.font.weight.bold};
|
|
84
|
+
margin: 0 0 16px;
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
`;
|
|
87
|
+
const List = styled_components_1.default.div `
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
margin-bottom: ${(props) => props.theme.grid.unit * 5}px;
|
|
91
|
+
overflow-y: auto;
|
|
92
|
+
`;
|
|
93
|
+
const ListItem = styled_components_1.default.div `
|
|
94
|
+
border-bottom: 1px solid ${(props) => props.theme.colors.border.secondary};
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: flex-start;
|
|
97
|
+
gap: ${(props) => props.theme.grid.unit * 3}px;
|
|
98
|
+
padding: ${(props) => props.theme.grid.unit * 3}px 0;
|
|
99
|
+
`;
|
|
100
|
+
const ItemCheckbox = (0, styled_components_1.default)(style_guide_1.CheckboxLabel) `
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
|
|
103
|
+
> div {
|
|
104
|
+
margin: 0;
|
|
105
|
+
|
|
106
|
+
&::before {
|
|
107
|
+
width: 18px;
|
|
108
|
+
height: 18px;
|
|
109
|
+
border-radius: 4px;
|
|
110
|
+
margin: 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ImportSuccessPlaceholder = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const ImportSuccessPlaceholder = ({ count }) => {
|
|
10
|
+
const countLabel = count === 1 ? 'reference' : 'references';
|
|
11
|
+
return (react_1.default.createElement(Container, { "data-cy": "import-success-placeholder" },
|
|
12
|
+
react_1.default.createElement(IconCircle, null,
|
|
13
|
+
react_1.default.createElement(SuccessCheckIcon, null)),
|
|
14
|
+
react_1.default.createElement(Title, null, "Successfully Imported"),
|
|
15
|
+
react_1.default.createElement(Message, null,
|
|
16
|
+
"Your library has been updated with ",
|
|
17
|
+
count,
|
|
18
|
+
" new ",
|
|
19
|
+
countLabel,
|
|
20
|
+
".")));
|
|
21
|
+
};
|
|
22
|
+
exports.ImportSuccessPlaceholder = ImportSuccessPlaceholder;
|
|
23
|
+
const SuccessCheckIcon = () => (react_1.default.createElement("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
24
|
+
react_1.default.createElement("path", { d: "M26.6656 8L12.0004 22.6656L5.3344 15.9994", stroke: "#36B260", strokeWidth: "3", strokeLinecap: "round" })));
|
|
25
|
+
const Container = styled_components_1.default.div `
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
gap: ${(props) => props.theme.grid.unit * 4}px;
|
|
31
|
+
height: 100%;
|
|
32
|
+
padding: 40px;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
text-align: center;
|
|
35
|
+
`;
|
|
36
|
+
const IconCircle = styled_components_1.default.div `
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 64px;
|
|
41
|
+
height: 64px;
|
|
42
|
+
border-radius: 32px;
|
|
43
|
+
background: #f6ffed;
|
|
44
|
+
`;
|
|
45
|
+
const Title = styled_components_1.default.h2 `
|
|
46
|
+
margin: 0;
|
|
47
|
+
font-size: 24px;
|
|
48
|
+
line-height: 32px;
|
|
49
|
+
letter-spacing: -0.37px;
|
|
50
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
51
|
+
`;
|
|
52
|
+
const Message = styled_components_1.default.p `
|
|
53
|
+
margin: 0;
|
|
54
|
+
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
55
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
56
|
+
`;
|
|
@@ -89,7 +89,7 @@ const AddReferenceActions = (0, styled_components_1.default)(style_guide_1.Butto
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
`;
|
|
92
|
-
const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd,
|
|
92
|
+
const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onCite, onCancel, }) => {
|
|
93
93
|
const [query, setQuery] = (0, react_1.useState)(initialQuery || '');
|
|
94
94
|
const [selections, setSelections] = (0, react_1.useState)(new Map());
|
|
95
95
|
const toggleSelection = (item) => {
|
|
@@ -125,10 +125,7 @@ const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onImport,
|
|
|
125
125
|
react_1.default.createElement(AddReferenceActions, null,
|
|
126
126
|
react_1.default.createElement(style_guide_1.IconTextButton, { onClick: onAdd },
|
|
127
127
|
react_1.default.createElement(style_guide_1.AddNewIcon, null),
|
|
128
|
-
"Add new"),
|
|
129
|
-
react_1.default.createElement(style_guide_1.IconTextButton, { onClick: onImport },
|
|
130
|
-
react_1.default.createElement(style_guide_1.UploadIcon, null),
|
|
131
|
-
"Import new")),
|
|
128
|
+
"Add new")),
|
|
132
129
|
react_1.default.createElement(style_guide_1.ButtonGroup, null,
|
|
133
130
|
react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Close"),
|
|
134
131
|
react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 }, "Cite")))));
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ReferencesEditor = void 0;
|
|
37
|
+
const transform_1 = require("@manuscripts/transform");
|
|
37
38
|
const react_1 = __importStar(require("react"));
|
|
38
39
|
const array_reducer_1 = require("../../lib/array-reducer");
|
|
39
40
|
const utils_1 = require("../../lib/utils");
|
|
@@ -42,9 +43,13 @@ const itemsReducer = (0, array_reducer_1.attrsReducer)();
|
|
|
42
43
|
const ReferencesEditor = (props) => {
|
|
43
44
|
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
44
45
|
const [items, dispatch] = (0, react_1.useReducer)(itemsReducer, props.items);
|
|
46
|
+
const [selectedItem, setSelectedItem] = (0, react_1.useState)(props.item);
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
setSelectedItem(props.item);
|
|
49
|
+
}, [props.item]);
|
|
45
50
|
const handleSave = (item) => {
|
|
46
51
|
const cleanedItem = (0, utils_1.cleanItemValues)(item);
|
|
47
|
-
props.onSave(cleanedItem);
|
|
52
|
+
props.onSave([cleanedItem]);
|
|
48
53
|
dispatch({
|
|
49
54
|
type: 'update',
|
|
50
55
|
items: [cleanedItem],
|
|
@@ -57,6 +62,17 @@ const ReferencesEditor = (props) => {
|
|
|
57
62
|
item: item,
|
|
58
63
|
});
|
|
59
64
|
};
|
|
60
|
-
|
|
65
|
+
const handleImport = (data) => {
|
|
66
|
+
const newItems = data.map((item) => (0, utils_1.cleanItemValues)({
|
|
67
|
+
...item,
|
|
68
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.bibliography_item),
|
|
69
|
+
}));
|
|
70
|
+
props.onSave(newItems);
|
|
71
|
+
dispatch({
|
|
72
|
+
type: 'set',
|
|
73
|
+
state: [...items, ...newItems],
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return (react_1.default.createElement(ReferencesModal_1.ReferencesModal, { isOpen: isOpen, onCancel: () => setOpen(false), items: items, item: selectedItem, citationCounts: props.citationCounts, onSave: handleSave, onDelete: handleDelete, handleImport: handleImport }));
|
|
61
77
|
};
|
|
62
78
|
exports.ReferencesEditor = ReferencesEditor;
|