@monolith-forensics/monolith-ui 1.9.1-dev.8 → 1.9.3-dev.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/DropDownMenu/components/MenuItemList.js +32 -12
- package/dist/DropDownMenu/components/StyledContent.js +1 -1
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
- package/dist/FileViewer/FileViewer.js +32 -8
- package/dist/FileViewer/viewers/ImageViewer.d.ts +1 -0
- package/dist/FileViewer/viewers/ImageViewer.js +36 -15
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +8 -8
- package/dist/RichTextEditor/Components/BubbleMenu.js +202 -94
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
- package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
- package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
- package/dist/RichTextEditor/Components/TableCornerMenu.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableCornerMenu.js +202 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +19 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +24 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableRails.js +180 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +6 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +5 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +183 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +217 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +8 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +11 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +23 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +75 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.js +3 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +16 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +53 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +40 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +167 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +76 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +1 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +4 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +2 -0
- package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +12 -0
- package/dist/RichTextEditor/Components/TableTools/index.d.ts +3 -0
- package/dist/RichTextEditor/Components/TableTools/index.js +2 -0
- package/dist/RichTextEditor/Components/TableTools.d.ts +44 -0
- package/dist/RichTextEditor/Components/TableTools.js +790 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +7 -1
- package/dist/RichTextEditor/Enums/Controls.js +6 -0
- package/dist/RichTextEditor/Enums/Extensions.d.ts +4 -0
- package/dist/RichTextEditor/Enums/Extensions.js +4 -0
- package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
- package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +4 -1
- package/dist/RichTextEditor/Enums/SlashCommands.js +3 -0
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +39 -1
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +10 -2
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +157 -30
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +4 -7
- package/dist/RichTextEditor/RichTextEditor.d.ts +4 -2
- package/dist/RichTextEditor/RichTextEditor.js +395 -15
- package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
- package/dist/RichTextEditor/Toolbar/Control.js +13 -6
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +6 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +118 -1
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +17 -6
- package/dist/RichTextEditor/Toolbar/Labels.d.ts +1 -0
- package/dist/RichTextEditor/Toolbar/Labels.js +1 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -2
- package/dist/RichTextEditor/Toolbar/Toolbar.js +32 -67
- package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
- package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
- package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
- package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
- package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
- package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
- package/dist/RichTextEditor/Utils/tableUtils.d.ts +1 -0
- package/dist/RichTextEditor/Utils/tableUtils.js +1 -0
- package/dist/theme/variants.js +46 -0
- package/package.json +8 -1
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +0 -7
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +0 -157
|
@@ -56,11 +56,18 @@ const buildGroupedDisplayList = (items) => {
|
|
|
56
56
|
const ListViewPort = styled.div.attrs({ className: "ListViewPort" }) `
|
|
57
57
|
display: flex;
|
|
58
58
|
flex-direction: column;
|
|
59
|
+
flex: 1 1 auto;
|
|
60
|
+
min-height: 0;
|
|
59
61
|
width: 100%;
|
|
60
62
|
`;
|
|
63
|
+
const MenuItemListRoot = styled.div `
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
height: 100%;
|
|
67
|
+
min-height: 0;
|
|
68
|
+
`;
|
|
61
69
|
const ListScroller = styled.div `
|
|
62
70
|
scrollbar-color: ${({ theme }) => `${theme.scrollbar.thumb} ${theme.scrollbar.track}`};
|
|
63
|
-
scrollbar-gutter: stable;
|
|
64
71
|
scrollbar-width: thin;
|
|
65
72
|
|
|
66
73
|
&::-webkit-scrollbar {
|
|
@@ -234,16 +241,6 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
234
241
|
list.addEventListener("scroll", handleOnScroll);
|
|
235
242
|
return () => list.removeEventListener("scroll", handleOnScroll);
|
|
236
243
|
}, [dynamicOptionHeight, handleOnScroll, isLoading, renderOption]);
|
|
237
|
-
useLayoutEffect(() => {
|
|
238
|
-
var _a;
|
|
239
|
-
if (targetElm.current) {
|
|
240
|
-
const viewPortDimensions = (_a = targetElm.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
241
|
-
setViewPortDimensions({
|
|
242
|
-
width: viewPortDimensions.width,
|
|
243
|
-
height: viewPortDimensions.height,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}, [targetElm.current, isLoading]);
|
|
247
244
|
const overscanCount = 10;
|
|
248
245
|
const sizeTokens = getControlSizeTokens(size || "sm");
|
|
249
246
|
const itemHeight = sizeTokens.menuRowHeight;
|
|
@@ -267,6 +264,29 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
267
264
|
? estimatedHeight
|
|
268
265
|
: 200;
|
|
269
266
|
const width = "100%";
|
|
267
|
+
useLayoutEffect(() => {
|
|
268
|
+
const target = targetElm.current;
|
|
269
|
+
if (!target)
|
|
270
|
+
return;
|
|
271
|
+
const updateDimensions = () => {
|
|
272
|
+
const nextDimensions = target.getBoundingClientRect();
|
|
273
|
+
setViewPortDimensions((currentDimensions) => {
|
|
274
|
+
const width = Math.ceil(nextDimensions.width);
|
|
275
|
+
const height = Math.floor(nextDimensions.height);
|
|
276
|
+
if (currentDimensions.width === width &&
|
|
277
|
+
currentDimensions.height === height) {
|
|
278
|
+
return currentDimensions;
|
|
279
|
+
}
|
|
280
|
+
return { width, height };
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
updateDimensions();
|
|
284
|
+
if (typeof ResizeObserver === "undefined")
|
|
285
|
+
return;
|
|
286
|
+
const observer = new ResizeObserver(updateDimensions);
|
|
287
|
+
observer.observe(target);
|
|
288
|
+
return () => observer.disconnect();
|
|
289
|
+
}, [displayItemsKey, isLoading]);
|
|
270
290
|
const setItemSize = useCallback((index, measuredSize) => {
|
|
271
291
|
var _a;
|
|
272
292
|
if (itemSizeMap.current[index] === measuredSize)
|
|
@@ -335,7 +355,7 @@ export const MenuItemList = ({ menuItems, searchable, onSearch, manualSearch, dy
|
|
|
335
355
|
(item === null || item === void 0 ? void 0 : item.label) ||
|
|
336
356
|
(typeof item === "string" || typeof item === "number" ? item : null) }, index));
|
|
337
357
|
};
|
|
338
|
-
return (_jsxs(
|
|
358
|
+
return (_jsxs(MenuItemListRoot, { children: [searchable && (_jsx(SearchInput, { variant: "outlined", size: size, placeholder: "Search", defaultValue: searchValue, onChange: (e) => {
|
|
339
359
|
if (!manualSearch) {
|
|
340
360
|
handleSearch(e);
|
|
341
361
|
}
|
|
@@ -7,7 +7,7 @@ export const StyledContent = styled.div `
|
|
|
7
7
|
overflow-y: hidden;
|
|
8
8
|
overflow-x: hidden;
|
|
9
9
|
|
|
10
|
-
width: var(--mfui-dropdown-reference-width,
|
|
10
|
+
width: max(var(--mfui-dropdown-reference-width, 0px), 180px);
|
|
11
11
|
max-width: 400px;
|
|
12
12
|
max-height: ${({ maxDropdownHeight }) => Number.isInteger(maxDropdownHeight)
|
|
13
13
|
? `${maxDropdownHeight}px`
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { CodeViewer, ImageViewer, OfficeViewer, PdfViewer, VideoViewer, } from "./viewers";
|
|
4
4
|
import { FloatingPortal } from "@floating-ui/react";
|
|
5
|
-
import { DownloadIcon, XIcon, ZoomInIcon, ZoomOutIcon } from "lucide-react";
|
|
5
|
+
import { DownloadIcon, RotateCwIcon, XIcon, ZoomInIcon, ZoomOutIcon, } from "lucide-react";
|
|
6
6
|
import { Button } from "../Button";
|
|
7
|
-
import { useState } from "react";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
8
|
import Loader from "../Loader";
|
|
9
9
|
var ViewerTypes;
|
|
10
10
|
(function (ViewerTypes) {
|
|
@@ -24,7 +24,18 @@ const ZoomableViewerTypes = [
|
|
|
24
24
|
];
|
|
25
25
|
const RotatableViewerTypes = [ViewerTypes.Image];
|
|
26
26
|
const OfficeExtensions = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
|
|
27
|
-
const ImageExtensions = [
|
|
27
|
+
const ImageExtensions = [
|
|
28
|
+
"jpg",
|
|
29
|
+
"jpeg",
|
|
30
|
+
"png",
|
|
31
|
+
"gif",
|
|
32
|
+
"webp",
|
|
33
|
+
"bmp",
|
|
34
|
+
"svg",
|
|
35
|
+
"avif",
|
|
36
|
+
"tif",
|
|
37
|
+
"tiff",
|
|
38
|
+
];
|
|
28
39
|
const VideoExtensions = ["mp4", "webm", "mov"];
|
|
29
40
|
const AudioExtensions = ["mp3", "wav"];
|
|
30
41
|
const PDFExtensions = ["pdf"];
|
|
@@ -125,10 +136,14 @@ const StyledInnerContainer = styled.div.attrs({
|
|
|
125
136
|
}
|
|
126
137
|
`;
|
|
127
138
|
const resolveViewerType = (file) => {
|
|
128
|
-
var _a, _b;
|
|
139
|
+
var _a, _b, _c;
|
|
129
140
|
let ext = (_a = file === null || file === void 0 ? void 0 : file.ext) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
141
|
+
const type = (_b = file === null || file === void 0 ? void 0 : file.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
130
142
|
if (!ext) {
|
|
131
|
-
ext = (
|
|
143
|
+
ext = (_c = file.name.split(".").pop()) === null || _c === void 0 ? void 0 : _c.toLowerCase();
|
|
144
|
+
}
|
|
145
|
+
if (type === null || type === void 0 ? void 0 : type.startsWith("image/")) {
|
|
146
|
+
return ViewerTypes.Image;
|
|
132
147
|
}
|
|
133
148
|
if (!ext) {
|
|
134
149
|
return ViewerTypes.Code;
|
|
@@ -158,19 +173,28 @@ const resolveViewerType = (file) => {
|
|
|
158
173
|
};
|
|
159
174
|
export const FileViewer = ({ file, open, isPending, onClose }) => {
|
|
160
175
|
const [zoomFactor, setZoomFactor] = useState(1);
|
|
176
|
+
const [rotation, setRotation] = useState(0);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
setZoomFactor(1);
|
|
179
|
+
setRotation(0);
|
|
180
|
+
}, [file === null || file === void 0 ? void 0 : file.url, file === null || file === void 0 ? void 0 : file.name, open]);
|
|
161
181
|
if (!open)
|
|
162
182
|
return null;
|
|
163
183
|
if (!file)
|
|
164
184
|
return null;
|
|
165
185
|
const viewerType = resolveViewerType(file);
|
|
186
|
+
const resetViewerState = () => {
|
|
187
|
+
setZoomFactor(1);
|
|
188
|
+
setRotation(0);
|
|
189
|
+
};
|
|
166
190
|
const handleBackgroundClick = (e) => {
|
|
167
191
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
168
|
-
|
|
192
|
+
resetViewerState();
|
|
169
193
|
};
|
|
170
194
|
return (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsxs(StyledContainer, { className: "mfui-FileViewer", children: [_jsxs(StyledMenu, { className: "FileViewer-menu", children: [_jsx(Button, { variant: "text", onClick: () => {
|
|
171
195
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
172
|
-
|
|
173
|
-
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url,
|
|
196
|
+
resetViewerState();
|
|
197
|
+
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom in", title: "Zoom in", onClick: () => setZoomFactor((prev) => prev * 1.1), children: _jsx(ZoomInIcon, { size: 18 }) }), _jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom out", title: "Zoom out", onClick: () => setZoomFactor((prev) => prev * 0.9), children: _jsx(ZoomOutIcon, { size: 18 }) })] })), RotatableViewerTypes.includes(viewerType) && (_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Rotate image", title: "Rotate image", onClick: () => setRotation((prev) => (prev + 90) % 360), children: _jsx(RotateCwIcon, { size: 18 }) })), _jsx("a", { href: file.url, download: file.name, style: { pointerEvents: !file.url ? "none" : "auto" }, children: _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(DownloadIcon, { size: 18 }) }) })] })] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, rotation: rotation, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
174
198
|
margin: "auto",
|
|
175
199
|
display: "flex",
|
|
176
200
|
gap: "10px",
|
|
@@ -10,9 +10,7 @@ const ImageViewerContainer = styled.div `
|
|
|
10
10
|
overflow: auto;
|
|
11
11
|
`;
|
|
12
12
|
const ImageCanvas = styled.div `
|
|
13
|
-
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
13
|
+
position: relative;
|
|
16
14
|
flex: 0 0 auto;
|
|
17
15
|
min-width: 100%;
|
|
18
16
|
min-height: 100%;
|
|
@@ -20,8 +18,11 @@ const ImageCanvas = styled.div `
|
|
|
20
18
|
const Image = styled.img `
|
|
21
19
|
box-sizing: border-box;
|
|
22
20
|
display: block;
|
|
23
|
-
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 50%;
|
|
23
|
+
left: 50%;
|
|
24
24
|
object-fit: contain;
|
|
25
|
+
transform-origin: center;
|
|
25
26
|
|
|
26
27
|
// set orientation
|
|
27
28
|
image-orientation: from-image;
|
|
@@ -36,7 +37,7 @@ const StyledLoader = styled.div `
|
|
|
36
37
|
gap: 10px;
|
|
37
38
|
height: 100%;
|
|
38
39
|
`;
|
|
39
|
-
export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
40
|
+
export const ImageViewer = ({ file, zoomFactor = 1, rotation = 0, isPending }) => {
|
|
40
41
|
const containerRef = useRef(null);
|
|
41
42
|
const [imageLoaded, setImageLoaded] = useState(false);
|
|
42
43
|
const [containerSize, setContainerSize] = useState({
|
|
@@ -47,6 +48,8 @@ export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
|
47
48
|
naturalWidth: 0,
|
|
48
49
|
naturalHeight: 0,
|
|
49
50
|
});
|
|
51
|
+
const normalizedRotation = ((rotation % 360) + 360) % 360;
|
|
52
|
+
const isRotatedSideways = normalizedRotation % 180 !== 0;
|
|
50
53
|
const fittedDimensions = useMemo(() => {
|
|
51
54
|
const { naturalWidth, naturalHeight } = originalDimensions;
|
|
52
55
|
if (naturalWidth === 0 ||
|
|
@@ -54,16 +57,33 @@ export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
|
54
57
|
containerSize.width === 0 ||
|
|
55
58
|
containerSize.height === 0) {
|
|
56
59
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
canvasWidth: isRotatedSideways ? naturalHeight : naturalWidth,
|
|
61
|
+
canvasHeight: isRotatedSideways ? naturalWidth : naturalHeight,
|
|
62
|
+
imageWidth: naturalWidth,
|
|
63
|
+
imageHeight: naturalHeight,
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
|
-
const
|
|
66
|
+
const rotatedNaturalWidth = isRotatedSideways
|
|
67
|
+
? naturalHeight
|
|
68
|
+
: naturalWidth;
|
|
69
|
+
const rotatedNaturalHeight = isRotatedSideways
|
|
70
|
+
? naturalWidth
|
|
71
|
+
: naturalHeight;
|
|
72
|
+
const fitScale = Math.min(containerSize.width / rotatedNaturalWidth, containerSize.height / rotatedNaturalHeight);
|
|
73
|
+
const imageWidth = naturalWidth * fitScale * zoomFactor;
|
|
74
|
+
const imageHeight = naturalHeight * fitScale * zoomFactor;
|
|
62
75
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
canvasWidth: isRotatedSideways ? imageHeight : imageWidth,
|
|
77
|
+
canvasHeight: isRotatedSideways ? imageWidth : imageHeight,
|
|
78
|
+
imageWidth,
|
|
79
|
+
imageHeight,
|
|
65
80
|
};
|
|
66
|
-
}, [
|
|
81
|
+
}, [
|
|
82
|
+
containerSize,
|
|
83
|
+
isRotatedSideways,
|
|
84
|
+
originalDimensions,
|
|
85
|
+
zoomFactor,
|
|
86
|
+
]);
|
|
67
87
|
useEffect(() => {
|
|
68
88
|
if (!file.url)
|
|
69
89
|
return;
|
|
@@ -104,11 +124,12 @@ export const ImageViewer = ({ file, zoomFactor = 1, isPending }) => {
|
|
|
104
124
|
return (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] }));
|
|
105
125
|
}
|
|
106
126
|
return (_jsxs(ImageViewerContainer, { ref: containerRef, className: "mfui-ImageViewer", children: [!showImage && (_jsxs(StyledLoader, { children: [_jsx(Loader, { size: 50 }), _jsx("div", { children: "Loading Image..." })] })), showImage && (_jsx(ImageCanvas, { style: {
|
|
107
|
-
width: fittedDimensions.
|
|
108
|
-
height: fittedDimensions.
|
|
127
|
+
width: fittedDimensions.canvasWidth,
|
|
128
|
+
height: fittedDimensions.canvasHeight,
|
|
109
129
|
}, children: _jsx(Image, { src: file.url, alt: file.name ? file.name : "Image", style: {
|
|
110
|
-
width: fittedDimensions.
|
|
111
|
-
height: fittedDimensions.
|
|
130
|
+
width: fittedDimensions.imageWidth,
|
|
131
|
+
height: fittedDimensions.imageHeight,
|
|
132
|
+
transform: `translate(-50%, -50%) rotate(${normalizedRotation}deg)`,
|
|
112
133
|
}, onClick: (e) => {
|
|
113
134
|
e.stopPropagation();
|
|
114
135
|
} }) }))] }));
|
|
@@ -81,6 +81,29 @@ export interface MonolithDefaultTheme {
|
|
|
81
81
|
action: {
|
|
82
82
|
hover: string;
|
|
83
83
|
};
|
|
84
|
+
codeBlock?: {
|
|
85
|
+
background: string;
|
|
86
|
+
text: string;
|
|
87
|
+
border: string;
|
|
88
|
+
selection: string;
|
|
89
|
+
syntax: {
|
|
90
|
+
comment: string;
|
|
91
|
+
punctuation: string;
|
|
92
|
+
property: string;
|
|
93
|
+
selector: string;
|
|
94
|
+
operator: string;
|
|
95
|
+
keyword: string;
|
|
96
|
+
string: string;
|
|
97
|
+
number: string;
|
|
98
|
+
function: string;
|
|
99
|
+
variable: string;
|
|
100
|
+
tag: string;
|
|
101
|
+
attribute: string;
|
|
102
|
+
literal: string;
|
|
103
|
+
deleted: string;
|
|
104
|
+
inserted: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
84
107
|
divider: string;
|
|
85
108
|
};
|
|
86
109
|
header: {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Extensions } from "../Enums";
|
|
2
2
|
import { DropDownItem, DropDownMenuProps } from "../../DropDownMenu";
|
|
3
|
-
import { ReactElement } from "react";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
4
|
import { ButtonProps } from "../../Button";
|
|
5
5
|
import { Editor } from "@tiptap/react";
|
|
6
|
-
export interface
|
|
6
|
+
export interface BubbleMenuContentProps {
|
|
7
7
|
className?: string;
|
|
8
8
|
editor: Editor;
|
|
9
|
-
rect: DOMRect;
|
|
10
|
-
open: boolean;
|
|
11
|
-
onOpen?: (element: HTMLElement) => void;
|
|
12
9
|
customMenuItems?: BubbleItem[];
|
|
13
10
|
}
|
|
14
11
|
interface BubbleMenuDropDownItem extends DropDownItem {
|
|
@@ -20,7 +17,7 @@ export type BubbleItem = {
|
|
|
20
17
|
name: Extensions | string;
|
|
21
18
|
icon?: React.FC<any>;
|
|
22
19
|
type: "menu";
|
|
23
|
-
label?:
|
|
20
|
+
label?: ReactNode;
|
|
24
21
|
items: BubbleMenuDropDownItem[];
|
|
25
22
|
arrow?: boolean;
|
|
26
23
|
isActive?: (editor: Editor) => boolean;
|
|
@@ -32,12 +29,15 @@ export type BubbleItem = {
|
|
|
32
29
|
name: Extensions | string;
|
|
33
30
|
icon?: React.FC<any>;
|
|
34
31
|
type: "button";
|
|
35
|
-
label?:
|
|
32
|
+
label?: ReactNode;
|
|
36
33
|
arrow?: boolean;
|
|
37
34
|
isActive?: (editor: Editor) => boolean;
|
|
38
35
|
buttonRender?: (props: any) => ReactElement;
|
|
39
36
|
buttonProps?: Partial<ButtonProps>;
|
|
40
37
|
onClick?: (editor: Editor) => void;
|
|
41
38
|
};
|
|
42
|
-
|
|
39
|
+
export type BubbleMenuOptions = {
|
|
40
|
+
customMenuItems?: BubbleItem[];
|
|
41
|
+
};
|
|
42
|
+
declare const BubbleMenu: React.FC<BubbleMenuContentProps>;
|
|
43
43
|
export default BubbleMenu;
|