feat: restore Wolai workspace navigation and assets
This commit is contained in:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user