From a549364fc9cf402ee0d1079ced4c8095a434f82c Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:38:39 +0800 Subject: [PATCH] chore: support insert space between delta (#1069) --- Cargo.lock | 14 +++++++------- Cargo.toml | 14 +++++++------- .../src/indexer/document_indexer.rs | 2 +- .../appflowy-collaborate/tests/indexer_test.rs | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82812b03..2d6de2a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2135,7 +2135,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "arc-swap", @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "async-trait", @@ -2199,7 +2199,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "arc-swap", @@ -2220,7 +2220,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "bytes", @@ -2240,7 +2240,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "arc-swap", @@ -2262,7 +2262,7 @@ dependencies = [ [[package]] name = "collab-importer" version = "0.1.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "async-recursion", @@ -2365,7 +2365,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=508d6a51dd13ba115cf211fd11245174cea97ea8#508d6a51dd13ba115cf211fd11245174cea97ea8" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=33cca67554c29b1a3821df6faf5423cff2cd5db3#33cca67554c29b1a3821df6faf5423cff2cd5db3" dependencies = [ "anyhow", "collab", diff --git a/Cargo.toml b/Cargo.toml index 7cac6ec0..7de44b76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -321,13 +321,13 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } -collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "508d6a51dd13ba115cf211fd11245174cea97ea8" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } +collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "33cca67554c29b1a3821df6faf5423cff2cd5db3" } [features] history = [] diff --git a/services/appflowy-collaborate/src/indexer/document_indexer.rs b/services/appflowy-collaborate/src/indexer/document_indexer.rs index a1570ebd..02d1e507 100644 --- a/services/appflowy-collaborate/src/indexer/document_indexer.rs +++ b/services/appflowy-collaborate/src/indexer/document_indexer.rs @@ -51,7 +51,7 @@ impl Indexer for DocumentIndexer { ) })?; - let result = document.to_plain_text(collab.transact(), false); + let result = document.to_plain_text(collab.transact(), false, true); match result { Ok(content) => { create_embedding( diff --git a/services/appflowy-collaborate/tests/indexer_test.rs b/services/appflowy-collaborate/tests/indexer_test.rs index 4c1e5b69..a87457b8 100644 --- a/services/appflowy-collaborate/tests/indexer_test.rs +++ b/services/appflowy-collaborate/tests/indexer_test.rs @@ -10,7 +10,7 @@ fn document_plain_text() { let doc = getting_started_document_data().unwrap(); let collab = Collab::new_with_origin(CollabOrigin::Server, "1", vec![], false); let document = Document::create_with_data(collab, doc).unwrap(); - let text = document.to_plain_text(false).unwrap(); + let text = document.to_plain_text(false, true).unwrap(); let expected = "Welcome to AppFlowy $ Download for macOS, Windows, and Linux link $ $ quick start Ask AI powered by advanced AI models: chat, search, write, and much more ✨ ❤\u{fe0f}Love AppFlowy and open source? Follow our latest product updates: Twitter : @appflowy Reddit : r/appflowy Github "; assert_eq!(&text, expected); } @@ -20,7 +20,7 @@ fn document_plain_text_with_nested_blocks() { let doc = get_initial_document_data().unwrap(); let collab = Collab::new_with_origin(CollabOrigin::Server, "1", vec![], false); let document = Document::create_with_data(collab, doc).unwrap(); - let text = document.to_plain_text(false).unwrap(); + let text = document.to_plain_text(false, true).unwrap(); let expected = "Welcome to AppFlowy! Here are the basics Here is H3 Click anywhere and just start typing. Click Enter to create a new line. Highlight any text, and use the editing menu to style your writing however you like. As soon as you type / a menu will pop up. Select different types of content blocks you can add. Type / followed by /bullet or /num to create a list. Click + New Page button at the bottom of your sidebar to add a new page. Click + next to any page title in the sidebar to quickly add a new subpage, Document , Grid , or Kanban Board . Keyboard shortcuts, markdown, and code block Keyboard shortcuts guide Markdown reference Type /code to insert a code block // This is the main function.\nfn main() {\n // Print text to the console.\n println!(\"Hello World!\");\n} This is a paragraph This is a paragraph Have a question❓ Click ? at the bottom right for help and support. This is a paragraph This is a paragraph Click ? at the bottom right for help and support. Like AppFlowy? Follow us: GitHub Twitter : @appflowy Newsletter "; assert_eq!(&text, expected); }