The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.
TypeScript agent-skillsagentic-aiai-agentsai-videobyokclaude-codecodexdeepseek-harnessdsh-plugingenerative-ailocal-firstmcpmotionmotion-graphicsmultimodalopenmotionreverse-engineeringvideo-editingvideo-generationworkbuddy
fix(studio): show a small spinner while applying fonts
罗高4e7990a46028
diff --git a/studio/src/components/editor/propertyPanelFont.test.tsx b/studio/src/components/editor/propertyPanelFont.test.tsxindex bd3e371c..d65e5a22 100644--- a/studio/src/components/editor/propertyPanelFont.test.tsx+++ b/studio/src/components/editor/propertyPanelFont.test.tsx@@ -215,6 +215,43 @@ describe("FontFamilyField session font lists", () => {});describe("FontFamilyField installed fonts", () => {+ it.each([[true, true], [false, true], [true, false], [false, false]])("shows a small loading indicator through font import and save (flat: %s, saved: %s)", async (flat, saved) => {+ vi.resetModules();+ const { FontFamilyField } = await import("./propertyPanelFont");+ let imported!: (fonts: Array<{ family: string; path: string; url: string }>) => void;+ let finish!: () => void, fail!: (reason: Error) => void;+ const onImportFonts = vi.fn(() => new Promise<Array<{ family: string; path: string; url: string }>>(resolve => { imported = resolve; }));+ const onCommit = vi.fn(() => new Promise<void>((resolve, reject) => { finish = resolve; fail = reject; }));+ const log = vi.spyOn(console, "error").mockImplementation(() => {});+ const host = document.createElement("div");+ document.body.append(host);+ const root = createRoot(host);+ try {+ await act(async () => root.render(<FontFamilyField flat={flat} value="Arial" importedFonts={[]} onImportFonts={onImportFonts} onCommit={onCommit} />));+ await act(async () => new Promise(resolve => setTimeout(resolve, 10)));+ const trigger = host.querySelector<HTMLButtonElement>("button")!;+ await act(async () => trigger.click());+ const option = Array.from(document.querySelectorAll<HTMLButtonElement>("[data-font-option-index]")).find(button => button.textContent?.includes("Menlo"))!;+ await act(async () => option.click());+ expect(trigger.disabled).toBe(true);+ expect(trigger.getAttribute("aria-busy")).toBe("true");+ expect(trigger.querySelector('[role="status"]')?.getAttribute("aria-label")).toBe("Loading");+ expect(trigger.querySelector('[data-remix-icon="loader-4-line"]')).not.toBeNull();+ expect(onCommit).not.toHaveBeenCalled();+ await act(async () => imported([{ family: "Menlo", path: "font.ttf", url: "/font.ttf" }]));+ expect(onCommit).toHaveBeenCalledOnce();+ expect(trigger.querySelector('[role="status"]')).not.toBeNull();+ await act(async () => saved ? finish() : fail(new Error("Save failed")));+ expect(trigger.disabled).toBe(false);+ expect(trigger.getAttribute("aria-busy")).toBe("false");+ expect(trigger.querySelector('[role="status"]')).toBeNull();+ if (!saved) {+ expect(trigger.textContent).toContain("Arial");+ expect(document.body.textContent).toContain('Couldn\'t import "Menlo"');+ }+ } finally { act(() => root.unmount()); log.mockRestore(); }+ });+it.each([true, false])("uses the server font file without browser font access (available: %s)", async (available) => {vi.resetModules();const { FontFamilyField } = await import("./propertyPanelFont");diff --git a/studio/src/components/editor/propertyPanelFont.tsx b/studio/src/components/editor/propertyPanelFont.tsxindex a1f4dc53..ecdbff84 100644--- a/studio/src/components/editor/propertyPanelFont.tsx+++ b/studio/src/components/editor/propertyPanelFont.tsx@@ -17,6 +17,7 @@ import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";import { runWhenInputIdle } from "./overlayFrameLoop";import { studioApiFetch } from "../../utils/studioApiFetch";import { useStudioShellContextOptional } from "../../contexts/StudioContext";+import { RemixIcon } from "../../icons/RemixIcons";/* ------------------------------------------------------------------ *//* Font helper functions */@@ -426,6 +427,12 @@ export function FontFamilyField({</Popover>);+ const fontLoadingIndicator = importingFonts ? (+ <span role="status" aria-label={t("Loading")} className="flex shrink-0 text-panel-text-5">+ <RemixIcon name="loader-4-line" size={10} className="animate-spin motion-reduce:animate-none" />+ </span>+ ) : null;+if (flat) {return (<div className="relative flex min-h-[30px] items-center justify-between">@@ -434,6 +441,7 @@ export function FontFamilyField({type="button"data-flat-font-trigger="true"disabled={disabled || importingFonts}+ aria-busy={importingFonts}className="flex items-center gap-1.5 disabled:cursor-not-allowed"><span@@ -442,7 +450,7 @@ export function FontFamilyField({>{currentFamily}</span>- <svg+ {fontLoadingIndicator ?? <svgwidth="10"height="10"viewBox="0 0 10 10"@@ -450,7 +458,7 @@ export function FontFamilyField({className="shrink-0 text-panel-text-5"><path d="M2 3l3 4 3-4z" />- </svg>+ </svg>}</button>)}</div>);@@ -462,6 +470,7 @@ export function FontFamilyField({{renderPicker(<buttontype="button"disabled={disabled || importingFonts}+ aria-busy={importingFonts}className={`${FIELD} flex h-10 items-center justify-between gap-3 text-left hover:border-neutral-700 disabled:cursor-not-allowed`}><span@@ -470,8 +479,8 @@ export function FontFamilyField({>{currentFamily}</span>- <span className="shrink-0 text-[10px] uppercase tracking-[0.14em] text-neutral-600">- {t("Font")}</span>+ {fontLoadingIndicator ?? <span className="shrink-0 text-[10px] uppercase tracking-[0.14em] text-neutral-600">+ {t("Font")}</span>}</button>)}</div>);diff --git a/studio/tests/e2e/local-fonts.mjs b/studio/tests/e2e/local-fonts.mjsindex c011d7d5..a67a11e4 100644--- a/studio/tests/e2e/local-fonts.mjs+++ b/studio/tests/e2e/local-fonts.mjs@@ -157,6 +157,22 @@ try {results.pickerHeight = pickerHeight;page.off('request', holdCatalog);await page.setRequestInterception(false);+ await page.setRequestInterception(true);+ const holdImport = request => {+ if (!new URL(request.url()).pathname.endsWith('/fonts/import')) void request.continue();+ };+ page.on('request', holdImport);+ const firstImport = page.waitForRequest(request => new URL(request.url()).pathname.endsWith('/fonts/import'));+ await choose(results.fonts[0].family);+ const importing = await firstImport;+ await page.waitForSelector('[data-flat-font-trigger][aria-busy="true"] [role="status"]');+ await capture('font-applying.png');+ await importing.continue();+ page.off('request', holdImport);+ await page.setRequestInterception(false);+ await applied(results.fonts[0].family);+ assert.equal(await page.$('[data-flat-font-trigger] [role="status"]'), null);+ results.fontApplyingIndicator = true;for (const font of results.fonts) {await choose(font.family); await applied(font.family);await page.waitForFunction(family => document.querySelector('hyperframes-player').shadowRoot.querySelector('iframe').contentDocument.querySelector('#title').style.fontFamily.includes(family), {}, font.family);