fix(canvas): 提示词编辑 - 修复小视口溢出与窗口调整手柄失效

Refs #507
This commit is contained in:
ddCat
2026-09-18 13:19:57 +08:00
parent 10f2aa302c
commit 4eaa28b807
4 changed files with 72 additions and 27 deletions

View File

@@ -0,0 +1,12 @@
type Size = { width: number; height: number };
export const PROMPT_EDITOR_VIEWPORT_MARGIN = 24;
export function clampPromptEditorModalSize(size: Size, viewport: Size): Size {
const maxWidth = Math.max(1, viewport.width - PROMPT_EDITOR_VIEWPORT_MARGIN);
const maxHeight = Math.max(1, viewport.height - PROMPT_EDITOR_VIEWPORT_MARGIN);
return {
width: Math.min(maxWidth, Math.max(560, Math.round(size.width))),
height: Math.min(maxHeight, Math.max(320, Math.round(size.height))),
};
}