CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.
TypeScript ai-agentsai-diagramai-presentationbomcadcanvasdiagramdiagram-generatordrawioflowchartinfographicspptppt-generatorpresentation-generatorreactsvgedittext-to-diagramtypescriptworkflow
Canvas_edit
codingFeng1018d69ae5c8194
diff --git a/README.md b/README.mdindex 46e2460..aaa2479 100644--- a/README.md+++ b/README.md@@ -19,10 +19,11 @@</p><p align="center">- <a href="#creative-canvases">Canvases</a> ·- <a href="#skills">Skills</a> ·- <a href="#ppt-canvas">PPT Showcase</a> ·- <a href="#quick-start">Quick Start</a> ·+ <a href="#creative-canvases">Canvases</a> |+ <a href="#ppt-canvas">PPT Showcase</a> |+ <a href="#video-tutorial">Video Tutorial</a> |+ <a href="#skills">Skills</a> |+ <a href="#quick-start">Quick Start</a> |<a href="README.zh-CN.md">Chinese</a></p>@@ -32,24 +33,6 @@> CanvasAnvil brings diagramming, interior design workflows, presentation production, poster creation, infographic composition, and product storytelling into one unified workspace.-## 🌈 Release--Current release: `v2.1.0`--- Refreshed the CanvasAnvil portal interface with clearer product navigation.-- Added standalone `pptist-lab` deployment for the editable PPT editor.-- Standardized local and deployment ports around the main app and the dedicated PPT editor service.-- Updated the online access URL to `https://canvasanvil.codingfgd.asia`.-- Improved PPT editor embedding compatibility for domain, HTTPS, and reverse-proxy deployments.--## 🌐 Online Access--Current online access URL:--- 🔗 CanvasAnvil: [https://canvasanvil.codingfgd.asia](https://canvasanvil.codingfgd.asia)--The editable PPT editor is deployed as a standalone `pptist-lab` service and is embedded through the CanvasAnvil PPT workspace.-## 🎨 Creative Canvases| Workspace | Focus | Typical output |@@ -61,25 +44,6 @@ The editable PPT editor is deployed as a standalone `pptist-lab` service and is| `Infographic` | information design and visual explanation | explainer graphics, thematic information boards, comparison charts || `Product` | product storytelling and feature communication | product showcase pages, selling-point visuals, launch pages |-## 🧰 Skills--CanvasAnvil includes dedicated local skills for each canvas so workflows stay opinionated, repeatable, and easier to maintain.--- `flow-skill` · Diagram generation and packaging- Outputs clean diagram assets and skips standalone HTML preview by default.-- `cad-skill` · Interior-delivery workflow- Exports drawing bundles and a CSV material list for downstream delivery.-- `ppt-skill` · Full presentation production- Enforces outline review before generation and supports editable PPT, PDF, and image-based PPT output.-- `poster-skill` · Single-frame campaign visuals- Focuses on strong composition, typography, and poster-ready output.-- `infographic-skill` · Information-to-visual translation- Organizes dense content into readable infographic layouts.-- `product-skill` · Feature-led product storytelling- Builds showcase visuals around positioning, selling points, and launch messaging.--All skills use the host text model by default. Only image generation requires explicit provider configuration.-## 🔷 Flow CanvasTurn structured prompts into clear diagrams for research, systems, delivery plans, and teaching maps, then keep refining layout, labels, and node relationships in one place.@@ -201,6 +165,48 @@ Present products through feature-led layouts that combine hero imagery, selling</tr></table>++## 🌈 Release++Current release: `v2.1.0`++- Refreshed the CanvasAnvil portal interface with clearer product navigation.+- Added standalone `pptist-lab` deployment for the editable PPT editor.+- Standardized local and deployment ports around the main app and the dedicated PPT editor service.+- Updated the online access URL to `https://canvasanvil.codingfgd.asia`.+- Improved PPT editor embedding compatibility for domain, HTTPS, and reverse-proxy deployments.++## 🌐 Online Access++Current online access URL:++- 🔗 CanvasAnvil: [https://canvasanvil.codingfgd.asia](https://canvasanvil.codingfgd.asia)++The editable PPT editor is deployed as a standalone `pptist-lab` service and is embedded through the CanvasAnvil PPT workspace.++## Video Tutorial++- Bilibili tutorial: [https://b23.tv/RzhdtYZ](https://b23.tv/RzhdtYZ)++## 🧰 Skills++CanvasAnvil includes dedicated local skills for each canvas so workflows stay opinionated, repeatable, and easier to maintain.++- `flow-skill` · Diagram generation and packaging+ Outputs clean diagram assets and skips standalone HTML preview by default.+- `cad-skill` · Interior-delivery workflow+ Exports drawing bundles and a CSV material list for downstream delivery.+- `ppt-skill` · Full presentation production+ Enforces outline review before generation and supports editable PPT, PDF, and image-based PPT output.+- `poster-skill` · Single-frame campaign visuals+ Focuses on strong composition, typography, and poster-ready output.+- `infographic-skill` · Information-to-visual translation+ Organizes dense content into readable infographic layouts.+- `product-skill` · Feature-led product storytelling+ Builds showcase visuals around positioning, selling points, and launch messaging.++All skills use the host text model by default. Only image generation requires explicit provider configuration.+## 🚀 Quick Start1. Install dependenciesdiff --git a/README.zh-CN.md b/README.zh-CN.mdindex 771418c..43d380f 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -19,10 +19,11 @@</p><p align="center">- <a href="#创作画布">创作画布</a> ·- <a href="#skills">Skills</a> ·- <a href="#ppt-演示画布">PPT 展示</a> ·- <a href="#快速开始">快速开始</a> ·+ <a href="#创作画布">创作画布</a> |+ <a href="#ppt-演示画布">PPT 展示</a> |+ <a href="#视频教程">视频教程</a> |+ <a href="#skills">Skills</a> |+ <a href="#快速开始">快速开始</a> |<a href="README.md">English</a></p>@@ -32,24 +33,6 @@> CanvasAnvil 将流程图、室内设计工作流、PPT 制作、海报、信息图和产品介绍整合到一个统一工作区中。-## 🌈 版本发布--当前版本:`v2.1.0`--- 更新 CanvasAnvil 门户界面,优化入口体验与产品导航结构-- 新增 `pptist-lab` 独立部署方式,支持 PPT 编辑器作为独立服务运行-- 统一主应用与独立 PPT 编辑器服务的本地和部署端口规划-- 更新并同步在线访问地址为 `https://canvasanvil.codingfgd.asia`-- 优化 PPT 编辑器在域名、HTTPS 与反向代理生产环境下的嵌入兼容性--## 🌐 在线使用--当前在线访问地址:--- 🔗 CanvasAnvil:[https://canvasanvil.codingfgd.asia](https://canvasanvil.codingfgd.asia)--PPT 编辑器已改为独立 `pptist-lab` 服务部署,并通过 CanvasAnvil 的 PPT 工作区嵌入使用。-## 🎨 创作画布| 画布 | 核心能力 | 常见输出 |@@ -61,25 +44,6 @@ PPT 编辑器已改为独立 `pptist-lab` 服务部署,并通过 CanvasAnvil| `信息图` | 信息设计与可视化讲解 | 讲解型信息图、主题信息板、对比图表 || `产品介绍` | 产品叙事与卖点表达 | 产品展示页、卖点视觉页、上线宣传页 |-## 🧰 Skills--CanvasAnvil 为每个画布都提供了专用本地 skill,用来保证工作流稳定、输出一致,而不是把所有任务都塞进同一条通用提示链。--- `flow-skill` · 流程图生成与打包- 输出整洁的图表资源,并默认跳过独立 HTML 预览。-- `cad-skill` · 室内设计交付流程- 导出图纸打包结果与 CSV 材料清单,便于后续交付。-- `ppt-skill` · 完整演示稿生产- 强制先确认大纲,再生成整套演示稿,并导出可编辑 PPT、PDF 或图片版 PPT。-- `poster-skill` · 单张海报视觉生成- 强调海报级构图、字体层次和成品表达。-- `infographic-skill` · 信息图组织与讲解- 负责高密度信息整理、视觉讲解和信息图版式。-- `product-skill` · 产品卖点展示物料- 围绕产品定位、卖点和展示视觉组织内容。--所有 skill 默认使用宿主文本模型。只有生图能力需要单独配置图片生成供应商。-## 🔷 流程绘制画布将结构化提示快速转成清晰图表,适合学术框架、系统架构、实施路线和课程导图,并在同一画布中持续迭代布局、节点关系与说明文案。@@ -201,6 +165,48 @@ CanvasAnvil 为每个画布都提供了专用本地 skill,用来保证工作</tr></table>++## 🌈 版本发布++当前版本:`v2.1.0`++- 更新 CanvasAnvil 门户界面,优化入口体验与产品导航结构+- 新增 `pptist-lab` 独立部署方式,支持 PPT 编辑器作为独立服务运行+- 统一主应用与独立 PPT 编辑器服务的本地和部署端口规划+- 更新并同步在线访问地址为 `https://canvasanvil.codingfgd.asia`+- 优化 PPT 编辑器在域名、HTTPS 与反向代理生产环境下的嵌入兼容性++## 🌐 在线使用++当前在线访问地址:++- 🔗 CanvasAnvil:[https://canvasanvil.codingfgd.asia](https://canvasanvil.codingfgd.asia)++PPT 编辑器已改为独立 `pptist-lab` 服务部署,并通过 CanvasAnvil 的 PPT 工作区嵌入使用。++## 🎬 视频教程++- Bilibili 教程:[https://b23.tv/RzhdtYZ](https://b23.tv/RzhdtYZ)++## 🧰 Skills++CanvasAnvil 为每个画布都提供了专用本地 skill,用来保证工作流稳定、输出一致,而不是把所有任务都塞进同一条通用提示链。++- `flow-skill` · 流程图生成与打包+ 输出整洁的图表资源,并默认跳过独立 HTML 预览。+- `cad-skill` · 室内设计交付流程+ 导出图纸打包结果与 CSV 材料清单,便于后续交付。+- `ppt-skill` · 完整演示稿生产+ 强制先确认大纲,再生成整套演示稿,并导出可编辑 PPT、PDF 或图片版 PPT。+- `poster-skill` · 单张海报视觉生成+ 强调海报级构图、字体层次和成品表达。+- `infographic-skill` · 信息图组织与讲解+ 负责高密度信息整理、视觉讲解和信息图版式。+- `product-skill` · 产品卖点展示物料+ 围绕产品定位、卖点和展示视觉组织内容。++所有 skill 默认使用宿主文本模型。只有生图能力需要单独配置图片生成供应商。+## 🚀 快速开始1. 安装依赖diff --git a/src/lib/ai/gateway.ts b/src/lib/ai/gateway.tsindex 1015fec..c6633a4 100644--- a/src/lib/ai/gateway.ts+++ b/src/lib/ai/gateway.ts@@ -2,6 +2,7 @@ import {type AIChannelConfig,type CustomProviderMappingSpec,parseCustomProviderMapping,+ resolveImageCapabilities,resolveImageRoute,resolveTextRoute,} from "./provider-registry";@@ -24,6 +25,15 @@ export interface ImageGatewayRequest {maskImageUrl?: string;}+type ImageAdapter = {+ supports(request: ImageGatewayRequest): boolean;+ generate(request: ImageGatewayRequest): Promise<string>;+};++function shouldUseEditFlow(req: ImageGatewayRequest, capabilities?: { supportsEdits: boolean }) {+ return Boolean(req.referenceImageUrl && capabilities?.supportsEdits);+}+function joinUrl(baseUrl: string, endpoint: string): string {const base = String(baseUrl || "").trim().replace(/\/+$/, "");const path = String(endpoint || "").trim();@@ -151,6 +161,22 @@ function extractImageUrlFromOpenAIContent(content: any): string | null {return null;}+function extractImageUrlFromAliyunContent(content: any): string | null {+ if (Array.isArray(content)) {+ const imagePart = content.find((part) => part?.image);+ if (imagePart?.image) return String(imagePart.image);+ const textPart = content.find((part) => part?.text && typeof part.text === "string");+ if (textPart?.text) {+ const markdownMatch = textPart.text.match(/!\[.*?\]\((.*?)\)/);+ if (markdownMatch?.[1]) return markdownMatch[1];+ if (/^https?:\/\//i.test(textPart.text.trim()) || textPart.text.trim().startsWith("data:image")) {+ return textPart.text.trim();+ }+ }+ }+ return null;+}+async function convertRemoteImageToDataUrl(url: string): Promise<string> {if (url.startsWith("data:image")) return url;const response = await fetch(url);@@ -210,7 +236,7 @@ async function requestOpenAIImages(req: ImageGatewayRequest): Promise<string> {}async function requestOpenAIImageEdit(req: ImageGatewayRequest): Promise<string> {- if (!req.referenceImageUrl || !req.maskImageUrl) {+ if (!req.referenceImageUrl) {return await requestOpenAIImages(req);}@@ -218,7 +244,9 @@ async function requestOpenAIImageEdit(req: ImageGatewayRequest): Promise<string>form.append("model", req.channel.model);form.append("prompt", req.prompt);form.append("image", await dataUrlToFile(req.referenceImageUrl, "slide.png"));- form.append("mask", await dataUrlToFile(req.maskImageUrl, "mask.png"));+ if (req.maskImageUrl) {+ form.append("mask", await dataUrlToFile(req.maskImageUrl, "mask.png"));+ }const response = await fetch(joinUrl(req.channel.baseUrl, "/images/edits"), {method: "POST",@@ -293,6 +321,93 @@ async function requestOpenAIChatImage(req: ImageGatewayRequest): Promise<string>return await convertRemoteImageToDataUrl(url);}+async function requestAliyunImage(req: ImageGatewayRequest): Promise<string> {+ const content: any[] = [];+ for (const url of [+ ...(req.referenceImageUrl ? [req.referenceImageUrl] : []),+ ...(req.additionalReferenceImageUrls || []),+ ]) {+ content.push({ image: url });+ }+ content.push({ text: req.prompt });++ const response = await fetch(joinUrl(req.channel.baseUrl, "/services/aigc/multimodal-generation/generation"), {+ method: "POST",+ headers: {+ Authorization: `Bearer ${req.channel.apiKey}`,+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ model: req.channel.model,+ input: {+ messages: [+ {+ role: "user",+ content,+ },+ ],+ },+ parameters: {+ n: 1,+ watermark: false,+ },+ }),+ });++ const text = await response.text();+ let parsed: any = null;+ try {+ parsed = text ? JSON.parse(text) : null;+ } catch {+ parsed = null;+ }+ if (!response.ok) {+ throw new Error(parsed?.message || parsed?.error?.message || parsed?.error || text || `Request failed with status ${response.status}`);+ }++ const url = extractImageUrlFromAliyunContent(parsed?.output?.choices?.[0]?.message?.content);+ if (!url) {+ throw new Error("Aliyun image request succeeded but returned no image URL.");+ }+ return await convertRemoteImageToDataUrl(url);+}++const openaiImageAdapter: ImageAdapter = {+ supports: (req) => String(req.channel.provider || "").toLowerCase() === "openai",+ generate: async (req) => {+ const capabilities = resolveImageCapabilities(req.channel);+ if (shouldUseEditFlow(req, capabilities)) {+ return await requestOpenAIImageEdit(req);+ }+ return await requestOpenAIImages(req);+ },+};++const xaiImageAdapter: ImageAdapter = {+ supports: (req) => String(req.channel.provider || "").toLowerCase() === "xai",+ generate: async (req) => {+ // xAI image APIs are OpenAI-style at the transport layer in current provider support.+ const capabilities = resolveImageCapabilities(req.channel);+ if (shouldUseEditFlow(req, capabilities)) {+ return await requestOpenAIImageEdit(req);+ }+ return await requestOpenAIImages(req);+ },+};++const aliyunImageAdapter: ImageAdapter = {+ supports: (req) => String(req.channel.provider || "").toLowerCase() === "aliyun",+ generate: async (req) => {+ return await requestAliyunImage(req);+ },+};++const imageAdapters: ImageAdapter[] = [openaiImageAdapter, xaiImageAdapter, aliyunImageAdapter];++function findImageAdapter(req: ImageGatewayRequest): ImageAdapter | null {+ return imageAdapters.find((adapter) => adapter.supports(req)) || null;+}+export async function generateTextThroughGateway(req: TextGatewayRequest): Promise<string> {const route = resolveTextRoute(req.channel);if (route.protocol === "custom") {@@ -342,6 +457,7 @@ export async function generateTextThroughGateway(req: TextGatewayRequest): Promiexport async function generateImageThroughGateway(req: ImageGatewayRequest): Promise<string> {const route = resolveImageRoute(req.channel);+ const capabilities = resolveImageCapabilities(req.channel);if (route.protocol === "custom") {const spec = parseCustomProviderMapping(req.channel.customMapping);if (!spec) throw new Error("Custom image mapping is required.");@@ -367,25 +483,27 @@ export async function generateImageThroughGateway(req: ImageGatewayRequest): Proreturn await convertRemoteImageToDataUrl(url);}- if (route.protocol === "openai-images") {- if (req.referenceImageUrl && req.maskImageUrl) {- return await requestOpenAIImageEdit(req);- }- return await requestOpenAIImages(req);+ const adapter = findImageAdapter(req);+ if (adapter) {+ return await adapter.generate(req);+ }++ if (shouldUseEditFlow(req, capabilities)) {+ return await requestOpenAIImageEdit(req);}- if (route.protocol === "openai-images-fallback-chat-image") {+ if (route.protocol === "openai-images" || route.protocol === "openai-images-fallback-chat-image") {try {- if (req.referenceImageUrl && req.maskImageUrl) {- return await requestOpenAIImageEdit(req);- }return await requestOpenAIImages(req);} catch (imagesError) {- try {- return await requestOpenAIChatImage(req);- } catch {- throw imagesError;+ if (route.protocol === "openai-images-fallback-chat-image") {+ try {+ return await requestOpenAIChatImage(req);+ } catch {+ throw imagesError;+ }}+ throw imagesError;}}diff --git a/src/lib/ai/provider-registry.ts b/src/lib/ai/provider-registry.tsindex ceb8a40..bcf8fb1 100644--- a/src/lib/ai/provider-registry.ts+++ b/src/lib/ai/provider-registry.ts@@ -72,6 +72,14 @@ export interface ImageRoute {supportsReferenceImages: boolean;}+export interface ImageProviderCapabilities {+ supportsGeneration: boolean;+ supportsEdits: boolean;+ supportsMask: boolean;+ supportsReferenceImages: boolean;+ supportsMultiReferenceImages: boolean;+}+const TEXT_VISION_RULES: Array<{ provider: AIProviderId; patterns: RegExp[] }> = [{provider: "openai",@@ -153,6 +161,112 @@ const IMAGE_REFERENCE_RULES: Array<{ provider: AIProviderId; patterns: RegExp[]},];+const IMAGE_CAPABILITY_RULES: Array<{+ provider: AIProviderId;+ patterns: RegExp[];+ capabilities: Partial<ImageProviderCapabilities>;+}> = [+ {+ provider: "openai",+ patterns: [/gpt-image/i, /dall-e/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: true,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+ {+ provider: "aliyun",+ patterns: [/wan/i, /qwen-image/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: true,+ },+ },+ {+ provider: "bytedance",+ patterns: [/seedream/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: true,+ },+ },+ {+ provider: "zhipu",+ patterns: [/glm-image/i, /cogview/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+ {+ provider: "tencent",+ patterns: [/hunyuan/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+ {+ provider: "google",+ patterns: [/imagen/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: true,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+ {+ provider: "xai",+ patterns: [/grok/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+ {+ provider: "bfl",+ patterns: [/flux/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: true,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: true,+ },+ },+ {+ provider: "adobe",+ patterns: [/firefly/i],+ capabilities: {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: true,+ supportsReferenceImages: true,+ supportsMultiReferenceImages: false,+ },+ },+];+export const TEXT_PROVIDER_OPTIONS: ProviderOption[] = [{ id: "openai", label: "OpenAI", defaultBaseUrl: "https://api.openai.com/v1" },{ id: "ollama", label: "Ollama", defaultBaseUrl: "http://localhost:11434/v1" },@@ -247,6 +361,45 @@ export function resolveImageRoute(channel: AIChannelConfig): ImageRoute {};}+export function resolveImageCapabilities(channel: AIChannelConfig): ImageProviderCapabilities {+ const provider = String(channel.provider || "").toLowerCase();+ const model = String(channel.model || "");++ const matched = IMAGE_CAPABILITY_RULES.find(+ (rule) => rule.provider === provider && rule.patterns.some((pattern) => pattern.test(model)),+ );++ if (matched) {+ return {+ supportsGeneration: true,+ supportsEdits: true,+ supportsMask: false,+ supportsReferenceImages: false,+ supportsMultiReferenceImages: false,+ ...matched.capabilities,+ };+ }++ if (provider === "custom") {+ const spec = String(channel.customMapping || "").trim() ? parseCustomProviderMapping(channel.customMapping) : null;+ return {+ supportsGeneration: true,+ supportsEdits: Boolean(spec?.supportsReferenceImages),+ supportsMask: false,+ supportsReferenceImages: Boolean(spec?.supportsReferenceImages),+ supportsMultiReferenceImages: Boolean(spec?.supportsReferenceImages),+ };+ }++ return {+ supportsGeneration: true,+ supportsEdits: false,+ supportsMask: false,+ supportsReferenceImages: false,+ supportsMultiReferenceImages: false,+ };+}+export function getTextChannelConfig(config: AIConfig): AIChannelConfig {return {provider: String(config.textProvider || "openai"),diff --git a/src/workspaces/common/CanvasStudioBase.tsx b/src/workspaces/common/CanvasStudioBase.tsxindex e618a81..09ec809 100644--- a/src/workspaces/common/CanvasStudioBase.tsx+++ b/src/workspaces/common/CanvasStudioBase.tsx@@ -310,6 +310,70 @@ function updateProductTextBlocks(blocks: PptTextBlock[], text: ProductTextState)});}+function buildGenerationContext(mode: CanvasStudioMode, form: CanvasFormState) {+ const size = resolveCanvasSize(mode, form);+ const style = optionText(form.style, "zh");+ const color = optionText(form.color, "zh");+ const composition = optionText(form.composition, "zh");+ const focus = optionText(form.focus, "zh");+ const whitespace = optionText(form.whitespace, "zh");+ const chartType = optionText(form.chartType, "zh");+ const orientation = optionText(form.orientation, "zh");+ const backgroundType = optionText(form.backgroundType, "zh");+ const lighting = optionText(form.lighting, "zh");+ const sellingPoints = form.sellingPointsText+ .split(/\r?\n/)+ .map((item) => item.trim())+ .filter(Boolean);+ const bulletPoints = form.bulletPointsText+ .split(/\r?\n/)+ .map((item) => item.trim())+ .filter(Boolean);++ if (mode === "poster") {+ return [+ `当前画布参数:`,+ `- 尺寸:${size.width}x${size.height}`,+ `- 分辨率:${form.dpi} DPI`,+ `- 风格:${style}`,+ `- 主色调:${color}`,+ `- 构图:${composition}`,+ `- 视觉重点:${focus}`,+ `- 留白:${whitespace}`,+ `- 主题:${form.theme || "未填写"}`,+ `- 卖点:${sellingPoints.join("、") || "无"}`,+ ].join("\n");+ }++ if (mode === "infographic") {+ return [+ `当前画布参数:`,+ `- 尺寸:${size.width}x${size.height}`,+ `- 风格:${style}`,+ `- 主色调:${color}`,+ `- 构图:${composition}`,+ `- 视觉重点:${focus}`,+ `- 留白:${whitespace}`,+ `- 主题:${form.theme || "未填写"}`,+ `- 图表类型:${chartType}`,+ `- 排版方向:${orientation}`,+ `- 要点:${bulletPoints.join("、") || "无"}`,+ `- 数据:${form.dataText || "无"}`,+ ].join("\n");+ }++ return [+ `当前画布参数:`,+ `- 尺寸:${size.width}x${size.height}`,+ `- 风格:${style}`,+ `- 主色调:${color}`,+ `- 背景:${backgroundType}`,+ `- 光影:${lighting}`,+ `- 主题:${form.productName || "未填写"}`,+ `- 卖点:${sellingPoints.join("、") || "无"}`,+ ].join("\n");+}+async function loadImage(url: string) {const image = new Image();image.crossOrigin = "anonymous";@@ -737,11 +801,14 @@ export function CanvasStudioBase({ mode }: { mode: CanvasStudioMode }) {};const buildInteractionPrompt = (userRequest: string) => {+ const context = buildGenerationContext(mode, form);if (mode === "poster") {return ["Edit the provided poster image according to the user's request.","Use the current generated image as the main reference.",- "Keep the overall subject and composition unless the user explicitly asks to change them.",+ "Keep the overall subject, composition, and canvas orientation unless the user explicitly asks to change them.",+ "Preserve the original aspect ratio and do not rotate the layout from landscape to portrait.",+ context,`User request: ${userRequest}`,].join(" ");}@@ -750,6 +817,8 @@ export function CanvasStudioBase({ mode }: { mode: CanvasStudioMode }) {"Edit the provided infographic image according to the user's request.","Use the current generated image as the main reference.","Preserve the infographic style and layout logic unless the user explicitly asks to change them.",+ "Preserve the original aspect ratio and do not rotate the layout from landscape to portrait unless requested.",+ context,`User request: ${userRequest}`,].join(" ");}@@ -757,6 +826,7 @@ export function CanvasStudioBase({ mode }: { mode: CanvasStudioMode }) {"Edit the provided product showcase image according to the user's request.","Use the current generated image as the main reference.","Keep product identity stable. The uploaded product image is a hard reference constraint.",+ context,`User request: ${userRequest}`,].join(" ");};