fix: convert image size to string (#5717)
This commit is contained in:
parent
ec08fb078d
commit
04686d1721
2 changed files with 10 additions and 4 deletions
|
|
@ -11,7 +11,10 @@ export const CustomImageBlock: React.FC<CustomImageNodeViewProps> = (props) => {
|
||||||
const { node, updateAttributes, selected, getPos, editor } = props;
|
const { node, updateAttributes, selected, getPos, editor } = props;
|
||||||
const { src, width, height } = node.attrs;
|
const { src, width, height } = node.attrs;
|
||||||
|
|
||||||
const [size, setSize] = useState({ width: width || "35%", height: height || "auto" });
|
const [size, setSize] = useState({
|
||||||
|
width: width?.toString() || "35%",
|
||||||
|
height: height?.toString() || "auto",
|
||||||
|
});
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [initialResizeComplete, setInitialResizeComplete] = useState(false);
|
const [initialResizeComplete, setInitialResizeComplete] = useState(false);
|
||||||
const isShimmerVisible = isLoading || !initialResizeComplete;
|
const isShimmerVisible = isLoading || !initialResizeComplete;
|
||||||
|
|
@ -56,7 +59,10 @@ export const CustomImageBlock: React.FC<CustomImageNodeViewProps> = (props) => {
|
||||||
}, [width, height, updateAttributes]);
|
}, [width, height, updateAttributes]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
setSize({ width, height });
|
setSize({
|
||||||
|
width: width?.toString(),
|
||||||
|
height: height?.toString(),
|
||||||
|
});
|
||||||
}, [width, height]);
|
}, [width, height]);
|
||||||
|
|
||||||
const handleResizeStart = useCallback(
|
const handleResizeStart = useCallback(
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ export type CustomImageNodeViewProps = {
|
||||||
node: ProsemirrorNode & {
|
node: ProsemirrorNode & {
|
||||||
attrs: {
|
attrs: {
|
||||||
src: string;
|
src: string;
|
||||||
width: string;
|
width: number | string;
|
||||||
height: string;
|
height: number | string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
updateAttributes: (attrs: Record<string, any>) => void;
|
updateAttributes: (attrs: Record<string, any>) => void;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue