@manuscripts/article-editor 3.8.17-LEAN-4425.0 → 3.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.
- package/dist/cjs/components/FileManager/FileActions.js +43 -16
- package/dist/cjs/components/FileManager/FileActions.js.map +1 -1
- package/dist/cjs/components/FileManager/FileManager.js +7 -1
- package/dist/cjs/components/FileManager/FileManager.js.map +1 -1
- package/dist/cjs/components/FileManager/FileSectionAlert.js +12 -1
- package/dist/cjs/components/FileManager/FileSectionAlert.js.map +1 -1
- package/dist/cjs/components/FileManager/FileUploader.js +3 -3
- package/dist/cjs/components/FileManager/FileUploader.js.map +1 -1
- package/dist/cjs/components/FileManager/MainFilesSection.js +183 -0
- package/dist/cjs/components/FileManager/MainFilesSection.js.map +1 -0
- package/dist/cjs/components/FileManager/OtherFilesSection.js +12 -5
- package/dist/cjs/components/FileManager/OtherFilesSection.js.map +1 -1
- package/dist/cjs/components/FileManager/SupplementsSection.js +16 -4
- package/dist/cjs/components/FileManager/SupplementsSection.js.map +1 -1
- package/dist/es/components/FileManager/FileActions.js +44 -17
- package/dist/es/components/FileManager/FileActions.js.map +1 -1
- package/dist/es/components/FileManager/FileManager.js +7 -1
- package/dist/es/components/FileManager/FileManager.js.map +1 -1
- package/dist/es/components/FileManager/FileSectionAlert.js +12 -1
- package/dist/es/components/FileManager/FileSectionAlert.js.map +1 -1
- package/dist/es/components/FileManager/FileUploader.js +3 -3
- package/dist/es/components/FileManager/FileUploader.js.map +1 -1
- package/dist/es/components/FileManager/MainFilesSection.js +153 -0
- package/dist/es/components/FileManager/MainFilesSection.js.map +1 -0
- package/dist/es/components/FileManager/OtherFilesSection.js +13 -6
- package/dist/es/components/FileManager/OtherFilesSection.js.map +1 -1
- package/dist/es/components/FileManager/SupplementsSection.js +17 -5
- package/dist/es/components/FileManager/SupplementsSection.js.map +1 -1
- package/dist/types/components/FileManager/FileActions.d.ts +15 -0
- package/dist/types/components/FileManager/FileManager.d.ts +2 -1
- package/dist/types/components/FileManager/FileSectionAlert.d.ts +2 -1
- package/dist/types/components/FileManager/FileUploader.d.ts +2 -0
- package/dist/types/components/FileManager/MainFilesSection.d.ts +16 -0
- package/package.json +3 -3
@@ -1,29 +1,20 @@
|
|
1
|
-
|
2
|
-
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
-
*
|
4
|
-
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
-
*
|
6
|
-
* The Original Code is manuscripts-frontend.
|
7
|
-
*
|
8
|
-
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
-
*
|
10
|
-
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
|
-
*/
|
12
|
-
import { Category, Dialog, DotsIcon, DropdownContainer, DropdownList, useDropdown, usePermissions, } from '@manuscripts/style-guide';
|
1
|
+
import { AttentionOrangeIcon, Category, Dialog, DotsIcon, DropdownContainer, DropdownList, useDropdown, usePermissions, } from '@manuscripts/style-guide';
|
13
2
|
import React, { useRef, useState } from 'react';
|
14
3
|
import styled from 'styled-components';
|
15
4
|
/**
|
16
5
|
* This component represents the drop-down list action for each file item.
|
17
6
|
*/
|
18
|
-
export const FileActions = ({ sectionType, onDownload, onReplace, onDetach, move, className }) => {
|
7
|
+
export const FileActions = ({ sectionType, onDownload, onReplace, onDetach, onUseAsMain, move, className, file, accept, }) => {
|
19
8
|
const can = usePermissions();
|
20
9
|
const { isOpen, toggleOpen, wrapperRef } = useDropdown();
|
21
10
|
const [isMoveDialogOpen, setMoveDialogOpen] = useState(false);
|
11
|
+
const [isUseAsMainDialogOpen, setUseAsMainDialogOpen] = useState(false);
|
22
12
|
const showDownload = can?.downloadFiles && onDownload;
|
23
13
|
const showReplace = can?.replaceFile && onReplace;
|
24
14
|
const showDetach = can?.detachFile && onDetach;
|
25
15
|
const showMove = can?.moveFile && move;
|
26
|
-
const
|
16
|
+
const showUseAsMain = can?.moveFile && onUseAsMain && isValidMainDocumentFormat(file);
|
17
|
+
const show = showDownload || showReplace || showDetach || showMove || showUseAsMain;
|
27
18
|
const fileInputRef = useRef(null);
|
28
19
|
const handleChange = async (event) => {
|
29
20
|
if (onReplace && event && event.target && event.target.files) {
|
@@ -46,12 +37,38 @@ export const FileActions = ({ sectionType, onDownload, onReplace, onDetach, move
|
|
46
37
|
showDownload && (React.createElement(FileAction, { onClick: onDownload }, "Download")),
|
47
38
|
showReplace && (React.createElement(React.Fragment, null,
|
48
39
|
React.createElement(FileAction, { onClick: openFileDialog }, "Replace"),
|
49
|
-
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange }))),
|
40
|
+
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, accept: accept }))),
|
50
41
|
showDetach && React.createElement(FileAction, { onClick: onDetach }, "Detach"),
|
51
42
|
showMove && (React.createElement(FileAction, { onClick: () => setMoveDialogOpen(true) },
|
52
43
|
"Move to ",
|
53
|
-
move.sectionType))
|
54
|
-
|
44
|
+
move.sectionType)),
|
45
|
+
showUseAsMain && (React.createElement(FileAction, { onClick: () => setUseAsMainDialogOpen(true) }, "Use as main document")))),
|
46
|
+
showMove && (React.createElement(MoveFileConfirmationDialog, { "data-cy": "file-move-confirm-dialog", isOpen: isMoveDialogOpen, close: () => setMoveDialogOpen(false), source: sectionType, target: move.sectionType, handleMove: move.handler })),
|
47
|
+
showUseAsMain && (React.createElement(UseAsMainConfirmationDialog, { "data-cy": "file-use-as-main-confirm-dialog", isOpen: isUseAsMainDialogOpen, close: () => setUseAsMainDialogOpen(false), handleUseAsMain: onUseAsMain }))));
|
48
|
+
};
|
49
|
+
const UseAsMainConfirmationDialog = ({ isOpen, close, handleUseAsMain }) => {
|
50
|
+
const header = (React.createElement(React.Fragment, null,
|
51
|
+
React.createElement(StyledIcon, null),
|
52
|
+
"Use as main document"));
|
53
|
+
const message = (React.createElement(React.Fragment, null,
|
54
|
+
"This action will replace the current main document file with this one!",
|
55
|
+
React.createElement("br", null),
|
56
|
+
React.createElement("br", null),
|
57
|
+
"Do you want to continue?"));
|
58
|
+
const handleConfirm = () => {
|
59
|
+
handleUseAsMain();
|
60
|
+
close();
|
61
|
+
};
|
62
|
+
return (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: header, message: message, actions: {
|
63
|
+
primary: {
|
64
|
+
action: handleConfirm,
|
65
|
+
title: 'Replace',
|
66
|
+
},
|
67
|
+
secondary: {
|
68
|
+
action: () => close(),
|
69
|
+
title: 'Cancel',
|
70
|
+
},
|
71
|
+
} }));
|
55
72
|
};
|
56
73
|
const MoveFileConfirmationDialog = ({ isOpen, close, source, target, handleMove }) => {
|
57
74
|
const header = `Are you sure you want to move this file to “${target}”?`;
|
@@ -71,6 +88,9 @@ const MoveFileConfirmationDialog = ({ isOpen, close, source, target, handleMove
|
|
71
88
|
},
|
72
89
|
} }));
|
73
90
|
};
|
91
|
+
const StyledIcon = styled(AttentionOrangeIcon) `
|
92
|
+
margin-right: 8px;
|
93
|
+
`;
|
74
94
|
export const ActionsIcon = styled.button `
|
75
95
|
border: none;
|
76
96
|
background: transparent;
|
@@ -106,4 +126,11 @@ export const FileAction = styled.div `
|
|
106
126
|
background: #f2fbfc;
|
107
127
|
}
|
108
128
|
`;
|
129
|
+
const isValidMainDocumentFormat = (file) => {
|
130
|
+
if (!file) {
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
const validExtensions = ['.docx', '.doc', '.pdf', '.xml', '.tex'];
|
134
|
+
return validExtensions.some((ext) => file.name.toLowerCase().endsWith(ext.toLowerCase()));
|
135
|
+
};
|
109
136
|
//# sourceMappingURL=FileActions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileActions.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileActions.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"FileActions.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileActions.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAe,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAItC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAUnB,CAAC,EACJ,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,cAAc,EAAE,CAAA;IAC5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAAA;IACxD,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAA;IACtE,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,GACnD,QAAQ,CAAU,KAAK,CAAC,CAAA;IAE1B,MAAM,YAAY,GAAG,GAAG,EAAE,aAAa,IAAI,UAAU,CAAA;IACrD,MAAM,WAAW,GAAG,GAAG,EAAE,WAAW,IAAI,SAAS,CAAA;IACjD,MAAM,UAAU,GAAG,GAAG,EAAE,UAAU,IAAI,QAAQ,CAAA;IAC9C,MAAM,QAAQ,GAAG,GAAG,EAAE,QAAQ,IAAI,IAAI,CAAA;IACtC,MA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AM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;;;;;;CAWvC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;;;;;;gBAM1C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO;;;;CAI/D,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAA;iBACnB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;;;;WAI7C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;;;;;CAMpD,CAAA;AAED,MAAM,yBAAyB,GAAG,CAAC,IAAqB,EAAW,EAAE;IACnE,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAA;KACb;IAED,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAEjE,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAClC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CACpD,CAAA;AACH,CAAC,CAAA"}
|
@@ -16,6 +16,7 @@ import { useStore } from '../../store';
|
|
16
16
|
import { InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, SecondaryInspectorTab, } from '../Inspector';
|
17
17
|
import { FileManagerDragLayer } from './FileManagerDragLayer';
|
18
18
|
import { InlineFilesSection } from './InlineFilesSection';
|
19
|
+
import { MainFilesSection } from './MainFilesSection';
|
19
20
|
import { OtherFilesSection } from './OtherFilesSection';
|
20
21
|
import { SupplementsSection } from './SupplementsSection';
|
21
22
|
export var FileSectionType;
|
@@ -23,6 +24,7 @@ export var FileSectionType;
|
|
23
24
|
FileSectionType["Inline"] = "Inline files";
|
24
25
|
FileSectionType["Supplements"] = "Supplements";
|
25
26
|
FileSectionType["OtherFile"] = "Other files";
|
27
|
+
FileSectionType["MainFile"] = "Main Document";
|
26
28
|
})(FileSectionType || (FileSectionType = {}));
|
27
29
|
/**
|
28
30
|
* This is the main component of the file handling
|
@@ -41,12 +43,14 @@ export const FileManager = () => {
|
|
41
43
|
files: s.files,
|
42
44
|
inspectorOpenTabs: s.inspectorOpenTabs,
|
43
45
|
}));
|
44
|
-
const { figures, supplements, others } = groupFiles(doc, files);
|
46
|
+
const { figures, supplements, others, mainDocument } = groupFiles(doc, files);
|
45
47
|
return (React.createElement(InspectorTabs, { defaultIndex: 0, selectedIndex: inspectorOpenTabs?.secondaryTab || 0, "data-cy": "files-tabs", style: { overflow: 'visible' }, onChange: (index) => dispatch({ inspectorOpenTabs: { secondaryTab: index } }) },
|
46
48
|
React.createElement(FileManagerDragLayer, null),
|
47
49
|
React.createElement(InspectorTabList, null,
|
48
50
|
React.createElement(SecondaryInspectorTab, { "data-tooltip-id": "inline-tooltip" }, "Inline files"),
|
49
51
|
React.createElement(Tooltip, { id: "inline-tooltip", place: "bottom" }, "Files that can be found inline in the manuscript."),
|
52
|
+
React.createElement(SecondaryInspectorTab, { "data-tooltip-id": "main-tooltip" }, "Main Document"),
|
53
|
+
React.createElement(Tooltip, { id: "main-tooltip", place: "bottom" }, "The main document of the manuscript."),
|
50
54
|
React.createElement(SecondaryInspectorTab, { "data-tooltip-id": "supplements-tooltip" }, "Supplements"),
|
51
55
|
React.createElement(Tooltip, { id: "supplements-tooltip", place: "bottom" }, "Files that were marked as supplements."),
|
52
56
|
React.createElement(SecondaryInspectorTab, { "data-tooltip-id": "other-tooltip" }, "Other files"),
|
@@ -54,6 +58,8 @@ export const FileManager = () => {
|
|
54
58
|
React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
|
55
59
|
React.createElement(InspectorTabPanel, { "data-cy": "inline" },
|
56
60
|
React.createElement(InlineFilesSection, { elements: figures })),
|
61
|
+
React.createElement(InspectorTabPanel, { "data-cy": "main" },
|
62
|
+
React.createElement(MainFilesSection, { mainDocument: mainDocument[0] })),
|
57
63
|
React.createElement(InspectorTabPanel, { "data-cy": "supplements" },
|
58
64
|
React.createElement(SupplementsSection, { supplements: supplements })),
|
59
65
|
React.createElement(InspectorTabPanel, { "data-cy": "other" },
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileManager.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileManager.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,GACtB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,CAAN,IAAY,
|
1
|
+
{"version":3,"file":"FileManager.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileManager.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAA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_IN_PROGRESS"] = 1] = "UPLOAD_IN_PROGRESS";
|
21
21
|
FileSectionAlertType[FileSectionAlertType["UPLOAD_SUCCESSFUL"] = 2] = "UPLOAD_SUCCESSFUL";
|
22
22
|
FileSectionAlertType[FileSectionAlertType["MOVE_SUCCESSFUL"] = 3] = "MOVE_SUCCESSFUL";
|
23
|
+
FileSectionAlertType[FileSectionAlertType["REPLACE_SUCCESSFUL"] = 4] = "REPLACE_SUCCESSFUL";
|
23
24
|
})(FileSectionAlertType || (FileSectionAlertType = {}));
|
24
25
|
export const FileSectionAlert = ({ alert }) => {
|
25
26
|
return (React.createElement(React.Fragment, null,
|
26
27
|
alert.type === FileSectionAlertType.UPLOAD_IN_PROGRESS && (React.createElement(FileUploadInProgressAlert, { name: alert.message })),
|
27
28
|
alert.type === FileSectionAlertType.UPLOAD_SUCCESSFUL && (React.createElement(FileUploadSuccessful, null)),
|
28
|
-
alert.type === FileSectionAlertType.MOVE_SUCCESSFUL && (React.createElement(FileMoveSuccessful, { name: alert.message }))
|
29
|
+
alert.type === FileSectionAlertType.MOVE_SUCCESSFUL && (React.createElement(FileMoveSuccessful, { name: alert.message })),
|
30
|
+
alert.type === FileSectionAlertType.REPLACE_SUCCESSFUL && (React.createElement(FileReplaceSuccessful, { name: alert.message }))));
|
29
31
|
};
|
30
32
|
const FileUploadInProgressAlert = ({ name }) => {
|
31
33
|
return (React.createElement(FileUploadContainer, null,
|
@@ -48,6 +50,15 @@ const FileMoveSuccessful = ({ name }) => {
|
|
48
50
|
"File moved to ",
|
49
51
|
name)));
|
50
52
|
};
|
53
|
+
const FileReplaceSuccessful = ({ name }) => {
|
54
|
+
return (React.createElement(AlertMessageContainer, null,
|
55
|
+
React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
56
|
+
text: 'OK',
|
57
|
+
} },
|
58
|
+
"File replaced with ",
|
59
|
+
name,
|
60
|
+
" successfully")));
|
61
|
+
};
|
51
62
|
const AlertMessageContainer = styled.div `
|
52
63
|
margin-left: 16px;
|
53
64
|
margin-right: 16px;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileSectionAlert.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileSectionAlert.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,CAAN,IAAY,
|
1
|
+
{"version":3,"file":"FileSectionAlert.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileSectionAlert.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,CAAN,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,+DAAI,CAAA;IACJ,2FAAkB,CAAA;IAClB,yFAAiB,CAAA;IACjB,qFAAe,CAAA;IACf,2FAAkB,CAAA;AACpB,CAAC,EANW,oBAAoB,KAApB,oBAAoB,QAM/B;AAED,MAAM,CAAC,MAAM,gBAAgB,GAExB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjB,OAAO,CACL;QACG,KAAK,CAAC,IAAI,KAAK,oBAAoB,CAAC,kBAAkB,IAAI,CACzD,oBAAC,yBAAyB,IAAC,IAAI,EAAE,KAAK,CAAC,OA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AAO,CACL,oBAAC,qBAAqB;QACpB,oBAAC,YAAY,IACX,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAC9B,eAAe,EAAE,IAAI,EACrB,aAAa,EAAE;gBACb,IAAI,EAAE,IAAI;aACX;;YAEmB,IAAI;4BACX,CACO,CACzB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGvC,CAAA;AAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;;CAEhD,CAAA;AAED,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzC,CAAA;AAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;;CAE9C,CAAA;AAED,MAAM,qBAAqB,GAAa,GAAG,EAAE;IAC3C,OAAO,CACL,oBAAC,cAAc;QACb,oBAAC,GAAG,IAAC,SAAS,EAAC,MAAM,GAAO;QAC5B,oBAAC,GAAG,IAAC,SAAS,EAAC,MAAM,GAAO,CACb,CAClB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;gBACjB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ;;;;;;;;;CAShE,CAAA;AACD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FrB,CAAA"}
|
@@ -16,7 +16,7 @@ import styled, { css } from 'styled-components';
|
|
16
16
|
/**
|
17
17
|
* This component will show the drag or upload file area
|
18
18
|
*/
|
19
|
-
export const FileUploader = ({ onUpload }) => {
|
19
|
+
export const FileUploader = ({ onUpload, placeholder, accept, }) => {
|
20
20
|
const fileInputRef = useRef(null);
|
21
21
|
const openFileDialog = () => {
|
22
22
|
if (fileInputRef && fileInputRef.current) {
|
@@ -42,8 +42,8 @@ export const FileUploader = ({ onUpload }) => {
|
|
42
42
|
});
|
43
43
|
const isActive = canDrop && isOver;
|
44
44
|
return (React.createElement(Container, { ref: dropRef, "data-cy": "file-uploader", active: isActive, onClick: openFileDialog },
|
45
|
-
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, value: '' }),
|
46
|
-
|
45
|
+
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, accept: accept, value: '' }),
|
46
|
+
placeholder));
|
47
47
|
};
|
48
48
|
const activeBoxStyle = css `
|
49
49
|
background: #f2fbfc;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileUploader.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileUploader.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,EAAe,MAAM,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;
|
1
|
+
{"version":3,"file":"FileUploader.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileUploader.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,EAAe,MAAM,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAY/C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,EACxD,QAAQ,EACR,WAAW,EACX,MAAM,GACP,EAAE,EAAE;IACH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,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,EAAE,GACT;QACD,WAAW,CACF,CACb,CAAA;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,GAAG,CAAA;;;CAGzB,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAqB;gBACjC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS;;;;;;;;;;iBAUjD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;WAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;;IAGjD,CAAC,KAAK,EAAE,EAAE,CACV,KAAK,CAAC,MAAM;IACV,CAAC,CAAC,GAAG,CAAA;YACC,cAAc;SACjB;IACH,CAAC,CAAC,GAAG,CAAA,EAAE;CACZ,CAAA"}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
/*!
|
2
|
+
* The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
+
*
|
4
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
+
*
|
6
|
+
* The Original Code is manuscripts-frontend.
|
7
|
+
*
|
8
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
+
*
|
10
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2025 Atypon Systems LLC. All Rights Reserved.
|
11
|
+
*/
|
12
|
+
import { insertAttachment } from '@manuscripts/body-editor';
|
13
|
+
import { Category, Dialog, FileMainDocumentIcon, usePermissions, } from '@manuscripts/style-guide';
|
14
|
+
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
15
|
+
import React, { useState } from 'react';
|
16
|
+
import styled from 'styled-components';
|
17
|
+
import { useStore } from '../../store';
|
18
|
+
import { FileActions } from './FileActions';
|
19
|
+
import { FileSectionType } from './FileManager';
|
20
|
+
import { FileSectionAlert, FileSectionAlertType } from './FileSectionAlert';
|
21
|
+
import { FileUploader } from './FileUploader';
|
22
|
+
const MainDocumentContainer = styled.div `
|
23
|
+
display: flex;
|
24
|
+
align-items: center;
|
25
|
+
padding: 26px 16px;
|
26
|
+
gap: 12px;
|
27
|
+
position: relative;
|
28
|
+
&:hover {
|
29
|
+
background-color: #f2fbfc;
|
30
|
+
}
|
31
|
+
`;
|
32
|
+
const MainDocumentInfo = styled.div `
|
33
|
+
display: flex;
|
34
|
+
flex: 1;
|
35
|
+
`;
|
36
|
+
const MainDocumentTitle = styled.div `
|
37
|
+
color: ${(props) => props.theme.colors.text.primary};
|
38
|
+
font-weight: 700;
|
39
|
+
display: flex;
|
40
|
+
align-items: center;
|
41
|
+
margin-top: 20px;
|
42
|
+
padding: 0 16px 8px 16px;
|
43
|
+
gap: 12px;
|
44
|
+
position: relative;
|
45
|
+
`;
|
46
|
+
const Label = styled.span `
|
47
|
+
color: ${(props) => props.theme.colors.text.primary};
|
48
|
+
font-size: 16px;
|
49
|
+
margin-right: 3.2px;
|
50
|
+
font-weight: 700;
|
51
|
+
`;
|
52
|
+
const FileName = styled.span `
|
53
|
+
color: ${(props) => props.theme.colors.text.primary};
|
54
|
+
font-size: 16px;
|
55
|
+
`;
|
56
|
+
export const MainFilesSection = ({ mainDocument, }) => {
|
57
|
+
const [{ fileManagement, view }] = useStore((s) => ({
|
58
|
+
fileManagement: s.fileManagement,
|
59
|
+
view: s.view,
|
60
|
+
}));
|
61
|
+
const can = usePermissions();
|
62
|
+
const [alert, setAlert] = useState({
|
63
|
+
type: FileSectionAlertType.NONE,
|
64
|
+
message: '',
|
65
|
+
});
|
66
|
+
const [isConfirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
67
|
+
const [fileToUpload, setFileToUpload] = useState(null);
|
68
|
+
const handleUpload = async (file) => {
|
69
|
+
if (mainDocument) {
|
70
|
+
setFileToUpload(file);
|
71
|
+
setConfirmDialogOpen(true);
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
await uploadFile(file);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
if (!view) {
|
78
|
+
return null;
|
79
|
+
}
|
80
|
+
const uploadFile = async (file) => {
|
81
|
+
setAlert({
|
82
|
+
type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
|
83
|
+
message: file.name,
|
84
|
+
});
|
85
|
+
const uploaded = await fileManagement.upload(file);
|
86
|
+
insertAttachment(uploaded, view.state, 'document', view.dispatch);
|
87
|
+
setAlert({
|
88
|
+
type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
|
89
|
+
message: '',
|
90
|
+
});
|
91
|
+
return uploaded;
|
92
|
+
};
|
93
|
+
const handleDownload = () => {
|
94
|
+
if (mainDocument) {
|
95
|
+
fileManagement.download(mainDocument.file);
|
96
|
+
}
|
97
|
+
};
|
98
|
+
const handleReplace = async (file) => {
|
99
|
+
setFileToUpload(file);
|
100
|
+
setConfirmDialogOpen(true);
|
101
|
+
};
|
102
|
+
const handleMove = (mainFile) => {
|
103
|
+
const tr = view.state.tr;
|
104
|
+
const from = mainFile.pos;
|
105
|
+
const to = from + mainFile.node.nodeSize;
|
106
|
+
tr.delete(from, to);
|
107
|
+
view.dispatch(skipTracking(tr));
|
108
|
+
setAlert({
|
109
|
+
type: FileSectionAlertType.MOVE_SUCCESSFUL,
|
110
|
+
message: FileSectionType.OtherFile,
|
111
|
+
});
|
112
|
+
};
|
113
|
+
return (React.createElement("div", null,
|
114
|
+
mainDocument ? (React.createElement(MainDocumentContainer, { "data-cy": "file-container" },
|
115
|
+
React.createElement(FileMainDocumentIcon, null),
|
116
|
+
React.createElement(MainDocumentInfo, null,
|
117
|
+
React.createElement(Label, null, "Main:"),
|
118
|
+
React.createElement(FileName, null, mainDocument.file.name)),
|
119
|
+
React.createElement(FileActions, { "data-cy": "file-actions", sectionType: FileSectionType.MainFile, onDownload: handleDownload, onReplace: handleReplace, move: {
|
120
|
+
sectionType: FileSectionType.OtherFile,
|
121
|
+
handler: () => handleMove(mainDocument),
|
122
|
+
}, file: mainDocument.file, accept: ".docx, .doc, .pdf, .xml, .tex" }))) : (can?.uploadFile && (React.createElement(MainDocumentTitle, null, "Upload main document"))),
|
123
|
+
can?.uploadFile && (React.createElement(FileUploader, { onUpload: handleUpload, placeholder: "Drag or click to replace with a new file", accept: ".docx, .doc, .pdf, .xml, .tex" })),
|
124
|
+
React.createElement(FileSectionAlert, { alert: alert }),
|
125
|
+
React.createElement(Dialog, { isOpen: isConfirmDialogOpen, category: Category.confirmation, header: "Replace Main Document", message: React.createElement(React.Fragment, null,
|
126
|
+
"This action will replace the current main document file with this one!",
|
127
|
+
React.createElement("br", null),
|
128
|
+
React.createElement("br", null),
|
129
|
+
"Do you want to continue?"), actions: {
|
130
|
+
primary: {
|
131
|
+
action: async () => {
|
132
|
+
if (fileToUpload) {
|
133
|
+
const uploaded = await fileManagement.upload(fileToUpload);
|
134
|
+
insertAttachment(uploaded, view.state, 'document', view.dispatch);
|
135
|
+
}
|
136
|
+
setConfirmDialogOpen(false);
|
137
|
+
setAlert({
|
138
|
+
type: FileSectionAlertType.REPLACE_SUCCESSFUL,
|
139
|
+
message: FileSectionType.MainFile,
|
140
|
+
});
|
141
|
+
},
|
142
|
+
title: 'Replace',
|
143
|
+
},
|
144
|
+
secondary: {
|
145
|
+
action: () => {
|
146
|
+
setFileToUpload(null);
|
147
|
+
setConfirmDialogOpen(false);
|
148
|
+
},
|
149
|
+
title: 'Cancel',
|
150
|
+
},
|
151
|
+
} })));
|
152
|
+
};
|
153
|
+
//# sourceMappingURL=MainFilesSection.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MainFilesSection.js","sourceRoot":"","sources":["../../../../src/components/FileManager/MainFilesSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAY,MAAM,0BAA0B,CAAA;AACrE,OAAO,EACL,QAAQ,EACR,MAAM,EACN,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;CASvC,CAAA;AAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGlC,CAAA;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;WACzB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;;;;;;;CAQpD,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;WACd,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;;;CAIpD,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;WACjB,CAA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C,CAAA;oBACJ,CAAC;oBACD,KAAK,EAAE,SAAS;iBACjB;gBACD,SAAS,EAAE;oBACT,MAAM,EAAE,GAAG,EAAE;wBACX,eAAe,CAAC,IAAI,CAAC,CAAA;wBACrB,oBAAoB,CAAC,KAAK,CAAC,CAAA;oBAC7B,CAAC;oBACD,KAAK,EAAE,QAAQ;iBAChB;aACF,GACD,CACE,CACP,CAAA;AACH,CAAC,CAAA"}
|
@@ -9,7 +9,7 @@
|
|
9
9
|
*
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
11
|
*/
|
12
|
-
import { insertSupplement } from '@manuscripts/body-editor';
|
12
|
+
import { insertAttachment, insertSupplement, } from '@manuscripts/body-editor';
|
13
13
|
import { usePermissions } from '@manuscripts/style-guide';
|
14
14
|
import React, { useEffect, useState } from 'react';
|
15
15
|
import { useDrag } from 'react-dnd';
|
@@ -56,12 +56,19 @@ export const OtherFilesSection = ({ files }) => {
|
|
56
56
|
message: FileSectionType.Supplements,
|
57
57
|
});
|
58
58
|
};
|
59
|
+
const asMainDocument = async (file) => {
|
60
|
+
insertAttachment(file, view.state, 'document', view.dispatch);
|
61
|
+
setAlert({
|
62
|
+
type: FileSectionAlertType.MOVE_SUCCESSFUL,
|
63
|
+
message: FileSectionType.MainFile,
|
64
|
+
});
|
65
|
+
};
|
59
66
|
return (React.createElement("div", null,
|
60
|
-
can?.uploadFile && React.createElement(FileUploader, { onUpload: handleUpload }),
|
67
|
+
can?.uploadFile && (React.createElement(FileUploader, { onUpload: handleUpload, placeholder: "Drag or click to upload a new file" })),
|
61
68
|
React.createElement(FileSectionAlert, { alert: alert }),
|
62
|
-
files.map((file) => (React.createElement(OtherFile, { key: file.id, file: file, onDownload: () => fileManagement.download(file), onMoveToSupplements: async () => await moveToSupplements(file) })))));
|
69
|
+
files.map((file) => (React.createElement(OtherFile, { key: file.id, file: file, onDownload: () => fileManagement.download(file), onMoveToSupplements: async () => await moveToSupplements(file), onUseAsMain: async () => await asMainDocument(file) })))));
|
63
70
|
};
|
64
|
-
const OtherFile = ({ file, onDownload, onMoveToSupplements }) => {
|
71
|
+
const OtherFile = ({ file, onDownload, onMoveToSupplements, onUseAsMain }) => {
|
65
72
|
const [{ isDragging }, dragRef, preview] = useDrag({
|
66
73
|
type: 'file',
|
67
74
|
item: {
|
@@ -77,9 +84,9 @@ const OtherFile = ({ file, onDownload, onMoveToSupplements }) => {
|
|
77
84
|
return (React.createElement(FileContainer, { key: file.id, "data-cy": "file-container", ref: dragRef, className: isDragging ? 'dragging' : '' },
|
78
85
|
React.createElement(FileName, { file: file }),
|
79
86
|
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
80
|
-
React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, onDownload: onDownload, move: {
|
87
|
+
React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, onDownload: onDownload, onUseAsMain: onUseAsMain, move: {
|
81
88
|
sectionType: FileSectionType.Supplements,
|
82
89
|
handler: onMoveToSupplements,
|
83
|
-
} })));
|
90
|
+
}, file: file })));
|
84
91
|
};
|
85
92
|
//# sourceMappingURL=OtherFilesSection.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"OtherFilesSection.js","sourceRoot":"","sources":["../../../../src/components/FileManager/OtherFilesSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,
|
1
|
+
{"version":3,"file":"OtherFilesSection.js","sourceRoot":"","sources":["../../../../src/components/FileManager/OtherFilesSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,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ACnD,CACH,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAKV,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,EAAE,EAAE;IAC9D,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QACjD,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE;YACJ,IAAI;SACL;QACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrB,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;SACjC,CAAC;KACH,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;IAC1B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,OAAO,CACL,oBAAC,aAAa,IACZ,GAAG,EAAE,IAAI,CAAC,EAAE,aACJ,gBAAgB,EACxB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QAEvC,oBAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,GAAI;QACxB,oBAAC,eAAe,IAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,eAAe,GAAG;QACzD,oBAAC,WAAW,IACV,WAAW,EAAE,eAAe,CAAC,SAAS,EACtC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE;gBACJ,WAAW,EAAE,eAAe,CAAC,WAAW;gBACxC,OAAO,EAAE,mBAAmB;aAC7B,EACD,IAAI,EAAE,IAAI,GACV,CACY,CACjB,CAAA;AACH,CAAC,CAAA"}
|
@@ -9,7 +9,7 @@
|
|
9
9
|
*
|
10
10
|
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
11
|
*/
|
12
|
-
import { insertSupplement } from '@manuscripts/body-editor';
|
12
|
+
import { insertAttachment, insertSupplement, } from '@manuscripts/body-editor';
|
13
13
|
import { usePermissions } from '@manuscripts/style-guide';
|
14
14
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
15
15
|
import React, { useEffect, useState } from 'react';
|
@@ -72,12 +72,24 @@ export const SupplementsSection = ({ supplements, }) => {
|
|
72
72
|
message: FileSectionType.OtherFile,
|
73
73
|
});
|
74
74
|
};
|
75
|
+
const handleUseAsMain = async (supplement) => {
|
76
|
+
const tr = view.state.tr;
|
77
|
+
const from = supplement.pos;
|
78
|
+
const to = from + supplement.node.nodeSize;
|
79
|
+
tr.delete(from, to);
|
80
|
+
view.dispatch(skipTracking(tr));
|
81
|
+
insertAttachment(supplement.file, view.state, 'document', view.dispatch);
|
82
|
+
setAlert({
|
83
|
+
type: FileSectionAlertType.MOVE_SUCCESSFUL,
|
84
|
+
message: FileSectionType.MainFile,
|
85
|
+
});
|
86
|
+
};
|
75
87
|
return (React.createElement(React.Fragment, null,
|
76
|
-
can?.uploadFile && React.createElement(FileUploader, { onUpload: handleUpload }),
|
88
|
+
can?.uploadFile && (React.createElement(FileUploader, { onUpload: handleUpload, placeholder: "Drag or click to upload a new file" })),
|
77
89
|
React.createElement(FileSectionAlert, { alert: alert }),
|
78
|
-
supplements.map((supplement) => (React.createElement(SupplementFile, { key: supplement.node.attrs.id, supplement: supplement, onDownload: () => fileManagement.download(supplement.file), onReplace: async (f) => await handleReplace(supplement, f), onDetach: () => handleMoveToOtherFiles(supplement) })))));
|
90
|
+
supplements.map((supplement) => (React.createElement(SupplementFile, { key: supplement.node.attrs.id, supplement: supplement, onDownload: () => fileManagement.download(supplement.file), onReplace: async (f) => await handleReplace(supplement, f), onDetach: () => handleMoveToOtherFiles(supplement), onUseAsMain: () => handleUseAsMain(supplement) })))));
|
79
91
|
};
|
80
|
-
const SupplementFile = ({ supplement, onDownload, onReplace, onDetach }) => {
|
92
|
+
const SupplementFile = ({ supplement, onDownload, onReplace, onDetach, onUseAsMain }) => {
|
81
93
|
const [{ isDragging }, dragRef, preview] = useDrag({
|
82
94
|
type: 'file',
|
83
95
|
item: {
|
@@ -103,6 +115,6 @@ const SupplementFile = ({ supplement, onDownload, onReplace, onDetach }) => {
|
|
103
115
|
sectionType: FileSectionType.OtherFile,
|
104
116
|
handler: onDetach,
|
105
117
|
}
|
106
|
-
: undefined })));
|
118
|
+
: undefined, onUseAsMain: onUseAsMain, file: supplement.file })));
|
107
119
|
};
|
108
120
|
//# sourceMappingURL=SupplementsSection.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SupplementsSection.js","sourceRoot":"","sources":["../../../../src/components/FileManager/SupplementsSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,
|
1
|
+
{"version":3,"file":"SupplementsSection.js","sourceRoot":"","sources":["../../../../src/components/FileManager/SupplementsSection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAW,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAA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ents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
3
|
+
*
|
4
|
+
* Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
5
|
+
*
|
6
|
+
* The Original Code is manuscripts-frontend.
|
7
|
+
*
|
8
|
+
* The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
|
9
|
+
*
|
10
|
+
* All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
|
11
|
+
*/
|
12
|
+
import { FileAttachment } from '@manuscripts/body-editor';
|
1
13
|
import React from 'react';
|
2
14
|
import { FileSectionType, Move, Replace } from './FileManager';
|
3
15
|
/**
|
@@ -8,8 +20,11 @@ export declare const FileActions: React.FC<{
|
|
8
20
|
onDownload?: () => void;
|
9
21
|
onReplace?: Replace;
|
10
22
|
onDetach?: () => void;
|
23
|
+
onUseAsMain?: () => void;
|
11
24
|
move?: Move;
|
12
25
|
className?: string;
|
26
|
+
file?: FileAttachment;
|
27
|
+
accept?: string;
|
13
28
|
}>;
|
14
29
|
export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
15
30
|
export declare const FileActionDropdownList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
2
2
|
export declare enum FileSectionType {
|
3
3
|
Inline = "Inline files",
|
4
4
|
Supplements = "Supplements",
|
5
|
-
OtherFile = "Other files"
|
5
|
+
OtherFile = "Other files",
|
6
|
+
MainFile = "Main Document"
|
6
7
|
}
|
7
8
|
export type Replace = (file: File) => Promise<void>;
|
8
9
|
export type Move = {
|