@manuscripts/body-editor 3.16.1 → 3.16.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.
Files changed (63) hide show
  1. package/dist/cjs/components/references/CitationEditor.js +13 -19
  2. package/dist/cjs/components/references/ImportBibliography.js +77 -0
  3. package/dist/cjs/components/references/ImportBibliographyForm.js +1 -1
  4. package/dist/cjs/components/references/ImportBibliographyModal.js +12 -81
  5. package/dist/cjs/components/references/ImportReferencesConfirmation.js +113 -0
  6. package/dist/cjs/components/references/ImportSuccessPlaceholder.js +56 -0
  7. package/dist/cjs/components/references/ReferenceSearch.js +2 -5
  8. package/dist/cjs/components/references/ReferencesEditor.js +18 -2
  9. package/dist/cjs/components/references/ReferencesModal.js +86 -33
  10. package/dist/cjs/lib/view.js +39 -1
  11. package/dist/cjs/versions.js +1 -1
  12. package/dist/cjs/views/bibliography_element.js +1 -2
  13. package/dist/cjs/views/citation_editable.js +2 -29
  14. package/dist/cjs/views/equation.js +2 -0
  15. package/dist/cjs/views/equation_editable.js +2 -0
  16. package/dist/cjs/views/inline_equation.js +2 -0
  17. package/dist/cjs/views/inline_equation_editable.js +2 -0
  18. package/dist/es/components/references/CitationEditor.js +13 -19
  19. package/dist/es/components/references/ImportBibliography.js +70 -0
  20. package/dist/es/components/references/ImportBibliographyForm.js +1 -1
  21. package/dist/es/components/references/ImportBibliographyModal.js +13 -79
  22. package/dist/es/components/references/ImportReferencesConfirmation.js +73 -0
  23. package/dist/es/components/references/ImportSuccessPlaceholder.js +49 -0
  24. package/dist/es/components/references/ReferenceSearch.js +3 -6
  25. package/dist/es/components/references/ReferencesEditor.js +19 -3
  26. package/dist/es/components/references/ReferencesModal.js +88 -35
  27. package/dist/es/lib/view.js +36 -0
  28. package/dist/es/versions.js +1 -1
  29. package/dist/es/views/bibliography_element.js +2 -3
  30. package/dist/es/views/citation_editable.js +3 -30
  31. package/dist/es/views/equation.js +2 -0
  32. package/dist/es/views/equation_editable.js +2 -0
  33. package/dist/es/views/inline_equation.js +2 -0
  34. package/dist/es/views/inline_equation_editable.js +2 -0
  35. package/dist/types/components/references/CitationEditor.d.ts +1 -1
  36. package/dist/types/components/references/ImportBibliography.d.ts +7 -0
  37. package/dist/types/components/references/ImportReferencesConfirmation.d.ts +8 -0
  38. package/dist/types/components/references/ImportSuccessPlaceholder.d.ts +5 -0
  39. package/dist/types/components/references/ReferenceSearch.d.ts +0 -1
  40. package/dist/types/components/references/ReferencesEditor.d.ts +4 -1
  41. package/dist/types/components/references/ReferencesModal.d.ts +1 -0
  42. package/dist/types/lib/view.d.ts +3 -1
  43. package/dist/types/versions.d.ts +1 -1
  44. package/dist/types/views/citation_editable.d.ts +0 -1
  45. package/package.json +1 -1
  46. package/src/components/references/CitationEditor.tsx +16 -25
  47. package/src/components/references/ImportBibliography.tsx +119 -0
  48. package/src/components/references/ImportBibliographyForm.tsx +1 -1
  49. package/src/components/references/ImportBibliographyModal.tsx +34 -110
  50. package/src/components/references/ImportReferencesConfirmation.tsx +133 -0
  51. package/src/components/references/ImportSuccessPlaceholder.tsx +93 -0
  52. package/src/components/references/ReferenceSearch.tsx +0 -7
  53. package/src/components/references/ReferencesEditor.tsx +35 -6
  54. package/src/components/references/ReferencesModal.tsx +164 -78
  55. package/src/lib/view.ts +65 -0
  56. package/src/versions.ts +1 -1
  57. package/src/views/bibliography_element.ts +3 -4
  58. package/src/views/citation_editable.ts +5 -50
  59. package/src/views/equation.ts +5 -0
  60. package/src/views/equation_editable.ts +3 -0
  61. package/src/views/inline_equation.ts +5 -0
  62. package/src/views/inline_equation_editable.ts +3 -0
  63. package/styles/Editor.css +2 -1
@@ -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
- setSearching(false);
147
- setImporting(true);
148
- };
149
- const handleSaveImport = (data) => {
150
- data.forEach((item) => {
151
- const newItem = { ...item };
152
- newItem.id = (0, transform_1.generateNodeID)(transform_1.schema.nodes.bibliography_item);
153
- handleSave(newItem);
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, onImport: handleImport, onCite: (items) => {
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, onImport: handleImport, onCite: handleCite, onCancel: onCancel }));
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 }, "Save"))));
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 styled_components_1 = __importDefault(require("styled-components"));
43
- const ImportBibliographyForm_1 = require("./ImportBibliographyForm");
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 handleCancel = () => {
86
- handleClose();
87
- };
43
+ const [pendingItems, setPendingItems] = (0, react_1.useState)(null);
44
+ const isConfirming = pendingItems !== null;
88
45
  const handleClose = () => setOpen(false);
89
- const handleSave = (data) => {
90
- onSave(data);
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": "import-bibliography-modal" },
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": 640 },
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, onImport, onCite, onCancel, }) => {
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
- return (react_1.default.createElement(ReferencesModal_1.ReferencesModal, { ...props, isOpen: isOpen, onCancel: () => setOpen(false), items: items, onSave: handleSave, onDelete: handleDelete }));
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;