feat(editor): add edgeless media entry (#9949)

This commit is contained in:
Flrande
2025-02-07 06:10:11 +00:00
parent 12cc94f32a
commit 7eb1ed170c
6 changed files with 198 additions and 38 deletions

View File

@@ -428,6 +428,7 @@ export async function addImages(
options: {
point?: IVec;
maxWidth?: number;
transformPoint?: boolean; // determines whether we should use `toModelCoord` to convert the point
}
): Promise<string[]> {
const imageFiles = [...files].filter(file => file.type.startsWith('image/'));
@@ -449,9 +450,15 @@ export async function addImages(
return [];
}
const { point, maxWidth } = options;
const { point, maxWidth, transformPoint = true } = options;
let { x, y } = gfx.viewport.center;
if (point) [x, y] = gfx.viewport.toModelCoord(...point);
if (point) {
if (transformPoint) {
[x, y] = gfx.viewport.toModelCoord(...point);
} else {
[x, y] = point;
}
}
const dropInfos: { point: Point; blockId: string }[] = [];
const IMAGE_STACK_GAP = 32;