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
refactor(ppt): move the generation progress view into its own component
codingFeng1015830006f401d
diff --git a/client/workspaces/ppt/canvas/PptCanvas.tsx b/client/workspaces/ppt/canvas/PptCanvas.tsxindex 70cf67e..7f0cd13 100644--- a/client/workspaces/ppt/canvas/PptCanvas.tsx+++ b/client/workspaces/ppt/canvas/PptCanvas.tsx@@ -7,6 +7,7 @@ import { parseJsonLoose } from "./lib/parse-json";import { extractPdfPagesAsImages, isPdfFile } from "./lib/deck-source";import { getSlideshowDimensions } from "./lib/slideshow-size";import { clampTextBlockRect, withTextBlocks } from "./lib/render-layers";+import { GenerationProgress } from "./views/GenerationProgress";import {getOriginalSlideVersion as originalVersionOf,getTextlessBackgroundVersion as textlessBackgroundOf,@@ -46,7 +47,6 @@ import {Upload,Presentation,Sparkles,- Check,FileText,Download,Lightbulb,@@ -4172,41 +4172,7 @@ export function PptCanvas({// Render Progressif (isGenerating(creationStep)) {- const progressRatio = progress.total > 0 ? progress.current / progress.total : 0;- const clampedRatio = Math.max(0, Math.min(1, progressRatio));- const dash = clampedRatio * 251.2;- const percent = Math.round(clampedRatio * 100);- return (- <div className="w-full h-full bg-zinc-50 dark:bg-zinc-900 flex flex-col overflow-hidden">- <div className="flex-1 flex items-center justify-center p-6">- <div className="w-full max-w-md bg-white dark:bg-zinc-800 p-8 rounded-xl shadow-lg text-center space-y-6">- <div className="relative w-20 h-20 mx-auto">- <svg className="w-full h-full" viewBox="0 0 100 100">- <circle className="text-zinc-200 dark:text-zinc-700 stroke-current" strokeWidth="8" cx="50" cy="50" r="40" fill="transparent"></circle>- <circle className="text-blue-600 stroke-current transition-all duration-300 ease-in-out origin-center -rotate-90" strokeWidth="8" strokeLinecap="round" cx="50" cy="50" r="40" fill="transparent" strokeDasharray={`${dash} 251.2`}></circle>- </svg>- <div className="absolute inset-0 flex items-center justify-center text-sm font-bold">- {percent}%- </div>- </div>-- <div className="space-y-2">- <h3 className="font-semibold text-lg">{tr("AI 正在创作中", "AI is creating")}</h3>- <p className="text-sm text-muted-foreground">- {progress.message || tr("正在渲染图片…", "Rendering images...")}- </p>- </div>-- <div className="flex justify-center gap-2 text-xs text-muted-foreground">- <div className={`flex items-center gap-1 ${creationStep === 'generating_images' ? 'text-blue-600' : 'text-green-600'}`}>- {creationStep === 'generating_images' ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3" />}- <span>{tr("渲染图片", "Render images")}</span>- </div>- </div>- </div>- </div>- </div>- );+ return <GenerationProgress step={creationStep} progress={progress} tr={tr} />;}// Regular View (creationStep === 'done' or manually provided data)diff --git a/client/workspaces/ppt/canvas/views/GenerationProgress.tsx b/client/workspaces/ppt/canvas/views/GenerationProgress.tsxnew file mode 100644index 0000000..758b852--- /dev/null+++ b/client/workspaces/ppt/canvas/views/GenerationProgress.tsx@@ -0,0 +1,72 @@+import { Check, Loader2 } from "lucide-react";+import type { CreationProgress } from "@/workspaces/ppt/canvas/lib/creation-machine";+import type { CreationStep } from "@/workspaces/ppt/canvas/types";++/** Circumference of the r=40 progress ring, for the stroke-dash trick. */+const RING_LENGTH = 251.2;++interface GenerationProgressProps {+ step: CreationStep;+ progress: CreationProgress;+ tr: (zh: string, en: string) => string;+}++/**+ * The full-screen view shown while a deck is being written and rendered.+ *+ * It is the only thing on screen for the whole run, deliberately: there is no+ * way to cancel or navigate away mid-generation, so there is nothing else to+ * offer.+ */+export function GenerationProgress({ step, progress, tr }: GenerationProgressProps) {+ // A run with no known total shows an empty ring rather than jumping to 100%.+ const ratio = progress.total > 0 ? Math.max(0, Math.min(1, progress.current / progress.total)) : 0;+ const percent = Math.round(ratio * 100);+ const isRendering = step === "generating_images";++ return (+ <div className="w-full h-full bg-zinc-50 dark:bg-zinc-900 flex flex-col overflow-hidden">+ <div className="flex-1 flex items-center justify-center p-6">+ <div className="w-full max-w-md bg-white dark:bg-zinc-800 p-8 rounded-xl shadow-lg text-center space-y-6">+ <div className="relative w-20 h-20 mx-auto">+ <svg className="w-full h-full" viewBox="0 0 100 100">+ <circle+ className="text-zinc-200 dark:text-zinc-700 stroke-current"+ strokeWidth="8"+ cx="50"+ cy="50"+ r="40"+ fill="transparent"+ />+ <circle+ className="text-blue-600 stroke-current transition-all duration-300 ease-in-out origin-center -rotate-90"+ strokeWidth="8"+ strokeLinecap="round"+ cx="50"+ cy="50"+ r="40"+ fill="transparent"+ strokeDasharray={`${ratio * RING_LENGTH} ${RING_LENGTH}`}+ />+ </svg>+ <div className="absolute inset-0 flex items-center justify-center text-sm font-bold">{percent}%</div>+ </div>++ <div className="space-y-2">+ <h3 className="font-semibold text-lg">{tr("AI 正在创作中", "AI is creating")}</h3>+ <p className="text-sm text-muted-foreground">+ {progress.message || tr("正在渲染图片…", "Rendering images...")}+ </p>+ </div>++ <div className="flex justify-center gap-2 text-xs text-muted-foreground">+ <div className={`flex items-center gap-1 ${isRendering ? "text-blue-600" : ""}`}>+ {isRendering ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3" />}+ <span>{tr("渲染图片", "Render images")}</span>+ </div>+ </div>+ </div>+ </div>+ </div>+ );+}