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 { 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 [initialResizeComplete, setInitialResizeComplete] = useState(false);
|
||||
const isShimmerVisible = isLoading || !initialResizeComplete;
|
||||
|
|
@ -56,7 +59,10 @@ export const CustomImageBlock: React.FC<CustomImageNodeViewProps> = (props) => {
|
|||
}, [width, height, updateAttributes]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setSize({ width, height });
|
||||
setSize({
|
||||
width: width?.toString(),
|
||||
height: height?.toString(),
|
||||
});
|
||||
}, [width, height]);
|
||||
|
||||
const handleResizeStart = useCallback(
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ export type CustomImageNodeViewProps = {
|
|||
node: ProsemirrorNode & {
|
||||
attrs: {
|
||||
src: string;
|
||||
width: string;
|
||||
height: string;
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
};
|
||||
};
|
||||
updateAttributes: (attrs: Record<string, any>) => void;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue