From 0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f Mon Sep 17 00:00:00 2001 From: Christopher Warner Date: Sat, 10 Oct 2026 19:09:04 -0400 Subject: fix(update): stop applying Title style to every paragraph Updates copied TopoText via createInitialTopoTextString, which inherits "New notes start with Title" for all lines. Build styled text the same way create does, then load it onto the existing note. Co-authored-by: Cursor --- src/browser.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/browser.rs b/src/browser.rs index aee77ec..994ed19 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -252,11 +252,38 @@ fn paragraphs_json(title: &str, body: &str) -> Result { } fn style_helpers_js() -> &'static str { + // createInitialTopoTextString applies the "New notes start with" paragraph + // style (usually Title) to *every* line — that is why updates look huge. + // createNoteWithTitleText correctly styles first line = Title, rest = Body. + // For updates: build a scratch note that way, copy its TopoText, discard scratch. r#" - function writeNoteText(Note, dataManager, note, text) { - if (typeof Note.createInitialTopoTextString === "function" - && dataManager.topoTextManager - && typeof dataManager.topoTextManager.load === "function") { + function writeNoteText(Note, dataManager, note, text, folder) { + const canLoad = + dataManager.topoTextManager + && typeof dataManager.topoTextManager.load === "function"; + if (typeof Note.createNoteWithTitleText === "function" && folder && canLoad) { + const scratch = Note.createNoteWithTitleText(text, folder); + try { + const topo = scratch.TopoTextString; + if (topo) { + dataManager.topoTextManager.load(note.id, topo); + if (typeof note.userDidChangeTopoText === "function") { + note.userDidChangeTopoText(); + } + return; + } + } finally { + try { + if (typeof dataManager.removeUnsavedItem === "function") { + dataManager.removeUnsavedItem(scratch); + } else if (typeof dataManager.didDeleteNote === "function") { + dataManager.didDeleteNote(scratch); + } + } catch (_) {} + } + } + // Last resort — may mark every paragraph Title; avoid when possible + if (typeof Note.createInitialTopoTextString === "function" && canLoad) { const replacement = Note.createInitialTopoTextString(text); dataManager.topoTextManager.load(note.id, replacement); if (typeof note.userDidChangeTopoText === "function") note.userDidChangeTopoText(); @@ -315,7 +342,7 @@ async fn create_via_notes_app(page: &Page, title: &str, body: &str) -> Result