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: Export as Markdown
Yashwanth Kamireddi08f46965a92a
diff --git a/.uiverify/notes-export.mjs b/.uiverify/notes-export.mjsnew file mode 100644index 0000000..b707c74--- /dev/null+++ b/.uiverify/notes-export.mjs@@ -0,0 +1,44 @@+// A note saved as Markdown from its toolbar: the save dialog offers the note's title as the+// file's name, and what is written is the note as it is on screen — typing not yet sent+// included — with its formatting. Cancelling the dialog writes nothing.+import { engine } from "./engine.mjs";+import { SERVICES, installStub } 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: 1280, height: 820 }, 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 page.locator(".nav-item", { hasText: "Notes" }).click();+ await page.waitForTimeout(400);+ await page.locator(".note-row", { hasText: "Curtains" }).click();+ await page.waitForTimeout(400);+ const button = page.getByRole("button", { name: "Export as Markdown" });+ ok(await button.isVisible(), `${scheme}: Export as Markdown is in the note's toolbar`);++ // Cancelled: nothing written.+ await button.click();+ await page.waitForTimeout(300);+ const asked = await page.evaluate(() => window.__saveAsked);+ ok(asked?.options?.defaultPath === "Curtains.md", `${scheme}: the dialog offers the title as its name (${asked?.options?.defaultPath})`);+ ok((await page.evaluate(() => (window.__exported ?? []).length)) === 0, `${scheme}: cancelled, nothing is written`);++ // Typed into, not yet sent: the export has it.+ await page.locator(".note-rich-host .ProseMirror").click();+ await page.keyboard.press("Control+End");+ await page.keyboard.type(" plus a lamp");+ await page.evaluate(() => { window.__savePath = "/tmp/Curtains.md"; });+ await button.click();+ await page.waitForTimeout(300);+ const sent = await page.evaluate(() => (window.__exported ?? [])[0]);+ ok(sent?.path === "/tmp/Curtains.md", `${scheme}: written where it was asked`);+ ok(/^Curtains\n/.test(sent?.body ?? "") && /plus a lamp/.test(sent?.body ?? ""), `${scheme}: with the text on screen, typing included`);+ ok(Array.isArray(sent?.runs) && sent.runs.length > 0 && sent.runs.reduce((n, r) => n + r.length, 0) === [...(sent.body ?? "")].reduce((n, c) => n + c.length, 0),+ `${scheme}: and its formatting, covering the whole text (${sent?.runs?.length} runs)`);+ await ctx.close();+}+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 84c4e1b..397bdd7 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -555,6 +555,8 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notecase "photo_video_turn": (window.__turnAsks ??= []).push(args); return window.__turn ?? [1, 0, 0, 1];case "contacts_import": (window.__imports ??= []).push(args); return window.__importAnswer ?? [2, 0, 0];case "plugin:dialog|open": return window.__pick ?? null;+ case "plugin:dialog|save": window.__saveAsked = args; return window.__savePath ?? null;+ case "note_export_markdown": (window.__exported ??= []).push(args); return null;case "contact_lists": return !contactsFixture ? [] : (window.__lists ??= [{ guid: "L1", name: "Family", members: ["c2"], etag: "e1" },]).map((l) => ({ ...l, members: [...l.members] }));diff --git a/crates/quince-icloud/src/lib.rs b/crates/quince-icloud/src/lib.rsindex dc820aa..940bfa9 100644--- a/crates/quince-icloud/src/lib.rs+++ b/crates/quince-icloud/src/lib.rs@@ -19,6 +19,7 @@ pub mod ckdocument;pub mod cloudkit;pub mod contacts;pub mod drive;+pub mod markdown;pub mod mergeable;pub mod note_media;pub mod notes;diff --git a/crates/quince-icloud/src/markdown.rs b/crates/quince-icloud/src/markdown.rsnew file mode 100644index 0000000..a8ed809--- /dev/null+++ b/crates/quince-icloud/src/markdown.rs@@ -0,0 +1,387 @@+//! A note as Markdown, for export: its text set as Apple's attribute runs say — title and+//! headings, bulleted, dashed, numbered and checklist lines (indented as they are), monospaced+//! blocks, block quotes, bold, italic, strikethrough and links. Underline and colour have no+//! Markdown and are left as plain text; an attachment's character is left out.++use crate::ckdocument::Run;++/// Where an attachment stands in a note's text.+const ATTACHMENT: char = '\u{FFFC}';++/// One paragraph style, as `Run::style` has it.+const TITLE: u64 = 0;+const HEADING: u64 = 1;+const SUBHEADING: u64 = 2;+const MONOSPACED: u64 = 4;+const BULLETED: u64 = 100;+const DASHED: u64 = 101;+const NUMBERED: u64 = 102;+const CHECKLIST: u64 = 103;++/// `body` set as `runs` say (their lengths in UTF-16 units, as Apple counts); its first line+/// the title unless it is set otherwise (a list, say).+#[must_use]+pub fn note_to_markdown(body: &str, runs: &[Run]) -> String {+ let lines = styled_lines(body, runs);+ let mut out = String::new();+ // What the last line was, to know where a blank line goes and how a list counts.+ let mut last: Option<Kind> = None;+ let mut numbers: Vec<u64> = Vec::new();+ for (i, line) in lines.iter().enumerate() {+ // The first line is the note's title, as Notes lists it and Quince's editor shows it,+ // whether or not Apple stored the Title style on it.+ let style = line.style.or((i == 0).then_some(TITLE));+ let kind = Kind::of(style, line.quote);+ if kind != Kind::Number || last != Some(Kind::Number) {+ numbers.clear();+ }+ // A blank line between blocks; none inside a list, a code block or a quote.+ if let Some(was) = last {+ let together =+ was == kind && matches!(kind, Kind::List | Kind::Number | Kind::Code | Kind::Quote);+ let to_list = matches!(+ (was, kind),+ (Kind::List | Kind::Number, Kind::List | Kind::Number)+ );+ if !together && !to_list {+ out.push('\n');+ }+ }+ if kind == Kind::Code && last != Some(Kind::Code) {+ out.push_str("```\n");+ }+ let indent = " ".repeat(usize::try_from(line.indent).unwrap_or(0));+ let text = if kind == Kind::Code {+ line.plain()+ } else {+ line.inline()+ };+ match style {+ _ if kind == Kind::Code => out.push_str(&text),+ Some(TITLE) => push_heading(&mut out, "# ", &text),+ Some(HEADING) => push_heading(&mut out, "## ", &text),+ Some(SUBHEADING) => push_heading(&mut out, "### ", &text),+ Some(BULLETED | DASHED) => out.push_str(&format!("{indent}- {text}")),+ Some(CHECKLIST) => {+ let tick = if line.checked { "x" } else { " " };+ out.push_str(&format!("{indent}- [{tick}] {text}"));+ }+ Some(NUMBERED) => {+ let depth = usize::try_from(line.indent).unwrap_or(0);+ numbers.truncate(depth + 1);+ while numbers.len() <= depth {+ numbers.push(0);+ }+ let n = match line.start {+ Some(start) if numbers[depth] == 0 => start,+ _ => numbers[depth] + 1,+ };+ numbers[depth] = n;+ out.push_str(&format!("{indent}{n}. {text}"));+ }+ _ if line.quote => out.push_str(&format!("> {text}")),+ _ => out.push_str(&text),+ }+ out.push('\n');+ if kind == Kind::Code+ && lines+ .get(i + 1)+ .is_none_or(|next| Kind::of(next.style, next.quote) != Kind::Code)+ {+ out.push_str("```\n");+ }+ last = Some(kind);+ }+ out+}++fn push_heading(out: &mut String, mark: &str, text: &str) {+ if !text.trim().is_empty() {+ out.push_str(mark);+ }+ out.push_str(text);+}++/// What a line is, as far as the blank lines between them go.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum Kind {+ Text,+ List,+ Number,+ Code,+ Quote,+}++impl Kind {+ fn of(style: Option<u64>, quote: bool) -> Self {+ match style {+ Some(MONOSPACED) => Kind::Code,+ Some(BULLETED | DASHED | CHECKLIST) => Kind::List,+ Some(NUMBERED) => Kind::Number,+ _ if quote => Kind::Quote,+ _ => Kind::Text,+ }+ }+}++/// A line of the note: its paragraph's style, and its text in pieces as they are set.+#[derive(Debug, Default)]+struct Line {+ style: Option<u64>,+ indent: u64,+ checked: bool,+ start: Option<u64>,+ quote: bool,+ pieces: Vec<(String, Inline)>,+}++#[derive(Debug, Clone, Default, PartialEq)]+struct Inline {+ bold: bool,+ italic: bool,+ strike: bool,+ link: Option<String>,+}++impl Line {+ fn plain(&self) -> String {+ self.pieces.iter().map(|(t, _)| t.as_str()).collect()+ }++ /// The text with its inline marks, each piece marked on its own words (Markdown's marks+ /// do not hold across the spaces around a piece).+ fn inline(&self) -> String {+ let mut out = String::new();+ for (text, how) in &self.pieces {+ let core = text.trim();+ if core.is_empty() {+ out.push_str(&escape(text));+ continue;+ }+ let lead = &text[..text.len() - text.trim_start().len()];+ let tail = &text[text.trim_end().len()..];+ let mut s = escape(core);+ if how.strike {+ s = format!("~~{s}~~");+ }+ if how.italic {+ s = format!("*{s}*");+ }+ if how.bold {+ s = format!("**{s}**");+ }+ if let Some(url) = &how.link {+ s = format!("[{s}]({})", url.replace(' ', "%20").replace(')', "%29"));+ }+ out.push_str(lead);+ out.push_str(&s);+ out.push_str(tail);+ }+ out+ }+}++/// Characters that would otherwise be read as Markdown.+fn escape(text: &str) -> String {+ let mut out = String::with_capacity(text.len());+ for c in text.chars() {+ if matches!(c, '\\' | '*' | '_' | '`' | '[' | ']' | '~') {+ out.push('\\');+ }+ out.push(c);+ }+ out+}++/// The note's lines, each with its paragraph style (from the run its first character falls+/// in, as Notes styles a paragraph) and its inline pieces.+fn styled_lines(body: &str, runs: &[Run]) -> Vec<Line> {+ // Each run's end, in UTF-16 units.+ let mut ends = Vec::with_capacity(runs.len());+ let mut at = 0u64;+ for r in runs {+ at += r.length;+ ends.push(at);+ }+ let run_at = |pos: u64| -> Option<&Run> {+ let i = ends.partition_point(|&end| end <= pos);+ runs.get(i)+ };+ let mut lines = Vec::new();+ let mut line = Line::default();+ let mut fresh = true;+ let mut pos = 0u64;+ for c in body.chars() {+ let run = run_at(pos);+ pos += c.len_utf16() as u64;+ if fresh {+ if let Some(r) = run {+ line.style = r.style;+ line.indent = r.indent;+ line.checked = r.checked == Some(true);+ line.start = r.start;+ line.quote = r.quote;+ }+ fresh = false;+ }+ if c == '\n' {+ lines.push(std::mem::take(&mut line));+ fresh = true;+ continue;+ }+ if c == ATTACHMENT {+ continue;+ }+ let how = run.map_or_else(Inline::default, |r| Inline {+ bold: r.bold,+ italic: r.italic,+ strike: r.strike,+ link: r.link.clone(),+ });+ match line.pieces.last_mut() {+ Some((text, was)) if *was == how => text.push(c),+ _ => line.pieces.push((c.to_string(), how)),+ }+ }+ if !fresh || !line.pieces.is_empty() {+ lines.push(line);+ }+ lines+}++#[cfg(test)]+mod tests {+ use super::*;++ /// A run `n` long (in UTF-16 units) of paragraph style `style`.+ fn run(n: usize, style: Option<u64>) -> Run {+ Run {+ length: n as u64,+ style,+ ..Run::default()+ }+ }++ /// Runs for `lines`, each line (with its newline) one run of the given style.+ fn per_line(lines: &[(&str, Option<u64>)]) -> (String, Vec<Run>) {+ let body = lines.iter().map(|(t, _)| *t).collect::<Vec<_>>().join("\n");+ let runs = lines+ .iter()+ .enumerate()+ .map(|(i, (t, s))| {+ run(+ t.encode_utf16().count() + usize::from(i + 1 < lines.len()),+ *s,+ )+ })+ .collect();+ (body, runs)+ }++ #[test]+ fn headings_lists_and_text() {+ let (body, runs) = per_line(&[+ ("Groceries", Some(TITLE)),+ ("For the week", Some(HEADING)),+ ("Milk", Some(BULLETED)),+ ("Eggs", Some(BULLETED)),+ ("Then", None),+ ("Wash", Some(NUMBERED)),+ ("Dry", Some(NUMBERED)),+ ]);+ assert_eq!(+ note_to_markdown(&body, &runs),+ "# Groceries\n\n## For the week\n\n- Milk\n- Eggs\n\nThen\n\n1. Wash\n2. Dry\n"+ );+ }++ #[test]+ fn checklists_keep_their_ticks_and_indents() {+ let (body, mut runs) = per_line(&[+ ("Pack", Some(TITLE)),+ ("Passport", Some(CHECKLIST)),+ ("Visa", Some(CHECKLIST)),+ ]);+ runs[1].checked = Some(true);+ runs[2].indent = 1;+ assert_eq!(+ note_to_markdown(&body, &runs),+ "# Pack\n\n- [x] Passport\n - [ ] Visa\n"+ );+ }++ #[test]+ fn inline_marks_links_and_escapes() {+ // "Read the *docs* now": "the" bold, "docs" a link, the rest plain.+ let body = "Note\nRead the 2*3 docs now";+ let mut runs = vec![run(5, Some(TITLE)), run(5, None)];+ runs.push(Run {+ length: 4,+ bold: true,+ ..Run::default()+ });+ runs.push(run(4, None));+ runs.push(Run {+ length: 4,+ link: Some("https://example.com/a b".into()),+ ..Run::default()+ });+ runs.push(run(4, None));+ assert_eq!(+ note_to_markdown(body, &runs),+ "# Note\n\nRead **the** 2\\*3 [docs](https://example.com/a%20b) now\n"+ );+ }++ #[test]+ fn code_blocks_quotes_and_numbered_starts() {+ let (body, mut runs) = per_line(&[+ ("T", Some(TITLE)),+ ("let a = 1;", Some(MONOSPACED)),+ ("let b = *a;", Some(MONOSPACED)),+ ("Wise words", None),+ ("Third", Some(NUMBERED)),+ ("Fourth", Some(NUMBERED)),+ ]);+ runs[3].quote = true;+ runs[4].start = Some(3);+ assert_eq!(+ note_to_markdown(&body, &runs),+ "# T\n\n```\nlet a = 1;\nlet b = *a;\n```\n\n> Wise words\n\n3. Third\n4. Fourth\n"+ );+ }++ #[test]+ fn no_runs_and_attachments_and_emoji() {+ assert_eq!(+ note_to_markdown("Hello 👋\nworld\u{FFFC}", &[]),+ "# Hello 👋\n\nworld\n"+ );+ // Emoji count two UTF-16 units: the run after one still lands on the right word.+ let body = "T\n👋 hi";+ let runs = vec![+ run(2, Some(TITLE)),+ run(3, None),+ Run {+ length: 2,+ bold: true,+ ..Run::default()+ },+ ];+ assert_eq!(note_to_markdown(body, &runs), "# T\n\n👋 **hi**\n");+ }++ /// Runs as the window sends them (NoteEditor's fromDoc): nulls, and fields left out.+ #[test]+ fn runs_from_the_window_are_read() {+ let runs: Vec<Run> = serde_json::from_str(+ r#"[{"length":5,"style":0,"indent":0,"checked":null,"start":null,"bold":false,"italic":false,"underline":false,"strike":false,"link":null},+ {"length":4,"style":103,"indent":0,"checked":true,"bold":false,"italic":false,"underline":false,"strike":false,"link":null,"quote":false}]"#,+ )+ .unwrap();+ assert_eq!(+ note_to_markdown("Pack\nVisa", &runs),+ "# Pack\n\n- [x] Visa\n"+ );+ }+}diff --git a/probe/examples/notes_markdown.rs b/probe/examples/notes_markdown.rsnew file mode 100644index 0000000..a7060f3--- /dev/null+++ b/probe/examples/notes_markdown.rs@@ -0,0 +1,50 @@+//! Read-only: every note in a copy of the app's library written out as Markdown — checks the+//! export on real notes (no panic, every character of text kept) and prints counts only, never+//! a note's text. `notes_markdown <dir with a copy of library.db>`.+use anyhow::{anyhow, Result};+fn main() -> Result<()> {+ let dir = std::env::args()+ .nth(1)+ .ok_or_else(|| anyhow!("a directory"))?;+ let library = quince_core::Library::open(std::path::Path::new(&dir))?;+ let (mut notes, mut styled, mut lost) = (0, 0, 0);+ let mut marks = [0usize; 6];+ let mut all = library.notes_in(None)?;+ for folder in library.note_folders()? {+ all.extend(library.notes_in(Some(&folder.guid))?);+ }+ all.sort_by(|a, b| a.guid.cmp(&b.guid));+ all.dedup_by(|a, b| a.guid == b.guid);+ for note in all {+ let Some(body) = library.note_body(¬e.guid)? else {+ continue;+ };+ let runs: Vec<quince_icloud::ckdocument::Run> = library+ .note_runs(¬e.guid)?+ .and_then(|s| serde_json::from_str(&s).ok())+ .unwrap_or_default();+ notes += 1;+ styled += usize::from(!runs.is_empty());+ let md = quince_icloud::markdown::note_to_markdown(&body, &runs);+ // Every letter and digit of the note is in what was written.+ let letters = |s: &str| s.chars().filter(|c| c.is_alphanumeric()).count();+ if letters(&md) < letters(&body) {+ lost += 1;+ }+ for line in md.lines() {+ let t = line.trim_start();+ for (i, p) in ["# ", "## ", "- [", "- ", "```", "> "].iter().enumerate() {+ if t.starts_with(p) {+ marks[i] += 1;+ break;+ }+ }+ }+ }+ println!("{notes} notes ({styled} with runs); {lost} lost text");+ println!(+ "titles {} headings {} checklist {} bullets {} code fences {} quotes {}",+ marks[0], marks[1], marks[2], marks[3], marks[4], marks[5]+ );+ Ok(())+}diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex e163fad..a16c08e 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -7,6 +7,7 @@],"permissions": ["core:default",- "dialog:allow-open"+ "dialog:allow-open",+ "dialog:allow-save"]}diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 3a0eea7..f799e33 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -1921,6 +1921,21 @@ async fn note_body(guid: String, data: State<'_, Data>) -> UiResult<Option<Strinlibrary.note_body(&guid).map_err(|e| e.to_string())}+/// A note written out as Markdown at `path` (chosen in the save dialog): its text as it is on+/// screen, typing not yet sent included, set as it is in Notes — headings, lists,+/// checklists, code, quotes, bold, italic, links.+#[tauri::command]+async fn note_export_markdown(+ body: String,+ runs: Vec<quince_icloud::ckdocument::Run>,+ path: String,+) -> UiResult<()> {+ let text = quince_icloud::markdown::note_to_markdown(&body, &runs);+ tokio::fs::write(&path, text)+ .await+ .map_err(|e| format!("Could not save it there: {e}"))+}+/// Set one paragraph of a note: `style` from the Aa menu, or `checked` for a checklist tick.#[tauri::command]async fn note_paragraph(@@ -4332,6 +4347,7 @@ fn main() {note_folder_rename,note_folder_delete,note_body,+ note_export_markdown,note_runs,note_table,note_table_set_cell,diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex c3f7482..8d6a7e7 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -239,6 +239,8 @@ export const api = {* of thousands slow.*/noteBody: (guid: string) => invoke<string | null>("note_body", { guid }),+ noteExportMarkdown: (body: string, runs: unknown[], path: string) =>+ invoke<void>("note_export_markdown", { body, runs, path }),/** Answers with the text Apple now holds — ours, or ours combined with another device's. */noteSave: (guid: string,diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsxindex 5810d81..8a374f1 100644--- a/src/screens/NotesView.tsx+++ b/src/screens/NotesView.tsx@@ -1,7 +1,8 @@import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { usePending } from "../lib/pending";import { Notice } from "../components/Notice";-import { ChevronLeft, Folder, FolderOpen, FolderPlus, ListChecks, Pin, PinOff, SquarePen, Trash2 } from "lucide-react";+import { ChevronLeft, Folder, FolderOpen, FolderPlus, ListChecks, Pin, PinOff, Share, SquarePen, Trash2 } from "lucide-react";+import { save as saveFileDialog } from "@tauri-apps/plugin-dialog";import { editorDate, groupNotes, listDate, mergeEdits, splitTitle } from "./notes/model";import { api, messageOf, nestFolders, type Note, type NoteFolder } from "../lib/ipc";import { RowMenu } from "../components/RowMenu";@@ -690,6 +691,29 @@ export function NotesView() {}}, [open, body, runs, formatSafe]);+ /** The note as it is on screen, typing not yet sent included, saved as a Markdown file. */+ const exportNote = async () => {+ if (!open || body === null) return;+ // Read off the editor itself: the very text on screen, with its formatting.+ const shown = editorRef.current?.current();+ const text = shown?.text ?? draft ?? body;+ const set = shown?.runs ?? runs ?? [];+ const name = (text.split("\n")[0].trim() || "Note").replace(/[\\/:*?"<>|]/g, "-").slice(0, 80);+ let path: string | null;+ try {+ path = await saveFileDialog({ defaultPath: `${name}.md`, filters: [{ name: "Markdown", extensions: ["md"] }] });+ } catch (e) {+ setError(messageOf(e));+ return;+ }+ if (!path) return;+ try {+ await api.noteExportMarkdown(text, set, path);+ } catch (e) {+ setError(messageOf(e));+ }+ };+const leave = () => {editorRef.current?.flushChange();void (composingRef.current ? commitComposing() : flush());@@ -997,6 +1021,17 @@ export function NotesView() {.map((f) => ({ value: f.guid, label: f.title })),]}/>}+ {!inTrash && !open.locked && (+ <button+ className="notes-icon"+ aria-label="Export as Markdown"+ title="Export as Markdown"+ onClick={() => void exportNote()}+ disabled={body === null}+ >+ <Share size={17} strokeWidth={2} aria-hidden="true" />+ </button>+ )}{!inTrash && (<buttonclassName="notes-icon"diff --git a/src/screens/notes/NoteEditor.tsx b/src/screens/notes/NoteEditor.tsxindex 47dc030..773fed5 100644--- a/src/screens/notes/NoteEditor.tsx+++ b/src/screens/notes/NoteEditor.tsx@@ -322,6 +322,8 @@ export type EditorHandle = {focus: () => void;/** Hand over any change not yet reported, now. */flushChange: () => void;+ /** What the editor holds this moment: its text and how it is set. */+ current: () => { text: string; runs: Run[] } | null;};type Props = {@@ -677,6 +679,7 @@ export const NoteEditor = forwardRef<EditorHandle, Props>(function NoteEditor(flushChange: () => {if (later.current !== null) report();},+ current: () => (view.current ? fromDoc(view.current.state.doc) : null),}));const [cellMenu, setCellMenu] = useState<CellMenu | null>(null);