diff --git a/components/canvas/LiblibVideoCanvasReplica.tsx b/components/canvas/LiblibVideoCanvasReplica.tsx index ef86d8a17..7e0c18ea9 100644 --- a/components/canvas/LiblibVideoCanvasReplica.tsx +++ b/components/canvas/LiblibVideoCanvasReplica.tsx @@ -384,6 +384,7 @@ const OFFICIAL_TEXT_RESOURCE_WIDTH = 560; const OFFICIAL_IMAGE_TOOLBAR_SCALE = 0.7; const OFFICIAL_COMPOSER_SCALE = 0.546; const OFFICIAL_ZOOM_DOCK_SCALE = 0.65; +const OFFICIAL_DROPDOWN_SCALE = 0.7; const OFFICIAL_NINE_GRID_WIDTH = 930; const OFFICIAL_NINE_GRID_HEIGHT = 520; const PROMPT_COMPOSER_BASE_WIDTH = 895; @@ -1139,6 +1140,12 @@ function preventNativeImageDrag(event: ReactDragEvent) { function normalizeGridOption(option?: string) { const text = String(option || "").trim(); + const explicitGrid = text.match(/(\d+)\s*[x×]\s*(\d+)/i); + if (explicitGrid) { + const columns = Math.max(1, Math.min(5, Number.parseInt(explicitGrid[1] || "3", 10) || 3)); + const rows = Math.max(1, Math.min(5, Number.parseInt(explicitGrid[2] || "3", 10) || 3)); + return { columns, rows, tileCount: columns * rows }; + } const tileCount = /25\s*宫格|5\s*[x×]\s*5|25/.test(text) ? 25 @@ -5357,10 +5364,11 @@ function SceneToolbarPopover({ orbit: -245, panorama: -360, }; + const popoverScale = (anchor ? OFFICIAL_IMAGE_TOOLBAR_SCALE : 1) * OFFICIAL_DROPDOWN_SCALE; const officialPopoverStyle = { left: anchor ? anchor.centerX + popoverOffset[menu] : `calc(50% + ${popoverOffset[menu]}px)`, top: anchor ? anchor.topY - (24 * anchor.zoom + 10) + 8 : 168, - transform: `translateX(-50%) scale(${anchor ? OFFICIAL_IMAGE_TOOLBAR_SCALE : 1})`, + transform: `translateX(-50%) scale(${popoverScale})`, transformOrigin: "top center", }; const popoverSurfaceStyle = { @@ -5482,7 +5490,8 @@ function SceneToolbarPopover({ if (menu === "crop") { return (
setCustomGridOpen(false)} role="menu" style={{ ...officialPopoverStyle, ...popoverSurfaceStyle }} > @@ -5501,7 +5510,7 @@ function SceneToolbarPopover({ ))}
-
setCustomGridOpen(true)} onMouseLeave={() => setCustomGridOpen(false)}> +
setCustomGridOpen(true)}> - {customGridOpen ? ( -
setCustomGridOpen(true)} - onMouseLeave={() => setCustomGridOpen(false)} - style={popoverSurfaceStyle} - > - onSelect?.(`${rows} x ${columns}`)} /> -
- ) : null}
+ {customGridOpen ? ( +
setCustomGridOpen(true)} + style={popoverSurfaceStyle} + > + onSelect?.(`${columns} x ${rows}`)} /> +
+ ) : null}
); } @@ -5609,17 +5617,17 @@ function ImageToolMenuGlyph({ tool }: { tool: string }) { } function CustomGridPicker({ onSelect }: { onSelect: (rows: number, columns: number) => void }) { - const [hovered, setHovered] = useState({ columns: 0, rows: 0 }); + const [hovered, setHovered] = useState({ columns: 3, rows: 3 }); return ( -
+
- 自定义宫格 - - {hovered.rows > 0 && hovered.columns > 0 ? `${hovered.columns} x ${hovered.rows}` : ""} + 自定义宫格 + + {hovered.columns} × {hovered.rows}
-
setHovered({ columns: 0, rows: 0 })}> +
setHovered({ columns: 3, rows: 3 })}> {Array.from({ length: 25 }).map((_, index) => { const rows = Math.floor(index / 5) + 1; const columns = (index % 5) + 1; @@ -5627,8 +5635,8 @@ function CustomGridPicker({ onSelect }: { onSelect: (rows: number, columns: numb return (