chore: support insert space between delta (#1069)

This commit is contained in:
Nathan.fooo 2024-12-14 10:38:39 +08:00 committed by GitHub
parent a117130d8a
commit a549364fc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 17 deletions

14
Cargo.lock generated
View File

@ -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",

View File

@ -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 = []

View File

@ -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(

View File

@ -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);
}