chore: 初始化 BlockFlow Workbench 仓库

建立前端与 Tauri 桌面端的首个版本提交,包含核心编辑器、项目文件读写、测试与构建配置。

补充 Git 忽略规则和换行规范,排除依赖、构建产物、本地运行日志与临时验证文件,方便在其他电脑继续开发。
This commit is contained in:
2026-05-29 17:23:43 +08:00
commit 589ff15213
88 changed files with 31656 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
import { describe, expect, it } from "vitest"
import { astToTiptap, tiptapToAst } from "../src/editor/adapter"
import type { BlockNode } from "../src/core/types"
describe("BlockFlow TipTap adapter", () => {
it("round-trips paragraphs, text, and variables", () => {
const blocks: BlockNode[] = [
{
id: "p1",
type: "paragraph",
inlines: [
{ type: "text", content: "你好," },
{ type: "variable", path: "user.name", required: true }
]
}
]
expect(tiptapToAst(astToTiptap(blocks))).toEqual(blocks)
})
it("round-trips structured blocks and atom blocks", () => {
const blocks: BlockNode[] = [
{
id: "container1",
type: "container",
name: "用户通知",
children: [
{
id: "if1",
type: "condition",
expression: "user.isVip",
children: [
{
id: "loop1",
type: "loop",
source: "items",
itemName: "item",
indexName: "index",
children: [
{
id: "p1",
type: "paragraph",
inlines: [{ type: "variable", path: "item.title" }]
}
]
}
]
},
{
id: "frag1",
type: "fragmentRef",
fragmentId: "fragment_common_footer"
},
{
id: "comment1",
type: "comment",
content: "备注"
}
]
}
]
expect(tiptapToAst(astToTiptap(blocks))).toEqual(blocks)
})
it("does not leak TipTap document wrapper into BlockFlow AST", () => {
const ast = tiptapToAst({
type: "doc",
content: [
{
type: "paragraph",
attrs: { id: "p1" },
content: [{ type: "text", text: "plain" }]
}
]
})
expect(ast).toEqual([
{
id: "p1",
type: "paragraph",
inlines: [{ type: "text", content: "plain" }]
}
])
expect(JSON.stringify(ast)).not.toContain("\"doc\"")
})
})