@manuscripts/style-guide 1.13.12-LEAN-3771.0 → 1.13.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/components/FileManager/FileActions.js +134 -0
  2. package/dist/cjs/components/FileManager/FileContainer.js +39 -0
  3. package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
  4. package/dist/cjs/components/FileManager/FileManager.js +60 -0
  5. package/dist/cjs/components/FileManager/FileManagerDragLayer.js +55 -0
  6. package/dist/cjs/components/FileManager/FileManagerProvider.js +39 -0
  7. package/dist/cjs/components/FileManager/FileName.js +27 -0
  8. package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
  9. package/dist/cjs/components/FileManager/FileTypeIcon.js +20 -0
  10. package/dist/cjs/components/FileManager/FileUploader.js +85 -0
  11. package/dist/cjs/components/FileManager/InlineFilesSection.js +133 -0
  12. package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
  13. package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
  14. package/dist/cjs/components/FileManager/index.js +32 -0
  15. package/dist/cjs/components/FileManager/util.js +138 -0
  16. package/dist/cjs/components/InsertTableDialog.js +130 -0
  17. package/dist/cjs/components/Menus/Menus.js +19 -2
  18. package/dist/cjs/hooks/use-files.js +39 -0
  19. package/dist/cjs/hooks/use-menus.js +2 -2
  20. package/dist/cjs/index.js +4 -0
  21. package/dist/cjs/lib/files.js +77 -125
  22. package/dist/es/components/FileManager/FileActions.js +104 -0
  23. package/dist/es/components/FileManager/FileContainer.js +33 -0
  24. package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
  25. package/dist/es/components/FileManager/FileManager.js +33 -0
  26. package/dist/es/components/FileManager/FileManagerDragLayer.js +48 -0
  27. package/dist/es/components/FileManager/FileManagerProvider.js +12 -0
  28. package/dist/es/components/FileManager/FileName.js +20 -0
  29. package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
  30. package/dist/es/components/FileManager/FileTypeIcon.js +13 -0
  31. package/dist/es/components/FileManager/FileUploader.js +58 -0
  32. package/dist/es/components/FileManager/InlineFilesSection.js +103 -0
  33. package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
  34. package/dist/es/components/FileManager/SupplementsSection.js +91 -0
  35. package/dist/es/components/FileManager/index.js +16 -0
  36. package/dist/es/components/FileManager/util.js +128 -0
  37. package/dist/es/components/InsertTableDialog.js +100 -0
  38. package/dist/es/components/Menus/Menus.js +19 -2
  39. package/dist/es/hooks/use-files.js +35 -0
  40. package/dist/es/hooks/use-menus.js +2 -2
  41. package/dist/es/index.js +4 -0
  42. package/dist/es/lib/files.js +73 -117
  43. package/dist/types/components/FileManager/FileActions.d.ts +19 -0
  44. package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
  45. package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
  46. package/dist/types/components/FileManager/FileManager.d.ts +30 -0
  47. package/dist/types/components/FileManager/FileManagerDragLayer.d.ts +2 -0
  48. package/dist/types/components/FileManager/FileManagerProvider.d.ts +15 -0
  49. package/dist/types/components/FileManager/FileName.d.ts +6 -0
  50. package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
  51. package/dist/types/components/FileManager/FileTypeIcon.d.ts +5 -0
  52. package/dist/types/components/FileManager/FileUploader.d.ts +5 -0
  53. package/dist/types/components/FileManager/InlineFilesSection.d.ts +6 -0
  54. package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
  55. package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
  56. package/dist/types/components/FileManager/index.d.ts +16 -0
  57. package/dist/types/components/FileManager/util.d.ts +25 -0
  58. package/dist/types/components/InsertTableDialog.d.ts +22 -0
  59. package/dist/types/components/Menus/Menus.d.ts +2 -2
  60. package/dist/types/hooks/use-files.d.ts +8 -0
  61. package/dist/types/hooks/use-menus.d.ts +2 -2
  62. package/dist/types/index.d.ts +4 -0
  63. package/dist/types/lib/files.d.ts +24 -19
  64. package/dist/types/lib/menus.d.ts +6 -1
  65. package/package.json +1 -1
@@ -0,0 +1,100 @@
1
+ /*!
2
+ * © 2024 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import React, { useState } from 'react';
17
+ import Select from 'react-select';
18
+ import styled from 'styled-components';
19
+ import { CheckboxField, CheckboxLabel } from './Checkbox';
20
+ import { Category, Dialog } from './Dialog';
21
+ const Label = styled.div `
22
+ padding-right: 16px;
23
+ width: 150px;
24
+ `;
25
+ const SelectContainer = styled.div `
26
+ width: 182px;
27
+ height: 30px;
28
+ `;
29
+ const Container = styled.div `
30
+ display: flex;
31
+ align-items: center;
32
+ padding-bottom: 16px;
33
+ `;
34
+ const OptionWrapper = styled.div `
35
+ padding-left: ${(props) => props.theme.grid.unit * 4}px;
36
+ padding-top: ${(props) => props.theme.grid.unit * 2}px;
37
+ padding-bottom: ${(props) => props.theme.grid.unit * 2}px;
38
+
39
+ background-color: ${(props) => props.focused ? props.theme.colors.background.fifth : 'transparent'};
40
+
41
+ &:hover {
42
+ background-color: ${(props) => props.theme.colors.background.fifth};
43
+ }
44
+ `;
45
+ export const InsertTableDialog = ({ run, open, onClose }) => {
46
+ const [numberOfColumns, setNumColumns] = useState({ value: 4, label: `4` });
47
+ const [numberOfRows, setNumRows] = useState({ value: 4, label: `4` });
48
+ const [includeHeader, setIncludeHeader] = useState(true);
49
+ const handleColumnChange = (newValue) => {
50
+ setNumColumns(newValue);
51
+ };
52
+ const handleRowChange = (newValue) => {
53
+ setNumRows(newValue);
54
+ };
55
+ const options = Array.from({ length: 20 }, (_, index) => ({
56
+ value: index + 1,
57
+ label: `${index + 1}`,
58
+ }));
59
+ const OptionComponent = ({ innerProps, data, }) => {
60
+ return (React.createElement(OptionWrapper, Object.assign({}, innerProps, { ref: null }), data.label));
61
+ };
62
+ const insertTableDialogActions = {
63
+ primary: {
64
+ action: () => {
65
+ const tableConfig = {
66
+ numberOfColumns: numberOfColumns.value,
67
+ numberOfRows: numberOfRows.value,
68
+ includeHeader,
69
+ };
70
+ run(tableConfig);
71
+ onClose();
72
+ },
73
+ title: 'Create table',
74
+ },
75
+ secondary: {
76
+ action: onClose,
77
+ title: 'Cancel',
78
+ },
79
+ };
80
+ return (React.createElement(Dialog, { isOpen: open, actions: insertTableDialogActions, category: Category.confirmation, header: 'Insert table', message: '' },
81
+ React.createElement(React.Fragment, null,
82
+ React.createElement(React.Fragment, null,
83
+ React.createElement(Container, null,
84
+ React.createElement(Label, null, "Number of columns:"),
85
+ React.createElement(SelectContainer, null,
86
+ React.createElement(Select, { onChange: (newValue) => handleColumnChange(newValue), value: numberOfColumns, options: options, components: {
87
+ Option: OptionComponent,
88
+ }, menuPosition: "fixed", maxMenuHeight: 150 }))),
89
+ React.createElement(Container, null,
90
+ React.createElement(Label, null, "Number of rows:"),
91
+ React.createElement(SelectContainer, null,
92
+ React.createElement(Select, { onChange: (newValue) => handleRowChange(newValue), value: numberOfRows, options: options, components: {
93
+ Option: OptionComponent,
94
+ }, menuPosition: "fixed", maxMenuHeight: 150 })))),
95
+ React.createElement(CheckboxLabel, null,
96
+ React.createElement(CheckboxField, { name: 'include-header', checked: includeHeader, onChange: (e) => {
97
+ setIncludeHeader(e.target.checked);
98
+ } }),
99
+ React.createElement("div", null, "Include header row")))));
100
+ };
@@ -16,6 +16,7 @@
16
16
  import React, { useState } from 'react';
17
17
  import styled from 'styled-components';
18
18
  import { Category, Dialog } from '../Dialog';
19
+ import { InsertTableDialog } from '../InsertTableDialog';
19
20
  import { Submenu, SubmenusContainer, Text } from './Submenu';
20
21
  const MenusContainer = styled.div `
21
22
  display: flex;
@@ -40,6 +41,11 @@ const MenuContainer = styled.div `
40
41
  `;
41
42
  export const Menus = ({ menus, innerRef, handleClick, }) => {
42
43
  const [columnMenu, setColumnMenu] = useState(undefined);
44
+ const [openDialog, setOpenDialog] = useState(false);
45
+ const [indices, setIndices] = useState([]);
46
+ const toggleDialog = () => {
47
+ setOpenDialog(!openDialog);
48
+ };
43
49
  return (React.createElement(MenusContainer, { ref: innerRef },
44
50
  menus.map((menu, index) => {
45
51
  return (React.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
@@ -49,7 +55,17 @@ export const Menus = ({ menus, innerRef, handleClick, }) => {
49
55
  }, isOpen: menu.isOpen },
50
56
  React.createElement(Text, null, menu.label)),
51
57
  menu.isEnabled && menu.isOpen && menu.submenu && (React.createElement(SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
52
- return (React.createElement(Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]), setColumnMenu: setColumnMenu }));
58
+ return (React.createElement(Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => {
59
+ const indices = [index, sindex, ...i];
60
+ if ('id' in submenu &&
61
+ submenu.id === 'insert-table-element') {
62
+ setIndices(indices);
63
+ toggleDialog();
64
+ }
65
+ else {
66
+ handleClick(indices);
67
+ }
68
+ }, setColumnMenu: setColumnMenu }));
53
69
  })))));
54
70
  }),
55
71
  React.createElement(ColumnChangeWarningDialog, { isOpen: !!columnMenu, primaryAction: () => {
@@ -57,7 +73,8 @@ export const Menus = ({ menus, innerRef, handleClick, }) => {
57
73
  columnMenu.run();
58
74
  setColumnMenu(undefined);
59
75
  }
60
- }, secondaryAction: () => setColumnMenu(undefined) })));
76
+ }, secondaryAction: () => setColumnMenu(undefined) }),
77
+ openDialog && (React.createElement(InsertTableDialog, { run: (tableConfig) => handleClick(indices, tableConfig), open: openDialog, onClose: toggleDialog }))));
61
78
  };
62
79
  export const orderedListContextMenu = [
63
80
  { items: ['1.', '2.', '3.'], type: 'order' },
@@ -0,0 +1,35 @@
1
+ import { ObjectTypes } from '@manuscripts/json-schema';
2
+ import { getInlineFiles, getSupplements, } from '../lib/files';
3
+ import { useDeepCompareMemo } from './use-deep-compare';
4
+ const types = [
5
+ ObjectTypes.Section,
6
+ ObjectTypes.FigureElement,
7
+ ObjectTypes.Figure,
8
+ ObjectTypes.Supplement,
9
+ ObjectTypes.ElementsOrder,
10
+ ];
11
+ const getOtherFiles = (inlineFiles, supplements, files) => {
12
+ const excluded = new Set();
13
+ inlineFiles.flatMap((f) => f.files).forEach((f) => excluded.add(f.id));
14
+ supplements.forEach((s) => excluded.add(s.id));
15
+ return files.filter((f) => !excluded.has(f.id));
16
+ };
17
+ export const useFiles = (modelMap, files) => {
18
+ const models = [];
19
+ for (const [_, model] of modelMap.entries()) {
20
+ if (types.includes(model.objectType)) {
21
+ models.push(model);
22
+ }
23
+ }
24
+ return useDeepCompareMemo(() => {
25
+ const inlineFiles = getInlineFiles(modelMap, files);
26
+ const supplements = getSupplements(modelMap, files);
27
+ const otherFiles = getOtherFiles(inlineFiles, supplements, files);
28
+ return {
29
+ inlineFiles,
30
+ supplements,
31
+ otherFiles,
32
+ };
33
+ }, [models, files]);
34
+ };
35
+ export default useFiles;
@@ -50,13 +50,13 @@ const getMenuAt = (state, position) => {
50
50
  export const useMenus = (menus) => {
51
51
  const [pointer, setPointer] = useState(initialPointer);
52
52
  const state = getMenuState(menus, pointer);
53
- const handleClick = useCallback((indices) => {
53
+ const handleClick = useCallback((indices, tableConfig) => {
54
54
  const menu = getMenuAt(state, indices);
55
55
  if (!menu || !menu.isEnabled) {
56
56
  return;
57
57
  }
58
58
  if (menu.run) {
59
- menu.run();
59
+ menu.run(tableConfig);
60
60
  setPointer([-1, -1, -1]);
61
61
  }
62
62
  else if (menu.submenu) {
package/dist/es/index.js CHANGED
@@ -20,8 +20,11 @@ export * from './components/RadioButton';
20
20
  export * from './components/AutoSaveInput';
21
21
  export * from './components/Avatar';
22
22
  export * from './components/Dialog';
23
+ export * from './components/InsertTableDialog';
23
24
  export * from './components/Checkbox';
24
25
  export * from './components/Form';
26
+ export * from './components/FileManager';
27
+ export * from './components/FileManager/util';
25
28
  export * from './components/Resizer';
26
29
  export * from './components/SaveStatus';
27
30
  export * from './components/StyledModal';
@@ -46,6 +49,7 @@ export * from './components/RelativeDate';
46
49
  export * from './components/Menus';
47
50
  export * from './components/SelectField';
48
51
  export * from './hooks/use-dropdown';
52
+ export * from './hooks/use-files';
49
53
  export * from './hooks/use-menus';
50
54
  export * from './hooks/use-scroll-detection';
51
55
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
@@ -1,122 +1,78 @@
1
- import React from 'react';
2
- import { FileAudioIcon, FileCodeIcon, FileCompressedIcon, FileDocumentIcon, FileFigureIcon, FileGraphicalAbstractIcon, FileImageIcon, FileLatexIcon, FilePdfIcon, FileTableIcon, FileUnknownIcon, FileVideoIcon, } from '../components/icons';
3
- export var FileType;
4
- (function (FileType) {
5
- FileType[FileType["Image"] = 0] = "Image";
6
- FileType[FileType["Audio"] = 1] = "Audio";
7
- FileType[FileType["Video"] = 2] = "Video";
8
- FileType[FileType["PlainDocument"] = 3] = "PlainDocument";
9
- FileType[FileType["SheetsWorkbooks"] = 4] = "SheetsWorkbooks";
10
- FileType[FileType["Latex"] = 5] = "Latex";
11
- FileType[FileType["CodeFile"] = 6] = "CodeFile";
12
- FileType[FileType["PdfFile"] = 7] = "PdfFile";
13
- FileType[FileType["CompressedFile"] = 8] = "CompressedFile";
14
- FileType[FileType["PlainText"] = 9] = "PlainText";
15
- FileType[FileType["Figure"] = 10] = "Figure";
16
- FileType[FileType["GraphicalAbstract"] = 11] = "GraphicalAbstract";
17
- })(FileType || (FileType = {}));
18
- const extension2type = new Map([
19
- ['png', FileType.Image],
20
- ['jpg', FileType.Image],
21
- ['jpeg', FileType.Image],
22
- ['jfif', FileType.Image],
23
- ['gif', FileType.Image],
24
- ['svg', FileType.Image],
25
- ['tif', FileType.Image],
26
- ['tiff', FileType.Image],
27
- ['mp3', FileType.Audio],
28
- ['wav', FileType.Audio],
29
- ['wma', FileType.Audio],
30
- ['flac', FileType.Audio],
31
- ['avi', FileType.Video],
32
- ['mp4', FileType.Video],
33
- ['mov', FileType.Video],
34
- ['wmv', FileType.Video],
35
- ['doc', FileType.PlainDocument],
36
- ['docx', FileType.PlainDocument],
37
- ['rtf', FileType.PlainDocument],
38
- ['xls', FileType.SheetsWorkbooks],
39
- ['xlsx', FileType.SheetsWorkbooks],
40
- ['xml', FileType.SheetsWorkbooks],
41
- ['tex', FileType.Latex],
42
- ['js', FileType.CodeFile],
43
- ['py', FileType.CodeFile],
44
- ['tsx', FileType.CodeFile],
45
- ['html', FileType.CodeFile],
46
- ['pdf', FileType.PdfFile],
47
- ['zip', FileType.CompressedFile],
48
- ['rar', FileType.CompressedFile],
49
- ['arj', FileType.CompressedFile],
50
- ['tar.gz', FileType.CompressedFile],
51
- ['tgz', FileType.CompressedFile],
52
- ['txt', FileType.PlainText],
53
- ]);
54
- const type2icon = new Map([
55
- [
56
- FileType.Audio,
57
- React.createElement(FileAudioIcon, { key: FileType.Audio, className: "file-icon" }),
58
- ],
59
- [
60
- FileType.Video,
61
- React.createElement(FileVideoIcon, { key: FileType.Video, className: "file-icon" }),
62
- ],
63
- [
64
- FileType.PlainDocument,
65
- React.createElement(FileDocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7", className: "file-icon" }),
66
- ],
67
- [
68
- FileType.SheetsWorkbooks,
69
- React.createElement(FileTableIcon, { key: FileType.SheetsWorkbooks, className: "file-icon" }),
70
- ],
71
- [
72
- FileType.Latex,
73
- React.createElement(FileLatexIcon, { key: FileType.Latex, color: "#1A9BC7", className: "file-icon" }),
74
- ],
75
- [
76
- FileType.CodeFile,
77
- React.createElement(FileCodeIcon, { key: FileType.CodeFile, className: "file-icon" }),
78
- ],
79
- [
80
- FileType.PdfFile,
81
- React.createElement(FilePdfIcon, { key: FileType.PdfFile, className: "file-icon" }),
82
- ],
83
- [
84
- FileType.CompressedFile,
85
- React.createElement(FileCompressedIcon, { key: FileType.CompressedFile, className: "file-icon" }),
86
- ],
87
- [
88
- FileType.PlainText,
89
- React.createElement(FileDocumentIcon, { key: FileType.PlainText, color: "#FFBD26", className: "file-icon" }),
90
- ],
91
- [
92
- FileType.Image,
93
- React.createElement(FileImageIcon, { key: FileType.Image, className: "file-icon" }),
94
- ],
95
- [
96
- FileType.Figure,
97
- React.createElement(FileFigureIcon, { key: FileType.Figure, className: "file-icon" }),
98
- ],
99
- [
100
- FileType.GraphicalAbstract,
101
- React.createElement(FileGraphicalAbstractIcon, { key: FileType.GraphicalAbstract, className: "file-icon" }),
102
- ],
103
- [undefined, React.createElement(FileUnknownIcon, { key: undefined, className: "file-icon" })],
104
- ]);
105
- export const getFileType = (name) => {
106
- const extension = getExtension(name);
107
- return extension2type.get(extension.toLowerCase());
1
+ import { getModelsByType, ObjectTypes, } from '@manuscripts/json-schema';
2
+ import { FileType } from '../components/FileManager/util';
3
+ export const isModelFile = (file) => {
4
+ return file.modelId;
108
5
  };
109
- export const getFileIcon = (name) => {
110
- const type = getFileType(name);
111
- return type2icon.get(type);
6
+ const MISSING_FILE = {
7
+ id: '',
8
+ name: 'Missing file',
9
+ type: {
10
+ id: 'missing',
11
+ },
112
12
  };
113
- export const getFileTypeIcon = (type) => {
114
- return type2icon.get(type);
13
+ const getFile = (files, id) => {
14
+ return files.filter((f) => f.id === id)[0] || MISSING_FILE;
115
15
  };
116
- export const isImageFile = (name) => {
117
- return getFileType(name) === FileType.Image;
16
+ const getFigureFiles = (element, modelMap, files) => {
17
+ const figureFiles = [];
18
+ element.containedObjectIDs.map((id) => {
19
+ const model = modelMap.get(id);
20
+ if (model && model.objectType === ObjectTypes.Figure) {
21
+ const figure = model;
22
+ if (figure.src) {
23
+ figureFiles.push(Object.assign(Object.assign({}, getFile(files, figure.src)), { modelId: figure._id }));
24
+ }
25
+ }
26
+ });
27
+ return figureFiles;
118
28
  };
119
- const getExtension = (name) => {
120
- const index = name.indexOf('.');
121
- return index ? name.substring(index + 1) : '';
29
+ const getSupplementFiles = (supplement, files) => {
30
+ if (supplement.href) {
31
+ const href = supplement.href;
32
+ if (href) {
33
+ return [
34
+ Object.assign(Object.assign({}, getFile(files, href)), { modelId: supplement._id }),
35
+ ];
36
+ }
37
+ }
38
+ return [];
39
+ };
40
+ export const getInlineFiles = (modelMap, files) => {
41
+ var _a;
42
+ const elements = [];
43
+ const orders = getOrderByType(modelMap);
44
+ const sections = getModelsByType(modelMap, ObjectTypes.Section);
45
+ const graphicalAbstractElementIds = (_a = sections.filter((s) => s.category === 'MPSectionCategory:abstract-graphical')[0]) === null || _a === void 0 ? void 0 : _a.elementIDs;
46
+ graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.map((id) => {
47
+ const figure = modelMap.get(id);
48
+ if (figure) {
49
+ elements.push({
50
+ modelId: id,
51
+ type: FileType.GraphicalAbstract,
52
+ label: 'Graphical Abstract',
53
+ files: getFigureFiles(figure, modelMap, files),
54
+ });
55
+ }
56
+ });
57
+ const figures = getModelsByType(modelMap, ObjectTypes.FigureElement);
58
+ const figureOrder = orders.get(ObjectTypes.FigureElement);
59
+ if (figureOrder) {
60
+ }
61
+ figures === null || figures === void 0 ? void 0 : figures.filter((f) => !(graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.includes(f._id))).map((figure, index) => ({
62
+ modelId: figure._id,
63
+ type: FileType.Figure,
64
+ label: `Figure ${index + 1}`,
65
+ files: getFigureFiles(figure, modelMap, files),
66
+ })).forEach((e) => elements.push(e));
67
+ return elements;
68
+ };
69
+ export const getSupplements = (modelMap, files) => {
70
+ const supplements = getModelsByType(modelMap, ObjectTypes.Supplement);
71
+ return supplements.flatMap((s) => getSupplementFiles(s, files));
72
+ };
73
+ const getOrderByType = (modelMap) => {
74
+ const groups = new Map();
75
+ const orders = getModelsByType(modelMap, ObjectTypes.ElementsOrder);
76
+ orders.forEach((o) => groups.set(o.elementType, o));
77
+ return groups;
122
78
  };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { Move, Replace } from './FileManager';
3
+ import { FileSectionType } from './util';
4
+ export declare const FileActions: React.FC<{
5
+ sectionType: FileSectionType;
6
+ handleDownload?: () => void;
7
+ handleReplace?: Replace;
8
+ handleDetach?: () => void;
9
+ move?: Move;
10
+ className?: string;
11
+ }>;
12
+ export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
13
+ export declare const FileActionDropdownList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
14
+ direction?: "right" | "left" | undefined;
15
+ width?: number | undefined;
16
+ height?: number | undefined;
17
+ top?: number | undefined;
18
+ }, never>;
19
+ export declare const FileAction: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1 @@
1
+ export declare const FileContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const FileCreatedDate: React.FC<{
4
+ file: FileAttachment;
5
+ className?: string;
6
+ }>;
7
+ export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,30 @@
1
+ import { Build, Model } from '@manuscripts/json-schema';
2
+ import React from 'react';
3
+ import { FileSectionType } from '../../index';
4
+ import { Capabilities } from '../../lib/capabilities';
5
+ import { FileAttachment } from '../../lib/files';
6
+ export type Upload = (file: File) => Promise<FileAttachment>;
7
+ export type Download = (file: FileAttachment) => void;
8
+ export type PreviewLink = (file: FileAttachment) => string | undefined;
9
+ export type Replace = (file: File) => Promise<void>;
10
+ export type Move = {
11
+ sectionType: FileSectionType;
12
+ handler: () => Promise<void>;
13
+ };
14
+ export interface FileManagement {
15
+ upload: Upload;
16
+ download: Download;
17
+ previewLink: PreviewLink;
18
+ }
19
+ export type SaveModel = <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
20
+ export type DeleteModel = (id: string) => Promise<string>;
21
+ export declare const PermissionsContext: React.Context<Capabilities | null>;
22
+ export declare const FileManager: React.FC<{
23
+ files: FileAttachment[];
24
+ fileManagement: FileManagement;
25
+ modelMap: Map<string, Model>;
26
+ saveModel: SaveModel;
27
+ deleteModel: DeleteModel;
28
+ enableDragAndDrop: boolean;
29
+ can: Capabilities;
30
+ }>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const FileManagerDragLayer: React.FC;
@@ -0,0 +1,15 @@
1
+ import { Model } from '@manuscripts/json-schema';
2
+ import React from 'react';
3
+ import { DeleteModel, FileManagement, SaveModel } from './FileManager';
4
+ export declare const FileManagerContext: React.Context<{
5
+ saveModel: SaveModel;
6
+ deleteModel: DeleteModel;
7
+ modelMap: Map<string, Model>;
8
+ fileManagement: FileManagement;
9
+ }>;
10
+ export declare const FileManagerProvider: React.FC<{
11
+ saveModel: SaveModel;
12
+ deleteModel: DeleteModel;
13
+ modelMap: Map<string, Model>;
14
+ fileManagement: FileManagement;
15
+ }>;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const FileName: React.FC<{
4
+ file: FileAttachment;
5
+ }>;
6
+ export declare const FileNameText: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export declare enum FileSectionAlertType {
3
+ NONE = 0,
4
+ UPLOAD_IN_PROGRESS = 1,
5
+ UPLOAD_SUCCESSFUL = 2,
6
+ MOVE_SUCCESSFUL = 3
7
+ }
8
+ export declare const FileSectionAlert: React.FC<{
9
+ alert: {
10
+ type: FileSectionAlertType;
11
+ message: string;
12
+ };
13
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const FileTypeIcon: React.FC<{
4
+ file: FileAttachment;
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface FileUploaderProps {
3
+ onUpload: (file: File) => void;
4
+ }
5
+ export declare const FileUploader: React.FC<FileUploaderProps>;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ElementFiles } from '../../lib/files';
3
+ export declare const InlineFilesSection: React.FC<{
4
+ elements: ElementFiles[];
5
+ isEditor: boolean;
6
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const OtherFilesSection: React.FC<{
4
+ files: FileAttachment[];
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ModelFile } from '../../lib/files';
3
+ export declare const SupplementsSection: React.FC<{
4
+ supplements: ModelFile[];
5
+ }>;
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * © 2020 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './FileManager';
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare enum FileSectionType {
4
+ Inline = "Inline files",
5
+ Supplements = "Supplements",
6
+ OtherFile = "Other files"
7
+ }
8
+ export declare enum FileType {
9
+ Image = 0,
10
+ Audio = 1,
11
+ Video = 2,
12
+ PlainDocument = 3,
13
+ SheetsWorkbooks = 4,
14
+ Latex = 5,
15
+ CodeFile = 6,
16
+ PdfFile = 7,
17
+ CompressedFile = 8,
18
+ PlainText = 9,
19
+ Figure = 10,
20
+ GraphicalAbstract = 11
21
+ }
22
+ export declare const getFileType: (file: FileAttachment) => FileType | undefined;
23
+ export declare const getFileIcon: (file: FileAttachment) => JSX.Element | undefined;
24
+ export declare const getFileTypeIcon: (type: FileType) => JSX.Element | undefined;
25
+ export declare const isImageFile: (file: FileAttachment) => boolean;
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * © 2024 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import React from 'react';
17
+ import { TableConfig } from '../lib/menus';
18
+ export declare const InsertTableDialog: React.FC<{
19
+ run: (tableConfig: TableConfig) => void;
20
+ open: boolean;
21
+ onClose: () => void;
22
+ }>;
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import React, { Ref } from 'react';
17
- import { Menu } from '../../lib/menus';
17
+ import { Menu, TableConfig } from '../../lib/menus';
18
18
  interface MenusProps {
19
19
  menus: Menu[];
20
20
  innerRef: Ref<HTMLDivElement>;
21
- handleClick: (position: number[]) => void;
21
+ handleClick: (position: number[], tableConfig?: TableConfig) => void;
22
22
  }
23
23
  export declare const Menus: React.FC<MenusProps>;
24
24
  export declare const orderedListContextMenu: {
@@ -0,0 +1,8 @@
1
+ import { Model } from '@manuscripts/json-schema';
2
+ import { ElementFiles, FileAttachment, ModelFile } from '../lib/files';
3
+ export declare const useFiles: (modelMap: Map<string, Model>, files: FileAttachment[]) => {
4
+ inlineFiles: ElementFiles[];
5
+ supplements: ModelFile[];
6
+ otherFiles: FileAttachment[];
7
+ };
8
+ export default useFiles;