Skip to content

Commit

Permalink
fix image width when uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed Jun 6, 2024
1 parent 1d1598c commit 28efa34
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions uui-editor/src/plugins/imagePlugin/ImageElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React from 'react';
import {
PlateElement,
PlateElementProps,
Expand Down Expand Up @@ -29,7 +29,6 @@ export const ImageElement = withHOC(ResizableProvider, ({
...props
}: ImageElementProps) => {
const { children, nodeProps } = props;
const imageRef = useRef<HTMLImageElement>();

const focused = useFocused();
const selected = useSelected();
Expand Down Expand Up @@ -72,11 +71,8 @@ export const ImageElement = withHOC(ResizableProvider, ({
)}
<Image
{ ...nodeProps }
ref={ imageRef }
onLoad={ () => {
if (typeof imageRef.current?.width === 'number') {
setWidth(imageRef.current?.width);
}
onLoad={ (event) => {
setWidth((event.target as HTMLImageElement).width);
} }
className={ cx(
css.image,
Expand Down

0 comments on commit 28efa34

Please sign in to comment.