@manuscripts/body-editor 2.8.17 → 2.8.18

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.
@@ -15,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.isCommentingAllowed = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.insertEmbed = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
- exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = void 0;
18
+ exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.isCommentingAllowed = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertAttachment = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.insertEmbed = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
+ exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = void 0;
20
20
  const json_schema_1 = require("@manuscripts/json-schema");
21
21
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
22
22
  const transform_1 = require("@manuscripts/transform");
@@ -265,6 +265,29 @@ const insertSupplement = (file, state, dispatch) => {
265
265
  return true;
266
266
  };
267
267
  exports.insertSupplement = insertSupplement;
268
+ const insertAttachment = (file, state, type, dispatch) => {
269
+ const tr = state.tr;
270
+ const attachments = (0, doc_1.insertAttachmentsNode)(tr);
271
+ if (!attachments) {
272
+ return false;
273
+ }
274
+ if (attachments.node.childCount > 0) {
275
+ const startPos = attachments.pos + 1;
276
+ const endPos = attachments.pos + attachments.node.nodeSize - 1;
277
+ tr.delete(startPos, endPos);
278
+ }
279
+ const attachment = transform_1.schema.nodes.attachment.createAndFill({
280
+ id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.attachment),
281
+ href: file.id,
282
+ type: type,
283
+ });
284
+ tr.insert(attachments.pos + 1, attachment);
285
+ if (dispatch) {
286
+ dispatch((0, track_changes_plugin_1.skipTracking)(tr));
287
+ }
288
+ return true;
289
+ };
290
+ exports.insertAttachment = insertAttachment;
268
291
  const insertBlock = (nodeType) => (state, dispatch) => {
269
292
  const position = findBlockInsertPosition(state);
270
293
  if (position === null) {
@@ -33,7 +33,6 @@ const react_1 = __importStar(require("react"));
33
33
  const styled_components_1 = __importDefault(require("styled-components"));
34
34
  const array_reducer_1 = require("../../lib/array-reducer");
35
35
  const CitationViewer_1 = require("./CitationViewer");
36
- const ImportBibliographyModal_1 = require("./ImportBibliographyModal");
37
36
  const ReferenceLine_1 = require("./ReferenceLine");
38
37
  const ReferenceSearch_1 = require("./ReferenceSearch");
39
38
  const ReferencesModal_1 = require("./ReferencesModal");
@@ -113,7 +112,6 @@ const CitationEditor = ({ query, rids: $rids, items: $items, citationCounts, sou
113
112
  show: false,
114
113
  });
115
114
  const [searching, setSearching] = (0, react_1.useState)(false);
116
- const [importing, setImporting] = (0, react_1.useState)(false);
117
115
  const handleAdd = () => {
118
116
  setSearching(false);
119
117
  const item = {
@@ -124,32 +122,17 @@ const CitationEditor = ({ query, rids: $rids, items: $items, citationCounts, sou
124
122
  handleCite([item]);
125
123
  setEditingForm({ show: true, item: item });
126
124
  };
127
- const handleImport = () => {
128
- setSearching(false);
129
- setImporting(true);
130
- };
131
- const handleSaveImport = (data) => {
132
- data.forEach((item) => {
133
- const newItem = Object.assign({}, item);
134
- newItem.id = (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.BibliographyItem);
135
- handleSave(newItem);
136
- handleCite([newItem]);
137
- });
138
- };
139
125
  const cited = (0, react_1.useMemo)(() => {
140
126
  return rids.flatMap((rid) => items.filter((i) => i.id === rid));
141
127
  }, [rids, items]);
142
- if (importing) {
143
- return (react_1.default.createElement(ImportBibliographyModal_1.ImportBibliographyModal, { onCancel: () => setImporting(false), onSave: handleSaveImport }));
144
- }
145
128
  if (searching) {
146
- return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onImport: handleImport, onCite: (items) => {
129
+ return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onCite: (items) => {
147
130
  setSearching(false);
148
131
  handleCite(items);
149
132
  }, onCancel: () => setSearching(false) }));
150
133
  }
151
134
  if (!rids.length) {
152
- return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onImport: handleImport, onCite: handleCite, onCancel: onCancel }));
135
+ return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onCite: handleCite, onCancel: onCancel }));
153
136
  }
154
137
  return (react_1.default.createElement(react_1.default.Fragment, null,
155
138
  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: {
@@ -79,7 +79,7 @@ const AddReferenceActions = (0, styled_components_1.default)(style_guide_1.Butto
79
79
  }
80
80
  }
81
81
  `;
82
- const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onImport, onCite, onCancel, }) => {
82
+ const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onCite, onCancel }) => {
83
83
  const [query, setQuery] = (0, react_1.useState)(initialQuery || '');
84
84
  const [selections, setSelections] = (0, react_1.useState)(new Map());
85
85
  const toggleSelection = (item) => {
@@ -115,10 +115,7 @@ const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onImport,
115
115
  react_1.default.createElement(AddReferenceActions, null,
116
116
  react_1.default.createElement(style_guide_1.IconTextButton, { onClick: onAdd },
117
117
  react_1.default.createElement(style_guide_1.AddNewIcon, null),
118
- "Add new"),
119
- react_1.default.createElement(style_guide_1.IconTextButton, { onClick: onImport },
120
- react_1.default.createElement(style_guide_1.UploadIcon, null),
121
- "Import new")),
118
+ "Add new")),
122
119
  react_1.default.createElement(style_guide_1.ButtonGroup, null,
123
120
  react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Close"),
124
121
  react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 }, "Cite")))));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findNodeByID = exports.findGraphicalAbstractFigureElement = exports.findFootnotesSection = exports.findBibliographySection = exports.findBackmatter = exports.findBody = exports.findAbstractsNode = exports.insertFootnotesSection = exports.insertSupplementsNode = exports.insertAwardsNode = void 0;
3
+ exports.findNodeByID = exports.findGraphicalAbstractFigureElement = exports.findFootnotesSection = exports.findBibliographySection = exports.findBackmatter = exports.findBody = exports.findAbstractsNode = exports.insertFootnotesSection = exports.insertAttachmentsNode = exports.insertSupplementsNode = exports.insertAwardsNode = void 0;
4
4
  const transform_1 = require("@manuscripts/transform");
5
5
  const prosemirror_utils_1 = require("prosemirror-utils");
6
6
  const insertAwardsNode = (tr) => {
@@ -47,6 +47,23 @@ const insertSupplementsNode = (tr) => {
47
47
  };
48
48
  };
49
49
  exports.insertSupplementsNode = insertSupplementsNode;
50
+ const insertAttachmentsNode = (tr) => {
51
+ const attachmentsNodes = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.attachments);
52
+ if (attachmentsNodes.length) {
53
+ return {
54
+ node: attachmentsNodes[0].node,
55
+ pos: attachmentsNodes[0].pos,
56
+ };
57
+ }
58
+ const comments = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.comments)[0];
59
+ const pos = comments.pos + comments.node.content.size;
60
+ const node = transform_1.schema.nodes.attachments.create({
61
+ id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.attachments),
62
+ });
63
+ tr.insert(pos, node);
64
+ return { node, pos };
65
+ };
66
+ exports.insertAttachmentsNode = insertAttachmentsNode;
50
67
  const insertFootnotesSection = (tr) => {
51
68
  const doc = tr.doc;
52
69
  const section = (0, prosemirror_utils_1.findChildrenByType)(doc, transform_1.schema.nodes.footnotes_section)[0];
@@ -16,6 +16,7 @@ const groupFiles = (doc, files) => {
16
16
  const fileMap = new Map(files.map((f) => [f.id, f]));
17
17
  const figures = [];
18
18
  const supplements = [];
19
+ const mainDocument = [];
19
20
  const getFigureElementFiles = (node, pos) => {
20
21
  const figureFiles = [];
21
22
  for (const figure of (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.figure)) {
@@ -75,11 +76,30 @@ const groupFiles = (doc, files) => {
75
76
  file,
76
77
  });
77
78
  }
79
+ if (node.type === transform_1.schema.nodes.attachment) {
80
+ if ((0, track_changes_utils_1.isHidden)(node)) {
81
+ return;
82
+ }
83
+ const href = node.attrs.href;
84
+ let file = fileMap.get(href);
85
+ if (file) {
86
+ fileMap.delete(href);
87
+ }
88
+ else {
89
+ file = MISSING_FILE;
90
+ }
91
+ mainDocument.push({
92
+ node,
93
+ pos,
94
+ file,
95
+ });
96
+ }
78
97
  });
79
98
  return {
80
99
  figures,
81
100
  supplements,
82
101
  others: [...fileMap.values()],
102
+ mainDocument,
83
103
  };
84
104
  };
85
105
  exports.groupFiles = groupFiles;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.8.17';
4
+ exports.VERSION = '2.8.18';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -23,7 +23,7 @@ import { addColumnAfter, addColumnBefore, addRow, selectedRect, } from 'prosemir
23
23
  import { findWrapping, liftTarget, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
24
24
  import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos, flatten, hasParentNodeOfType, } from 'prosemirror-utils';
25
25
  import { getCommentKey, getCommentRange } from './lib/comments';
26
- import { findAbstractsNode, findBackmatter, findBibliographySection, findBody, findFootnotesSection, insertAwardsNode, insertFootnotesSection, insertSupplementsNode, } from './lib/doc';
26
+ import { findAbstractsNode, findBackmatter, findBibliographySection, findBody, insertAttachmentsNode, findFootnotesSection, insertAwardsNode, insertFootnotesSection, insertSupplementsNode, } from './lib/doc';
27
27
  import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from './lib/footnotes';
28
28
  import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
29
29
  import { isDeleted } from './lib/track-changes-utils';
@@ -248,6 +248,28 @@ export const insertSupplement = (file, state, dispatch) => {
248
248
  }
249
249
  return true;
250
250
  };
251
+ export const insertAttachment = (file, state, type, dispatch) => {
252
+ const tr = state.tr;
253
+ const attachments = insertAttachmentsNode(tr);
254
+ if (!attachments) {
255
+ return false;
256
+ }
257
+ if (attachments.node.childCount > 0) {
258
+ const startPos = attachments.pos + 1;
259
+ const endPos = attachments.pos + attachments.node.nodeSize - 1;
260
+ tr.delete(startPos, endPos);
261
+ }
262
+ const attachment = schema.nodes.attachment.createAndFill({
263
+ id: generateNodeID(schema.nodes.attachment),
264
+ href: file.id,
265
+ type: type,
266
+ });
267
+ tr.insert(attachments.pos + 1, attachment);
268
+ if (dispatch) {
269
+ dispatch(skipTracking(tr));
270
+ }
271
+ return true;
272
+ };
251
273
  export const insertBlock = (nodeType) => (state, dispatch) => {
252
274
  const position = findBlockInsertPosition(state);
253
275
  if (position === null) {
@@ -4,7 +4,6 @@ import React, { useMemo, useReducer, useState } from 'react';
4
4
  import styled from 'styled-components';
5
5
  import { arrayReducer, attrsReducer } from '../../lib/array-reducer';
6
6
  import { CitedItem, CitedItems } from './CitationViewer';
7
- import { ImportBibliographyModal } from './ImportBibliographyModal';
8
7
  import { ReferenceLine } from './ReferenceLine';
9
8
  import { ReferenceSearch } from './ReferenceSearch';
10
9
  import { ReferencesModal } from './ReferencesModal';
@@ -84,7 +83,6 @@ export const CitationEditor = ({ query, rids: $rids, items: $items, citationCoun
84
83
  show: false,
85
84
  });
86
85
  const [searching, setSearching] = useState(false);
87
- const [importing, setImporting] = useState(false);
88
86
  const handleAdd = () => {
89
87
  setSearching(false);
90
88
  const item = {
@@ -95,32 +93,17 @@ export const CitationEditor = ({ query, rids: $rids, items: $items, citationCoun
95
93
  handleCite([item]);
96
94
  setEditingForm({ show: true, item: item });
97
95
  };
98
- const handleImport = () => {
99
- setSearching(false);
100
- setImporting(true);
101
- };
102
- const handleSaveImport = (data) => {
103
- data.forEach((item) => {
104
- const newItem = Object.assign({}, item);
105
- newItem.id = generateID(ObjectTypes.BibliographyItem);
106
- handleSave(newItem);
107
- handleCite([newItem]);
108
- });
109
- };
110
96
  const cited = useMemo(() => {
111
97
  return rids.flatMap((rid) => items.filter((i) => i.id === rid));
112
98
  }, [rids, items]);
113
- if (importing) {
114
- return (React.createElement(ImportBibliographyModal, { onCancel: () => setImporting(false), onSave: handleSaveImport }));
115
- }
116
99
  if (searching) {
117
- return (React.createElement(ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onImport: handleImport, onCite: (items) => {
100
+ return (React.createElement(ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onCite: (items) => {
118
101
  setSearching(false);
119
102
  handleCite(items);
120
103
  }, onCancel: () => setSearching(false) }));
121
104
  }
122
105
  if (!rids.length) {
123
- return (React.createElement(ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onImport: handleImport, onCite: handleCite, onCancel: onCancel }));
106
+ return (React.createElement(ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onCite: handleCite, onCancel: onCancel }));
124
107
  }
125
108
  return (React.createElement(React.Fragment, null,
126
109
  React.createElement(Dialog, { isOpen: deleteDialog.show, category: 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: {
@@ -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 { AddNewIcon, ButtonGroup, IconTextButton, PrimaryButton, SecondaryButton, UploadIcon, } from '@manuscripts/style-guide';
16
+ import { AddNewIcon, ButtonGroup, IconTextButton, PrimaryButton, SecondaryButton, } from '@manuscripts/style-guide';
17
17
  import { debounce } from 'lodash';
18
18
  import React, { useState } from 'react';
19
19
  import styled from 'styled-components';
@@ -50,7 +50,7 @@ const AddReferenceActions = styled(ButtonGroup) `
50
50
  }
51
51
  }
52
52
  `;
53
- export const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onImport, onCite, onCancel, }) => {
53
+ export const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, onCite, onCancel }) => {
54
54
  const [query, setQuery] = useState(initialQuery || '');
55
55
  const [selections, setSelections] = useState(new Map());
56
56
  const toggleSelection = (item) => {
@@ -86,10 +86,7 @@ export const ReferenceSearch = ({ query: initialQuery, sources, items, onAdd, on
86
86
  React.createElement(AddReferenceActions, null,
87
87
  React.createElement(IconTextButton, { onClick: onAdd },
88
88
  React.createElement(AddNewIcon, null),
89
- "Add new"),
90
- React.createElement(IconTextButton, { onClick: onImport },
91
- React.createElement(UploadIcon, null),
92
- "Import new")),
89
+ "Add new")),
93
90
  React.createElement(ButtonGroup, null,
94
91
  React.createElement(SecondaryButton, { onClick: onCancel }, "Close"),
95
92
  React.createElement(PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 }, "Cite")))));
@@ -1,4 +1,4 @@
1
- import { schema, } from '@manuscripts/transform';
1
+ import { generateNodeID, schema, } from '@manuscripts/transform';
2
2
  import { findChildren, findChildrenByType } from 'prosemirror-utils';
3
3
  export const insertAwardsNode = (tr) => {
4
4
  const doc = tr.doc;
@@ -42,6 +42,22 @@ export const insertSupplementsNode = (tr) => {
42
42
  pos,
43
43
  };
44
44
  };
45
+ export const insertAttachmentsNode = (tr) => {
46
+ const attachmentsNodes = findChildrenByType(tr.doc, schema.nodes.attachments);
47
+ if (attachmentsNodes.length) {
48
+ return {
49
+ node: attachmentsNodes[0].node,
50
+ pos: attachmentsNodes[0].pos,
51
+ };
52
+ }
53
+ const comments = findChildrenByType(tr.doc, schema.nodes.comments)[0];
54
+ const pos = comments.pos + comments.node.content.size;
55
+ const node = schema.nodes.attachments.create({
56
+ id: generateNodeID(schema.nodes.attachments),
57
+ });
58
+ tr.insert(pos, node);
59
+ return { node, pos };
60
+ };
45
61
  export const insertFootnotesSection = (tr) => {
46
62
  const doc = tr.doc;
47
63
  const section = findChildrenByType(doc, schema.nodes.footnotes_section)[0];
@@ -13,6 +13,7 @@ export const groupFiles = (doc, files) => {
13
13
  const fileMap = new Map(files.map((f) => [f.id, f]));
14
14
  const figures = [];
15
15
  const supplements = [];
16
+ const mainDocument = [];
16
17
  const getFigureElementFiles = (node, pos) => {
17
18
  const figureFiles = [];
18
19
  for (const figure of findChildrenByType(node, schema.nodes.figure)) {
@@ -72,10 +73,29 @@ export const groupFiles = (doc, files) => {
72
73
  file,
73
74
  });
74
75
  }
76
+ if (node.type === schema.nodes.attachment) {
77
+ if (isHidden(node)) {
78
+ return;
79
+ }
80
+ const href = node.attrs.href;
81
+ let file = fileMap.get(href);
82
+ if (file) {
83
+ fileMap.delete(href);
84
+ }
85
+ else {
86
+ file = MISSING_FILE;
87
+ }
88
+ mainDocument.push({
89
+ node,
90
+ pos,
91
+ file,
92
+ });
93
+ }
75
94
  });
76
95
  return {
77
96
  figures,
78
97
  supplements,
79
98
  others: [...fileMap.values()],
99
+ mainDocument,
80
100
  };
81
101
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.8.17';
1
+ export const VERSION = '2.8.18';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -33,6 +33,7 @@ export declare const insertGeneralTableFootnote: (element: [ManuscriptNode, numb
33
33
  export declare const insertFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
34
34
  export declare const insertTable: (config: TableConfig, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
35
35
  export declare const insertSupplement: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
36
+ export declare const insertAttachment: (file: FileAttachment, state: ManuscriptEditorState, type: string, dispatch?: Dispatch) => boolean;
36
37
  export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
37
38
  export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
38
39
  export declare const insertBreak: EditorAction;
@@ -21,7 +21,6 @@ export declare const ReferenceSearch: React.FC<{
21
21
  sources: BibliographyItemSource[];
22
22
  items: BibliographyItemAttrs[];
23
23
  onAdd: () => void;
24
- onImport: () => void;
25
24
  onCite: (items: BibliographyItemAttrs[]) => void;
26
25
  onCancel: () => void;
27
26
  }>;
@@ -1,41 +1,18 @@
1
1
  import { ManuscriptNode, ManuscriptTransaction } from '@manuscripts/transform';
2
- export declare const insertAwardsNode: (tr: ManuscriptTransaction) => {
3
- node: import("prosemirror-model").Node;
4
- pos: number;
5
- };
6
- export declare const insertSupplementsNode: (tr: ManuscriptTransaction) => {
7
- node: import("prosemirror-model").Node;
8
- pos: number;
9
- };
10
- export declare const insertFootnotesSection: (tr: ManuscriptTransaction) => {
11
- node: import("prosemirror-model").Node;
12
- pos: number;
13
- };
14
- export declare const findAbstractsNode: (doc: ManuscriptNode) => {
15
- node: import("prosemirror-model").Node;
16
- pos: number;
17
- };
18
- export declare const findBody: (doc: ManuscriptNode) => {
19
- node: import("prosemirror-model").Node;
20
- pos: number;
21
- };
22
- export declare const findBackmatter: (doc: ManuscriptNode) => {
23
- node: import("prosemirror-model").Node;
24
- pos: number;
25
- };
26
- export declare const findBibliographySection: (doc: ManuscriptNode) => {
27
- node: import("prosemirror-model").Node;
28
- pos: number;
29
- };
30
- export declare const findFootnotesSection: (doc: ManuscriptNode) => {
2
+ export declare const insertAwardsNode: (tr: ManuscriptTransaction) => import("prosemirror-utils").NodeWithPos;
3
+ export declare const insertSupplementsNode: (tr: ManuscriptTransaction) => import("prosemirror-utils").NodeWithPos;
4
+ export declare const insertAttachmentsNode: (tr: ManuscriptTransaction) => {
31
5
  node: import("prosemirror-model").Node;
32
6
  pos: number;
33
7
  };
8
+ export declare const insertFootnotesSection: (tr: ManuscriptTransaction) => import("prosemirror-utils").NodeWithPos;
9
+ export declare const findAbstractsNode: (doc: ManuscriptNode) => import("prosemirror-utils").NodeWithPos;
10
+ export declare const findBody: (doc: ManuscriptNode) => import("prosemirror-utils").NodeWithPos;
11
+ export declare const findBackmatter: (doc: ManuscriptNode) => import("prosemirror-utils").NodeWithPos;
12
+ export declare const findBibliographySection: (doc: ManuscriptNode) => import("prosemirror-utils").NodeWithPos;
13
+ export declare const findFootnotesSection: (doc: ManuscriptNode) => import("prosemirror-utils").NodeWithPos;
34
14
  export declare const findGraphicalAbstractFigureElement: (doc: ManuscriptNode) => {
35
15
  node: import("prosemirror-model").Node;
36
16
  pos: number;
37
17
  } | undefined;
38
- export declare const findNodeByID: (doc: ManuscriptNode, id: string) => {
39
- node: import("prosemirror-model").Node;
40
- pos: number;
41
- };
18
+ export declare const findNodeByID: (doc: ManuscriptNode, id: string) => import("prosemirror-utils").NodeWithPos;
@@ -22,6 +22,7 @@ export type ManuscriptFiles = {
22
22
  figures: ElementFiles[];
23
23
  supplements: NodeFile[];
24
24
  others: FileAttachment[];
25
+ mainDocument: NodeFile[];
25
26
  };
26
27
  export type Upload = (file: File) => Promise<FileAttachment>;
27
28
  export type Download = (file: FileAttachment) => void;
@@ -18,7 +18,7 @@ export declare const findFootnotesContainerNode: (doc: ManuscriptNode, pos: numb
18
18
  node: import("prosemirror-model").Node;
19
19
  pos: number;
20
20
  };
21
- export declare const findParentFootnote: (selection: import("prosemirror-state").Selection) => import("prosemirror-utils/dist/types").FindResult;
21
+ export declare const findParentFootnote: (selection: import("prosemirror-state").Selection) => import("prosemirror-utils").ContentNodeWithPos | undefined;
22
22
  export declare const getFootnotesElementState: (state: ManuscriptEditorState, id: string) => import("../plugins/footnotes").FootnotesElementState | undefined;
23
23
  export declare const getFootnoteLabel: (state: ManuscriptEditorState, footnote: FootnoteNode) => string;
24
24
  export declare const createFootnote: () => FootnoteNode;
@@ -20,10 +20,10 @@ export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean)
20
20
  export declare const getMatchingChild: (parent: ManuscriptNode, matcher: (node: ManuscriptNode) => boolean, deep?: boolean) => ManuscriptNode | undefined;
21
21
  export declare const getMatchingDescendant: (parent: ManuscriptNode, matcher: (node: ManuscriptNode) => boolean) => ManuscriptNode | undefined;
22
22
  export declare const getChildOfType: (parent: ManuscriptNode, nodeType: ManuscriptNodeType, deep?: boolean) => boolean;
23
- export declare const findParentNodeWithId: ({ $from, $to }: Selection, validateSameParent?: boolean | undefined) => import("prosemirror-utils/dist/types").FindResult;
24
- export declare const findParentNodeWithIdValue: ({ $from, $to }: Selection, validateSameParent?: boolean | undefined) => import("prosemirror-utils/dist/types").FindResult;
25
- export declare const findParentSection: ({ $from, $to }: Selection, validateSameParent?: boolean | undefined) => import("prosemirror-utils/dist/types").FindResult;
26
- export declare const findParentElement: (selection: Selection, validIds?: string[]) => import("prosemirror-utils/dist/types").FindResult;
23
+ export declare const findParentNodeWithId: (selection: Selection) => import("prosemirror-utils").ContentNodeWithPos | undefined;
24
+ export declare const findParentNodeWithIdValue: (selection: Selection) => import("prosemirror-utils").ContentNodeWithPos | undefined;
25
+ export declare const findParentSection: (selection: Selection) => import("prosemirror-utils").ContentNodeWithPos | undefined;
26
+ export declare const findParentElement: (selection: Selection, validIds?: string[]) => import("prosemirror-utils").ContentNodeWithPos | undefined;
27
27
  export declare const isChildOfNodeTypes: (doc: ManuscriptNode, pos: number, parentNodeTypes: NodeType[]) => boolean;
28
28
  export declare const isSelectionInNode: (state: EditorState, targetNode: ProseMirrorNode) => boolean;
29
29
  export declare const createHeader: (typeName: string, text: string) => HTMLHeadingElement;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.8.17";
1
+ export declare const VERSION = "2.8.18";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
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": "2.8.17",
4
+ "version": "2.8.18",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,10 +31,10 @@
31
31
  "dependencies": {
32
32
  "@iarna/word-count": "^1.1.2",
33
33
  "@manuscripts/json-schema": "2.2.11",
34
- "@manuscripts/library": "1.3.12",
34
+ "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.1.6",
36
36
  "@manuscripts/track-changes-plugin": "1.10.1",
37
- "@manuscripts/transform": "3.0.48",
37
+ "@manuscripts/transform": "3.0.47",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",
@@ -56,7 +56,7 @@
56
56
  "prosemirror-state": "^1.4.2",
57
57
  "prosemirror-tables": "^1.5.0",
58
58
  "prosemirror-transform": "^1.7.0",
59
- "prosemirror-utils": "^1.2.2",
59
+ "prosemirror-utils": "^0.9.6",
60
60
  "prosemirror-view": "^1.29.1",
61
61
  "react": "^18.3.1",
62
62
  "react-dnd": "^16.0.1",
@@ -1,194 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2025 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
- return new (P || (P = Promise))(function (resolve, reject) {
43
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
- });
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.ImportBibliographyForm = void 0;
51
- const library_1 = require("@manuscripts/library");
52
- const style_guide_1 = require("@manuscripts/style-guide");
53
- const formik_1 = require("formik");
54
- const lodash_1 = require("lodash");
55
- const react_1 = __importStar(require("react"));
56
- const styled_components_1 = __importStar(require("styled-components"));
57
- const ReferenceLine_1 = require("./ReferenceLine");
58
- const ImportBibliographyForm = ({ onCancel, onSave, }) => {
59
- const [dragging, setDragging] = (0, react_1.useState)(false);
60
- const formik = (0, formik_1.useFormik)({
61
- initialValues: {
62
- content: '',
63
- err: '',
64
- data: [],
65
- },
66
- onSubmit: (values, { setSubmitting }) => {
67
- onSave(values.data);
68
- setSubmitting(false);
69
- },
70
- onReset: onCancel,
71
- });
72
- const setDataField = (0, react_1.useCallback)((fileContent) => __awaiter(void 0, void 0, void 0, function* () {
73
- const NO_CITATION = 'No citation available';
74
- const ERROR_CITATION = 'Error generating citation';
75
- try {
76
- if (!fileContent.trim()) {
77
- formik.setFieldValue('err', NO_CITATION);
78
- formik.setFieldValue('data', []);
79
- return;
80
- }
81
- const data = yield (0, library_1.transformBibliography)(fileContent.trim());
82
- formik.setFieldValue('data', data ? data : []);
83
- formik.setFieldValue('err', '');
84
- }
85
- catch (error) {
86
- console.error('Citation generation error:', error);
87
- formik.setFieldValue('err', ERROR_CITATION);
88
- formik.setFieldValue('data', []);
89
- }
90
- }), []);
91
- const debouncedGenerateData = (0, react_1.useMemo)(() => (0, lodash_1.debounce)(setDataField, 300), [setDataField]);
92
- (0, react_1.useEffect)(() => {
93
- debouncedGenerateData(formik.values.content);
94
- }, [debouncedGenerateData, formik.values.content]);
95
- const handleDrop = (event) => {
96
- event.preventDefault();
97
- setDragging(false);
98
- const file = event.dataTransfer.files[0];
99
- if (file) {
100
- readFileContent(file);
101
- }
102
- };
103
- const handleFileChange = (event) => {
104
- var _a;
105
- const file = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[0];
106
- if (file) {
107
- readFileContent(file);
108
- }
109
- };
110
- const readFileContent = (file) => {
111
- const reader = new FileReader();
112
- reader.onload = (e) => {
113
- var _a;
114
- if ((_a = e.target) === null || _a === void 0 ? void 0 : _a.result) {
115
- formik.setFieldValue('content', e.target.result);
116
- }
117
- };
118
- reader.readAsText(file);
119
- };
120
- return (react_1.default.createElement("form", { onSubmit: formik.handleSubmit, onReset: formik.handleReset },
121
- react_1.default.createElement(DropContainer, { onDrop: handleDrop, onDragOver: (e) => {
122
- e.preventDefault();
123
- setDragging(true);
124
- }, onDragLeave: () => setDragging(false), active: dragging },
125
- react_1.default.createElement("input", { id: "file", name: "file", type: "file", onChange: handleFileChange, style: { display: 'none' } }),
126
- react_1.default.createElement(Label, { htmlFor: "file" }, "Drag & Drop or Click here to upload a file.")),
127
- react_1.default.createElement(LabelContainer, null,
128
- react_1.default.createElement(Label, null, "Alternatively, you can directly Copy&Paste below, the text of the bibliography items.")),
129
- react_1.default.createElement(style_guide_1.TextArea, { name: "content", rows: 6, value: formik.values.content, onChange: formik.handleChange }),
130
- react_1.default.createElement(Preview, null,
131
- formik.values.err,
132
- formik.values.data.map((item) => (react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item, key: item.id })))),
133
- react_1.default.createElement(ButtonContainer, null,
134
- react_1.default.createElement(style_guide_1.SecondaryButton, { type: "reset" }, "Cancel"),
135
- react_1.default.createElement(style_guide_1.PrimaryButton, { type: "submit", disabled: !formik.dirty || formik.isSubmitting || !formik.values.data.length }, "Save"))));
136
- };
137
- exports.ImportBibliographyForm = ImportBibliographyForm;
138
- const Preview = styled_components_1.default.div `
139
- display: flex;
140
- flex-direction: column;
141
- gap: ${(props) => 4 * props.theme.grid.unit}px;
142
- min-height: 50px;
143
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
144
- margin-bottom: ${(props) => props.theme.grid.unit}px;
145
- `;
146
- const LabelContainer = styled_components_1.default.div `
147
- display: flex;
148
- justify-content: space-between;
149
- align-items: center;
150
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
151
- margin-bottom: ${(props) => props.theme.grid.unit}px;
152
- `;
153
- const Label = styled_components_1.default.label `
154
- font-size: ${(props) => props.theme.font.size.normal};
155
- line-height: ${(props) => props.theme.font.lineHeight.large};
156
- font-family: ${(props) => props.theme.font.family.Lato};
157
- display: block;
158
- color: ${(props) => props.theme.colors.text.secondary};
159
- `;
160
- const ButtonContainer = styled_components_1.default.div `
161
- display: flex;
162
- justify-content: flex-end;
163
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
164
- gap: ${(props) => 2 * props.theme.grid.unit}px;
165
- `;
166
- const activeBoxStyle = (0, styled_components_1.css) `
167
- background: #f2fbfc;
168
- border: 1px dashed #bce7f6;
169
- `;
170
- const DropContainer = styled_components_1.default.div `
171
- background: ${(props) => props.theme.colors.background.secondary};
172
- border: 1px dashed ${(props) => props.theme.colors.border.secondary};
173
- box-sizing: border-box;
174
- border-radius: ${(props) => props.theme.grid.radius.default};
175
- cursor: pointer;
176
- ${({ active }) => active && activeBoxStyle};
177
-
178
- &:hover {
179
- ${activeBoxStyle}
180
- }
181
-
182
- & label {
183
- width: 100%;
184
- height: 80px;
185
- display: flex;
186
- align-items: center;
187
- justify-content: center;
188
- text-align: center;
189
- font-size: ${(props) => props.theme.font.size.normal};
190
- line-height: ${(props) => props.theme.font.lineHeight.large};
191
- font-family: ${(props) => props.theme.font.family.Lato};
192
- color: ${(props) => props.theme.colors.text.onLight};
193
- }
194
- `;
@@ -1,68 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ImportBibliographyModal = void 0;
30
- const style_guide_1 = require("@manuscripts/style-guide");
31
- const react_1 = __importStar(require("react"));
32
- const styled_components_1 = __importDefault(require("styled-components"));
33
- const ImportBibliographyForm_1 = require("./ImportBibliographyForm");
34
- const ImportBibliographyModal = ({ onCancel, onSave }) => {
35
- const [isOpen, setOpen] = (0, react_1.useState)(true);
36
- const handleCancel = () => {
37
- handleClose();
38
- };
39
- const handleClose = () => setOpen(false);
40
- const handleSave = (data) => {
41
- onSave(data);
42
- handleClose();
43
- };
44
- return (react_1.default.createElement(style_guide_1.StyledModal, { isOpen: isOpen, onRequestClose: onCancel },
45
- react_1.default.createElement(style_guide_1.ModalContainer, { "data-cy": "import-bibliography-modal" },
46
- react_1.default.createElement(style_guide_1.ModalHeader, null,
47
- react_1.default.createElement(style_guide_1.CloseButton, { onClick: onCancel, "data-cy": "modal-close-button" })),
48
- react_1.default.createElement(ModalBody, null,
49
- react_1.default.createElement(ModalTitle, null, "Import Bibliography"),
50
- react_1.default.createElement("p", null, "BibTex, PubMed, RIS, ENW and DOI formats are supported"),
51
- react_1.default.createElement(ImportBibliographyForm_1.ImportBibliographyForm, { onCancel: handleCancel, onSave: handleSave })))));
52
- };
53
- exports.ImportBibliographyModal = ImportBibliographyModal;
54
- const ModalBody = styled_components_1.default.div `
55
- box-sizing: border-box;
56
- padding: ${(props) => 6 * props.theme.grid.unit}px;
57
- background-color: ${(props) => props.theme.colors.background.primary};
58
- width: 640px;
59
- max-width: 60vw;
60
- max-height: 80vh;
61
- `;
62
- const ModalTitle = styled_components_1.default.h2 `
63
- font-family: ${(props) => props.theme.font.family.sans};
64
- font-size: ${(props) => props.theme.font.size.medium};
65
- font-weight: ${(props) => props.theme.font.weight.bold};
66
- color: ${(props) => props.theme.colors.text.primary};
67
- margin: 0;
68
- `;
@@ -1,167 +0,0 @@
1
- /*!
2
- * © 2025 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- import { transformBibliography } from '@manuscripts/library';
26
- import { PrimaryButton, SecondaryButton, TextArea, } from '@manuscripts/style-guide';
27
- import { useFormik } from 'formik';
28
- import { debounce } from 'lodash';
29
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
30
- import styled, { css } from 'styled-components';
31
- import { ReferenceLine } from './ReferenceLine';
32
- export const ImportBibliographyForm = ({ onCancel, onSave, }) => {
33
- const [dragging, setDragging] = useState(false);
34
- const formik = useFormik({
35
- initialValues: {
36
- content: '',
37
- err: '',
38
- data: [],
39
- },
40
- onSubmit: (values, { setSubmitting }) => {
41
- onSave(values.data);
42
- setSubmitting(false);
43
- },
44
- onReset: onCancel,
45
- });
46
- const setDataField = useCallback((fileContent) => __awaiter(void 0, void 0, void 0, function* () {
47
- const NO_CITATION = 'No citation available';
48
- const ERROR_CITATION = 'Error generating citation';
49
- try {
50
- if (!fileContent.trim()) {
51
- formik.setFieldValue('err', NO_CITATION);
52
- formik.setFieldValue('data', []);
53
- return;
54
- }
55
- const data = yield transformBibliography(fileContent.trim());
56
- formik.setFieldValue('data', data ? data : []);
57
- formik.setFieldValue('err', '');
58
- }
59
- catch (error) {
60
- console.error('Citation generation error:', error);
61
- formik.setFieldValue('err', ERROR_CITATION);
62
- formik.setFieldValue('data', []);
63
- }
64
- }), []);
65
- const debouncedGenerateData = useMemo(() => debounce(setDataField, 300), [setDataField]);
66
- useEffect(() => {
67
- debouncedGenerateData(formik.values.content);
68
- }, [debouncedGenerateData, formik.values.content]);
69
- const handleDrop = (event) => {
70
- event.preventDefault();
71
- setDragging(false);
72
- const file = event.dataTransfer.files[0];
73
- if (file) {
74
- readFileContent(file);
75
- }
76
- };
77
- const handleFileChange = (event) => {
78
- var _a;
79
- const file = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[0];
80
- if (file) {
81
- readFileContent(file);
82
- }
83
- };
84
- const readFileContent = (file) => {
85
- const reader = new FileReader();
86
- reader.onload = (e) => {
87
- var _a;
88
- if ((_a = e.target) === null || _a === void 0 ? void 0 : _a.result) {
89
- formik.setFieldValue('content', e.target.result);
90
- }
91
- };
92
- reader.readAsText(file);
93
- };
94
- return (React.createElement("form", { onSubmit: formik.handleSubmit, onReset: formik.handleReset },
95
- React.createElement(DropContainer, { onDrop: handleDrop, onDragOver: (e) => {
96
- e.preventDefault();
97
- setDragging(true);
98
- }, onDragLeave: () => setDragging(false), active: dragging },
99
- React.createElement("input", { id: "file", name: "file", type: "file", onChange: handleFileChange, style: { display: 'none' } }),
100
- React.createElement(Label, { htmlFor: "file" }, "Drag & Drop or Click here to upload a file.")),
101
- React.createElement(LabelContainer, null,
102
- React.createElement(Label, null, "Alternatively, you can directly Copy&Paste below, the text of the bibliography items.")),
103
- React.createElement(TextArea, { name: "content", rows: 6, value: formik.values.content, onChange: formik.handleChange }),
104
- React.createElement(Preview, null,
105
- formik.values.err,
106
- formik.values.data.map((item) => (React.createElement(ReferenceLine, { item: item, key: item.id })))),
107
- React.createElement(ButtonContainer, null,
108
- React.createElement(SecondaryButton, { type: "reset" }, "Cancel"),
109
- React.createElement(PrimaryButton, { type: "submit", disabled: !formik.dirty || formik.isSubmitting || !formik.values.data.length }, "Save"))));
110
- };
111
- const Preview = styled.div `
112
- display: flex;
113
- flex-direction: column;
114
- gap: ${(props) => 4 * props.theme.grid.unit}px;
115
- min-height: 50px;
116
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
117
- margin-bottom: ${(props) => props.theme.grid.unit}px;
118
- `;
119
- const LabelContainer = styled.div `
120
- display: flex;
121
- justify-content: space-between;
122
- align-items: center;
123
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
124
- margin-bottom: ${(props) => props.theme.grid.unit}px;
125
- `;
126
- const Label = styled.label `
127
- font-size: ${(props) => props.theme.font.size.normal};
128
- line-height: ${(props) => props.theme.font.lineHeight.large};
129
- font-family: ${(props) => props.theme.font.family.Lato};
130
- display: block;
131
- color: ${(props) => props.theme.colors.text.secondary};
132
- `;
133
- const ButtonContainer = styled.div `
134
- display: flex;
135
- justify-content: flex-end;
136
- margin-top: ${(props) => 4 * props.theme.grid.unit}px;
137
- gap: ${(props) => 2 * props.theme.grid.unit}px;
138
- `;
139
- const activeBoxStyle = css `
140
- background: #f2fbfc;
141
- border: 1px dashed #bce7f6;
142
- `;
143
- const DropContainer = styled.div `
144
- background: ${(props) => props.theme.colors.background.secondary};
145
- border: 1px dashed ${(props) => props.theme.colors.border.secondary};
146
- box-sizing: border-box;
147
- border-radius: ${(props) => props.theme.grid.radius.default};
148
- cursor: pointer;
149
- ${({ active }) => active && activeBoxStyle};
150
-
151
- &:hover {
152
- ${activeBoxStyle}
153
- }
154
-
155
- & label {
156
- width: 100%;
157
- height: 80px;
158
- display: flex;
159
- align-items: center;
160
- justify-content: center;
161
- text-align: center;
162
- font-size: ${(props) => props.theme.font.size.normal};
163
- line-height: ${(props) => props.theme.font.lineHeight.large};
164
- font-family: ${(props) => props.theme.font.family.Lato};
165
- color: ${(props) => props.theme.colors.text.onLight};
166
- }
167
- `;
@@ -1,38 +0,0 @@
1
- import { CloseButton, ModalContainer, ModalHeader, StyledModal, } from '@manuscripts/style-guide';
2
- import React, { useState } from 'react';
3
- import styled from 'styled-components';
4
- import { ImportBibliographyForm } from './ImportBibliographyForm';
5
- export const ImportBibliographyModal = ({ onCancel, onSave }) => {
6
- const [isOpen, setOpen] = useState(true);
7
- const handleCancel = () => {
8
- handleClose();
9
- };
10
- const handleClose = () => setOpen(false);
11
- const handleSave = (data) => {
12
- onSave(data);
13
- handleClose();
14
- };
15
- return (React.createElement(StyledModal, { isOpen: isOpen, onRequestClose: onCancel },
16
- React.createElement(ModalContainer, { "data-cy": "import-bibliography-modal" },
17
- React.createElement(ModalHeader, null,
18
- React.createElement(CloseButton, { onClick: onCancel, "data-cy": "modal-close-button" })),
19
- React.createElement(ModalBody, null,
20
- React.createElement(ModalTitle, null, "Import Bibliography"),
21
- React.createElement("p", null, "BibTex, PubMed, RIS, ENW and DOI formats are supported"),
22
- React.createElement(ImportBibliographyForm, { onCancel: handleCancel, onSave: handleSave })))));
23
- };
24
- const ModalBody = styled.div `
25
- box-sizing: border-box;
26
- padding: ${(props) => 6 * props.theme.grid.unit}px;
27
- background-color: ${(props) => props.theme.colors.background.primary};
28
- width: 640px;
29
- max-width: 60vw;
30
- max-height: 80vh;
31
- `;
32
- const ModalTitle = styled.h2 `
33
- font-family: ${(props) => props.theme.font.family.sans};
34
- font-size: ${(props) => props.theme.font.size.medium};
35
- font-weight: ${(props) => props.theme.font.weight.bold};
36
- color: ${(props) => props.theme.colors.text.primary};
37
- margin: 0;
38
- `;
@@ -1,22 +0,0 @@
1
- /*!
2
- * © 2025 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { BibliographyItemAttrs } from '@manuscripts/transform';
17
- import React from 'react';
18
- export interface ImportBibFormProps {
19
- onCancel: () => void;
20
- onSave: (data: BibliographyItemAttrs[]) => void;
21
- }
22
- export declare const ImportBibliographyForm: ({ onCancel, onSave, }: ImportBibFormProps) => React.JSX.Element;
@@ -1,7 +0,0 @@
1
- import { BibliographyItemAttrs } from '@manuscripts/transform';
2
- import React from 'react';
3
- export interface ImportBibliographyModalProps {
4
- onCancel: () => void;
5
- onSave: (data: BibliographyItemAttrs[]) => void;
6
- }
7
- export declare const ImportBibliographyModal: React.FC<ImportBibliographyModalProps>;