feat(*): 画布创作体验 - 完善 Agent 引导、生成防重、搜索快捷键、素材多选与分辨率兼容
This commit is contained in:
1 parent
913cf4b304
commit
ab89c05362
52 files changed
+2344
-500
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { expect, test } from "bun:test";
|
||||
|
||||
import { hasCanvasTextSelection } from "../src/pages/canvas/use-canvas-keyboard";
|
||||
|
||||
test("Canvas copy shortcut yields to a real browser text selection", () => {
|
||||
expect(hasCanvasTextSelection(null)).toBe(false);
|
||||
expect(hasCanvasTextSelection({ isCollapsed: true, rangeCount: 1, toString: () => "Agent 文本" })).toBe(false);
|
||||
expect(hasCanvasTextSelection({ isCollapsed: false, rangeCount: 0, toString: () => "Agent 文本" })).toBe(false);
|
||||
expect(hasCanvasTextSelection({ isCollapsed: false, rangeCount: 1, toString: () => "" })).toBe(false);
|
||||
expect(hasCanvasTextSelection({ isCollapsed: false, rangeCount: 1, toString: () => "Agent 文本" })).toBe(true);
|
||||
});
|
||||
|
||||
test("Canvas keyboard keeps node copy as the fallback when no text is selected", async () => {
|
||||
const source = await Bun.file(new URL("../src/pages/canvas/use-canvas-keyboard.ts", import.meta.url)).text();
|
||||
expect(source).toContain("if (hasCanvasTextSelection(window.getSelection())) return;");
|
||||
expect(source).toContain("event.preventDefault();\n copySelectedNodes();");
|
||||
});
|
||||
Reference in new issue
Block a user