Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Notes: the phone's line tools and colours; table cells editable; unreadable tables said plainly
Yashwanth Kamireddi806ddd6a832e
diff --git a/.uiverify/notes-linetools.mjs b/.uiverify/notes-linetools.mjsnew file mode 100644index 0000000..e6af241--- /dev/null+++ b/.uiverify/notes-linetools.mjs@@ -0,0 +1,80 @@+// The phone's line tools in the Aa panel, as Notes has them: Move Line Up and Down take the+// line (and the cursor) past the next one; the colours set Notes' text colour on what is+// selected and None takes it off; Increase and Decrease Indent step the line in and out.+// Each saves to Apple as the phone writes it.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+for (const scheme of ["light", "dark"]) {+ const ctx = await b.newContext({ viewport: { width: 1200, height: 800 }, colorScheme: scheme });+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, notesFixture: true });+ const page = await ctx.newPage();+ page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+ await openScreen(page, "Notes");+ await page.locator(".note-row", { hasText: "Curtains" }).first().click();+ await page.waitForTimeout(500);+ const lines = () => page.locator(".note-rich .nf-p").allInnerTexts();+ const lastSave = async () => { await page.waitForTimeout(1200); return page.evaluate(() => window.__noteSaves?.at(-1)); };+ const runAt = (save, text) => {+ const at = save.body.indexOf(text);+ let n = 0;+ for (const r of save.runs ?? []) { if (at < n + r.length) return r; n += r.length; }+ return null;+ };+ const panel = page.locator(".format-panel");+ const tool = (name) => panel.getByRole("button", { name, exact: true });+ const open = async () => { if (!(await panel.isVisible())) await page.getByRole("button", { name: "Format", exact: true }).click(); await page.waitForTimeout(120); };+ const fan = page.locator(".note-rich .nf-p", { hasText: /^Fan$/ }).first();++ // Move Line Up, then Down.+ await fan.click();+ await page.keyboard.press("End");+ await open();+ const before = await lines();+ const at = before.indexOf("Fan");+ await tool("Move Line Up").click();+ await page.waitForTimeout(120);+ let now = await lines();+ ok(now[at - 1] === "Fan" && now[at] === before[at - 1], `${scheme}: Move Line Up takes the line above the one before it`);+ let save = await lastSave();+ ok(save && save.body.split("\n").indexOf("Fan") === at - 1, `${scheme}: and saves it there`);+ await tool("Move Line Down").click();+ await tool("Move Line Down").click();+ await page.waitForTimeout(120);+ now = await lines();+ ok(now[at + 1] === "Fan" && now[at] === before[at + 1], `${scheme}: Move Line Down takes it below the next, the cursor with it`);+ await tool("Move Line Up").click();+ await page.waitForTimeout(120);+ ok(JSON.stringify(await lines()) === JSON.stringify(before), `${scheme}: and back where it was`);++ // A colour on the selected word; the swatch shows it; None takes it off.+ // The cursor is on the line still: the whole of it selected from the keyboard.+ await page.keyboard.press("End");+ await page.keyboard.press("Shift+Home");+ await open();+ await panel.getByRole("radio", { name: "Pink" }).click();+ await page.waitForTimeout(120);+ ok(await fan.locator(".nf-em-2").count() === 1, `${scheme}: Pink colours the selected word`);+ ok((await panel.getByRole("radio", { name: "Pink" }).getAttribute("aria-checked")) === "true", `${scheme}: and the panel shows Pink chosen`);+ save = await lastSave();+ ok(save && runAt(save, "Fan")?.emphasis === 2, `${scheme}: saved as Notes' pink (2)`);+ await panel.getByRole("radio", { name: "No colour" }).click();+ await page.waitForTimeout(120);+ ok(await fan.locator(".nf-em-2").count() === 0, `${scheme}: None takes the colour off`);+ save = await lastSave();+ ok(save && !runAt(save, "Fan")?.emphasis, `${scheme}: and the save has none`);++ // Indent in and out.+ await tool("Increase Indent").click();+ save = await lastSave();+ ok(save && runAt(save, "Fan")?.indent === 1, `${scheme}: Increase Indent steps the line in`);+ await tool("Decrease Indent").click();+ save = await lastSave();+ ok(save && runAt(save, "Fan")?.indent === 0, `${scheme}: Decrease Indent steps it back`);+ await ctx.close();+}+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/notes-quote.mjs b/.uiverify/notes-quote.mjsindex 83b68f0..697ee03 100644--- a/.uiverify/notes-quote.mjs+++ b/.uiverify/notes-quote.mjs@@ -42,11 +42,12 @@ for (const scheme of ["light", "dark"]) {// The Aa panel shows it ticked, and takes it off.await page.getByRole("button", { name: /^(Aa|Format)/ }).first().click().catch(() => page.locator(".notes-aa").click());await page.waitForTimeout(150);- const item = page.getByRole("menuitemcheckbox", { name: "Block Quote" });- ok((await item.getAttribute("aria-checked")) === "true", `${scheme}: Aa shows Block Quote ticked on a quoted line`);+ const item = page.locator(".format-panel").getByRole("button", { name: "Block Quote" });+ ok((await item.getAttribute("aria-pressed")) === "true", `${scheme}: Aa shows Block Quote on for a quoted line`);await item.click();await page.waitForTimeout(150);ok((await bar("Yashps")) === 0, `${scheme}: and takes it off`);+ await page.keyboard.press("Escape");// Return on an empty quoted line ends the quote.// At the line's start: its middle is a link, and a click there opens it.await atStart("Read");diff --git a/.uiverify/notes-table.mjs b/.uiverify/notes-table.mjsindex a2d03f7..8acd98c 100644--- a/.uiverify/notes-table.mjs+++ b/.uiverify/notes-table.mjs@@ -1,5 +1,7 @@-// A table in a note, drawn as its grid, its text colour shown, and copied as its cells.-// Editing is off until an edit made here is seen on an iPhone.+// A table in a note, drawn as its grid, its text colour shown, and copied as its cells. Its+// cells are edited where they stand (a cell set here showed on an iPhone); adding and removing+// rows and columns stays off until one made here is seen there. A table this app cannot read+// says so where it stands — never a file to open.import { engine } from "./engine.mjs";import { SERVICES, installStub, openScreen } from "./stub.mjs";const b = await engine.launch();@@ -17,11 +19,19 @@ await page.waitForSelector(".nf-table");const grid = await page.locator(".nf-table tr").evaluateAll((rows) => rows.map((r) => [...r.cells].map((c) => c.textContent)));ok(JSON.stringify(grid) === JSON.stringify([["Item", "Qty"], ["Milk", "2"], ["", ""]]), `the table is drawn as its grid ${JSON.stringify(grid)}`);-// Read-only for now: Quince's table edits were stored at Apple but did not show on the-// iPhone, so no cell is offered for typing and no table menu opens.-ok((await page.locator(".nf-cell-edit").count()) === 0, "no table cell is offered for typing while table writes are off");+// A cell typed into is saved to Apple, that cell alone.+const empty = page.locator(".nf-table tr").nth(2).locator(".nf-cell-edit").first();+ok((await empty.count()) === 1, "a table's cells are offered for typing, an empty one too");+await empty.click();+await page.keyboard.type("Eggs");+await page.keyboard.press("Enter");+await page.waitForTimeout(500);+const wrote = await page.evaluate(() => window.__cellWrites ?? []);+ok(wrote.length === 1 && wrote[0].id === "T1" && wrote[0].row === 2 && wrote[0].column === 0 && wrote[0].text === "Eggs",+ `typed into a cell, that cell is saved ${JSON.stringify(wrote)}`);+await page.evaluate(() => { window.__table[2] = ["", ""]; });await page.locator(".nf-table tr").nth(1).locator("td").first().click({ button: "right" });-ok((await page.getByRole("menuitem", { name: /Add Row|Delete Row/ }).count()) === 0, "and right-click offers no row or column changes");+ok((await page.getByRole("menuitem", { name: /Add Row|Delete Row/ }).count()) === 0, "right-click offers no row or column changes yet");await page.keyboard.press("Escape");const coloured = await page.locator(".note-rich .nf-em-4").evaluateAll((e) => e.map((x) => [x.textContent, getComputedStyle(x).color]));ok(coloured.length === 1 && coloured[0][0] === "end" && !/rgb\(29, 29, 31\)|rgb\(0, 0, 0\)/.test(coloured[0][1]), `text coloured on a phone shows in its colour ${JSON.stringify(coloured)}`);@@ -80,5 +90,17 @@ await page.evaluate(() => {await page.waitForTimeout(500);const after = await page.locator(".nf-table tr").nth(2).evaluate((r) => [...r.cells].map((c) => c.textContent));ok(JSON.stringify(after) === JSON.stringify(["Bread", "1"]), `a table changed elsewhere redraws after the next sync ${JSON.stringify(after)}`);++// A table this app cannot read: said so where it stands, never a file chip to open.+const ctx2 = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx2.addInitScript(() => { window.__tableNote = true; window.__unreadTable = true; });+await ctx2.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, notesFixture: true });+const p2 = await ctx2.newPage();+await p2.goto("http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(p2, "Notes");+await p2.locator(".note-row", { hasText: "Groceries" }).first().click();+await p2.waitForTimeout(600);+ok((await p2.locator(".nf-table-unread").count()) === 1 && (await p2.locator(".nf-file").count()) === 0,+ `a table that can't be read says so, and is no file to open ${await p2.locator(".nf-attachment").first().innerText().catch(() => "")}`);await b.close();process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 397bdd7..5afc735 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -263,7 +263,8 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note// "Groceries", a table on its own line, then a last line: the table's run names it.const plain = (length) => ({ length, style: null, indent: 0, checked: null, bold: false, italic: false, underline: false, strike: false, link: null });// "end" coloured mint on a phone (field 14).- return [plain(10), { ...plain(1), attachment: "T1" }, plain(1), { ...plain(3), emphasis: 4 }];+ // `__unreadTable`: a table this app cannot read (U1).+ return [plain(10), { ...plain(1), attachment: window.__unreadTable ? "U1" : "T1" }, plain(1), { ...plain(3), emphasis: 4 }];}// Curtains, set as a phone sets one: a title, then a dashed list and a ticked item.if (args.guid !== "n1") return [];@@ -335,11 +336,12 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notereturn !notesFixture ? [] : noteList.map((n) => ({ ...n }));case "note_attachment_info":if (args.id === "D1") return { id: "D1", uti: "com.apple.paper", kind: "drawing", filename: null, title: null, width: 768, height: 621, size: null, hasPreview: true };+ if (args.id === "U1") return { id: "U1", uti: "com.apple.notes.table", kind: "table", filename: null, title: null, width: null, height: null, size: 1116, hasPreview: false };return args.id === "M1"? { id: "M1", uti: "public.jpeg", kind: "image", filename: "beach.jpeg", title: null, width: 1200, height: 800, size: 271872, hasPreview: true }: { id: "M2", uti: "org.openxmlformats.spreadsheetml.sheet", kind: "file", filename: "Budget.xlsx", title: null, width: null, height: null, size: 9100, hasPreview: false };case "note_attachment_open": (window.__opened ??= []).push(args.id); return null;- case "note_table": if (/^[MD]/.test(String(args.id))) return null; return (window.__table ??= [["Item", "Qty"], ["Milk", "2"], ["", ""]]).map((r) => r.slice());+ case "note_table": if (/^[MDU]/.test(String(args.id))) return null; return (window.__table ??= [["Item", "Qty"], ["Milk", "2"], ["", ""]]).map((r) => r.slice());case "photos_list": case "photos_counts": {const P = (id, takenAt, extra = {}) => ({ id, master: `m${id}`, takenAt, addedAt: takenAt, kind: "image",width: 4032, height: 3024, duration: null, filename: `IMG_${id}.JPG`, size: 2400000, uti: "public.jpeg",diff --git a/crates/quince-icloud/src/note_media.rs b/crates/quince-icloud/src/note_media.rsindex 4084711..5297f8a 100644--- a/crates/quince-icloud/src/note_media.rs+++ b/crates/quince-icloud/src/note_media.rs@@ -25,7 +25,7 @@ const ZONE: &str = "Notes";pub struct AttachmentInfo {pub id: String,pub uti: String,- /// `image`, `document` (PDF, scan), `audio`, `video`, or `file`.+ /// `image`, `drawing`, `table`, `document` (PDF, scan), `audio`, `video`, or `file`.pub kind: &'static str,pub filename: Option<String>,pub title: Option<String>,@@ -48,6 +48,10 @@ pub fn kind_of(uti: &str) -> &'static str {) {return "drawing";}+ // A table: drawn as its grid, never offered as a file to open.+ if u == crate::table::UTI {+ return "table";+ }if matches!(u.as_str(),"public.jpeg"@@ -272,6 +276,8 @@ mod tests {// FallbackImage (1536×1242 for a 768×621 drawing) and two previews.assert_eq!(kind_of("com.apple.paper"), "drawing");assert_eq!(kind_of("com.apple.drawing.2"), "drawing");+ // A table is never a file to open, even one the table reader cannot read.+ assert_eq!(kind_of("com.apple.notes.table"), "table");assert_eq!(kind_of("com.apple.m4a-audio"), "audio");assert_eq!(kind_of("public.mpeg-4-audio"), "audio");assert_eq!(kind_of("com.apple.quicktime-movie"), "video");diff --git a/probe/examples/table_cell_in_note.rs b/probe/examples/table_cell_in_note.rsnew file mode 100644index 0000000..2a69dbd--- /dev/null+++ b/probe/examples/table_cell_in_note.rs@@ -0,0 +1,82 @@+//! Live, with his say-so, on a table in a note he named: one edit through the app's own write+//! (the table's and the note's modification dates stamped too), read back from Apple — for him+//! to look for on his iPhone. Undone the same way.+//! `table_cell_in_note <note title> <attachment id> cell <row> <column> <text>`+//! `table_cell_in_note <note title> <attachment id> +row|-row|+column|-column <at>`+use anyhow::{anyhow, Result};+use quince_icloud::notes::{+ add_table_line_cloudkit, remove_table_line_cloudkit, set_table_cell_cloudkit,+};+#[tokio::main]+async fn main() -> Result<()> {+ let a: Vec<String> = std::env::args().collect();+ let [_, title, id, op, rest @ ..] = a.as_slice() else {+ return Err(anyhow!(+ "table_cell_in_note <note title> <attachment id> <op> …"+ ));+ };+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");+ let mut client = quince_auth::Client::new(&dir)?;+ if !client.resume().await? {+ return Err(anyhow!("no session"));+ }+ let root = client+ .session()+ .service_url("ckdatabasews")+ .ok_or_else(|| anyhow!("no ck"))?;+ let (http, p) = (client.http().clone(), client.service_params());+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &root, "com.apple.notes", p.clone());+ let walk = zc.all_records("Notes", None).await?;+ // Only a table that note places, once: never one anywhere else.+ let placed = walk+ .records+ .iter()+ .filter(|r| r["recordType"] == "Note")+ .filter(|n| {+ n["fields"]["TextDataEncrypted"]["value"]+ .as_str()+ .and_then(quince_icloud::ckdocument::text_from_base64)+ .is_some_and(|t| t.lines().next().map(str::trim) == Some(title.as_str()))+ })+ .map(|n| {+ n["fields"]["TextDataEncrypted"]["value"]+ .as_str()+ .map(quince_icloud::ckdocument::runs_from_base64)+ .unwrap_or_default()+ .iter()+ .filter(|r| r.attachment.as_deref() == Some(id.as_str()))+ .count()+ })+ .collect::<Vec<_>>();+ if placed != [1] {+ return Err(anyhow!(+ "that table is not placed once in one note titled {title:?} ({placed:?})"+ ));+ }+ let cells = match (op.as_str(), rest) {+ ("cell", [row, col, text]) => {+ set_table_cell_cloudkit(&http, &root, p, id, row.parse()?, col.parse()?, text).await?+ }+ ("+row", [at]) => add_table_line_cloudkit(&http, &root, p, id, false, at.parse()?).await?,+ ("+column", [at]) => {+ add_table_line_cloudkit(&http, &root, p, id, true, at.parse()?).await?+ }+ ("-row", [at]) => {+ remove_table_line_cloudkit(&http, &root, p, id, false, at.parse()?).await?+ }+ ("-column", [at]) => {+ remove_table_line_cloudkit(&http, &root, p, id, true, at.parse()?).await?+ }+ _ => return Err(anyhow!("unknown edit")),+ };+ let shape: Vec<Vec<usize>> = cells+ .iter()+ .map(|r| r.iter().map(String::len).collect())+ .collect();+ println!(+ "read back: {} rows x {} columns; cell lengths {shape:?}",+ cells.len(),+ cells.first().map_or(0, Vec::len)+ );+ Ok(())+}diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex f799e33..e569641 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -1981,11 +1981,15 @@ async fn note_runs(guid: String, data: State<'_, Data>) -> UiResult<serde_json::}/// A table's cells, row by row, as the last pass read them — `None` when none are known.-/// Whether Quince writes to Notes tables. Off: Apple stored what Quince wrote, but his iPhone-/// did not show it (2026-10-19), so no table is written until a write is seen on the phone.-const TABLE_WRITES: bool = false;+/// Whether Quince writes a table's cells. On: a cell set here — the table's and the note's+/// modification dates stamped with it — showed on his iPhone (2026-10-21). Before those stamps+/// (2026-10-19) Apple stored the write but the phone did not show it.+const TABLE_CELL_WRITES: bool = true;+/// Whether Quince adds and removes rows and columns: off until one made here is seen on the+/// phone.+const TABLE_LINE_WRITES: bool = false;const TABLE_WRITES_OFF: &str =- "Tables are read-only in Quince for now: edits made here did not show on iPhone yet.";+ "Adding and removing rows and columns isn’t on in Quince yet: it waits to be seen working on an iPhone.";/// Add an empty row to a Notes table at `at` (0 is the top), as Notes does, and keep the/// table as Apple now holds it.@@ -1997,7 +2001,7 @@ async fn note_table_add_row(auth: State<'_, Auth>,data: State<'_, Data>,) -> UiResult<Vec<Vec<String>>> {- if !TABLE_WRITES {+ if !TABLE_LINE_WRITES {return Err(TABLE_WRITES_OFF.into());}let (http, root, params) = cloudkit_context(&auth).await?;@@ -2031,7 +2035,7 @@ async fn note_table_remove(auth: State<'_, Auth>,data: State<'_, Data>,) -> UiResult<Vec<Vec<String>>> {- if !TABLE_WRITES {+ if !TABLE_LINE_WRITES {return Err(TABLE_WRITES_OFF.into());}let (http, root, params) = cloudkit_context(&auth).await?;@@ -2059,7 +2063,7 @@ async fn note_table_set_cell(auth: State<'_, Auth>,data: State<'_, Data>,) -> UiResult<Vec<Vec<String>>> {- if !TABLE_WRITES {+ if !TABLE_CELL_WRITES {return Err(TABLE_WRITES_OFF.into());}let (http, root, params) = cloudkit_context(&auth).await?;diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex 8d6a7e7..2e80ca9 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -592,7 +592,7 @@ export type AccountInfo = {export type NoteAttachment = {id: string;uti: string;- kind: "image" | "drawing" | "document" | "audio" | "video" | "file";+ kind: "image" | "drawing" | "table" | "document" | "audio" | "video" | "file";filename: string | null;title: string | null;width: number | null;diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsxindex 8a374f1..d5957fe 100644--- a/src/screens/NotesView.tsx+++ b/src/screens/NotesView.tsx@@ -1000,6 +1000,9 @@ export function NotesView() {onStyle={(style) => editorRef.current?.setStyle(style)}onMark={(mark) => editorRef.current?.toggleMark(mark)}onQuote={() => editorRef.current?.toggleQuote()}+ onColour={(c) => editorRef.current?.setColour(c)}+ onIndent={(by) => editorRef.current?.indent(by)}+ onMove={(by) => editorRef.current?.moveLines(by)}/>)}</>diff --git a/src/screens/notes/FormatPanel.tsx b/src/screens/notes/FormatPanel.tsxindex 3230002..828b665 100644--- a/src/screens/notes/FormatPanel.tsx+++ b/src/screens/notes/FormatPanel.tsx@@ -17,6 +17,34 @@ const STYLES: { style: number | null; label: string; className: string; mark?: s{ style: STYLE.numbered, label: "Numbered List", className: "fp-list", mark: "1." },];+/** The phone's line tools, drawn as Notes draws them: lines of text with a triangle for+ * indenting, an arrow to a bar for moving, a bar beside a block for quoting, dotted lines for+ * a list. 22 units square, stroked in the text colour. */+const LineGlyph = ({ d, fill }: { d: string; fill?: string }) => (+ <svg width="20" height="20" viewBox="0 0 22 22" aria-hidden="true" fill="none" stroke="currentColor"+ strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">+ <path d={d} />+ {fill && <path d={fill} fill="currentColor" stroke="none" />}+ </svg>+);+const GLYPHS = {+ outdent: <LineGlyph d="M3 5h11M3 9h8M3 13h8M3 17h11" fill="M19 8.2v5.6L15 11z" />,+ indent: <LineGlyph d="M8 5h11M11 9h8M11 13h8M8 17h11" fill="M3 8.2v5.6L7 11z" />,+ up: <LineGlyph d="M5 3.5h12M11 19V7.5M6.5 12L11 7.5l4.5 4.5" />,+ down: <LineGlyph d="M5 18.5h12M11 3v11.5M6.5 10l4.5 4.5 4.5-4.5" />,+ quote: <LineGlyph d="M4.5 3.5v15" fill="M9 6.5a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2z" />,+ list: <LineGlyph d="M9 6h10M9 11h10M9 16h10" fill="M3.4 6a1.4 1.4 0 1 0 2.8 0a1.4 1.4 0 1 0-2.8 0M3.4 11a1.4 1.4 0 1 0 2.8 0a1.4 1.4 0 1 0-2.8 0M3.4 16a1.4 1.4 0 1 0 2.8 0a1.4 1.4 0 1 0-2.8 0" />,+};++/** Notes' text colours, in the phone's order; the number is what Apple stores. */+const COLOURS = [+ { colour: 1, label: "Purple" },+ { colour: 2, label: "Pink" },+ { colour: 3, label: "Orange" },+ { colour: 4, label: "Mint" },+ { colour: 5, label: "Blue" },+] as const;+const MARKS = [{ mark: "bold", label: "Bold", glyph: <b>B</b> },{ mark: "italic", label: "Italic", glyph: <i>I</i> },@@ -26,8 +54,9 @@ const MARKS = [/*** Notes' Aa panel: bold, italic, underline and strikethrough across the top, the paragraph- * styles beneath with the current one ticked — as icloud.com and the Mac lay it out. It acts- * on the note without taking the cursor out of it, so a style is chosen and typing goes on.+ * styles beneath with the current one ticked — as icloud.com and the Mac lay it out — and the+ * phone's line tools (indent, outdent, move up, move down) and text colours. It acts on the+ * note without taking the cursor out of it, so a style is chosen and typing goes on.*/export function FormatPanel({at,@@ -36,6 +65,9 @@ export function FormatPanel({onStyle,onMark,onQuote,+ onColour,+ onIndent,+ onMove,}: {at: { x: number; y: number };status: EditorStatus | null;@@ -43,6 +75,9 @@ export function FormatPanel({onStyle: (style: number | null) => void;onMark: (mark: "bold" | "italic" | "underline" | "strike") => void;onQuote: () => void;+ onColour: (colour: number | null) => void;+ onIndent: (by: 1 | -1) => void;+ onMove: (by: 1 | -1) => void;}) {const box = useRef<HTMLDivElement | null>(null);const [pos, setPos] = useState({ left: at.x, top: at.y });@@ -101,6 +136,44 @@ export function FormatPanel({</button>))}</div>+ <div className="fp-marks fp-lines" role="group" aria-label="Line">+ {[+ { label: "Decrease Indent", glyph: GLYPHS.outdent, run: () => onIndent(-1) },+ { label: "Increase Indent", glyph: GLYPHS.indent, run: () => onIndent(1) },+ { label: "Move Line Up", glyph: GLYPHS.up, run: () => onMove(-1) },+ { label: "Move Line Down", glyph: GLYPHS.down, run: () => onMove(1) },+ { label: "Block Quote", glyph: GLYPHS.quote, run: onQuote, on: Boolean(status?.quote) },+ { label: "Bulleted List", glyph: GLYPHS.list, run: () => onStyle(status?.style === STYLE.bulleted ? null : STYLE.bulleted), on: status?.style === STYLE.bulleted },+ ].map(({ label, glyph, run, on }) => (+ <button key={label} type="button" className="fp-mark" aria-label={label} title={label} aria-pressed={on} onClick={run}>+ {glyph}+ </button>+ ))}+ </div>+ <div className="fp-colours" role="radiogroup" aria-label="Text colour">+ <button+ type="button"+ role="radio"+ aria-checked={!status?.colour}+ aria-label="No colour"+ title="None"+ className="fp-colour is-none"+ onClick={() => onColour(null)}+ />+ {COLOURS.map(({ colour, label }) => (+ <button+ key={colour}+ type="button"+ role="radio"+ aria-checked={status?.colour === colour}+ aria-label={label}+ title={label}+ className="fp-colour"+ style={{ "--swatch": `var(--note-c${colour})` } as React.CSSProperties}+ onClick={() => onColour(colour)}+ />+ ))}+ </div><div className="fp-styles" role="menu" aria-label="Paragraph style">{STYLES.map(({ style, label, className, mark }) => (<button@@ -120,24 +193,6 @@ export function FormatPanel({</button>))}</div>- {/* Not a style but a setting on top of one, as Notes keeps it: a quoted heading or- list stays a heading or a list. */}- <div className="fp-styles fp-extra" role="group" aria-label="Block quote">- <button- type="button"- role="menuitemcheckbox"- aria-checked={Boolean(status?.quote)}- className="fp-style fp-quote"- onClick={() => {- onQuote();- onClose();- }}- >- <span className="fp-check" aria-hidden="true">{status?.quote && <Check size={15} strokeWidth={2} />}</span>- <span className="fp-quote-bar" aria-hidden="true" />- <span>Block Quote</span>- </button>- </div></div></Portal>);diff --git a/src/screens/notes/NoteEditor.tsx b/src/screens/notes/NoteEditor.tsxindex 773fed5..84c1027 100644--- a/src/screens/notes/NoteEditor.tsx+++ b/src/screens/notes/NoteEditor.tsx@@ -34,8 +34,10 @@ export function refreshTables() {liveTables.forEach((read) => read());}-/** Whether tables can be edited here. Off until an edit made here is seen on an iPhone. */-const TABLE_WRITES = false;+/** Whether a table's cells can be edited here: on since a cell set here showed on an iPhone. */+const TABLE_CELL_WRITES = true;+/** Whether rows and columns can be added and removed: off until one made here is seen there. */+const TABLE_LINE_WRITES = false;/** A table's right-click menu: drawn by the editor that holds the table, opened by a cell. */type CellMenu = { at: { x: number; y: number; alignRight: boolean }; entries: MenuEntry[] };@@ -150,6 +152,15 @@ function drawMedia(dom: HTMLElement, info: NoteAttachment) {dark.addEventListener("click", show);dom.className = "nf-attachment is-image is-drawing";dom.replaceChildren(light, dark);+ } else if (info.kind === "table") {+ // A table this app cannot read yet: said plainly, where it stands, never offered as a file+ // to open. It is read again after every sync, and drawn as its grid once it can be.+ const box = document.createElement("span");+ box.className = "nf-table-unread";+ box.textContent = "Table — can’t be shown here yet. It’s unchanged on your other devices.";+ dom.className = "nf-attachment is-table-unread";+ dom.title = "";+ dom.replaceChildren(box);} else if ((info.kind === "document" || info.kind === "video") && info.hasPreview) {const figure = document.createElement("button");figure.type = "button";@@ -184,15 +195,14 @@ function attachmentView(node: PMNode) {row.forEach((cell, c) => {const td = tr.insertCell();const was = cell.trimEnd();- // Read-only for now: what Quince wrote to a table was stored at Apple but did not show- // on his iPhone, so no table is written until a write is seen there.- if (!id || !TABLE_WRITES) {+ if (!id || !TABLE_CELL_WRITES) {td.textContent = was;td.className = was ? "nf-cell" : "nf-cell-empty";return;}// Right-click, as in Notes: a row added above or below this one.td.addEventListener("contextmenu", (e) => {+ if (!TABLE_LINE_WRITES) return;e.preventDefault();const add = (at: number, column = false) => () => {dom.classList.add("is-saving");@@ -280,7 +290,7 @@ function attachmentView(node: PMNode) {// Read again after every sync, so a table typed in on a phone shows its new cells here// without leaving the note; drawn again only when they changed.liveTables.set(dom, () => {- if (!dom.classList.contains("is-table")) return;+ if (!dom.classList.contains("is-table") && !dom.classList.contains("is-table-unread")) return;api.noteTable(id).then((cells) => {if (cells && cells.length && JSON.stringify(cells) !== JSON.stringify(tableCells.get(id))) draw(cells);@@ -307,9 +317,17 @@ export type EditorStatus = {strike: boolean;checklist: boolean;quote: boolean;+ /** The text colour where the cursor is (1 purple … 5 blue), as Notes' colour menu ticks it. */+ colour: number | null;};export type EditorHandle = {+ /** Text colour on the selection (or on what is typed next), or none. */+ setColour: (colour: number | null) => void;+ /** Indent or outdent the lines the selection touches. */+ indent: (by: 1 | -1) => void;+ /** Move the lines the selection touches up or down past the next line. */+ moveLines: (by: 1 | -1) => void;/** Block Quote on the lines the selection touches, or off. */toggleQuote: () => void;/** Set every line the selection touches to one of Notes' styles. */@@ -392,6 +410,49 @@ function shift(by: 1 | -1, onlyLists: boolean): Command {};}+/** Notes' text colour on the selection, or on what is typed next when nothing is selected. */+function colour(c: number | null): Command {+ return (state, dispatch) => {+ const type = schema.marks.emphasis;+ const { from, to, empty } = state.selection;+ const tr = state.tr;+ if (empty) {+ tr.removeStoredMark(type);+ if (c) tr.addStoredMark(type.create({ color: c }));+ } else {+ tr.removeMark(from, to, type);+ if (c) tr.addMark(from, to, type.create({ color: c }));+ }+ dispatch?.(tr);+ return true;+ };+}++/**+ * The lines the selection touches moved up or down past one line, as Notes' Move Line Up+ * and Down do — the cursor and selection go with them, and a table moves with its line.+ */+function moveLines(by: 1 | -1): Command {+ return (state, dispatch) => {+ const lines = linesIn(state);+ if (!lines.length) return false;+ const start = lines[0].pos;+ const end = lines[lines.length - 1].pos + lines[lines.length - 1].node.nodeSize;+ const first = state.doc.resolve(start).index(0);+ const last = first + lines.length - 1;+ if (by < 0 ? first === 0 : last >= state.doc.childCount - 1) return false;+ const past = state.doc.child(by < 0 ? first - 1 : last + 1).nodeSize;+ const block = state.doc.slice(start, end).content;+ const tr = state.tr.delete(start, end);+ const shiftBy = by < 0 ? -past : past;+ tr.insert(start + (by < 0 ? -past : past), block);+ const { from, to } = state.selection;+ tr.setSelection(TextSelection.create(tr.doc, from + shiftBy, to + shiftBy));+ dispatch?.(tr.scrollIntoView());+ return true;+ };+}+const parentOf = (state: EditorState) => state.selection.$from.parent;const inList = (state: EditorState) => LIST_STYLES.includes(parentOf(state).attrs.style);@@ -456,6 +517,8 @@ function statusOf(state: EditorState): EditorStatus {strike: has("strike"),checklist: p.attrs.style === STYLE.checklist,quote: Boolean(p.attrs.quote),+ colour: ((empty ? marks : state.doc.resolve(from).marksAcross(state.doc.resolve(to)) ?? marks).find((m) => m.type === schema.marks.emphasis)+ ?.attrs.color as number | undefined) ?? null,};}@@ -512,6 +575,9 @@ export const NoteEditor = forwardRef<EditorHandle, Props>(function NoteEditor("Mod-i": toggleMark(schema.marks.italic),"Mod-u": toggleMark(schema.marks.underline),"Mod-'": toggleQuote,+ // Move Line Up and Down, as Notes on a Mac has them (Control-Command-Up and Down).+ "Mod-Alt-ArrowUp": moveLines(-1),+ "Mod-Alt-ArrowDown": moveLines(1),"Mod-]": shift(1, false),"Mod-[": shift(-1, false),Tab: tab,@@ -647,6 +713,24 @@ export const NoteEditor = forwardRef<EditorHandle, Props>(function NoteEditor(toggleChecklistCmd(v.state, v.dispatch);v.focus();},+ setColour: (c) => {+ const v = view.current;+ if (!v) return;+ colour(c)(v.state, v.dispatch);+ v.focus();+ },+ indent: (by) => {+ const v = view.current;+ if (!v) return;+ shift(by, false)(v.state, v.dispatch);+ v.focus();+ },+ moveLines: (by) => {+ const v = view.current;+ if (!v) return;+ moveLines(by)(v.state, v.dispatch);+ v.focus();+ },toggleQuote: () => {const v = view.current;if (!v) return;diff --git a/src/styles/notes.css b/src/styles/notes.cssindex ad57110..ae98d32 100644--- a/src/styles/notes.css+++ b/src/styles/notes.css@@ -395,6 +395,25 @@ textarea.note-title::placeholder { color: var(--text-3); }}.fp-mark:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }.fp-mark[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-strong); }+.fp-lines { grid-template-columns: repeat(6, 1fr); gap: 2px; color: var(--text-2); }+.fp-lines .fp-mark { display: grid; place-items: center; color: inherit; }+/* Notes' colours as the phone shows them: a dot each, the chosen one ringed. */+.fp-colours {+ display: flex; justify-content: space-between; padding: 2px 8px 10px; margin-bottom: 6px;+ border-bottom: 1px solid var(--separator);+}+.fp-colour {+ width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; cursor: default;+ background: var(--swatch); box-shadow: none;+}+.fp-colour[aria-checked="true"] { box-shadow: 0 0 0 2px var(--glass-thick, var(--bg)), 0 0 0 3.5px var(--swatch, var(--text-3)); }+.fp-colour:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }+/* None: a hairline ring with a stroke through it. */+.fp-colour.is-none {+ background: linear-gradient(135deg, transparent calc(50% - 0.75px), var(--text-3) calc(50% - 0.75px) calc(50% + 0.75px), transparent calc(50% + 0.75px));+ box-shadow: inset 0 0 0 1.5px var(--text-3);+}+.fp-colour.is-none[aria-checked="true"] { box-shadow: inset 0 0 0 1.5px var(--text-3), 0 0 0 2px var(--glass-thick, var(--bg)), 0 0 0 3.5px var(--text-3); }.fp-styles { display: flex; flex-direction: column; }.fp-style {display: grid; grid-template-columns: 22px auto 1fr; align-items: center; column-gap: 2px;@@ -472,9 +491,6 @@ textarea.note-title::placeholder { color: var(--text-3); }.note-formatted .nf-body[data-quote="true"] {padding-inline-start: calc(11px + var(--indent, 0) * 1.5em);}-.fp-extra { border-top: 1px solid var(--separator); margin-top: 6px; padding-top: 6px; }-.fp-quote-bar { width: 3px; height: 16px; border-radius: 2px; margin: 0 6px 0 4px;- background: color-mix(in srgb, var(--text) 30%, transparent); }/* A drawing made in a note: its ink alone, made for a light page and for a dark one(quince_media::drawing_ink); the look in force shows its own. */@@ -497,3 +513,9 @@ textarea.note-title::placeholder { color: var(--text-3); }outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;}.nf-file-meta.is-trouble { color: var(--danger); white-space: normal; }++/* A table not readable here yet: a quiet dashed frame where the grid will be. */+.nf-table-unread {+ display: block; padding: 10px 12px; border: 1px dashed var(--separator); border-radius: 8px;+ color: var(--text-3); font-size: var(--t-13, 13px);+}