Fix tiptap selection sync and toolbar event loop
This commit is contained in:
@@ -273,7 +273,9 @@ pub fn search_pages(
|
||||
IndexedEntityKind::PageTitle | IndexedEntityKind::PageSummary
|
||||
)
|
||||
})
|
||||
.filter(|document| workspace_id.map_or(true, |workspace| document.workspace_id == workspace))
|
||||
.filter(|document| {
|
||||
workspace_id.map_or(true, |workspace| document.workspace_id == workspace)
|
||||
})
|
||||
.filter(|document| {
|
||||
document
|
||||
.title
|
||||
@@ -376,7 +378,8 @@ pub fn evaluate_search_documents(
|
||||
request.custom_range_to.as_deref(),
|
||||
),
|
||||
_ => within_range(
|
||||
document.updated_at
|
||||
document
|
||||
.updated_at
|
||||
.as_deref()
|
||||
.or(document.created_at.as_deref()),
|
||||
boundary_iso.as_deref(),
|
||||
@@ -386,7 +389,10 @@ pub fn evaluate_search_documents(
|
||||
})
|
||||
.collect();
|
||||
|
||||
let eligible_doc_ids: HashSet<&str> = eligible_docs.iter().map(|document| document.id.as_str()).collect();
|
||||
let eligible_doc_ids: HashSet<&str> = eligible_docs
|
||||
.iter()
|
||||
.map(|document| document.id.as_str())
|
||||
.collect();
|
||||
let doc_map: HashMap<&str, &SearchDocumentRecord> = eligible_docs
|
||||
.iter()
|
||||
.map(|document| (document.id.as_str(), *document))
|
||||
@@ -511,7 +517,10 @@ pub fn evaluate_search_documents(
|
||||
}
|
||||
|
||||
let file_name = asset.file_name.as_deref().unwrap_or("").trim();
|
||||
if !request.title_only && !file_name.is_empty() && file_name.to_lowercase().contains(&normalized_lower) {
|
||||
if !request.title_only
|
||||
&& !file_name.is_empty()
|
||||
&& file_name.to_lowercase().contains(&normalized_lower)
|
||||
{
|
||||
upsert_match(
|
||||
&mut matches,
|
||||
&asset.document_id,
|
||||
@@ -552,7 +561,14 @@ pub fn evaluate_search_documents(
|
||||
score: 1.7,
|
||||
match_field: SearchMatchField::Content,
|
||||
snippet: build_snippet(
|
||||
&format!("附件:{}\n{ocr_text}", if file_name.is_empty() { asset.id.as_str() } else { file_name }),
|
||||
&format!(
|
||||
"附件:{}\n{ocr_text}",
|
||||
if file_name.is_empty() {
|
||||
asset.id.as_str()
|
||||
} else {
|
||||
file_name
|
||||
}
|
||||
),
|
||||
normalized_query,
|
||||
),
|
||||
has_ocr: true,
|
||||
@@ -798,7 +814,12 @@ fn extract_text_from_mindmap_data(value: &Value, max_chars: usize) -> String {
|
||||
}
|
||||
|
||||
fn normalize_text(value: &str) -> String {
|
||||
value.split_whitespace().collect::<Vec<_>>().join(" ").trim().to_string()
|
||||
value
|
||||
.split_whitespace()
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn escape_html(value: &str) -> String {
|
||||
@@ -1090,7 +1111,10 @@ mod tests {
|
||||
|
||||
assert_eq!(result.results.len(), 1);
|
||||
assert_eq!(result.results[0].id, "page_1");
|
||||
assert!(result.results[0].snippet.contains("<mark>Rust</mark>") || result.results[0].snippet.contains("<mark>rust</mark>"));
|
||||
assert!(
|
||||
result.results[0].snippet.contains("<mark>Rust</mark>")
|
||||
|| result.results[0].snippet.contains("<mark>rust</mark>")
|
||||
);
|
||||
assert_eq!(result.results[0].node_id.as_deref(), Some("page_1"));
|
||||
assert_eq!(result.results[0].subtree_root_id.as_deref(), Some("page_1"));
|
||||
assert_eq!(result.results[0].evidence.len(), 1);
|
||||
|
||||
Reference in New Issue
Block a user