feat: restore Wolai workspace navigation and assets

This commit is contained in:
Agent Board
2026-07-15 23:12:15 +08:00
parent 31a160fcc5
commit 6f9c7d3b58
48 changed files with 6734 additions and 517 deletions
+64 -1
View File
@@ -6288,6 +6288,47 @@ fn legacy_block_projection_attrs(block: &Value, block_type: &str) -> Value {
attrs.insert("tiptapImage".into(), tiptap_image);
}
}
if block_type == "media" {
for (raw_key, canonical_key) in [
("name", "name"),
("fileName", "name"),
("file_name", "name"),
("sourcePath", "sourcePath"),
("source_path", "sourcePath"),
("url", "sourcePath"),
("src", "sourcePath"),
] {
if let Some(value) = props
.and_then(|map| map.get(raw_key))
.and_then(Value::as_str)
.map(str::trim)
.filter(|value| !value.is_empty())
{
attrs.insert(canonical_key.into(), json!(value));
}
}
}
if matches!(block_type, "page_reference" | "pagereference") {
for (raw_key, canonical_key) in [
("title", "title"),
("name", "title"),
("pageId", "pageId"),
("page_id", "pageId"),
("sourcePath", "sourcePath"),
("source_path", "sourcePath"),
("href", "href"),
("url", "href"),
] {
if let Some(value) = props
.and_then(|map| map.get(raw_key))
.and_then(Value::as_str)
.map(str::trim)
.filter(|value| !value.is_empty())
{
attrs.insert(canonical_key.into(), json!(value));
}
}
}
if block_type == "table" {
if let Some(tiptap_table) = props
.and_then(|map| map.get("tiptapTable"))
@@ -13359,9 +13400,31 @@ mod tests {
}
#[test]
fn local_markdown_table_legacy_projection_exposes_tiptap_table_attrs() {
fn local_markdown_media_legacy_projection_exposes_attachment_attrs() {
let legacy = json!([{
"id": "local-block-3",
"type": "media",
"props": {
"name": "Spec.pdf",
"sourcePath": ".assets/file/Spec.pdf"
},
"content": [],
"children": []
}]);
let projection =
project_legacy_content_to_block_document("local-md:docs~2FPage.md", &legacy, &json!(0))
.expect("media block should project");
let block = &projection["blocks"][0];
assert_eq!(block["type"], json!("media"));
assert_eq!(block["attrs"]["name"], json!("Spec.pdf"));
assert_eq!(block["attrs"]["sourcePath"], json!(".assets/file/Spec.pdf"));
}
#[test]
fn local_markdown_table_legacy_projection_exposes_tiptap_table_attrs() {
let legacy = json!([{
"id": "local-block-4",
"type": "table",
"props": {
"tiptapTable": {