@manuscripts/style-guide 0.31.11 → 0.31.14

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.
@@ -48,7 +48,7 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
48
48
  const TooltipDiv_1 = require("./TooltipDiv");
49
49
  const util_1 = require("./util");
50
50
  exports.PermissionsContext = (0, react_1.createContext)(null);
51
- const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
51
+ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
52
52
  const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
53
53
  const handleReplaceFile = (0, react_1.useCallback)((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
54
54
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
@@ -102,9 +102,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
102
102
  const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
103
103
  attachments.filter((element) => {
104
104
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
105
- return (designation !== undefined &&
106
- util_1.designationWithFileSectionsMap.get(designation) === fileSection &&
107
- !excludedAttachmentsIds.has(element.id));
105
+ return (designation !== undefined && !excludedAttachmentsIds.has(element.id));
108
106
  });
109
107
  const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
110
108
  const filesItems = itemsDataWithTitle.map((element) => {
@@ -154,7 +152,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
154
152
  react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
155
153
  react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
156
154
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
157
- react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
155
+ react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
158
156
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
159
157
  react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
160
158
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
@@ -18,6 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
21
30
  Object.defineProperty(exports, "__esModule", { value: true });
22
31
  exports.ItemActions = void 0;
23
32
  const react_1 = __importStar(require("react"));
@@ -25,22 +34,40 @@ const Dropdown_1 = require("../../Dropdown");
25
34
  const FileManager_1 = require("../FileManager");
26
35
  const FileSectionState_1 = require("../FileSectionState");
27
36
  const ItemsAction_1 = require("../ItemsAction");
28
- const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
37
+ const util_1 = require("../util");
38
+ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
29
39
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
40
+ const attachmentDesignationName = attachmentDesignation !== 'undefined'
41
+ ? util_1.namesWithDesignationMap.get(attachmentDesignation)
42
+ : undefined;
43
+ const canBeReplaced = attachmentDesignationName == undefined ||
44
+ ![
45
+ util_1.Designation.MainManuscript,
46
+ util_1.Designation.SubmissionFile,
47
+ util_1.Designation.SubmissionPdf,
48
+ ].includes(attachmentDesignationName);
30
49
  const fileInputRef = (0, react_1.useRef)(null);
31
50
  const [selectedFile, setSelectedFile] = (0, react_1.useState)();
32
51
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
33
- const handleChange = (event) => {
52
+ const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
34
53
  if (event && event.target && event.target.files) {
35
54
  const file = event.target.files[0];
36
55
  setSelectedFile(file);
37
56
  if (dispatch) {
38
- dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
57
+ dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
58
+ dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
59
+ }
60
+ const result = yield replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
61
+ const { uploadAttachment } = result === null || result === void 0 ? void 0 : result.data;
62
+ if (uploadAttachment && handleUpdateInline) {
63
+ handleUpdateInline(uploadAttachment);
64
+ }
65
+ if (dispatch) {
66
+ dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
39
67
  }
40
- replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
41
68
  hideActionList();
42
69
  }
43
- };
70
+ });
44
71
  const openFileDialog = () => {
45
72
  if (fileInputRef && fileInputRef.current) {
46
73
  fileInputRef.current.click();
@@ -50,7 +77,7 @@ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, subm
50
77
  react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => {
51
78
  publicUrl !== undefined ? downloadAttachmentHandler(publicUrl) : {};
52
79
  } }, "Download"),
53
- (can === null || can === void 0 ? void 0 : can.replaceFile) && (react_1.default.createElement(react_1.default.Fragment, null,
80
+ (can === null || can === void 0 ? void 0 : can.replaceFile) && canBeReplaced && (react_1.default.createElement(react_1.default.Fragment, null,
54
81
  react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: openFileDialog }, "Replace"),
55
82
  react_1.default.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' })))));
56
83
  };
@@ -31,7 +31,7 @@ const FileInfo_1 = require("./FileSectionItem/FileInfo");
31
31
  const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
32
32
  const ItemActions_1 = require("./FileSectionItem/ItemActions");
33
33
  const util_1 = require("./util");
34
- const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, inlineFiles, isEditor, dispatch, }) => {
34
+ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
35
35
  const onElementClick = (0, react_1.useCallback)((e) => {
36
36
  if (!isEditor) {
37
37
  return;
@@ -46,7 +46,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, inlin
46
46
  return (react_1.default.createElement("div", null, inlineFiles.map((file, index) => {
47
47
  var _a;
48
48
  return (react_1.default.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
49
- react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, dispatch: dispatch })))),
49
+ react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
50
50
  react_1.default.createElement(Element, { className: 'element' },
51
51
  util_1.fileTypesWithIconMap.get(file.type),
52
52
  react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
@@ -55,7 +55,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, inlin
55
55
  })));
56
56
  };
57
57
  exports.InlineFilesSection = InlineFilesSection;
58
- const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, dispatch, }) => {
58
+ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
59
59
  const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
60
60
  if (!attachment || !attachment.name) {
61
61
  return null;
@@ -68,7 +68,9 @@ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload
68
68
  handleDownload && handleReplace && submissionId && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
69
69
  react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
70
70
  react_1.default.createElement(dots_icon_1.default, null)),
71
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
71
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
72
+ (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
73
+ handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
72
74
  };
73
75
  const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
74
76
  display: flex;
@@ -281,6 +281,7 @@ exports.extensionsWithFileTypesMap = new Map([
281
281
  ['png', FileType.Image],
282
282
  ['jpg', FileType.Image],
283
283
  ['jpeg', FileType.Image],
284
+ ['jfif', FileType.Image],
284
285
  ['gif', FileType.Image],
285
286
  ['svg', FileType.Image],
286
287
  ['tif', FileType.Image],
@@ -18,13 +18,14 @@ const getAttachment = (externalFileRef, attachmentsMap) => {
18
18
  };
19
19
  const getFigureData = (element, modelMap, attachmentsMap) => {
20
20
  const attachments = [];
21
- element.containedObjectIDs.map((e) => {
21
+ element.containedObjectIDs.map((id) => {
22
22
  var _a;
23
- const object = modelMap.get(e);
23
+ const object = modelMap.get(id);
24
24
  if (object && object.objectType === manuscripts_json_schema_1.ObjectTypes.Figure) {
25
25
  const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
26
26
  const attachment = getAttachment(externalFileRef, attachmentsMap);
27
27
  if (attachment) {
28
+ attachment.modelId = id;
28
29
  attachments.push(attachment);
29
30
  }
30
31
  }
@@ -21,9 +21,9 @@ import { actions, getInitialState, reducer } from './FileSectionState';
21
21
  import { FilesSection } from './FilesSection';
22
22
  import { InlineFilesSection } from './InlineFilesSection';
23
23
  import { TooltipDiv } from './TooltipDiv';
24
- import { Designation, designationWithFileSectionsMap, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
24
+ import { Designation, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
25
25
  export const PermissionsContext = createContext(null);
26
- export const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
26
+ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
27
27
  const [state, dispatch] = useReducer(reducer, getInitialState());
28
28
  const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
29
29
  dispatch(actions.HANDLE_UPLOAD_ACTION());
@@ -77,9 +77,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
77
77
  const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
78
78
  attachments.filter((element) => {
79
79
  const designation = namesWithDesignationMap.get(element.type.label);
80
- return (designation !== undefined &&
81
- designationWithFileSectionsMap.get(designation) === fileSection &&
82
- !excludedAttachmentsIds.has(element.id));
80
+ return (designation !== undefined && !excludedAttachmentsIds.has(element.id));
83
81
  });
84
82
  const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
85
83
  const filesItems = itemsDataWithTitle.map((element) => {
@@ -129,7 +127,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
129
127
  React.createElement("div", null, "Files excluded from the final submission.")))),
130
128
  React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
131
129
  React.createElement(InspectorTabPanel, null,
132
- React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
130
+ React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
133
131
  React.createElement(InspectorTabPanel, null,
134
132
  React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
135
133
  React.createElement(InspectorTabPanel, null,
@@ -1,24 +1,51 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import React, { useContext, useRef, useState, } from 'react';
2
11
  import { DropdownList } from '../../Dropdown';
3
12
  import { PermissionsContext } from '../FileManager';
4
13
  import { actions } from '../FileSectionState';
5
14
  import { ActionsItem } from '../ItemsAction';
6
- export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
15
+ import { Designation, namesWithDesignationMap } from '../util';
16
+ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
7
17
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
18
+ const attachmentDesignationName = attachmentDesignation !== 'undefined'
19
+ ? namesWithDesignationMap.get(attachmentDesignation)
20
+ : undefined;
21
+ const canBeReplaced = attachmentDesignationName == undefined ||
22
+ ![
23
+ Designation.MainManuscript,
24
+ Designation.SubmissionFile,
25
+ Designation.SubmissionPdf,
26
+ ].includes(attachmentDesignationName);
8
27
  const fileInputRef = useRef(null);
9
28
  const [selectedFile, setSelectedFile] = useState();
10
29
  const can = useContext(PermissionsContext);
11
- const handleChange = (event) => {
30
+ const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
12
31
  if (event && event.target && event.target.files) {
13
32
  const file = event.target.files[0];
14
33
  setSelectedFile(file);
15
34
  if (dispatch) {
16
- dispatch(actions.UPLOAD_FILE(file));
35
+ dispatch(actions.HANDLE_UPLOAD_ACTION());
36
+ dispatch(actions.SELECT_DESIGNATION(attachmentDesignationName || Designation.Document));
37
+ }
38
+ const result = yield replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
39
+ const { uploadAttachment } = result === null || result === void 0 ? void 0 : result.data;
40
+ if (uploadAttachment && handleUpdateInline) {
41
+ handleUpdateInline(uploadAttachment);
42
+ }
43
+ if (dispatch) {
44
+ dispatch(actions.HANDLE_FINISH_UPLOAD());
17
45
  }
18
- replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
19
46
  hideActionList();
20
47
  }
21
- };
48
+ });
22
49
  const openFileDialog = () => {
23
50
  if (fileInputRef && fileInputRef.current) {
24
51
  fileInputRef.current.click();
@@ -28,7 +55,7 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
28
55
  React.createElement(ActionsItem, { onClick: () => {
29
56
  publicUrl !== undefined ? downloadAttachmentHandler(publicUrl) : {};
30
57
  } }, "Download"),
31
- (can === null || can === void 0 ? void 0 : can.replaceFile) && (React.createElement(React.Fragment, null,
58
+ (can === null || can === void 0 ? void 0 : can.replaceFile) && canBeReplaced && (React.createElement(React.Fragment, null,
32
59
  React.createElement(ActionsItem, { onClick: openFileDialog }, "Replace"),
33
60
  React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' })))));
34
61
  };
@@ -6,7 +6,7 @@ import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSec
6
6
  import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
7
7
  import { ItemActions } from './FileSectionItem/ItemActions';
8
8
  import { extensionsWithFileTypesMap, fileTypesWithIconMap, } from './util';
9
- export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, inlineFiles, isEditor, dispatch, }) => {
9
+ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
10
10
  const onElementClick = useCallback((e) => {
11
11
  if (!isEditor) {
12
12
  return;
@@ -21,7 +21,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
21
21
  return (React.createElement("div", null, inlineFiles.map((file, index) => {
22
22
  var _a;
23
23
  return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
24
- React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, dispatch: dispatch })))),
24
+ React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
25
25
  React.createElement(Element, { className: 'element' },
26
26
  fileTypesWithIconMap.get(file.type),
27
27
  React.createElement(FileInfoContainer, null,
@@ -29,7 +29,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
29
29
  React.createElement(FileTitle, null, file.label))))));
30
30
  })));
31
31
  };
32
- const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, dispatch, }) => {
32
+ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
33
33
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
34
34
  if (!attachment || !attachment.name) {
35
35
  return null;
@@ -42,7 +42,9 @@ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload
42
42
  handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
43
43
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
44
44
  React.createElement(DotsIcon, null)),
45
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
45
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
46
+ (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
47
+ handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
46
48
  };
47
49
  const ElementItem = styled(Item) `
48
50
  display: flex;
@@ -275,6 +275,7 @@ export const extensionsWithFileTypesMap = new Map([
275
275
  ['png', FileType.Image],
276
276
  ['jpg', FileType.Image],
277
277
  ['jpeg', FileType.Image],
278
+ ['jfif', FileType.Image],
278
279
  ['gif', FileType.Image],
279
280
  ['svg', FileType.Image],
280
281
  ['tif', FileType.Image],
@@ -15,13 +15,14 @@ const getAttachment = (externalFileRef, attachmentsMap) => {
15
15
  };
16
16
  const getFigureData = (element, modelMap, attachmentsMap) => {
17
17
  const attachments = [];
18
- element.containedObjectIDs.map((e) => {
18
+ element.containedObjectIDs.map((id) => {
19
19
  var _a;
20
- const object = modelMap.get(e);
20
+ const object = modelMap.get(id);
21
21
  if (object && object.objectType === ObjectTypes.Figure) {
22
22
  const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
23
23
  const attachment = getAttachment(externalFileRef, attachmentsMap);
24
24
  if (attachment) {
25
+ attachment.modelId = id;
25
26
  attachments.push(attachment);
26
27
  }
27
28
  }
@@ -15,4 +15,5 @@ export declare const FileManager: React.FC<{
15
15
  handleDownload: (url: string) => void;
16
16
  handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<any>;
17
17
  handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<any>;
18
+ handleUpdateInline?: (modelId: string, attachment: SubmissionAttachment) => void;
18
19
  }>;
@@ -20,7 +20,11 @@ export interface FileSectionItemProps {
20
20
  showDesignationActions?: boolean;
21
21
  showActions?: boolean;
22
22
  handleDownload?: (url: string) => void;
23
- handleReplace?: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
23
+ handleReplace?: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
24
+ data: {
25
+ uploadAttachment: SubmissionAttachment;
26
+ };
27
+ }>;
24
28
  handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
25
29
  dispatch?: Dispatch<Action>;
26
30
  dragRef?: DragElementWrapper<DragSourceOptions>;
@@ -1,9 +1,15 @@
1
1
  import React, { Dispatch } from 'react';
2
2
  import { Maybe } from '../../SubmissionInspector/types';
3
3
  import { Action } from '../FileSectionState';
4
+ import { SubmissionAttachment } from './FileSectionItem';
4
5
  export declare const ItemActions: React.FC<{
5
6
  downloadAttachmentHandler: (url: string) => void;
6
- replaceAttachmentHandler: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
7
+ replaceAttachmentHandler: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
8
+ data: {
9
+ uploadAttachment: SubmissionAttachment;
10
+ };
11
+ }>;
12
+ handleUpdateInline?: (attachment: SubmissionAttachment) => void;
7
13
  submissionId: string;
8
14
  attachmentId: string;
9
15
  fileName: string;
@@ -16,8 +16,13 @@ export declare const InlineFilesSection: React.FC<{
16
16
  caption?: string;
17
17
  attachments?: SubmissionAttachment[];
18
18
  }[];
19
- handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
19
+ handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
20
+ data: {
21
+ uploadAttachment: SubmissionAttachment;
22
+ };
23
+ }>;
20
24
  handleDownload: (url: string) => void;
25
+ handleUpdateInline?: (modelId: string, attachment: SubmissionAttachment) => void;
21
26
  isEditor: boolean;
22
27
  dispatch: Dispatch<Action>;
23
28
  }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "0.31.11",
4
+ "version": "0.31.14",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",