@manuscripts/style-guide 0.30.26 → 0.30.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/FileManager/FileManager.js +1 -1
- package/dist/cjs/components/FileManager/InlineFilesSection.js +9 -9
- package/dist/cjs/components/icons/attach.js +2 -4
- package/dist/cjs/components/icons/upload.js +4 -6
- package/dist/cjs/lib/inlineFiles.js +23 -11
- package/dist/es/components/FileManager/FileManager.js +1 -1
- package/dist/es/components/FileManager/InlineFilesSection.js +10 -10
- package/dist/es/components/icons/attach.js +2 -4
- package/dist/es/components/icons/upload.js +4 -6
- package/dist/es/lib/inlineFiles.js +23 -11
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +4 -2
- package/dist/types/components/icons/attach.d.ts +1 -1
- package/dist/types/components/icons/upload.d.ts +1 -1
- package/dist/types/lib/inlineFiles.d.ts +3 -3
- package/package.json +1 -1
|
@@ -130,7 +130,7 @@ const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, c
|
|
|
130
130
|
react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
|
|
131
131
|
react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
|
|
132
132
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
133
|
-
react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { modelMap: modelMap, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
133
|
+
react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { modelMap: modelMap, attachments: attachments, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
134
134
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
135
135
|
react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
136
136
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
@@ -32,8 +32,8 @@ const FileInfo_1 = require("./FileSectionItem/FileInfo");
|
|
|
32
32
|
const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
|
|
33
33
|
const ItemActions_1 = require("./FileSectionItem/ItemActions");
|
|
34
34
|
const util_1 = require("./util");
|
|
35
|
-
const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, isEditor, dispatch, }) => {
|
|
36
|
-
const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap), [modelMap]);
|
|
35
|
+
const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, attachments, isEditor, dispatch, }) => {
|
|
36
|
+
const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap, attachments]);
|
|
37
37
|
const onElementClick = (0, react_1.useCallback)((e) => {
|
|
38
38
|
if (!isEditor) {
|
|
39
39
|
return;
|
|
@@ -48,7 +48,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, model
|
|
|
48
48
|
return (react_1.default.createElement("div", null, inlineFiles.map((file, index) => {
|
|
49
49
|
var _a;
|
|
50
50
|
return (react_1.default.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
|
|
51
|
-
react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.
|
|
51
|
+
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 })))),
|
|
52
52
|
react_1.default.createElement(Element, { className: 'element' },
|
|
53
53
|
util_1.fileTypesWithIconMap.get(file.type),
|
|
54
54
|
react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
|
|
@@ -58,20 +58,20 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, model
|
|
|
58
58
|
})));
|
|
59
59
|
};
|
|
60
60
|
exports.InlineFilesSection = InlineFilesSection;
|
|
61
|
-
const FileReference = ({
|
|
61
|
+
const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, dispatch, }) => {
|
|
62
62
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
63
|
-
if (!
|
|
63
|
+
if (!attachment || !attachment.name) {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
const fileExtension =
|
|
67
|
-
return (react_1.default.createElement(FileReferenceItem, { key:
|
|
66
|
+
const fileExtension = attachment.name.substring(attachment.name.lastIndexOf('.') + 1);
|
|
67
|
+
return (react_1.default.createElement(FileReferenceItem, { key: attachment.id },
|
|
68
68
|
react_1.default.createElement(Container, null,
|
|
69
69
|
util_1.fileTypesWithIconMap.get(util_1.extensionsWithFileTypesMap.get(fileExtension)),
|
|
70
|
-
react_1.default.createElement(FileReferenceName, null,
|
|
70
|
+
react_1.default.createElement(FileReferenceName, null, attachment.name)),
|
|
71
71
|
handleDownload && handleReplace && submissionId && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
|
|
72
72
|
react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
73
73
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
74
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId:
|
|
74
|
+
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' }))))));
|
|
75
75
|
};
|
|
76
76
|
const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
|
|
77
77
|
display: flex;
|
|
@@ -19,8 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const react_1 = __importDefault(require("react"));
|
|
22
|
-
const AttachIcon = () => {
|
|
23
|
-
|
|
24
|
-
react_1.default.createElement("path", { d: "M8.85683 5.35715L5.85183 8.36215C5.16883 9.04515 5.16883 10.1531 5.85183 10.8371C6.53483 11.5201 7.64283 11.5201 8.32683 10.8371L12.3928 6.77115C13.7598 5.40415 13.7598 3.18815 12.3928 1.82115C11.0258 0.454148 8.80983 0.454148 7.44283 1.82115L3.02383 6.24115C0.973828 8.29115 0.973828 11.6151 3.02383 13.6661C5.07383 15.7161 8.39783 15.7161 10.4488 13.6661L14.5138 9.60015", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
25
|
-
};
|
|
22
|
+
const AttachIcon = () => (react_1.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
23
|
+
react_1.default.createElement("path", { d: "M8.85683 5.35715L5.85183 8.36215C5.16883 9.04515 5.16883 10.1531 5.85183 10.8371C6.53483 11.5201 7.64283 11.5201 8.32683 10.8371L12.3928 6.77115C13.7598 5.40415 13.7598 3.18815 12.3928 1.82115C11.0258 0.454148 8.80983 0.454148 7.44283 1.82115L3.02383 6.24115C0.973828 8.29115 0.973828 11.6151 3.02383 13.6661C5.07383 15.7161 8.39783 15.7161 10.4488 13.6661L14.5138 9.60015", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
26
24
|
exports.default = AttachIcon;
|
|
@@ -4,10 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const UploadIcon = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
react_1.default.createElement("path", { d: "M15.5 16.5H1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
12
|
-
};
|
|
7
|
+
const UploadIcon = () => (react_1.default.createElement("svg", { width: "17", height: "18", viewBox: "0 0 17 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
8
|
+
react_1.default.createElement("path", { d: "M8.5 12.5V1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
9
|
+
react_1.default.createElement("path", { d: "M13.5 6.5L8.5 1.5L3.5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
10
|
+
react_1.default.createElement("path", { d: "M15.5 16.5H1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
13
11
|
exports.default = UploadIcon;
|
|
@@ -6,33 +6,44 @@ const util_1 = require("../components/FileManager/util");
|
|
|
6
6
|
const getCaptionText = (caption) => caption &&
|
|
7
7
|
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
8
8
|
.innerText;
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const getAttachment = (externalFileRef, attachmentsMap) => {
|
|
10
|
+
if (!(externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.includes('https://'))) {
|
|
11
|
+
const attachmentId = externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.replace('attachment:', '');
|
|
12
|
+
return attachmentId ? attachmentsMap.get(attachmentId) : undefined;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return [...attachmentsMap.values()].find((attachment) => attachment.link === externalFileRef.url);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const getFigureData = (element, modelMap, attachmentsMap) => {
|
|
19
|
+
const attachments = [];
|
|
11
20
|
element.containedObjectIDs.map((e) => {
|
|
12
21
|
var _a;
|
|
13
22
|
const object = modelMap.get(e);
|
|
14
23
|
if (object && object.objectType === manuscripts_json_schema_1.ObjectTypes.Figure) {
|
|
15
24
|
const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
const attachment = getAttachment(externalFileRef, attachmentsMap);
|
|
26
|
+
if (attachment) {
|
|
27
|
+
attachments.push(attachment);
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
30
|
});
|
|
21
31
|
return {
|
|
22
32
|
id: element._id,
|
|
23
|
-
|
|
33
|
+
attachments,
|
|
24
34
|
caption: getCaptionText(element.caption),
|
|
25
35
|
};
|
|
26
36
|
};
|
|
27
|
-
exports.default = (modelMap) => {
|
|
37
|
+
exports.default = (modelMap, attachments) => {
|
|
28
38
|
const files = [];
|
|
39
|
+
const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
|
|
29
40
|
(0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Section).map((section) => {
|
|
30
41
|
var _a, _b;
|
|
31
42
|
if (section.category === 'MPSectionCategory:abstract-graphical') {
|
|
32
43
|
(_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.some((elementId) => {
|
|
33
44
|
const element = modelMap.get(elementId);
|
|
34
45
|
if (element && (0, manuscript_transform_1.hasObjectType)(manuscripts_json_schema_1.ObjectTypes.FigureElement)(element)) {
|
|
35
|
-
files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Graphical Abstract`, type: util_1.FileType.GraphicalAbstract }));
|
|
46
|
+
files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: util_1.FileType.GraphicalAbstract }));
|
|
36
47
|
return true;
|
|
37
48
|
}
|
|
38
49
|
});
|
|
@@ -47,19 +58,20 @@ exports.default = (modelMap) => {
|
|
|
47
58
|
switch (element.objectType) {
|
|
48
59
|
case manuscripts_json_schema_1.ObjectTypes.FigureElement:
|
|
49
60
|
case manuscripts_json_schema_1.ObjectTypes.MultiGraphicFigureElement: {
|
|
50
|
-
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: util_1.FileType.Figure }));
|
|
61
|
+
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure`, type: util_1.FileType.Figure }));
|
|
51
62
|
break;
|
|
52
63
|
}
|
|
53
64
|
case manuscripts_json_schema_1.ObjectTypes.TableElement: {
|
|
54
65
|
const tableElement = element;
|
|
55
66
|
const table = modelMap.get(tableElement.containedObjectID);
|
|
56
|
-
const
|
|
57
|
-
|
|
67
|
+
const externalFileReference = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((file) => file.kind === 'dataset' && file.ref);
|
|
68
|
+
const attachment = getAttachment(externalFileReference, attachmentsMap);
|
|
69
|
+
if (attachment) {
|
|
58
70
|
files.push({
|
|
59
71
|
id: element._id,
|
|
60
72
|
label: `Table`,
|
|
61
73
|
type: util_1.FileType.SheetsWorkbooks,
|
|
62
|
-
|
|
74
|
+
attachments: [attachment],
|
|
63
75
|
caption: getCaptionText(tableElement.caption),
|
|
64
76
|
});
|
|
65
77
|
}
|
|
@@ -105,7 +105,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, enableDragAnd
|
|
|
105
105
|
React.createElement("div", null, "Files excluded from the final submission.")))),
|
|
106
106
|
React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
|
|
107
107
|
React.createElement(InspectorTabPanel, null,
|
|
108
|
-
React.createElement(InlineFilesSection, { modelMap: modelMap, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
108
|
+
React.createElement(InlineFilesSection, { modelMap: modelMap, attachments: attachments, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
109
109
|
React.createElement(InspectorTabPanel, null,
|
|
110
110
|
React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
111
111
|
React.createElement(InspectorTabPanel, null,
|
|
@@ -4,11 +4,11 @@ import { useDropdown } from '../../hooks/use-dropdown';
|
|
|
4
4
|
import getInlineFiles from '../../lib/inlineFiles';
|
|
5
5
|
import DotsIcon from '../icons/dots-icon';
|
|
6
6
|
import { FileDescription, FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
|
|
7
|
-
import { ActionsIcon, Item } from './FileSectionItem/FileSectionItem';
|
|
7
|
+
import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
|
|
8
8
|
import { ItemActions } from './FileSectionItem/ItemActions';
|
|
9
9
|
import { extensionsWithFileTypesMap, fileTypesWithIconMap } from './util';
|
|
10
|
-
export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, isEditor, dispatch, }) => {
|
|
11
|
-
const inlineFiles = useMemo(() => getInlineFiles(modelMap), [modelMap]);
|
|
10
|
+
export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, attachments, isEditor, dispatch, }) => {
|
|
11
|
+
const inlineFiles = useMemo(() => getInlineFiles(modelMap, attachments), [modelMap, attachments]);
|
|
12
12
|
const onElementClick = useCallback((e) => {
|
|
13
13
|
if (!isEditor) {
|
|
14
14
|
return;
|
|
@@ -23,7 +23,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
|
|
|
23
23
|
return (React.createElement("div", null, inlineFiles.map((file, index) => {
|
|
24
24
|
var _a;
|
|
25
25
|
return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
|
|
26
|
-
React.createElement(FileReferences, { className: 'refItems' }, (_a = file.
|
|
26
|
+
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 })))),
|
|
27
27
|
React.createElement(Element, { className: 'element' },
|
|
28
28
|
fileTypesWithIconMap.get(file.type),
|
|
29
29
|
React.createElement(FileInfoContainer, null,
|
|
@@ -32,20 +32,20 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
|
|
|
32
32
|
file.caption && (React.createElement(FileDescription, null, file.caption))))));
|
|
33
33
|
})));
|
|
34
34
|
};
|
|
35
|
-
const FileReference = ({
|
|
35
|
+
const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, dispatch, }) => {
|
|
36
36
|
const { isOpen, toggleOpen, wrapperRef } = useDropdown();
|
|
37
|
-
if (!
|
|
37
|
+
if (!attachment || !attachment.name) {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
const fileExtension =
|
|
41
|
-
return (React.createElement(FileReferenceItem, { key:
|
|
40
|
+
const fileExtension = attachment.name.substring(attachment.name.lastIndexOf('.') + 1);
|
|
41
|
+
return (React.createElement(FileReferenceItem, { key: attachment.id },
|
|
42
42
|
React.createElement(Container, null,
|
|
43
43
|
fileTypesWithIconMap.get(extensionsWithFileTypesMap.get(fileExtension)),
|
|
44
|
-
React.createElement(FileReferenceName, null,
|
|
44
|
+
React.createElement(FileReferenceName, null, attachment.name)),
|
|
45
45
|
handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
46
46
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
47
47
|
React.createElement(DotsIcon, null)),
|
|
48
|
-
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId:
|
|
48
|
+
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' }))))));
|
|
49
49
|
};
|
|
50
50
|
const ElementItem = styled(Item) `
|
|
51
51
|
display: flex;
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import React from 'react';
|
|
17
|
-
const AttachIcon = () => {
|
|
18
|
-
|
|
19
|
-
React.createElement("path", { d: "M8.85683 5.35715L5.85183 8.36215C5.16883 9.04515 5.16883 10.1531 5.85183 10.8371C6.53483 11.5201 7.64283 11.5201 8.32683 10.8371L12.3928 6.77115C13.7598 5.40415 13.7598 3.18815 12.3928 1.82115C11.0258 0.454148 8.80983 0.454148 7.44283 1.82115L3.02383 6.24115C0.973828 8.29115 0.973828 11.6151 3.02383 13.6661C5.07383 15.7161 8.39783 15.7161 10.4488 13.6661L14.5138 9.60015", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
20
|
-
};
|
|
17
|
+
const AttachIcon = () => (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
18
|
+
React.createElement("path", { d: "M8.85683 5.35715L5.85183 8.36215C5.16883 9.04515 5.16883 10.1531 5.85183 10.8371C6.53483 11.5201 7.64283 11.5201 8.32683 10.8371L12.3928 6.77115C13.7598 5.40415 13.7598 3.18815 12.3928 1.82115C11.0258 0.454148 8.80983 0.454148 7.44283 1.82115L3.02383 6.24115C0.973828 8.29115 0.973828 11.6151 3.02383 13.6661C5.07383 15.7161 8.39783 15.7161 10.4488 13.6661L14.5138 9.60015", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
21
19
|
export default AttachIcon;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
const UploadIcon = () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
React.createElement("path", { d: "M15.5 16.5H1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
7
|
-
};
|
|
2
|
+
const UploadIcon = () => (React.createElement("svg", { width: "17", height: "18", viewBox: "0 0 17 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
3
|
+
React.createElement("path", { d: "M8.5 12.5V1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
4
|
+
React.createElement("path", { d: "M13.5 6.5L8.5 1.5L3.5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
5
|
+
React.createElement("path", { d: "M15.5 16.5H1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
|
|
8
6
|
export default UploadIcon;
|
|
@@ -4,33 +4,44 @@ import { FileType } from '../components/FileManager/util';
|
|
|
4
4
|
const getCaptionText = (caption) => caption &&
|
|
5
5
|
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
6
6
|
.innerText;
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const getAttachment = (externalFileRef, attachmentsMap) => {
|
|
8
|
+
if (!(externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.includes('https://'))) {
|
|
9
|
+
const attachmentId = externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.replace('attachment:', '');
|
|
10
|
+
return attachmentId ? attachmentsMap.get(attachmentId) : undefined;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return [...attachmentsMap.values()].find((attachment) => attachment.link === externalFileRef.url);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getFigureData = (element, modelMap, attachmentsMap) => {
|
|
17
|
+
const attachments = [];
|
|
9
18
|
element.containedObjectIDs.map((e) => {
|
|
10
19
|
var _a;
|
|
11
20
|
const object = modelMap.get(e);
|
|
12
21
|
if (object && object.objectType === ObjectTypes.Figure) {
|
|
13
22
|
const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
const attachment = getAttachment(externalFileRef, attachmentsMap);
|
|
24
|
+
if (attachment) {
|
|
25
|
+
attachments.push(attachment);
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
28
|
});
|
|
19
29
|
return {
|
|
20
30
|
id: element._id,
|
|
21
|
-
|
|
31
|
+
attachments,
|
|
22
32
|
caption: getCaptionText(element.caption),
|
|
23
33
|
};
|
|
24
34
|
};
|
|
25
|
-
export default (modelMap) => {
|
|
35
|
+
export default (modelMap, attachments) => {
|
|
26
36
|
const files = [];
|
|
37
|
+
const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
|
|
27
38
|
getModelsByType(modelMap, ObjectTypes.Section).map((section) => {
|
|
28
39
|
var _a, _b;
|
|
29
40
|
if (section.category === 'MPSectionCategory:abstract-graphical') {
|
|
30
41
|
(_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.some((elementId) => {
|
|
31
42
|
const element = modelMap.get(elementId);
|
|
32
43
|
if (element && hasObjectType(ObjectTypes.FigureElement)(element)) {
|
|
33
|
-
files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
|
|
44
|
+
files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
|
|
34
45
|
return true;
|
|
35
46
|
}
|
|
36
47
|
});
|
|
@@ -45,19 +56,20 @@ export default (modelMap) => {
|
|
|
45
56
|
switch (element.objectType) {
|
|
46
57
|
case ObjectTypes.FigureElement:
|
|
47
58
|
case ObjectTypes.MultiGraphicFigureElement: {
|
|
48
|
-
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: FileType.Figure }));
|
|
59
|
+
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure`, type: FileType.Figure }));
|
|
49
60
|
break;
|
|
50
61
|
}
|
|
51
62
|
case ObjectTypes.TableElement: {
|
|
52
63
|
const tableElement = element;
|
|
53
64
|
const table = modelMap.get(tableElement.containedObjectID);
|
|
54
|
-
const
|
|
55
|
-
|
|
65
|
+
const externalFileReference = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((file) => file.kind === 'dataset' && file.ref);
|
|
66
|
+
const attachment = getAttachment(externalFileReference, attachmentsMap);
|
|
67
|
+
if (attachment) {
|
|
56
68
|
files.push({
|
|
57
69
|
id: element._id,
|
|
58
70
|
label: `Table`,
|
|
59
71
|
type: FileType.SheetsWorkbooks,
|
|
60
|
-
|
|
72
|
+
attachments: [attachment],
|
|
61
73
|
caption: getCaptionText(tableElement.caption),
|
|
62
74
|
});
|
|
63
75
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
2
2
|
import React, { Dispatch } from 'react';
|
|
3
|
+
import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
|
|
3
4
|
import { Action } from './FileSectionState';
|
|
4
5
|
export interface ExternalFileRef {
|
|
5
6
|
url: string;
|
|
6
7
|
kind?: string;
|
|
7
|
-
ref?:
|
|
8
|
+
ref?: SubmissionAttachment;
|
|
8
9
|
}
|
|
9
10
|
export declare const InlineFilesSection: React.FC<{
|
|
10
11
|
submissionId: string;
|
|
12
|
+
attachments: SubmissionAttachment[];
|
|
11
13
|
modelMap: Map<string, Model>;
|
|
12
14
|
handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
13
15
|
handleDownload: (url: string) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
2
|
-
import {
|
|
2
|
+
import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
|
|
3
3
|
import { FileType } from '../components/FileManager/util';
|
|
4
|
-
declare const _default: (modelMap: Map<string, Model
|
|
4
|
+
declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => {
|
|
5
5
|
id: string;
|
|
6
6
|
label: string;
|
|
7
7
|
type: FileType;
|
|
8
8
|
caption?: string | undefined;
|
|
9
|
-
|
|
9
|
+
attachments?: SubmissionAttachment[] | undefined;
|
|
10
10
|
}[];
|
|
11
11
|
export default _default;
|
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.30.
|
|
4
|
+
"version": "0.30.27",
|
|
5
5
|
"repository": "gitlab:atypon-opensource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|