feat(canvas): 绘图工具 - 集成 Excalidraw 并支持后台切换默认引擎
This commit is contained in:
1 parent
7fa5d7215a
commit
6058602bf2
28 files changed
+1617
-177
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { drawingEngineForNode } from "../src/lib/canvas/canvas-drawing-engine";
|
||||
import { summarizeCanvasDrawing } from "../src/lib/canvas/canvas-drawing-storage";
|
||||
|
||||
describe("canvas drawing engines", () => {
|
||||
it("treats drawings without an engine as legacy tldraw documents", () => {
|
||||
expect(drawingEngineForNode({ metadata: {} } as never)).toBe("tldraw");
|
||||
expect(drawingEngineForNode({ metadata: { drawingEngine: "excalidraw" } } as never)).toBe("excalidraw");
|
||||
});
|
||||
|
||||
it("summarizes Excalidraw elements without deleted records", () => {
|
||||
expect(summarizeCanvasDrawing("excalidraw", {
|
||||
elements: [{ id: "visible", isDeleted: false }, { id: "deleted", isDeleted: true }],
|
||||
})).toEqual({ shapeCount: 1, pageCount: 1 });
|
||||
});
|
||||
|
||||
it("keeps the legacy tldraw snapshot summary", () => {
|
||||
expect(summarizeCanvasDrawing("tldraw", {
|
||||
store: { "page:1": { typeName: "page" }, "shape:1": { typeName: "shape" } },
|
||||
})).toEqual({ shapeCount: 1, pageCount: 1 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user