add properties for crop
This commit is contained in:
parent
3d92a3bf1f
commit
f4bebaaa50
@ -254,6 +254,14 @@ const restoreElement = (
|
|||||||
status: element.status || "pending",
|
status: element.status || "pending",
|
||||||
fileId: element.fileId,
|
fileId: element.fileId,
|
||||||
scale: element.scale || [1, 1],
|
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":
|
case "line":
|
||||||
// @ts-ignore LEGACY type
|
// @ts-ignore LEGACY type
|
||||||
|
@ -478,6 +478,7 @@ export const newImageElement = (
|
|||||||
status?: ExcalidrawImageElement["status"];
|
status?: ExcalidrawImageElement["status"];
|
||||||
fileId?: ExcalidrawImageElement["fileId"];
|
fileId?: ExcalidrawImageElement["fileId"];
|
||||||
scale?: ExcalidrawImageElement["scale"];
|
scale?: ExcalidrawImageElement["scale"];
|
||||||
|
crop?: ExcalidrawImageElement["crop"];
|
||||||
} & ElementConstructorOpts,
|
} & ElementConstructorOpts,
|
||||||
): NonDeleted<ExcalidrawImageElement> => {
|
): NonDeleted<ExcalidrawImageElement> => {
|
||||||
return {
|
return {
|
||||||
@ -488,6 +489,13 @@ export const newImageElement = (
|
|||||||
status: opts.status ?? "pending",
|
status: opts.status ?? "pending",
|
||||||
fileId: opts.fileId ?? null,
|
fileId: opts.fileId ?? null,
|
||||||
scale: opts.scale ?? [1, 1],
|
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";
|
status: "pending" | "saved" | "error";
|
||||||
/** X and Y scale factors <-1, 1>, used for image axis flipping */
|
/** X and Y scale factors <-1, 1>, used for image axis flipping */
|
||||||
scale: [number, number];
|
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<
|
export type InitializedExcalidrawImageElement = MarkNonNullable<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user