Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Type › Notes › Previous Note and Next Note: the insertion point moves from note to note, as in InDesign

dotCooCoo42d2857fcc60
diff --git a/ROADMAP.md b/ROADMAP.md
index c997b9e35..b3bd74a02 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -358,6 +358,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
Newest first.
+- **2026-10-24** · Type › Notes › Previous Note and Next Note (`note.previous`, `note.next`): as in InDesign, they move the insertion point from note to note in the story, putting the caret after the note's anchor. Each item is unavailable when no note lies in its direction in the story, or when the insertion point is in a table cell or a footnote. No readiness percentage change.
- **2026-10-24** · Anchored text frames, such as marginal notes, compose where their host story places them: they align to the baseline grid at that position, and page-number markers and spine-relative alignment inside them read the host's page. They composed against a grid measured from their stored position and on no page, so a note set to Only Align First Line to Grid could sit a fraction of a line off the body text's grid line. No readiness percentage change.
- **2026-10-24** · New documents start with Hyphenate Capitalized Words, Hyphenate Last Word and Hyphenate Across Column off in [Basic Paragraph], as in InDesign. Opened and imported files keep the values they carry. No readiness percentage change.
- **2026-10-24** · The baseline grid's Relative To setting applies: with Top Margin, the grid starts at each page's own top margin in text composition, on the canvas and for snapping. It started at the page top, so grid-aligned text sat on the wrong lines and a page could fit one line fewer. No readiness percentage change.
diff --git a/crates/engine/src/cmd/editorial.rs b/crates/engine/src/cmd/editorial.rs
index 5b210da90..618a735ff 100644
--- a/crates/engine/src/cmd/editorial.rs
+++ b/crates/engine/src/cmd/editorial.rs
@@ -93,6 +93,24 @@ pub fn specs() -> Vec<CommandSpec> {
}
Ok(Value::Array(out))
}),
+ cmd!(
+ noundo "note.previous",
+ "Previous Note",
+ ["Type", "Notes"],
+ None,
+ "{} → {story, id, pos}. The caret moves after the anchor of the story's previous note.",
+ has_previous,
+ |s, _| go_to(s, false)
+ ),
+ cmd!(
+ noundo "note.next",
+ "Next Note",
+ ["Type", "Notes"],
+ None,
+ "{} → {story, id, pos}. The caret moves after the anchor of the story's next note.",
+ has_next,
+ |s, _| go_to(s, true)
+ ),
]
}
@@ -108,6 +126,53 @@ fn anchor(st: &designcraft_doc::Story, id: u64) -> Option<usize> {
st.text.match_indices(NOTE_MARK).nth(k).map(|(i, _)| i)
}
+/// The anchor offset and id of the note before or after the selection `t` in its story. Going
+/// back skips the note whose anchor the caret directly follows, so repeated steps reach every note.
+fn neighbor(st: &designcraft_doc::Story, t: &designcraft_doc::TextSel, forward: bool) -> Option<(usize, u64)> {
+ let r = t.range();
+ let mut anchors = st.text.match_indices(NOTE_MARK).enumerate().map(|(k, (i, _))| (k, i));
+ let (k, at) = if forward { anchors.find(|&(_, i)| i >= r.end) } else { anchors.filter(|&(_, i)| i + NOTE_MARK.len_utf8() < r.start).last() }?;
+ Some((at, st.editorial.get(k)?.id))
+}
+
+fn has_note(s: &crate::Session, forward: bool) -> std::result::Result<(), String> {
+ has_text(s)?;
+ match s.active().and_then(|d| Some((d, d.selection.text?))) {
+ Some((_, t)) if t.cell.is_some() => Err("notes go in story text".into()),
+ Some((d, t)) if d.doc.story(t.story).and_then(|st| neighbor(st, &t, forward)).is_some() => Ok(()),
+ _ => Err(no_note(forward).into()),
+ }
+}
+
+fn has_previous(s: &crate::Session) -> std::result::Result<(), String> {
+ has_note(s, false)
+}
+
+fn has_next(s: &crate::Session) -> std::result::Result<(), String> {
+ has_note(s, true)
+}
+
+fn no_note(forward: bool) -> &'static str {
+ if forward { "no later note in this story" } else { "no earlier note in this story" }
+}
+
+/// Type › Notes › Previous Note and Next Note: from the insertion point, the caret moves after
+/// the anchor of the story's previous or next note.
+fn go_to(s: &mut crate::Session, forward: bool) -> Result<Value> {
+ let id = if forward { "note.next" } else { "note.previous" };
+ let st = s.doc_mut()?;
+ let t = st.selection.text.ok_or_else(|| bad(id, "place the insertion point in text"))?;
+ if t.cell.is_some() {
+ return Err(bad(id, "notes go in story text"));
+ }
+ let (at, note) = st.doc.story(t.story).and_then(|x| neighbor(x, &t, forward)).ok_or_else(|| bad(id, no_note(forward)))?;
+ let pos = at + NOTE_MARK.len_utf8();
+ st.selection.text = Some(designcraft_doc::TextSel::caret(t.story, pos));
+ st.bump_revision();
+ s.typing_format = None;
+ Ok(json!({"story": t.story.0, "id": note, "pos": pos}))
+}
+
#[cfg(test)]
mod tests {
use serde_json::json;
@@ -136,6 +201,46 @@ mod tests {
assert!(s.doc().unwrap().doc.stories[&sid].editorial.is_empty());
}
+ #[test]
+ fn previous_and_next_note_step_through_the_story_s_notes() {
+ let mut s = Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let r = s.execute("frame.create", &json!({"rect": [72, 72, 400, 300], "content": "text", "text": "One two three."})).unwrap();
+ let len = designcraft_doc::NOTE_MARK.len_utf8();
+ let caret = |s: &mut Session, at: usize| s.execute("text.select", &json!({"story": r["story"], "anchor": at, "focus": at})).unwrap();
+ caret(&mut s, 3);
+ let first = s.execute("note.new", &json!({"text": "a"})).unwrap();
+ caret(&mut s, 7 + len);
+ let second = s.execute("note.new", &json!({"text": "b"})).unwrap();
+ caret(&mut s, 0);
+ let disabled = |s: &mut Session, id: &str| matches!(s.execute(id, &json!({})), Err(crate::EngineError::Disabled(..)));
+ assert!(disabled(&mut s, "note.previous"), "no note before the start");
+ let n = s.execute("note.next", &json!({})).unwrap();
+ assert_eq!((n["id"].clone(), n["pos"].clone()), (first["id"].clone(), json!(3 + len)));
+ let n = s.execute("note.next", &json!({})).unwrap();
+ assert_eq!((n["id"].clone(), n["pos"].clone()), (second["id"].clone(), json!(7 + 2 * len)));
+ let t = s.doc().unwrap().selection.text.unwrap();
+ assert_eq!((t.anchor, t.focus), (7 + 2 * len, 7 + 2 * len), "the caret follows the anchor");
+ assert!(disabled(&mut s, "note.next"), "no note after the last");
+ // From just after the second anchor, Previous Note goes to the first one.
+ let n = s.execute("note.previous", &json!({})).unwrap();
+ assert_eq!(n["id"], first["id"]);
+ assert!(disabled(&mut s, "note.previous"));
+ // From the middle of the story, each direction finds its neighbor.
+ caret(&mut s, 5 + len);
+ assert_eq!(s.execute("note.previous", &json!({})).unwrap()["id"], first["id"]);
+ caret(&mut s, 5 + len);
+ assert_eq!(s.execute("note.next", &json!({})).unwrap()["id"], second["id"]);
+ // Formatting set at the insertion point does not survive the move.
+ s.execute("type.char", &json!({"attrs": {"size": 30}})).unwrap();
+ assert!(s.typing_format.is_some());
+ s.execute("note.previous", &json!({})).unwrap();
+ assert!(s.typing_format.is_none(), "note.previous");
+ s.execute("type.char", &json!({"attrs": {"size": 30}})).unwrap();
+ s.execute("note.next", &json!({})).unwrap();
+ assert!(s.typing_format.is_none(), "note.next");
+ }
+
#[test]
fn notes_insert_into_a_story_whose_markers_lack_payloads() {
let mut s = Session::new();
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index e74cc0f73..da24464f7 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -2084,6 +2084,7 @@ const TABLE: &[(&str, [&str; 5])] = &[
("New Table Style…", ["New Table Style…", "Nouveau style de tableau…", "New Table Style…", "New Table Style…", "新建表样式…"]),
("Next Cell", ["Next Cell", "Cellule suivante", "Next Cell", "Next Cell", "下一个单元格"]),
("Next Document", ["Next Document", "Document suivant", "Next Document", "Next Document", "下一个文档"]),
+ ("Next Note", ["Next Note", "Note suivante", "Next Note", "Next Note", "下一个注释"]),
("Next Object Above", ["Next Object Above", "Objet suivant au-dessus", "Next Object Above", "Next Object Above", "上方下一个对象"]),
("Next Object Below", ["Next Object Below", "Objet suivant en dessous", "Next Object Below", "Next Object Below", "下方下一个对象"]),
(
@@ -2162,6 +2163,7 @@ const TABLE: &[(&str, [&str; 5])] = &[
("Preflight Document", ["Preflight Document", "Contrôle en amont du document", "Preflight Document", "Preflight Document", "预检文档"]),
("Previous Cell", ["Previous Cell", "Cellule précédente", "Previous Cell", "Previous Cell", "上一个单元格"]),
("Previous Document", ["Previous Document", "Document précédent", "Previous Document", "Previous Document", "上一个文档"]),
+ ("Previous Note", ["Previous Note", "Note précédente", "Previous Note", "Previous Note", "上一个注释"]),
(
"Previous Object in Group",
["Previous Object in Group", "Objet précédent du groupe", "Previous Object in Group", "Previous Object in Group", "组中的上一个对象"],
diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs
index 49fd3046e..281a9b9f7 100644
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@ -1481,6 +1481,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "نمط جدول جديد…"),
("Next Cell", "الخلية التالية"),
("Next Document", "المستند التالي"),
+ ("Next Note", "الملاحظة التالية"),
("Next Object Above", "الكائن التالي أعلى"),
("Next Object Below", "الكائن التالي أسفل"),
("Next Object in Group", "الكائن التالي في المجموعة"),
@@ -1509,6 +1510,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "فحص المستند قبل الطباعة"),
("Previous Cell", "الخلية السابقة"),
("Previous Document", "المستند السابق"),
+ ("Previous Note", "الملاحظة السابقة"),
("Previous Object in Group", "الكائن السابق في المجموعة"),
("Printers", "طابعات"),
("Proof Colors", "ألوان المعاينة الطباعية"),
diff --git a/crates/ui-egui/src/i18n/cs.rs b/crates/ui-egui/src/i18n/cs.rs
index 6f47fdaff..c47b4cb12 100644
--- a/crates/ui-egui/src/i18n/cs.rs
+++ b/crates/ui-egui/src/i18n/cs.rs
@@ -632,6 +632,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Nový styl tabulky…"),
("Next Cell", "Další buňka"),
("Next Document", "Další dokument"),
+ ("Next Note", "Další poznámka"),
("Next Object Above", "Další objekt nad"),
("Next Object Below", "Další objekt pod"),
("Next Object in Group", "Další objekt ve skupině"),
@@ -665,6 +666,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Předtisková kontrola dokumentu"),
("Previous Cell", "Předchozí buňka"),
("Previous Document", "Předchozí dokument"),
+ ("Previous Note", "Předchozí poznámka"),
("Previous Object in Group", "Předchozí objekt ve skupině"),
("Primary Text Frame", "Primární textový rámeček"),
("Print Booklet…", "Tisk brožury…"),
diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rs
index 97b48316b..4d056bae5 100644
--- a/crates/ui-egui/src/i18n/de.rs
+++ b/crates/ui-egui/src/i18n/de.rs
@@ -669,6 +669,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Neues Tabellenformat …"),
("Next Cell", "Nächste Zelle"),
("Next Document", "Nächstes Dokument"),
+ ("Next Note", "Nächste Notiz"),
("Next Object Above", "Nächstes Objekt darüber"),
("Next Object Below", "Nächstes Objekt darunter"),
("Next Object in Group", "Nächstes Objekt in der Gruppe"),
@@ -702,6 +703,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Preflight für Dokument"),
("Previous Cell", "Vorherige Zelle"),
("Previous Document", "Vorheriges Dokument"),
+ ("Previous Note", "Vorherige Notiz"),
("Previous Object in Group", "Vorheriges Objekt in der Gruppe"),
("Primary Text Frame", "Primärer Textrahmen"),
("Print Booklet…", "Broschüre drucken …"),
diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rs
index 4a3656699..e074076a1 100644
--- a/crates/ui-egui/src/i18n/it.rs
+++ b/crates/ui-egui/src/i18n/it.rs
@@ -760,6 +760,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Nuovo stile tabella…"),
("Next Cell", "Cella successiva"),
("Next Document", "Documento successivo"),
+ ("Next Note", "Nota successiva"),
("Next Object Above", "Oggetto successivo sopra"),
("Next Object Below", "Oggetto successivo sotto"),
("Next Object in Group", "Oggetto successivo nel gruppo"),
@@ -793,6 +794,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Verifica preliminare documento"),
("Previous Cell", "Cella precedente"),
("Previous Document", "Documento precedente"),
+ ("Previous Note", "Nota precedente"),
("Previous Object in Group", "Oggetto precedente nel gruppo"),
("Primary Text Frame", "Cornice di testo principale"),
("Print Booklet…", "Stampa opuscolo…"),
diff --git a/crates/ui-egui/src/i18n/ja.rs b/crates/ui-egui/src/i18n/ja.rs
index 6180858af..5972340eb 100644
--- a/crates/ui-egui/src/i18n/ja.rs
+++ b/crates/ui-egui/src/i18n/ja.rs
@@ -861,6 +861,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "新規表スタイル…"),
("Next Cell", "次のセル"),
("Next Document", "次のドキュメント"),
+ ("Next Note", "次の注釈"),
("Next Object Above", "1つ前面のオブジェクト"),
("Next Object Below", "1つ背面のオブジェクト"),
("Next Object in Group", "グループ内の次のオブジェクト"),
@@ -894,6 +895,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "ドキュメントのプリフライト"),
("Previous Cell", "前のセル"),
("Previous Document", "前のドキュメント"),
+ ("Previous Note", "前の注釈"),
("Previous Object in Group", "グループ内の前のオブジェクト"),
("Primary Text Frame", "主テキストフレーム"),
("Print Booklet…", "小冊子をプリント…"),
diff --git a/crates/ui-egui/src/i18n/ka.rs b/crates/ui-egui/src/i18n/ka.rs
index 4767b6c30..a3e9df769 100644
--- a/crates/ui-egui/src/i18n/ka.rs
+++ b/crates/ui-egui/src/i18n/ka.rs
@@ -688,6 +688,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "ცხრილის ახალი სტილი…"),
("Next Cell", "შემდეგი უჯრა"),
("Next Document", "შემდეგი დოკუმენტი"),
+ ("Next Note", "შემდეგი შენიშვნა"),
("Next Object Above", "შემდეგი ობიექტი ზემოთ"),
("Next Object Below", "შემდეგი ობიექტი ქვემოთ"),
("Next Object in Group", "ჯგუფის შემდეგი ობიექტი"),
@@ -721,6 +722,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "დოკუმენტის წინასწარი შემოწმება"),
("Previous Cell", "წინა უჯრა"),
("Previous Document", "წინა დოკუმენტი"),
+ ("Previous Note", "წინა შენიშვნა"),
("Previous Object in Group", "ჯგუფის წინა ობიექტი"),
("Primary Text Frame", "ძირითადი ტექსტური ჩარჩო"),
("Print Booklet…", "ბროშურის დაბეჭდვა…"),
diff --git a/crates/ui-egui/src/i18n/pl.rs b/crates/ui-egui/src/i18n/pl.rs
index bf0c7600b..4b694aa35 100644
--- a/crates/ui-egui/src/i18n/pl.rs
+++ b/crates/ui-egui/src/i18n/pl.rs
@@ -639,6 +639,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Nowy styl tabeli…"),
("Next Cell", "Następna komórka"),
("Next Document", "Następny dokument"),
+ ("Next Note", "Następna notatka"),
("Next Object Above", "Następny obiekt powyżej"),
("Next Object Below", "Następny obiekt poniżej"),
("Next Object in Group", "Następny obiekt w grupie"),
@@ -672,6 +673,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Inspekcja wstępna dokumentu"),
("Previous Cell", "Poprzednia komórka"),
("Previous Document", "Poprzedni dokument"),
+ ("Previous Note", "Poprzednia notatka"),
("Previous Object in Group", "Poprzedni obiekt w grupie"),
("Primary Text Frame", "Główna ramka tekstowa"),
("Print Booklet…", "Drukuj broszurę…"),
diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs
index 59c4f2e23..d6e668bed 100644
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@ -1614,6 +1614,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Novo estilo de tabela…"),
("Next Cell", "Próxima célula"),
("Next Document", "Próximo documento"),
+ ("Next Note", "Próxima nota"),
("Next Object Above", "Próximo objeto acima"),
("Next Object Below", "Próximo objeto abaixo"),
("Next Object in Group", "Próximo objeto no grupo"),
@@ -1641,6 +1642,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Verificar documento (preflight)"),
("Previous Cell", "Célula anterior"),
("Previous Document", "Documento anterior"),
+ ("Previous Note", "Nota anterior"),
("Previous Object in Group", "Objeto anterior no grupo"),
("Printers", "Impressoras"),
("Proof Colors", "Cores de prova"),
diff --git a/crates/ui-egui/src/i18n/ru.rs b/crates/ui-egui/src/i18n/ru.rs
index 412faea7e..bbf5bfeaf 100644
--- a/crates/ui-egui/src/i18n/ru.rs
+++ b/crates/ui-egui/src/i18n/ru.rs
@@ -619,6 +619,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Новый стиль таблицы…"),
("Next Cell", "Следующая ячейка"),
("Next Document", "Следующий документ"),
+ ("Next Note", "Следующая заметка"),
("Next Object Above", "Следующий объект выше"),
("Next Object Below", "Следующий объект ниже"),
("Next Object in Group", "Следующий объект в группе"),
@@ -652,6 +653,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Предпечатная проверка документа"),
("Previous Cell", "Предыдущая ячейка"),
("Previous Document", "Предыдущий документ"),
+ ("Previous Note", "Предыдущая заметка"),
("Previous Object in Group", "Предыдущий объект в группе"),
("Primary Text Frame", "Основная текстовая рамка"),
("Print Booklet…", "Печать буклета…"),
diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rs
index 62c594fd1..4c016860a 100644
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@ -763,6 +763,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("New Table Style…", "Новий стиль таблиці…"),
("Next Cell", "Наступна клітинка"),
("Next Document", "Наступний документ"),
+ ("Next Note", "Наступна примітка"),
("Next Object Above", "Наступний об’єкт вище"),
("Next Object Below", "Наступний об’єкт нижче"),
("Next Object in Group", "Наступний об’єкт у групі"),
@@ -796,6 +797,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Preflight Document", "Перевірити документ перед друком"),
("Previous Cell", "Попередня клітинка"),
("Previous Document", "Попередній документ"),
+ ("Previous Note", "Попередня примітка"),
("Previous Object in Group", "Попередній об’єкт у групі"),
("Primary Text Frame", "Основний текстовий фрейм"),
("Print Booklet…", "Друк буклета…"),
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 75053ef1b..51be71818 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -499,6 +499,9 @@ pub const MENUS: &[(&str, &[&str])] = &[
">Notes",
"cmd:note.new",
"ui:window.panel|Notes|{\"panel\": \"notes\"}",
+ "-",
+ "cmd:note.previous",
+ "cmd:note.next",
"<",
">Track Changes",
"cmd:changes.track",