add properties for crop
This commit is contained in:
parent
3d92a3bf1f
commit
f4bebaaa50
@ -254,6 +254,14 @@ const restoreElement = (
|
||||
status: element.status || "pending",
|
||||
fileId: element.fileId,
|
||||
scale: element.scale || [1, 1],
|
||||
crop: element.crop ?? null,
|
||||
// TODO: restore properly
|
||||
widthAtCreation: element.widthAtCreation,
|
||||
heightAtCreation: element.heightAtCreation,
|
||||
naturalWidth: element.naturalWidth,
|
||||
naturalHeight: element.naturalHeight,
|
||||
resizedFactorX: element.resizedFactorX,
|
||||
resizedFactorY: element.resizedFactorY,
|
||||
});
|
||||
case "line":
|
||||
// @ts-ignore LEGACY type
|
||||
|
@ -478,6 +478,7 @@ export const newImageElement = (
|
||||
status?: ExcalidrawImageElement["status"];
|
||||
fileId?: ExcalidrawImageElement["fileId"];
|
||||
scale?: ExcalidrawImageElement["scale"];
|
||||
crop?: ExcalidrawImageElement["crop"];
|
||||
} & ElementConstructorOpts,
|
||||
): NonDeleted<ExcalidrawImageElement> => {
|
||||
return {
|
||||
@ -488,6 +489,13 @@ export const newImageElement = (
|
||||
status: opts.status ?? "pending",
|
||||
fileId: opts.fileId ?? null,
|
||||
scale: opts.scale ?? [1, 1],
|
||||
widthAtCreation: 0,
|
||||
heightAtCreation: 0,
|
||||
naturalWidth: 0,
|
||||
naturalHeight: 0,
|
||||
crop: opts.crop ?? null,
|
||||
resizedFactorX: 1,
|
||||
resizedFactorY: 1,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -140,6 +140,23 @@ export type ExcalidrawImageElement = _ExcalidrawElementBase &
|
||||
status: "pending" | "saved" | "error";
|
||||
/** X and Y scale factors <-1, 1>, used for image axis flipping */
|
||||
scale: [number, number];
|
||||
|
||||
/** the image's dimension after adjustment at creation */
|
||||
widthAtCreation: number;
|
||||
heightAtCreation: number;
|
||||
/** how much the image has been resized with respect the dimension at creation */
|
||||
resizedFactorX: number;
|
||||
resizedFactorY: number;
|
||||
|
||||
naturalWidth: number;
|
||||
naturalHeight: number;
|
||||
|
||||
crop: {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
} | null;
|
||||
}>;
|
||||
|
||||
export type InitializedExcalidrawImageElement = MarkNonNullable<
|
||||
|
Loading…
x
Reference in New Issue
Block a user