fix: stabilize local folder AI document workflow
- scope local-folder PageTree revision and document sidebar rendering to fileTreeScope - preserve projected table/image attrs for local Markdown aggregate fallback - avoid FileTree restore forced layouts on cold design open - add API ChatOnly provider runtime and local OCR task handling regressions
This commit is contained in:
@@ -6439,6 +6439,34 @@ fn legacy_block_projection_attrs(block: &Value, block_type: &str) -> Value {
|
||||
}
|
||||
}
|
||||
}
|
||||
if block_type == "image" {
|
||||
for key in ["src", "alt", "title"] {
|
||||
if let Some(value) = props
|
||||
.and_then(|map| map.get(key))
|
||||
.and_then(Value::as_str)
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
{
|
||||
attrs.insert(key.into(), json!(value));
|
||||
}
|
||||
}
|
||||
if let Some(tiptap_image) = props
|
||||
.and_then(|map| map.get("tiptapImage"))
|
||||
.filter(|value| value.get("type").and_then(Value::as_str) == Some("image"))
|
||||
.cloned()
|
||||
{
|
||||
attrs.insert("tiptapImage".into(), tiptap_image);
|
||||
}
|
||||
}
|
||||
if block_type == "table" {
|
||||
if let Some(tiptap_table) = props
|
||||
.and_then(|map| map.get("tiptapTable"))
|
||||
.filter(|value| value.get("type").and_then(Value::as_str) == Some("table"))
|
||||
.cloned()
|
||||
{
|
||||
attrs.insert("tiptapTable".into(), tiptap_table);
|
||||
}
|
||||
}
|
||||
Value::Object(attrs)
|
||||
}
|
||||
|
||||
@@ -13486,6 +13514,68 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_markdown_image_legacy_projection_exposes_image_attrs() {
|
||||
let legacy = json!([{
|
||||
"id": "local-block-2",
|
||||
"type": "image",
|
||||
"props": {
|
||||
"src": "./Page.assets/photo.png",
|
||||
"alt": "photo",
|
||||
"title": "photo"
|
||||
},
|
||||
"content": [],
|
||||
"children": []
|
||||
}]);
|
||||
|
||||
let projection =
|
||||
project_legacy_content_to_block_document("local-md:docs~2FPage.md", &legacy, &json!(0))
|
||||
.expect("image block should project");
|
||||
let block = &projection["blocks"][0];
|
||||
assert_eq!(block["type"], json!("image"));
|
||||
assert_eq!(block["attrs"]["src"], json!("./Page.assets/photo.png"));
|
||||
assert_eq!(block["attrs"]["alt"], json!("photo"));
|
||||
assert_eq!(block["attrs"]["title"], json!("photo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_markdown_table_legacy_projection_exposes_tiptap_table_attrs() {
|
||||
let legacy = json!([{
|
||||
"id": "local-block-3",
|
||||
"type": "table",
|
||||
"props": {
|
||||
"tiptapTable": {
|
||||
"type": "table",
|
||||
"content": [{
|
||||
"type": "tableRow",
|
||||
"content": [{
|
||||
"type": "tableCell",
|
||||
"attrs": { "colspan": 1, "rowspan": 1, "colwidth": null },
|
||||
"content": [{
|
||||
"type": "paragraph",
|
||||
"content": [{ "type": "text", "text": "Provider 类别" }]
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
},
|
||||
"content": [],
|
||||
"children": []
|
||||
}]);
|
||||
|
||||
let projection =
|
||||
project_legacy_content_to_block_document("local-md:docs~2FPage.md", &legacy, &json!(0))
|
||||
.expect("table block should project");
|
||||
let block = &projection["blocks"][0];
|
||||
assert_eq!(block["type"], json!("table"));
|
||||
assert_eq!(block["attrs"]["tiptapTable"]["type"], json!("table"));
|
||||
assert_eq!(
|
||||
block["attrs"]["tiptapTable"]["content"][0]["content"][0]["content"][0]["content"][0]
|
||||
["text"],
|
||||
json!("Provider 类别")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_content_from_editor_document_preserves_inline_link_styles() {
|
||||
let mut attrs = BTreeMap::new();
|
||||
|
||||
Reference in New Issue
Block a user