Skip to content

Commit

Permalink
fix: convert image size to string (#5717)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 authored Sep 27, 2024
1 parent ec08fb0 commit 04686d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 04686d1

Please sign in to comment.