feat: image cropping (#8613)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Ryan Di 2024-10-22 04:26:52 +08:00 committed by GitHub
parent eb09b48ae6
commit e957c8e9ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 2199 additions and 92 deletions

View file

@ -16,6 +16,7 @@ import {
isArrowElement,
isElbowArrow,
isFrameLikeElement,
isImageElement,
isTextElement,
} from "./typeChecks";
import { getFontString } from "../utils";
@ -251,6 +252,14 @@ export const dragNewElement = ({
}
if (width !== 0 && height !== 0) {
let imageInitialDimension = null;
if (isImageElement(newElement)) {
imageInitialDimension = {
initialWidth: width,
initialHeight: height,
};
}
mutateElement(
newElement,
{
@ -259,6 +268,7 @@ export const dragNewElement = ({
width,
height,
...textAutoResize,
...imageInitialDimension,
},
informMutation,
);