@blocklet/editor 2.4.40 → 2.4.41
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.
|
@@ -7,6 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import { exportToSvg } from '@excalidraw/excalidraw';
|
|
10
|
+
import { useTheme } from '@mui/material';
|
|
10
11
|
import { useEffect, useState } from 'react';
|
|
11
12
|
// exportToSvg has fonts from excalidraw.com
|
|
12
13
|
// We don't want them to be used in open source
|
|
@@ -30,10 +31,18 @@ const removeStyleFromSvg_HACK = (svg) => {
|
|
|
30
31
|
*/
|
|
31
32
|
export default function ExcalidrawImage({ elements, files, imageContainerRef, appState, rootClassName = null, ...rest }) {
|
|
32
33
|
const [Svg, setSvg] = useState(null);
|
|
34
|
+
const theme = useTheme();
|
|
33
35
|
useEffect(() => {
|
|
34
36
|
const setContent = async () => {
|
|
35
37
|
const svg = await exportToSvg({
|
|
36
|
-
appState
|
|
38
|
+
appState: {
|
|
39
|
+
...appState,
|
|
40
|
+
...(theme.palette.mode === 'dark' && {
|
|
41
|
+
theme: 'dark',
|
|
42
|
+
viewBackgroundColor: theme.palette.background.default,
|
|
43
|
+
// exportWithDarkMode: true,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
37
46
|
elements,
|
|
38
47
|
files,
|
|
39
48
|
});
|
|
@@ -11,6 +11,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
import LoadingButton from '@mui/lab/LoadingButton';
|
|
13
13
|
import '@excalidraw/excalidraw/index.css';
|
|
14
|
+
import { useTheme } from '@mui/material';
|
|
14
15
|
import Button from '../../ui/Button';
|
|
15
16
|
import Modal from '../../ui/Modal';
|
|
16
17
|
import { uploadImageToMediaKit } from './utils';
|
|
@@ -37,6 +38,7 @@ export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, i
|
|
|
37
38
|
const [loading, setLoading] = useState(false);
|
|
38
39
|
const [saveText, setSaveText] = useState('Save');
|
|
39
40
|
const [fullScreen, setFullScreen] = useState(false);
|
|
41
|
+
const theme = useTheme();
|
|
40
42
|
const markBlockletDirtyState = () => {
|
|
41
43
|
if (!readonly) {
|
|
42
44
|
window.dispatchEvent(new CustomEvent('blocklet:markDirty', { detail: { key: 'excalidraw' } }));
|
|
@@ -181,8 +183,14 @@ export default function ExcalidrawModal({ closeOnClickOutside = false, onSave, i
|
|
|
181
183
|
// like a module resolution issue with ESM vs CJS?
|
|
182
184
|
// @ts-ignore
|
|
183
185
|
const _Excalidraw = Excalidraw.$$typeof != null ? Excalidraw : Excalidraw.default;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
const appState = {
|
|
187
|
+
...initialAppState,
|
|
188
|
+
...(theme.palette.mode === 'dark' && {
|
|
189
|
+
theme: 'dark',
|
|
190
|
+
}),
|
|
191
|
+
};
|
|
192
|
+
return createPortal(_jsx("div", { className: `ExcalidrawModal__overlay ${fullScreen ? 'ExcalidrawModal__fullscreen' : ''}`, role: "dialog", children: _jsx("div", { className: "ExcalidrawModal__modal", ref: excaliDrawModelRef, tabIndex: -1, style: { backgroundColor: theme.palette.grey[100] }, children: _jsxs("div", { className: "ExcalidrawModal__row", children: [discardModalOpen && _jsx(ShowDiscardDialog, {}), _jsx(_Excalidraw, { onChange: onChange, onLibraryChange: onLibraryChange, ref: excaliDrawSceneRef, initialData: {
|
|
193
|
+
appState: appState || { isLoading: false },
|
|
186
194
|
elements: initialElements,
|
|
187
195
|
files: initialFiles,
|
|
188
196
|
} }), _jsxs("div", { className: "ExcalidrawModal__actions", children: [!fullScreen && (_jsx(LoadingButton, { className: "action-button", style: { width: 32, padding: 0, display: 'flex', alignItems: 'center' }, onClick: () => setFullScreen(true), children: _jsx("i", { className: "iconify", "data-icon": "material-symbols:fullscreen", "data-height": "18" }) })), fullScreen && (_jsx(LoadingButton, { className: "action-button", style: { width: 32, padding: 0, display: 'flex', alignItems: 'center' }, onClick: () => setFullScreen(false), children: _jsx("i", { className: "iconify", "data-icon": "material-symbols:fullscreen-exit", "data-height": "18" }) })), !readonly && (_jsxs(_Fragment, { children: [_jsx(LoadingButton, { loadingPosition: "start", disabled: loading, className: "action-button", onClick: discard, children: "Discard" }), _jsx(LoadingButton, { loadingPosition: "start", loading: loading, className: "action-button", onClick: save, children: saveText })] })), readonly && (_jsx(LoadingButton, { className: "action-button", onClick: () => onClose(), children: "Close" }))] })] }) }) }), document.body);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.41",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@blocklet/code-editor": "^0.5.
|
|
27
|
+
"@blocklet/code-editor": "^0.5.4",
|
|
28
28
|
"@blocklet/embed": "^0.2.5",
|
|
29
29
|
"@blocklet/js-sdk": "^1.16.48",
|
|
30
|
-
"@blocklet/pages-kit": "^0.6.
|
|
31
|
-
"@blocklet/pages-kit-runtime": "^0.6.
|
|
30
|
+
"@blocklet/pages-kit": "^0.6.46",
|
|
31
|
+
"@blocklet/pages-kit-runtime": "^0.6.46",
|
|
32
32
|
"@excalidraw/excalidraw": "^0.18.0",
|
|
33
33
|
"@iconify/iconify": "^3.1.1",
|
|
34
34
|
"@iconify/icons-tabler": "^1.2.95",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"ufo": "^1.5.4",
|
|
70
70
|
"url-join": "^4.0.1",
|
|
71
71
|
"zustand": "^4.5.5",
|
|
72
|
-
"@blocklet/pdf": "2.4.
|
|
72
|
+
"@blocklet/pdf": "2.4.41"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@babel/core": "^7.25.2",
|