@manuscripts/style-guide 1.8.2-LEAN-3300 → 1.8.3-LEAN-3321-0
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/FileManagerDragLayer.js → DragLayer.js} +17 -9
- package/dist/cjs/components/FileManager/FileManager.js +2 -2
- package/dist/cjs/components/FileManager/FileUploader.js +22 -8
- package/dist/cjs/components/FileManager/OtherFilesSection.js +5 -5
- package/dist/cjs/components/FileManager/SupplementsSection.js +4 -4
- package/dist/cjs/components/Menus/Menus.js +54 -1
- package/dist/cjs/components/Menus/Submenu.js +13 -3
- package/dist/cjs/components/TableFootnotesSelector.js +5 -6
- package/dist/cjs/hooks/use-dropdown.js +1 -2
- package/dist/cjs/hooks/use-menus.js +3 -0
- package/dist/cjs/index.js +1 -0
- package/dist/es/components/{FileManager/FileManagerDragLayer.js → DragLayer.js} +15 -7
- package/dist/es/components/FileManager/FileManager.js +2 -2
- package/dist/es/components/FileManager/FileUploader.js +23 -9
- package/dist/es/components/FileManager/OtherFilesSection.js +5 -5
- package/dist/es/components/FileManager/SupplementsSection.js +4 -4
- package/dist/es/components/Menus/Menus.js +53 -0
- package/dist/es/components/Menus/Submenu.js +13 -3
- package/dist/es/components/TableFootnotesSelector.js +5 -6
- package/dist/es/hooks/use-dropdown.js +1 -2
- package/dist/es/hooks/use-menus.js +3 -0
- package/dist/es/index.js +1 -0
- package/dist/types/components/DragLayer.d.ts +2 -0
- package/dist/types/components/FileManager/FileUploader.d.ts +3 -4
- package/dist/types/components/Menus/Menus.d.ts +15 -0
- package/dist/types/components/TableFootnotesSelector.d.ts +6 -2
- package/dist/types/hooks/use-dropdown.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/menus.d.ts +5 -0
- package/package.json +6 -6
- package/dist/types/components/FileManager/FileManagerDragLayer.d.ts +0 -2
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.DragLayer = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_dnd_1 = require("react-dnd");
|
|
9
9
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
-
const FileContainer_1 = require("./FileContainer");
|
|
11
|
-
const FileCreatedDate_1 = require("./FileCreatedDate");
|
|
12
|
-
const FileName_1 = require("./FileName");
|
|
10
|
+
const FileContainer_1 = require("./FileManager/FileContainer");
|
|
11
|
+
const FileCreatedDate_1 = require("./FileManager/FileCreatedDate");
|
|
12
|
+
const FileName_1 = require("./FileManager/FileName");
|
|
13
13
|
const Container = styled_components_1.default.div `
|
|
14
14
|
position: fixed;
|
|
15
15
|
pointer-events: none;
|
|
@@ -38,18 +38,26 @@ const getItemStyles = (currentOffset) => {
|
|
|
38
38
|
WebkitTransform: transform,
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
const
|
|
41
|
+
const DragLayer = () => {
|
|
42
42
|
const { itemType, isDragging, item, currentOffset } = (0, react_dnd_1.useDragLayer)((monitor) => ({
|
|
43
43
|
item: monitor.getItem(),
|
|
44
44
|
itemType: monitor.getItemType(),
|
|
45
45
|
currentOffset: monitor.getSourceClientOffset(),
|
|
46
46
|
isDragging: monitor.isDragging(),
|
|
47
47
|
}));
|
|
48
|
+
const renderItem = () => {
|
|
49
|
+
switch (itemType) {
|
|
50
|
+
case 'file':
|
|
51
|
+
return (react_1.default.createElement(DraggableFileContainer, null,
|
|
52
|
+
react_1.default.createElement(FileName_1.FileName, { file: item.file }),
|
|
53
|
+
item.file.createdDate && react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: item.file })));
|
|
54
|
+
default:
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
48
58
|
if (!isDragging) {
|
|
49
59
|
return null;
|
|
50
60
|
}
|
|
51
|
-
return (react_1.default.createElement(Container, { style: getItemStyles(currentOffset) },
|
|
52
|
-
react_1.default.createElement(FileName_1.FileName, { file: item.file }),
|
|
53
|
-
item.file.createdDate && react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: item.file })))));
|
|
61
|
+
return (react_1.default.createElement(Container, { style: getItemStyles(currentOffset) }, renderItem()));
|
|
54
62
|
};
|
|
55
|
-
exports.
|
|
63
|
+
exports.DragLayer = DragLayer;
|
|
@@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.FileManager = exports.PermissionsContext = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const index_1 = require("../../index");
|
|
29
|
+
const DragLayer_1 = require("../DragLayer");
|
|
29
30
|
const Inspector_1 = require("../Inspector");
|
|
30
31
|
const InspectorSection_1 = require("../InspectorSection");
|
|
31
32
|
const Tooltip_1 = require("../Tooltip");
|
|
32
|
-
const FileManagerDragLayer_1 = require("./FileManagerDragLayer");
|
|
33
33
|
const FileManagerProvider_1 = require("./FileManagerProvider");
|
|
34
34
|
const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
35
35
|
const OtherFilesSection_1 = require("./OtherFilesSection");
|
|
@@ -38,7 +38,7 @@ exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
|
38
38
|
const FileManager = ({ files, fileManagement, modelMap, saveModel, deleteModel, enableDragAndDrop, can, }) => {
|
|
39
39
|
const { inlineFiles, supplements, otherFiles } = (0, index_1.useFiles)(modelMap, files);
|
|
40
40
|
return (react_1.default.createElement(FileManagerProvider_1.FileManagerProvider, { saveModel: saveModel, deleteModel: deleteModel, modelMap: modelMap, fileManagement: fileManagement },
|
|
41
|
-
react_1.default.createElement(
|
|
41
|
+
react_1.default.createElement(DragLayer_1.DragLayer, null),
|
|
42
42
|
react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
|
|
43
43
|
react_1.default.createElement(InspectorSection_1.InspectorSection, { title: 'Files', contentStyles: { margin: '24px 16px' } },
|
|
44
44
|
react_1.default.createElement(Inspector_1.InspectorTabs, { defaultIndex: 0, "data-cy": "files-tabs", style: { overflow: 'visible' } },
|
|
@@ -22,30 +22,44 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
35
|
exports.FileUploader = void 0;
|
|
27
36
|
const react_1 = __importStar(require("react"));
|
|
28
37
|
const react_dnd_1 = require("react-dnd");
|
|
29
38
|
const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
|
|
30
39
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
31
|
-
const FileUploader = ({
|
|
40
|
+
const FileUploader = ({ handler }) => {
|
|
32
41
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
33
42
|
const openFileDialog = () => {
|
|
34
43
|
if (fileInputRef && fileInputRef.current) {
|
|
35
44
|
fileInputRef.current.click();
|
|
36
45
|
}
|
|
37
46
|
};
|
|
38
|
-
const handleChange = (event) => {
|
|
47
|
+
const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
48
|
if (event && event.target && event.target.files) {
|
|
40
49
|
const file = event.target.files[0];
|
|
41
|
-
|
|
50
|
+
yield handler(file);
|
|
42
51
|
}
|
|
43
|
-
};
|
|
52
|
+
});
|
|
53
|
+
const handleFileDrop = (0, react_1.useCallback)((monitor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
if (monitor) {
|
|
55
|
+
const file = monitor.getItem().files[0];
|
|
56
|
+
yield handler(file);
|
|
57
|
+
}
|
|
58
|
+
}), [handler]);
|
|
44
59
|
const [{ canDrop, isOver }, dropRef] = (0, react_dnd_1.useDrop)({
|
|
45
60
|
accept: [react_dnd_html5_backend_1.NativeTypes.FILE],
|
|
46
|
-
drop
|
|
47
|
-
|
|
48
|
-
onUpload(file);
|
|
61
|
+
drop(item, monitor) {
|
|
62
|
+
handleFileDrop(monitor);
|
|
49
63
|
},
|
|
50
64
|
collect: (monitor) => ({
|
|
51
65
|
isOver: monitor.isOver(),
|
|
@@ -54,7 +68,7 @@ const FileUploader = ({ onUpload }) => {
|
|
|
54
68
|
});
|
|
55
69
|
const isActive = canDrop && isOver;
|
|
56
70
|
return (react_1.default.createElement(Container, { ref: dropRef, "data-cy": "file-uploader", active: isActive, onClick: openFileDialog },
|
|
57
|
-
react_1.default.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, value: '' }),
|
|
71
|
+
react_1.default.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' }),
|
|
58
72
|
"Drag or click to upload a new file"));
|
|
59
73
|
};
|
|
60
74
|
exports.FileUploader = FileUploader;
|
|
@@ -53,7 +53,7 @@ const OtherFilesSection = ({ files }) => {
|
|
|
53
53
|
type: FileSectionAlert_1.FileSectionAlertType.NONE,
|
|
54
54
|
message: '',
|
|
55
55
|
});
|
|
56
|
-
const
|
|
56
|
+
const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
57
|
setAlert({
|
|
58
58
|
type: FileSectionAlert_1.FileSectionAlertType.UPLOAD_IN_PROGRESS,
|
|
59
59
|
message: file.name,
|
|
@@ -73,16 +73,16 @@ const OtherFilesSection = ({ files }) => {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
return (react_1.default.createElement("div", null,
|
|
76
|
-
(can === null || can === void 0 ? void 0 : can.uploadFile) && react_1.default.createElement(FileUploader_1.FileUploader, {
|
|
76
|
+
(can === null || can === void 0 ? void 0 : can.uploadFile) && react_1.default.createElement(FileUploader_1.FileUploader, { handler: upload }),
|
|
77
77
|
react_1.default.createElement(FileSectionAlert_1.FileSectionAlert, { alert: alert }),
|
|
78
78
|
files.map((file) => (react_1.default.createElement(OtherFile, { key: file.id, file: file, handleDownload: () => fileManagement.download(file), handleMoveToSupplements: () => __awaiter(void 0, void 0, void 0, function* () { return yield moveToSupplements(file); }) })))));
|
|
79
79
|
};
|
|
80
80
|
exports.OtherFilesSection = OtherFilesSection;
|
|
81
81
|
const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
|
|
82
|
-
const [{ isDragging },
|
|
83
|
-
type: 'file',
|
|
82
|
+
const [{ isDragging }, drag, preview] = (0, react_dnd_1.useDrag)({
|
|
84
83
|
item: {
|
|
85
84
|
file,
|
|
85
|
+
type: 'file',
|
|
86
86
|
},
|
|
87
87
|
collect: (monitor) => ({
|
|
88
88
|
isDragging: monitor.isDragging(),
|
|
@@ -91,7 +91,7 @@ const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
|
|
|
91
91
|
(0, react_1.useEffect)(() => {
|
|
92
92
|
preview((0, react_dnd_html5_backend_1.getEmptyImage)());
|
|
93
93
|
}, [preview]);
|
|
94
|
-
return (react_1.default.createElement(FileContainer_1.FileContainer, { key: file.id, "data-cy": "file-container", ref:
|
|
94
|
+
return (react_1.default.createElement(FileContainer_1.FileContainer, { key: file.id, "data-cy": "file-container", ref: drag, className: isDragging ? 'dragging' : '' },
|
|
95
95
|
react_1.default.createElement(FileName_1.FileName, { file: file }),
|
|
96
96
|
react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
97
97
|
react_1.default.createElement(FileActions_1.FileActions, { sectionType: util_1.FileSectionType.OtherFile, handleDownload: handleDownload, move: {
|
|
@@ -84,20 +84,20 @@ const SupplementsSection = ({ supplements }) => {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
87
|
-
(can === null || can === void 0 ? void 0 : can.uploadFile) && react_1.default.createElement(FileUploader_1.FileUploader, {
|
|
87
|
+
(can === null || can === void 0 ? void 0 : can.uploadFile) && react_1.default.createElement(FileUploader_1.FileUploader, { handler: handleUpload }),
|
|
88
88
|
react_1.default.createElement(FileSectionAlert_1.FileSectionAlert, { alert: alert }),
|
|
89
89
|
supplements.map((supplement) => (react_1.default.createElement(SupplementFile, { key: supplement.modelId, file: supplement, handleDownload: () => fileManagement.download(supplement), handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield handleReplace(supplement.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield handleMoveToOtherFiles(supplement.modelId); }) })))));
|
|
90
90
|
};
|
|
91
91
|
exports.SupplementsSection = SupplementsSection;
|
|
92
92
|
const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) => {
|
|
93
|
-
const [{ isDragging },
|
|
94
|
-
type: 'file',
|
|
93
|
+
const [{ isDragging }, drag, preview] = (0, react_dnd_1.useDrag)({
|
|
95
94
|
item: {
|
|
96
95
|
file,
|
|
97
96
|
model: {
|
|
98
97
|
_id: file.modelId,
|
|
99
98
|
objectType: json_schema_1.ObjectTypes.Supplement,
|
|
100
99
|
},
|
|
100
|
+
type: 'file',
|
|
101
101
|
},
|
|
102
102
|
collect: (monitor) => ({
|
|
103
103
|
isDragging: monitor.isDragging(),
|
|
@@ -106,7 +106,7 @@ const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) =
|
|
|
106
106
|
(0, react_1.useEffect)(() => {
|
|
107
107
|
preview((0, react_dnd_html5_backend_1.getEmptyImage)());
|
|
108
108
|
}, [preview]);
|
|
109
|
-
return (react_1.default.createElement(FileContainer_1.FileContainer, { "data-cy": "file-container", key: file.id, ref:
|
|
109
|
+
return (react_1.default.createElement(FileContainer_1.FileContainer, { "data-cy": "file-container", key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
|
|
110
110
|
react_1.default.createElement(FileName_1.FileName, { file: file }),
|
|
111
111
|
react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
112
112
|
react_1.default.createElement(FileActions_1.FileActions, { "data-cy": "file-actions", sectionType: util_1.FileSectionType.Supplements, handleDownload: file.id ? handleDownload : undefined, handleReplace: handleReplace, move: file.id
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Menus = void 0;
|
|
21
|
+
exports.Label = exports.Block = exports.BlockItem = exports.StyleBlock = exports.ListContainer = exports.bulletListContextMenu = exports.orderedListContextMenu = exports.Menus = void 0;
|
|
22
22
|
const react_1 = __importDefault(require("react"));
|
|
23
23
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
24
|
const Submenu_1 = require("./Submenu");
|
|
@@ -58,3 +58,56 @@ const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
|
58
58
|
})));
|
|
59
59
|
};
|
|
60
60
|
exports.Menus = Menus;
|
|
61
|
+
exports.orderedListContextMenu = [
|
|
62
|
+
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
63
|
+
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
64
|
+
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
65
|
+
{ items: ['I.', 'II.', 'III.'], type: 'roman-upper' },
|
|
66
|
+
{ items: ['i.', 'ii.', 'iii.'], type: 'roman-lower' },
|
|
67
|
+
];
|
|
68
|
+
exports.bulletListContextMenu = [
|
|
69
|
+
{ items: ['•', '•', '•'], type: 'bullet' },
|
|
70
|
+
{ items: ['-', '-', '-'], type: 'simple' },
|
|
71
|
+
];
|
|
72
|
+
exports.ListContainer = styled_components_1.default.div `
|
|
73
|
+
padding: ${(props) => props.theme.grid.unit * 4}px;
|
|
74
|
+
display: grid;
|
|
75
|
+
grid-template-columns:
|
|
76
|
+
${(props) => props.theme.grid.unit * 21}px
|
|
77
|
+
${(props) => props.theme.grid.unit * 21}px;
|
|
78
|
+
gap: 6px;
|
|
79
|
+
`;
|
|
80
|
+
exports.StyleBlock = styled_components_1.default.div `
|
|
81
|
+
border: 1px solid ${(props) => props.theme.colors.border.tertiary};
|
|
82
|
+
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
row-gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
87
|
+
|
|
88
|
+
&:hover {
|
|
89
|
+
background: ${(props) => props.theme.colors.button.default.border.hover};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&:active {
|
|
93
|
+
border-color: ${(props) => props.theme.colors.border.primary};
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
exports.BlockItem = styled_components_1.default.div `
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: 6px;
|
|
100
|
+
`;
|
|
101
|
+
exports.Block = styled_components_1.default.div `
|
|
102
|
+
height: 3px;
|
|
103
|
+
width: ${(props) => props.theme.grid.unit * 14}px;
|
|
104
|
+
background: ${(props) => props.theme.colors.border.tertiary};
|
|
105
|
+
`;
|
|
106
|
+
exports.Label = styled_components_1.default.div `
|
|
107
|
+
font-family: Lato, serif;
|
|
108
|
+
font-size: ${(props) => props.theme.font.size.small};
|
|
109
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
110
|
+
line-height: ${(props) => props.theme.font.lineHeight.small};
|
|
111
|
+
font-style: normal;
|
|
112
|
+
color: ${(props) => (props.hide && 'white') || 'initial'};
|
|
113
|
+
`;
|
|
@@ -23,6 +23,7 @@ const TriangleCollapsed_1 = __importDefault(require("@manuscripts/assets/react/T
|
|
|
23
23
|
const react_1 = __importDefault(require("react"));
|
|
24
24
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
25
25
|
const menus_1 = require("../../lib/menus");
|
|
26
|
+
const Menus_1 = require("./Menus");
|
|
26
27
|
const Shortcut_1 = require("./Shortcut");
|
|
27
28
|
exports.Text = styled_components_1.default.div `
|
|
28
29
|
flex: 1 0 auto;
|
|
@@ -37,8 +38,6 @@ exports.SubmenusContainer = styled_components_1.default.div `
|
|
|
37
38
|
box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);
|
|
38
39
|
color: #353535;
|
|
39
40
|
min-width: 150px;
|
|
40
|
-
max-height: 70vh;
|
|
41
|
-
overflow-y: auto;
|
|
42
41
|
padding: 4px 0;
|
|
43
42
|
white-space: nowrap;
|
|
44
43
|
width: auto;
|
|
@@ -96,7 +95,7 @@ const Submenu = ({ menu, handleClick }) => {
|
|
|
96
95
|
if ((0, menus_1.isMenuSeparator)(menu)) {
|
|
97
96
|
return react_1.default.createElement(Separator, null);
|
|
98
97
|
}
|
|
99
|
-
if (!menu.submenu) {
|
|
98
|
+
if (!menu.submenu && !menu.options) {
|
|
100
99
|
return (react_1.default.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
|
|
101
100
|
e.preventDefault();
|
|
102
101
|
handleClick([]);
|
|
@@ -105,6 +104,17 @@ const Submenu = ({ menu, handleClick }) => {
|
|
|
105
104
|
react_1.default.createElement(exports.Text, null, menu.label),
|
|
106
105
|
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })));
|
|
107
106
|
}
|
|
107
|
+
if (menu.options) {
|
|
108
|
+
const styles = menu.id === 'bullet-list-context-menu'
|
|
109
|
+
? Menus_1.bulletListContextMenu
|
|
110
|
+
: Menus_1.orderedListContextMenu;
|
|
111
|
+
return (react_1.default.createElement(Menus_1.ListContainer, null, styles.map((style, index) => (react_1.default.createElement(Menus_1.StyleBlock, { key: index, onClick: () => {
|
|
112
|
+
menu.options && menu.options[style.type]();
|
|
113
|
+
handleClick([-1, -1]);
|
|
114
|
+
} }, style.items.map((style, index) => (react_1.default.createElement(Menus_1.BlockItem, { key: index },
|
|
115
|
+
react_1.default.createElement(Menus_1.Label, { hide: style === '-' }, style),
|
|
116
|
+
react_1.default.createElement(Menus_1.Block, null)))))))));
|
|
117
|
+
}
|
|
108
118
|
return (react_1.default.createElement(SubmenuContainer, null,
|
|
109
119
|
react_1.default.createElement(Container, { onMouseDown: (e) => {
|
|
110
120
|
e.preventDefault();
|
|
@@ -96,8 +96,7 @@ const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) => {
|
|
|
96
96
|
return selections.has(item.attrs.id);
|
|
97
97
|
};
|
|
98
98
|
const handleClick = () => {
|
|
99
|
-
|
|
100
|
-
return onInsert(items);
|
|
99
|
+
return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
|
|
101
100
|
};
|
|
102
101
|
return (react_1.default.createElement(Container, null,
|
|
103
102
|
react_1.default.createElement(NotesContainer, null,
|
|
@@ -113,11 +112,11 @@ const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) => {
|
|
|
113
112
|
};
|
|
114
113
|
exports.TableFootnotesSelector = TableFootnotesSelector;
|
|
115
114
|
const TableFootnotesList = ({ notes, isSelected, onSelect }) => {
|
|
116
|
-
return (react_1.default.createElement(NotesListContainer, null, notes.map((
|
|
115
|
+
return (react_1.default.createElement(NotesListContainer, null, notes.map(({ node, index }) => {
|
|
117
116
|
var _a;
|
|
118
|
-
return (react_1.default.createElement(FootnoteItem, { onClick: () => onSelect(
|
|
119
|
-
react_1.default.createElement(StatusIcon, null, isSelected(
|
|
120
|
-
react_1.default.createElement(NoteText, null,
|
|
117
|
+
return (react_1.default.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
|
|
118
|
+
react_1.default.createElement(StatusIcon, null, isSelected(node) ? (react_1.default.createElement(AddedIcon_1.default, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (react_1.default.createElement(AddIcon_1.default, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
|
|
119
|
+
react_1.default.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
|
|
121
120
|
})));
|
|
122
121
|
};
|
|
123
122
|
const NotesListContainer = styled_components_1.default.div `
|
|
@@ -19,8 +19,7 @@ exports.useDropdown = void 0;
|
|
|
19
19
|
const react_1 = require("react");
|
|
20
20
|
const useDropdown = () => {
|
|
21
21
|
const [isOpen, setOpen] = (0, react_1.useState)(false);
|
|
22
|
-
const toggleOpen = (0, react_1.useCallback)((
|
|
23
|
-
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
22
|
+
const toggleOpen = (0, react_1.useCallback)(() => {
|
|
24
23
|
setOpen((open) => !open);
|
|
25
24
|
}, []);
|
|
26
25
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
@@ -67,6 +67,9 @@ const useMenus = (menus) => {
|
|
|
67
67
|
const index = indices[depth];
|
|
68
68
|
setPointer(transformPointer(depth, index));
|
|
69
69
|
}
|
|
70
|
+
if (menu.options) {
|
|
71
|
+
setPointer([-1, -1, -1]);
|
|
72
|
+
}
|
|
70
73
|
}, [state]);
|
|
71
74
|
const ref = (0, react_1.useRef)(null);
|
|
72
75
|
(0, react_1.useEffect)(() => {
|
package/dist/cjs/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __exportStar(require("./components/SaveStatus"), exports);
|
|
|
49
49
|
__exportStar(require("./components/StyledModal"), exports);
|
|
50
50
|
__exportStar(require("./components/TableFootnotesSelector"), exports);
|
|
51
51
|
__exportStar(require("./components/Sidebar"), exports);
|
|
52
|
+
__exportStar(require("./components/DragLayer"), exports);
|
|
52
53
|
__exportStar(require("./components/TextField"), exports);
|
|
53
54
|
__exportStar(require("./components/TextFieldContainer"), exports);
|
|
54
55
|
__exportStar(require("./components/TextFieldError"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useDragLayer } from 'react-dnd';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { FileContainer } from './FileContainer';
|
|
5
|
-
import { FileCreatedDate } from './FileCreatedDate';
|
|
6
|
-
import { FileName } from './FileName';
|
|
4
|
+
import { FileContainer } from './FileManager/FileContainer';
|
|
5
|
+
import { FileCreatedDate } from './FileManager/FileCreatedDate';
|
|
6
|
+
import { FileName } from './FileManager/FileName';
|
|
7
7
|
const Container = styled.div `
|
|
8
8
|
position: fixed;
|
|
9
9
|
pointer-events: none;
|
|
@@ -32,17 +32,25 @@ const getItemStyles = (currentOffset) => {
|
|
|
32
32
|
WebkitTransform: transform,
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
export const
|
|
35
|
+
export const DragLayer = () => {
|
|
36
36
|
const { itemType, isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
37
37
|
item: monitor.getItem(),
|
|
38
38
|
itemType: monitor.getItemType(),
|
|
39
39
|
currentOffset: monitor.getSourceClientOffset(),
|
|
40
40
|
isDragging: monitor.isDragging(),
|
|
41
41
|
}));
|
|
42
|
+
const renderItem = () => {
|
|
43
|
+
switch (itemType) {
|
|
44
|
+
case 'file':
|
|
45
|
+
return (React.createElement(DraggableFileContainer, null,
|
|
46
|
+
React.createElement(FileName, { file: item.file }),
|
|
47
|
+
item.file.createdDate && React.createElement(FileCreatedDate, { file: item.file })));
|
|
48
|
+
default:
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
42
52
|
if (!isDragging) {
|
|
43
53
|
return null;
|
|
44
54
|
}
|
|
45
|
-
return (React.createElement(Container, { style: getItemStyles(currentOffset) },
|
|
46
|
-
React.createElement(FileName, { file: item.file }),
|
|
47
|
-
item.file.createdDate && React.createElement(FileCreatedDate, { file: item.file })))));
|
|
55
|
+
return (React.createElement(Container, { style: getItemStyles(currentOffset) }, renderItem()));
|
|
48
56
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { createContext } from 'react';
|
|
2
2
|
import { useFiles } from '../../index';
|
|
3
|
+
import { DragLayer } from '../DragLayer';
|
|
3
4
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
4
5
|
import { InspectorSection } from '../InspectorSection';
|
|
5
6
|
import { Tooltip } from '../Tooltip';
|
|
6
|
-
import { FileManagerDragLayer } from './FileManagerDragLayer';
|
|
7
7
|
import { FileManagerProvider } from './FileManagerProvider';
|
|
8
8
|
import { InlineFilesSection } from './InlineFilesSection';
|
|
9
9
|
import { OtherFilesSection } from './OtherFilesSection';
|
|
@@ -12,7 +12,7 @@ export const PermissionsContext = createContext(null);
|
|
|
12
12
|
export const FileManager = ({ files, fileManagement, modelMap, saveModel, deleteModel, enableDragAndDrop, can, }) => {
|
|
13
13
|
const { inlineFiles, supplements, otherFiles } = useFiles(modelMap, files);
|
|
14
14
|
return (React.createElement(FileManagerProvider, { saveModel: saveModel, deleteModel: deleteModel, modelMap: modelMap, fileManagement: fileManagement },
|
|
15
|
-
React.createElement(
|
|
15
|
+
React.createElement(DragLayer, null),
|
|
16
16
|
React.createElement(PermissionsContext.Provider, { value: can },
|
|
17
17
|
React.createElement(InspectorSection, { title: 'Files', contentStyles: { margin: '24px 16px' } },
|
|
18
18
|
React.createElement(InspectorTabs, { defaultIndex: 0, "data-cy": "files-tabs", style: { overflow: 'visible' } },
|
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useCallback, useRef } from 'react';
|
|
2
11
|
import { useDrop } from 'react-dnd';
|
|
3
12
|
import { NativeTypes } from 'react-dnd-html5-backend';
|
|
4
13
|
import styled, { css } from 'styled-components';
|
|
5
|
-
export const FileUploader = ({
|
|
14
|
+
export const FileUploader = ({ handler }) => {
|
|
6
15
|
const fileInputRef = useRef(null);
|
|
7
16
|
const openFileDialog = () => {
|
|
8
17
|
if (fileInputRef && fileInputRef.current) {
|
|
9
18
|
fileInputRef.current.click();
|
|
10
19
|
}
|
|
11
20
|
};
|
|
12
|
-
const handleChange = (event) => {
|
|
21
|
+
const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
22
|
if (event && event.target && event.target.files) {
|
|
14
23
|
const file = event.target.files[0];
|
|
15
|
-
|
|
24
|
+
yield handler(file);
|
|
16
25
|
}
|
|
17
|
-
};
|
|
26
|
+
});
|
|
27
|
+
const handleFileDrop = useCallback((monitor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
if (monitor) {
|
|
29
|
+
const file = monitor.getItem().files[0];
|
|
30
|
+
yield handler(file);
|
|
31
|
+
}
|
|
32
|
+
}), [handler]);
|
|
18
33
|
const [{ canDrop, isOver }, dropRef] = useDrop({
|
|
19
34
|
accept: [NativeTypes.FILE],
|
|
20
|
-
drop
|
|
21
|
-
|
|
22
|
-
onUpload(file);
|
|
35
|
+
drop(item, monitor) {
|
|
36
|
+
handleFileDrop(monitor);
|
|
23
37
|
},
|
|
24
38
|
collect: (monitor) => ({
|
|
25
39
|
isOver: monitor.isOver(),
|
|
@@ -28,7 +42,7 @@ export const FileUploader = ({ onUpload }) => {
|
|
|
28
42
|
});
|
|
29
43
|
const isActive = canDrop && isOver;
|
|
30
44
|
return (React.createElement(Container, { ref: dropRef, "data-cy": "file-uploader", active: isActive, onClick: openFileDialog },
|
|
31
|
-
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, value: '' }),
|
|
45
|
+
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' }),
|
|
32
46
|
"Drag or click to upload a new file"));
|
|
33
47
|
};
|
|
34
48
|
const activeBoxStyle = css `
|
|
@@ -27,7 +27,7 @@ export const OtherFilesSection = ({ files }) => {
|
|
|
27
27
|
type: FileSectionAlertType.NONE,
|
|
28
28
|
message: '',
|
|
29
29
|
});
|
|
30
|
-
const
|
|
30
|
+
const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
setAlert({
|
|
32
32
|
type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
|
|
33
33
|
message: file.name,
|
|
@@ -47,15 +47,15 @@ export const OtherFilesSection = ({ files }) => {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
return (React.createElement("div", null,
|
|
50
|
-
(can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, {
|
|
50
|
+
(can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: upload }),
|
|
51
51
|
React.createElement(FileSectionAlert, { alert: alert }),
|
|
52
52
|
files.map((file) => (React.createElement(OtherFile, { key: file.id, file: file, handleDownload: () => fileManagement.download(file), handleMoveToSupplements: () => __awaiter(void 0, void 0, void 0, function* () { return yield moveToSupplements(file); }) })))));
|
|
53
53
|
};
|
|
54
54
|
const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
|
|
55
|
-
const [{ isDragging },
|
|
56
|
-
type: 'file',
|
|
55
|
+
const [{ isDragging }, drag, preview] = useDrag({
|
|
57
56
|
item: {
|
|
58
57
|
file,
|
|
58
|
+
type: 'file',
|
|
59
59
|
},
|
|
60
60
|
collect: (monitor) => ({
|
|
61
61
|
isDragging: monitor.isDragging(),
|
|
@@ -64,7 +64,7 @@ const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
|
|
|
64
64
|
useEffect(() => {
|
|
65
65
|
preview(getEmptyImage());
|
|
66
66
|
}, [preview]);
|
|
67
|
-
return (React.createElement(FileContainer, { key: file.id, "data-cy": "file-container", ref:
|
|
67
|
+
return (React.createElement(FileContainer, { key: file.id, "data-cy": "file-container", ref: drag, className: isDragging ? 'dragging' : '' },
|
|
68
68
|
React.createElement(FileName, { file: file }),
|
|
69
69
|
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
70
70
|
React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, handleDownload: handleDownload, move: {
|
|
@@ -58,19 +58,19 @@ export const SupplementsSection = ({ supplements }) => {
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
return (React.createElement(React.Fragment, null,
|
|
61
|
-
(can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, {
|
|
61
|
+
(can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: handleUpload }),
|
|
62
62
|
React.createElement(FileSectionAlert, { alert: alert }),
|
|
63
63
|
supplements.map((supplement) => (React.createElement(SupplementFile, { key: supplement.modelId, file: supplement, handleDownload: () => fileManagement.download(supplement), handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield handleReplace(supplement.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield handleMoveToOtherFiles(supplement.modelId); }) })))));
|
|
64
64
|
};
|
|
65
65
|
const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) => {
|
|
66
|
-
const [{ isDragging },
|
|
67
|
-
type: 'file',
|
|
66
|
+
const [{ isDragging }, drag, preview] = useDrag({
|
|
68
67
|
item: {
|
|
69
68
|
file,
|
|
70
69
|
model: {
|
|
71
70
|
_id: file.modelId,
|
|
72
71
|
objectType: ObjectTypes.Supplement,
|
|
73
72
|
},
|
|
73
|
+
type: 'file',
|
|
74
74
|
},
|
|
75
75
|
collect: (monitor) => ({
|
|
76
76
|
isDragging: monitor.isDragging(),
|
|
@@ -79,7 +79,7 @@ const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) =
|
|
|
79
79
|
useEffect(() => {
|
|
80
80
|
preview(getEmptyImage());
|
|
81
81
|
}, [preview]);
|
|
82
|
-
return (React.createElement(FileContainer, { "data-cy": "file-container", key: file.id, ref:
|
|
82
|
+
return (React.createElement(FileContainer, { "data-cy": "file-container", key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
|
|
83
83
|
React.createElement(FileName, { file: file }),
|
|
84
84
|
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
85
85
|
React.createElement(FileActions, { "data-cy": "file-actions", sectionType: FileSectionType.Supplements, handleDownload: file.id ? handleDownload : undefined, handleReplace: handleReplace, move: file.id
|
|
@@ -51,3 +51,56 @@ export const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
|
51
51
|
})))));
|
|
52
52
|
})));
|
|
53
53
|
};
|
|
54
|
+
export const orderedListContextMenu = [
|
|
55
|
+
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
56
|
+
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
57
|
+
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
58
|
+
{ items: ['I.', 'II.', 'III.'], type: 'roman-upper' },
|
|
59
|
+
{ items: ['i.', 'ii.', 'iii.'], type: 'roman-lower' },
|
|
60
|
+
];
|
|
61
|
+
export const bulletListContextMenu = [
|
|
62
|
+
{ items: ['•', '•', '•'], type: 'bullet' },
|
|
63
|
+
{ items: ['-', '-', '-'], type: 'simple' },
|
|
64
|
+
];
|
|
65
|
+
export const ListContainer = styled.div `
|
|
66
|
+
padding: ${(props) => props.theme.grid.unit * 4}px;
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns:
|
|
69
|
+
${(props) => props.theme.grid.unit * 21}px
|
|
70
|
+
${(props) => props.theme.grid.unit * 21}px;
|
|
71
|
+
gap: 6px;
|
|
72
|
+
`;
|
|
73
|
+
export const StyleBlock = styled.div `
|
|
74
|
+
border: 1px solid ${(props) => props.theme.colors.border.tertiary};
|
|
75
|
+
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
row-gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
background: ${(props) => props.theme.colors.button.default.border.hover};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:active {
|
|
86
|
+
border-color: ${(props) => props.theme.colors.border.primary};
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
export const BlockItem = styled.div `
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
gap: 6px;
|
|
93
|
+
`;
|
|
94
|
+
export const Block = styled.div `
|
|
95
|
+
height: 3px;
|
|
96
|
+
width: ${(props) => props.theme.grid.unit * 14}px;
|
|
97
|
+
background: ${(props) => props.theme.colors.border.tertiary};
|
|
98
|
+
`;
|
|
99
|
+
export const Label = styled.div `
|
|
100
|
+
font-family: Lato, serif;
|
|
101
|
+
font-size: ${(props) => props.theme.font.size.small};
|
|
102
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
103
|
+
line-height: ${(props) => props.theme.font.lineHeight.small};
|
|
104
|
+
font-style: normal;
|
|
105
|
+
color: ${(props) => (props.hide && 'white') || 'initial'};
|
|
106
|
+
`;
|
|
@@ -17,6 +17,7 @@ import TriangleCollapsed from '@manuscripts/assets/react/TriangleCollapsed';
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import styled from 'styled-components';
|
|
19
19
|
import { isMenuSeparator } from '../../lib/menus';
|
|
20
|
+
import { Block, BlockItem, bulletListContextMenu, Label, ListContainer, orderedListContextMenu, StyleBlock, } from './Menus';
|
|
20
21
|
import { Shortcut } from './Shortcut';
|
|
21
22
|
export const Text = styled.div `
|
|
22
23
|
flex: 1 0 auto;
|
|
@@ -31,8 +32,6 @@ export const SubmenusContainer = styled.div `
|
|
|
31
32
|
box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);
|
|
32
33
|
color: #353535;
|
|
33
34
|
min-width: 150px;
|
|
34
|
-
max-height: 70vh;
|
|
35
|
-
overflow-y: auto;
|
|
36
35
|
padding: 4px 0;
|
|
37
36
|
white-space: nowrap;
|
|
38
37
|
width: auto;
|
|
@@ -90,7 +89,7 @@ export const Submenu = ({ menu, handleClick }) => {
|
|
|
90
89
|
if (isMenuSeparator(menu)) {
|
|
91
90
|
return React.createElement(Separator, null);
|
|
92
91
|
}
|
|
93
|
-
if (!menu.submenu) {
|
|
92
|
+
if (!menu.submenu && !menu.options) {
|
|
94
93
|
return (React.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
|
|
95
94
|
e.preventDefault();
|
|
96
95
|
handleClick([]);
|
|
@@ -99,6 +98,17 @@ export const Submenu = ({ menu, handleClick }) => {
|
|
|
99
98
|
React.createElement(Text, null, menu.label),
|
|
100
99
|
menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })));
|
|
101
100
|
}
|
|
101
|
+
if (menu.options) {
|
|
102
|
+
const styles = menu.id === 'bullet-list-context-menu'
|
|
103
|
+
? bulletListContextMenu
|
|
104
|
+
: orderedListContextMenu;
|
|
105
|
+
return (React.createElement(ListContainer, null, styles.map((style, index) => (React.createElement(StyleBlock, { key: index, onClick: () => {
|
|
106
|
+
menu.options && menu.options[style.type]();
|
|
107
|
+
handleClick([-1, -1]);
|
|
108
|
+
} }, style.items.map((style, index) => (React.createElement(BlockItem, { key: index },
|
|
109
|
+
React.createElement(Label, { hide: style === '-' }, style),
|
|
110
|
+
React.createElement(Block, null)))))))));
|
|
111
|
+
}
|
|
102
112
|
return (React.createElement(SubmenuContainer, null,
|
|
103
113
|
React.createElement(Container, { onMouseDown: (e) => {
|
|
104
114
|
e.preventDefault();
|
|
@@ -67,8 +67,7 @@ export const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) =>
|
|
|
67
67
|
return selections.has(item.attrs.id);
|
|
68
68
|
};
|
|
69
69
|
const handleClick = () => {
|
|
70
|
-
|
|
71
|
-
return onInsert(items);
|
|
70
|
+
return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
|
|
72
71
|
};
|
|
73
72
|
return (React.createElement(Container, null,
|
|
74
73
|
React.createElement(NotesContainer, null,
|
|
@@ -83,11 +82,11 @@ export const TableFootnotesSelector = ({ notes, onAdd, onInsert, onCancel }) =>
|
|
|
83
82
|
React.createElement(PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 }, "Insert")))));
|
|
84
83
|
};
|
|
85
84
|
const TableFootnotesList = ({ notes, isSelected, onSelect }) => {
|
|
86
|
-
return (React.createElement(NotesListContainer, null, notes.map((
|
|
85
|
+
return (React.createElement(NotesListContainer, null, notes.map(({ node, index }) => {
|
|
87
86
|
var _a;
|
|
88
|
-
return (React.createElement(FootnoteItem, { onClick: () => onSelect(
|
|
89
|
-
React.createElement(StatusIcon, null, isSelected(
|
|
90
|
-
React.createElement(NoteText, null,
|
|
87
|
+
return (React.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
|
|
88
|
+
React.createElement(StatusIcon, null, isSelected(node) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok', width: 24, height: 24 })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon', width: 24, height: 24 }))),
|
|
89
|
+
React.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
|
|
91
90
|
})));
|
|
92
91
|
};
|
|
93
92
|
const NotesListContainer = styled.div `
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
17
17
|
export const useDropdown = () => {
|
|
18
18
|
const [isOpen, setOpen] = useState(false);
|
|
19
|
-
const toggleOpen = useCallback((
|
|
20
|
-
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
19
|
+
const toggleOpen = useCallback(() => {
|
|
21
20
|
setOpen((open) => !open);
|
|
22
21
|
}, []);
|
|
23
22
|
const wrapperRef = useRef(null);
|
package/dist/es/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export * from './components/SaveStatus';
|
|
|
29
29
|
export * from './components/StyledModal';
|
|
30
30
|
export * from './components/TableFootnotesSelector';
|
|
31
31
|
export * from './components/Sidebar';
|
|
32
|
+
export * from './components/DragLayer';
|
|
32
33
|
export * from './components/TextField';
|
|
33
34
|
export * from './components/TextFieldContainer';
|
|
34
35
|
export * from './components/TextFieldError';
|
|
@@ -21,4 +21,19 @@ interface MenusProps {
|
|
|
21
21
|
handleClick: (position: number[]) => void;
|
|
22
22
|
}
|
|
23
23
|
export declare const Menus: React.FC<MenusProps>;
|
|
24
|
+
export declare const orderedListContextMenu: {
|
|
25
|
+
items: string[];
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
export declare const bulletListContextMenu: {
|
|
29
|
+
items: string[];
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
export declare const ListContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
33
|
+
export declare const StyleBlock: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
34
|
+
export declare const BlockItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
35
|
+
export declare const Block: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
36
|
+
export declare const Label: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
37
|
+
hide?: boolean | undefined;
|
|
38
|
+
}, never>;
|
|
24
39
|
export {};
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { FootnoteNode } from '@manuscripts/transform';
|
|
17
17
|
import React from 'react';
|
|
18
|
+
export type FootnoteWithIndex = {
|
|
19
|
+
node: FootnoteNode;
|
|
20
|
+
index?: string;
|
|
21
|
+
};
|
|
18
22
|
export declare const TableFootnotesSelector: React.FC<{
|
|
19
|
-
notes:
|
|
23
|
+
notes: FootnoteWithIndex[];
|
|
20
24
|
onAdd: () => void;
|
|
21
|
-
onInsert: (notes:
|
|
25
|
+
onInsert: (notes: FootnoteWithIndex[]) => void;
|
|
22
26
|
onCancel: () => void;
|
|
23
27
|
}>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from './components/SaveStatus';
|
|
|
30
30
|
export * from './components/StyledModal';
|
|
31
31
|
export * from './components/TableFootnotesSelector';
|
|
32
32
|
export * from './components/Sidebar';
|
|
33
|
+
export * from './components/DragLayer';
|
|
33
34
|
export * from './components/TextField';
|
|
34
35
|
export * from './components/TextFieldContainer';
|
|
35
36
|
export * from './components/TextFieldError';
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { ManuscriptTransaction } from '@manuscripts/transform';
|
|
17
|
+
export type Dispatch = (tr: ManuscriptTransaction) => void;
|
|
16
18
|
export interface MenuShortcut {
|
|
17
19
|
mac: string;
|
|
18
20
|
pc: string;
|
|
@@ -26,6 +28,9 @@ export interface MenuSpec {
|
|
|
26
28
|
isEnabled: boolean;
|
|
27
29
|
run?: () => void;
|
|
28
30
|
submenu?: (MenuSpec | MenuSeparator)[];
|
|
31
|
+
options?: {
|
|
32
|
+
[key: string]: () => void;
|
|
33
|
+
};
|
|
29
34
|
}
|
|
30
35
|
export interface Menu extends MenuSpec {
|
|
31
36
|
isOpen: boolean;
|
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": "1.8.
|
|
4
|
+
"version": "1.8.3-LEAN-3321-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@manuscripts/assets": "^0.6.4",
|
|
36
|
-
"@manuscripts/json-schema": "^2.2.
|
|
37
|
-
"@manuscripts/transform": "
|
|
36
|
+
"@manuscripts/json-schema": "^2.2.7",
|
|
37
|
+
"@manuscripts/transform": "2.1.10-LEAN-3321",
|
|
38
38
|
"@reach/tabs": "^0.18.0",
|
|
39
39
|
"date-fns": "^2.29.3",
|
|
40
40
|
"formik": "^2.2.9",
|
|
41
41
|
"fuzzysort": "^2.0.4",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
43
|
"react": "^17.0.2",
|
|
44
|
-
"react-dnd": "^
|
|
45
|
-
"react-dnd-html5-backend": "^
|
|
44
|
+
"react-dnd": "^11.1.3",
|
|
45
|
+
"react-dnd-html5-backend": "^11.1.3",
|
|
46
46
|
"react-dom": "^17.0.2",
|
|
47
47
|
"react-is": "^17.0.2",
|
|
48
48
|
"react-modal": "^3.16.1",
|
|
@@ -103,4 +103,4 @@
|
|
|
103
103
|
"@types/react": "^17.0.2",
|
|
104
104
|
"jackspeak": "2.1.1"
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
}
|