@blocklet/editor 2.4.72 → 2.4.73
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/lib/config.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface EditorConfig {
|
|
|
26
26
|
minimalMode?: boolean;
|
|
27
27
|
openLinkInNewTab?: boolean;
|
|
28
28
|
characterLimitConfig?: CharacterLimitConfig;
|
|
29
|
+
simpleImageComponent?: boolean;
|
|
29
30
|
}
|
|
30
31
|
export declare function EditorConfigProvider({ children, value }: {
|
|
31
32
|
children: React.ReactNode;
|
|
@@ -9,7 +9,7 @@ import { LexicalEditor, NodeKey } from 'lexical';
|
|
|
9
9
|
import { type JSX } from 'react';
|
|
10
10
|
import './ImageNode.css';
|
|
11
11
|
import type { ImageSizeMode } from '../../types';
|
|
12
|
-
export default function
|
|
12
|
+
export default function ImageComponentWrapper({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }: {
|
|
13
13
|
file?: File;
|
|
14
14
|
altText: string;
|
|
15
15
|
caption: LexicalEditor;
|
|
@@ -61,7 +61,7 @@ function LazyImage({ altText, className, imageRef, src, width, height, }) {
|
|
|
61
61
|
};
|
|
62
62
|
return (_jsx("img", { className: className || undefined, src: src, alt: altText, ref: imageRef, draggable: "false", crossOrigin: "anonymous", ...imgProps }));
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
function ImageComponent({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }) {
|
|
65
65
|
const imageFrameRef = useRef(null);
|
|
66
66
|
const imageRef = useRef(null);
|
|
67
67
|
const buttonRef = useRef(null);
|
|
@@ -356,3 +356,25 @@ function formatFileSize(size) {
|
|
|
356
356
|
const [factor, symbol] = size >= GB ? [GB, 'GB'] : size >= MB ? [MB, 'MB'] : size >= KB ? [KB, 'KB'] : [1, 'B'];
|
|
357
357
|
return `${Number((size / factor).toFixed(2))}${symbol}`;
|
|
358
358
|
}
|
|
359
|
+
function SimpleImageComponent({ src, altText = '', width, height, }) {
|
|
360
|
+
const [loaded, setLoaded] = useState(false);
|
|
361
|
+
const imageRef = useRef(null);
|
|
362
|
+
useMediumZoom(imageRef);
|
|
363
|
+
return (_jsxs(_Fragment, { children: [!loaded && _jsx(Skeleton, { variant: "rectangular", animation: "wave", sx: { width: 300, height: 200, borderRadius: 1 } }), _jsx(Box, { sx: {
|
|
364
|
+
p: 1,
|
|
365
|
+
border: 1,
|
|
366
|
+
borderColor: 'divider',
|
|
367
|
+
borderRadius: 2,
|
|
368
|
+
visibility: loaded ? 'visible' : 'hidden',
|
|
369
|
+
}, children: _jsx(Box, { component: "img", src: src, alt: altText || '', onLoad: () => {
|
|
370
|
+
setLoaded(true);
|
|
371
|
+
}, sx: { width, height }, ref: imageRef }) })] }));
|
|
372
|
+
}
|
|
373
|
+
export default function ImageComponentWrapper({ file, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled, markerState, frame, sizeMode, }) {
|
|
374
|
+
const [editor] = useLexicalComposerContext();
|
|
375
|
+
const config = useEditorConfig();
|
|
376
|
+
if (!editor.isEditable() && config.simpleImageComponent && src) {
|
|
377
|
+
return _jsx(SimpleImageComponent, { src: src, altText: altText, width: width, height: height });
|
|
378
|
+
}
|
|
379
|
+
return (_jsx(ImageComponent, { file: file, src: src, altText: altText, nodeKey: nodeKey, width: width, height: height, maxWidth: maxWidth, resizable: resizable, showCaption: showCaption, caption: caption, captionsEnabled: captionsEnabled, markerState: markerState, frame: frame, sizeMode: sizeMode }));
|
|
380
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.73",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"ufo": "^1.5.4",
|
|
71
71
|
"url-join": "^4.0.1",
|
|
72
72
|
"zustand": "^4.5.5",
|
|
73
|
-
"@blocklet/pdf": "2.4.
|
|
73
|
+
"@blocklet/pdf": "2.4.73"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@babel/core": "^7.25.2",
|