summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Warner <cwarner@kernelcode.com>2026-10-10 19:09:04 -0400
committerChristopher Warner <cwarner@kernelcode.com>2026-10-10 19:09:04 -0400
commit0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f (patch)
tree03060c8d4b1ce90c6a3961b16d058701b364e8f0
parentfb9d23c213e2cdfdeddb94ed66459cc13b5d339e (diff)
downloadiphone-notes-0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f.tar.gz
iphone-notes-0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f.tar.bz2
iphone-notes-0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f.tar.xz
iphone-notes-0b3d1a7cab856fb77cf8a89e40108e1a49d60e5f.zip
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 <cursoragent@cursor.com>
-rw-r--r--README.md6
-rw-r--r--src/browser.rs74
2 files changed, 74 insertions, 6 deletions
diff --git a/README.md b/README.md
index b998abd..27e736a 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,12 @@ Bodies may be plain text or light Markdown. The CLI rewrites them to match
`ICLOUD_NOTES_DRY_RUN=1` prints a formatted preview without touching iCloud.
+**Updates and Title size:** Prefer `update` after installing a build that copies
+TopoText from `createNoteWithTitleText` (first line Title, rest Body). Older
+updates used `createInitialTopoTextString`, which can mark every line as Title
+(huge text). You do **not** need a permanent new note — re-`update` with the
+fixed CLI, or create once and delete the broken copy if you prefer.
+
## Layout
```text
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<String> {
}
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<Cr
note = Note.createNoteWithTitleText(payload, folder);
}} else {{
note = Note.createEmptyNote(folder);
- writeNoteText(Note, dataManager, note, payload);
+ writeNoteText(Note, dataManager, note, payload, folder);
if (note.Title !== undefined) note.Title = payload.split("\n")[0] || "Note";
}}
if (typeof dataManager.userDidCreateNote === "function") {{
@@ -357,7 +384,18 @@ async fn update_via_notes_app(page: &Page, match_title: &str, title: &str, body:
throw new Error("No note titled " + JSON.stringify(matchTitle));
}}
const Note = note.constructor;
- writeNoteText(Note, dataManager, note, text);
+ const mv = app.mainViewModel;
+ const folderList =
+ dataManager.allFolders || dataManager.__CW__allFolders || dataManager.folders;
+ const folder =
+ note.Folder ||
+ note.folder ||
+ mv?.selectedFolder ||
+ dataManager.defaultFolder ||
+ dataManager.inboxFolder ||
+ noteAt(folderList, 0) ||
+ null;
+ writeNoteText(Note, dataManager, note, text, folder);
if (note.Title !== undefined) {{
note.Title = text.split("\n")[0] || matchTitle;
}}
@@ -462,3 +500,27 @@ pub async fn cmd_update(
Ok(())
}
+
+#[cfg(test)]
+mod tests {
+ use super::style_helpers_js;
+
+ #[test]
+ fn update_write_prefers_styled_create_scratch() {
+ let js = style_helpers_js();
+ assert!(
+ js.contains("createNoteWithTitleText"),
+ "updates must build TopoText via createNoteWithTitleText"
+ );
+ assert!(
+ js.contains("removeUnsavedItem"),
+ "scratch note from create path must be discarded"
+ );
+ let scratch = js.find("createNoteWithTitleText").expect("scratch");
+ let fallback = js.find("createInitialTopoTextString").expect("fallback");
+ assert!(
+ scratch < fallback,
+ "styled scratch path must run before Title-everywhere fallback"
+ );
+ }
+}