@blocklet/editor 1.6.258 → 1.6.260
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.
|
@@ -307,7 +307,6 @@ export default function ImageComponent({ file, src, altText, nodeKey, width, hei
|
|
|
307
307
|
onResizeStart: onResizeStart, onResizeEnd: onResizeEnd, captionsEnabled: false }), _jsxs(ImageEnhancer, { frame: frame, sizeMode: width === 'inherit' ? sizeMode || 'best-fit' : undefined, onSizeModeChange: setSizeMode, onFrameChange: setFrame, children: [_jsx(Button, { disabled: !!isDeviceFrameUsed, onClick: () => setMarkerEditing(true), variant: "outlined", size: "small", sx: {
|
|
308
308
|
minWidth: 36,
|
|
309
309
|
height: 36,
|
|
310
|
-
ml: 1,
|
|
311
310
|
p: 0,
|
|
312
311
|
borderColor: 'grey.400',
|
|
313
312
|
'.MuiButton-icon': { m: 0 },
|
|
@@ -316,7 +315,6 @@ export default function ImageComponent({ file, src, altText, nodeKey, width, hei
|
|
|
316
315
|
}, variant: "outlined", size: "small", sx: {
|
|
317
316
|
minWidth: 36,
|
|
318
317
|
height: 36,
|
|
319
|
-
ml: 1,
|
|
320
318
|
p: 0,
|
|
321
319
|
borderColor: 'grey.400',
|
|
322
320
|
'.MuiButton-icon': { m: 0 },
|
|
@@ -4,6 +4,7 @@ import { useEffect, useRef } from 'react';
|
|
|
4
4
|
import * as markerjs2 from 'markerjs2';
|
|
5
5
|
import * as mjslive from 'markerjs-live';
|
|
6
6
|
import { frames } from './FrameMockup';
|
|
7
|
+
import { useEditorSize } from '../hooks/hooks';
|
|
7
8
|
const parseMarkerState = (markerState) => {
|
|
8
9
|
if (!markerState)
|
|
9
10
|
return null;
|
|
@@ -63,6 +64,20 @@ export function ImageAnnotationView({ imageRef, markerState, sx, ...rest }) {
|
|
|
63
64
|
const timer = setTimeout(() => {
|
|
64
65
|
markerView.targetRoot = viewRef.current;
|
|
65
66
|
markerView.show(parsed);
|
|
67
|
+
if (imageRef.current) {
|
|
68
|
+
const scaleFactor = imageRef.current.width / parsed.width;
|
|
69
|
+
markerView.markers.forEach((marker) => {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
if (marker.setStrokeWidth)
|
|
72
|
+
marker.setStrokeWidth(marker.strokeWidth * scaleFactor);
|
|
73
|
+
if (marker instanceof mjslive.ArrowMarker) {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
marker.arrowBaseWidth *= scaleFactor;
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
marker.arrowBaseHeight *= scaleFactor;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
66
81
|
}, 10);
|
|
67
82
|
return () => {
|
|
68
83
|
clearTimeout(timer);
|
|
@@ -76,7 +91,23 @@ export function ImageEnhancer({ sizeMode, frame, onSizeModeChange, onFrameChange
|
|
|
76
91
|
const handleFrameChange = (value) => {
|
|
77
92
|
onFrameChange(value === 'none' ? undefined : value);
|
|
78
93
|
};
|
|
79
|
-
|
|
94
|
+
const size = useEditorSize();
|
|
95
|
+
return (
|
|
96
|
+
// zIndex 必须为 modal (或以下), 否则如果高于 Select.MuiPaper-root, 会导致点击 Select 无法显示选项, 且导致 image 失焦
|
|
97
|
+
// 上述问题在 discussion/blog 中可复现, doc 中未复现, 其它的解决方法是在 Select#onClick 中调用 e.stopPropagation 或提高 Select.MuiPaper-root 的 zIndex
|
|
98
|
+
_jsx(Box, { sx: {
|
|
99
|
+
position: 'relative',
|
|
100
|
+
zIndex: 'modal',
|
|
101
|
+
whiteSpace: 'nowrap',
|
|
102
|
+
mt: 1,
|
|
103
|
+
}, children: _jsxs(Box, { sx: {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexWrap: 'wrap',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
gap: 1,
|
|
109
|
+
...(size?.width && { width: size.width - 36 }),
|
|
110
|
+
}, children: [_jsxs(ToggleButtonGroup, { color: "standard", value: sizeMode, size: "small", exclusive: true, onChange: (_, v) => onSizeModeChange(v), sx: { bgcolor: '#fff' }, children: [_jsx(ToggleButton, { value: "small", children: "Small" }), _jsx(ToggleButton, { value: "best-fit", children: "Best fit" }), _jsx(ToggleButton, { value: "original", children: "Original size" })] }), _jsxs(Select, { value: frame ?? 'none', onChange: (e) => handleFrameChange(e.target.value), sx: { width: { xs: 100, sm: 'auto' } }, MenuProps: { sx: { '.MuiPaper-root': { maxHeight: 400 } }, disablePortal: false }, children: [_jsx(MenuItem, { value: "none", children: "Select frame mockup" }), frames.map((x) => {
|
|
80
111
|
return (_jsx(MenuItem, { value: x.id, children: x.name }, x.id));
|
|
81
112
|
})] }), children] }) }));
|
|
82
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.260",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npm run storybook",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@arcblock/ux": "^2.9.77",
|
|
41
41
|
"@blocklet/embed": "^0.1.11",
|
|
42
42
|
"@blocklet/pages-kit": "^0.2.302",
|
|
43
|
-
"@blocklet/pdf": "1.6.
|
|
43
|
+
"@blocklet/pdf": "1.6.260",
|
|
44
44
|
"@excalidraw/excalidraw": "^0.14.2",
|
|
45
45
|
"@iconify/iconify": "^3.0.1",
|
|
46
46
|
"@iconify/icons-tabler": "^1.2.95",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"react": "*",
|
|
114
114
|
"react-dom": "*"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "71a881e14c0e3b8268a7c269ae96a62150ca8350"
|
|
117
117
|
}
|