mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-25 17:04:40 +02:00
init width and height when dragging to create img
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
|||||||
isArrowElement,
|
isArrowElement,
|
||||||
isElbowArrow,
|
isElbowArrow,
|
||||||
isFrameLikeElement,
|
isFrameLikeElement,
|
||||||
|
isImageElement,
|
||||||
isTextElement,
|
isTextElement,
|
||||||
} from "./typeChecks";
|
} from "./typeChecks";
|
||||||
import { getFontString } from "../utils";
|
import { getFontString } from "../utils";
|
||||||
@@ -258,6 +259,14 @@ export const dragNewElement = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (width !== 0 && height !== 0) {
|
if (width !== 0 && height !== 0) {
|
||||||
|
let imageInitialDimension = null;
|
||||||
|
if (isImageElement(newElement)) {
|
||||||
|
imageInitialDimension = {
|
||||||
|
initialWidth: width,
|
||||||
|
initialHeight: height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
mutateElement(
|
mutateElement(
|
||||||
newElement,
|
newElement,
|
||||||
{
|
{
|
||||||
@@ -266,6 +275,7 @@ export const dragNewElement = ({
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
...textAutoResize,
|
...textAutoResize,
|
||||||
|
...imageInitialDimension,
|
||||||
},
|
},
|
||||||
informMutation,
|
informMutation,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user