From 73b12789d563dda86ef948015d1415cda3404ceb Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 08:18:38 -0800 Subject: [PATCH 01/19] feat(ui): colour icons for Paste and other ribbon controls Paste uses the Fluent colour clipboard. Notebook, page, code, lock, help and the Lasso icon use the approved Fluent set. Pen and unlock are NoteCraft drawings in the same style, recorded in ATTRIBUTION.md. Also adds the failing template label test (red until the templates work lands). Co-Authored-By: Claude Haiku 5.5 --- ATTRIBUTION.md | 3 +- .../ui-egui/assets/fluent-color/clipboard.svg | 24 +++++++++++ crates/ui-egui/assets/fluent-color/code.svg | 9 ++++ .../assets/fluent-color/lock_closed.svg | 19 +++++++++ .../ui-egui/assets/fluent-color/notebook.svg | 24 +++++++++++ .../assets/fluent-color/question_circle.svg | 14 +++++++ crates/ui-egui/assets/fluent/lasso.svg | 3 ++ crates/ui-egui/assets/notecraft-color/pen.svg | 1 + .../ui-egui/assets/notecraft-color/unlock.svg | 1 + crates/ui-egui/src/icons.rs | 17 ++++++++ crates/ui-egui/src/ribbon.rs | 2 + crates/ui-egui/tests/template_catalog.rs | 41 +++++++++++++++++++ 12 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/assets/fluent-color/clipboard.svg create mode 100644 crates/ui-egui/assets/fluent-color/code.svg create mode 100644 crates/ui-egui/assets/fluent-color/lock_closed.svg create mode 100644 crates/ui-egui/assets/fluent-color/notebook.svg create mode 100644 crates/ui-egui/assets/fluent-color/question_circle.svg create mode 100644 crates/ui-egui/assets/fluent/lasso.svg create mode 100644 crates/ui-egui/assets/notecraft-color/pen.svg create mode 100644 crates/ui-egui/assets/notecraft-color/unlock.svg create mode 100644 crates/ui-egui/tests/template_catalog.rs diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index c37e2ef8..eae1381a 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -150,7 +150,8 @@ data. specifications. No Microsoft text or code is included. | \crates/ui-egui/assets/fluent/*.svg\ | Selected Fluent UI System Icons used by the ribbon | Microsoft Fluent UI System Icons, MIT licensed; source: https://github.com/microsoft/fluentui-system-icons | Microsoft Corporation and contributors | -| \crates/ui-egui/assets/fluent-color/*.svg\ | Selected Fluent UI System Icons colour versions (calendar, clock, link, image, table, video, mic, document) used by the ribbon | Microsoft Fluent UI System Icons, MIT licensed; source: https://github.com/microsoft/fluentui-system-icons (`assets//SVG/ic_fluent__24_color.svg`) | Microsoft Corporation and contributors | +| \crates/ui-egui/assets/fluent-color/*.svg\ | Selected Fluent UI System Icons colour versions (calendar, clock, link, image, table, video, mic, document, notebook, code, lock closed, question circle, clipboard) used by the ribbon | Microsoft Fluent UI System Icons, MIT licensed; source: https://github.com/microsoft/fluentui-system-icons (`assets//SVG/ic_fluent__24_color.svg`) | Microsoft Corporation and contributors | +| \crates/ui-egui/assets/notecraft-color/*.svg\ | Pen and unlocked padlock colour icons used by the ribbon. Not Fluent: Fluent has no colour version of these two, so they were drawn for NoteCraft in the same 24px style | Drawn for this project | The project's own work, under its MIT OR Apache-2.0 licence | ## OCR demo pictures diff --git a/crates/ui-egui/assets/fluent-color/clipboard.svg b/crates/ui-egui/assets/fluent-color/clipboard.svg new file mode 100644 index 00000000..57fda396 --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/clipboard.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent-color/code.svg b/crates/ui-egui/assets/fluent-color/code.svg new file mode 100644 index 00000000..bd3914ff --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/code.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent-color/lock_closed.svg b/crates/ui-egui/assets/fluent-color/lock_closed.svg new file mode 100644 index 00000000..2900489c --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/lock_closed.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent-color/notebook.svg b/crates/ui-egui/assets/fluent-color/notebook.svg new file mode 100644 index 00000000..c784c2cb --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/notebook.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent-color/question_circle.svg b/crates/ui-egui/assets/fluent-color/question_circle.svg new file mode 100644 index 00000000..f1a69443 --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/question_circle.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent/lasso.svg b/crates/ui-egui/assets/fluent/lasso.svg new file mode 100644 index 00000000..49bbfb8d --- /dev/null +++ b/crates/ui-egui/assets/fluent/lasso.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui-egui/assets/notecraft-color/pen.svg b/crates/ui-egui/assets/notecraft-color/pen.svg new file mode 100644 index 00000000..ca44a38e --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/pen.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/notecraft-color/unlock.svg b/crates/ui-egui/assets/notecraft-color/unlock.svg new file mode 100644 index 00000000..113b402b --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/unlock.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 6a60a2ba..8b9fa38c 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -646,6 +646,16 @@ pub fn paint_ribbon(ui: &Ui, rect: Rect, icon: Icon, color: Color32) { coloured_svg(name, bytes, color).fit_to_exact_size(rect.size()).paint_at(ui, rect); } +/// The ribbon's Paste button: the Fluent colour clipboard, drawn in its own colours and faded +/// only when the control is disabled (as `paint_ribbon` does for the other colour icons). +pub fn paint_paste(ui: &Ui, rect: Rect, enabled: bool) { + let tint = if enabled { Color32::WHITE } else { Color32::from_white_alpha(90) }; + egui::Image::from_bytes("bytes://notecraft-fluent-color/clipboard.svg", include_bytes!("../assets/fluent-color/clipboard.svg")) + .fit_to_exact_size(rect.size()) + .tint(tint) + .paint_at(ui, rect); +} + /// A monochrome Fluent icon drawn in `colour`. The SVG is drawn in one near-black, and a tint /// can only multiply that, so it can never show a light icon. The colour is written into the /// file instead, and the picture is keyed by that colour so each colour is loaded once. @@ -667,6 +677,12 @@ fn fluent_color_asset(icon: Icon) -> Option<(&'static str, &'static [u8])> { Icon::Video => ("video", include_bytes!("../assets/fluent-color/video.svg")), Icon::Mic => ("mic", include_bytes!("../assets/fluent-color/mic.svg")), Icon::Page => ("document", include_bytes!("../assets/fluent-color/document.svg")), + Icon::Notebook => ("notebook", include_bytes!("../assets/fluent-color/notebook.svg")), + Icon::Code => ("code", include_bytes!("../assets/fluent-color/code.svg")), + Icon::Lock => ("lock_closed", include_bytes!("../assets/fluent-color/lock_closed.svg")), + Icon::Help => ("question_circle", include_bytes!("../assets/fluent-color/question_circle.svg")), + Icon::Pen => ("pen", include_bytes!("../assets/notecraft-color/pen.svg")), + Icon::Unlock => ("unlock", include_bytes!("../assets/notecraft-color/unlock.svg")), _ => return None, }) } @@ -686,6 +702,7 @@ fn fluent_asset(icon: Icon) -> Option<(&'static str, &'static [u8])> { Icon::Symbol => ("symbols", include_bytes!("../assets/fluent/symbols.svg")), Icon::Ruler => ("ruler", include_bytes!("../assets/fluent/ruler.svg")), Icon::InsertSpace => ("spacebar", include_bytes!("../assets/fluent/spacebar.svg")), + Icon::Lasso => ("lasso", include_bytes!("../assets/fluent/lasso.svg")), _ => return None, }) } diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 6ac7a083..43301051 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -991,6 +991,7 @@ fn strip_button(ui: &mut Ui, icon: SplitIcon, label: &str, tip: &str, menu: bool let icon_rect = Rect::from_center_size(egui::pos2(rect.left() + 15.0, rect.center().y), vec2(20.0, 20.0)); match icon { SplitIcon::Icon(icon) => icons::paint_ribbon(ui, icon_rect, icon, if enabled { t.accent } else { t.muted }), + SplitIcon::Mark(Mark::Paste) => icons::paint_paste(ui, icon_rect, enabled), SplitIcon::Mark(mark) => ribbon_icons::paint(&painter, icon_rect, mark, if enabled { mark.color(t.text, t.accent) } else { t.muted }), } let pos = egui::pos2(rect.left() + 29.0, rect.center().y - galley.size().y / 2.0); @@ -1435,6 +1436,7 @@ fn big_split(ui: &mut Ui, icon: impl Into, label: &str, tip: &str, let colour = if enabled { if icon == Icon::Picture { t.ok } else { t.accent } } else { t.muted }; icons::paint_ribbon(ui, Rect::from_center_size(at, vec2(28.0, 28.0)), icon, colour); } + SplitIcon::Mark(Mark::Paste) => icons::paint_paste(ui, Rect::from_center_size(at, vec2(24.0, 24.0)), enabled), SplitIcon::Mark(mark) => { let colour = if enabled { mark.color(t.text, t.accent) } else { t.muted }; ribbon_icons::paint(&painter, Rect::from_center_size(at, vec2(24.0, 24.0)), mark, colour); diff --git a/crates/ui-egui/tests/template_catalog.rs b/crates/ui-egui/tests/template_catalog.rs new file mode 100644 index 00000000..a93a42d7 --- /dev/null +++ b/crates/ui-egui/tests/template_catalog.rs @@ -0,0 +1,41 @@ +//! Every built-in page template and category has a translated label in every language NoteCraft +//! ships: the 14 languages plus the two pseudo-locales used for testing. A template with no +//! translation would show English in the Templates pane, so this is checked against the real +//! catalog files and the real template list. + +use notecraft_store::page_templates::{BUILT_IN, Category}; +use std::collections::BTreeSet; +use std::fs; +use std::path::Path; + +/// The 14 languages and the two pseudo-locales (`en-XA`, `ar-XB`). +const LANGUAGES: [&str; 16] = ["ar", "ar-XB", "de", "en", "en-XA", "es", "fa", "fr", "he", "hi", "ja", "ko", "ru", "tr", "ur", "zh"]; + +/// The catalog keys a template pane needs: one per category and one per built-in template. +fn required_keys() -> Vec { + let mut keys: Vec = Category::ALL.iter().map(|c| format!("ui.template_category_{}", c.id())).collect(); + keys.extend(BUILT_IN.iter().map(|b| format!("ui.template_name_{}", b.id.replace('-', "_")))); + keys +} + +/// The keys a language file defines, read from its `@idkeytext` rows. +fn keys_in(language: &str) -> BTreeSet { + let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("..").join("i18n").join(format!("{language}.tsv")); + let text = fs::read_to_string(&path).unwrap_or_else(|e| panic!("cannot read {}: {e}", path.display())); + text.lines().filter_map(|line| line.strip_prefix("@id\t")).filter_map(|rest| rest.split('\t').next()).map(str::to_string).collect() +} + +#[test] +fn every_template_label_is_translated_in_every_language() { + let required = required_keys(); + let mut missing = Vec::new(); + for language in LANGUAGES { + let have = keys_in(language); + for key in &required { + if !have.contains(key) { + missing.push(format!("{language}: {key}")); + } + } + } + assert!(missing.is_empty(), "{} template labels have no translation:\n{}", missing.len(), missing.join("\n")); +} From 83914108cb264fc1fb22ab8e0f6f4ccd92daf6db Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 08:33:12 -0800 Subject: [PATCH 02/19] feat(i18n): translate the page template names and categories Adds the template names and category labels to every language catalog, best-effort translations. The template label test checks all 16 languages, including the two pseudo-locales. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/tests/template_catalog.rs | 2 +- i18n/ar.tsv | 13 +++++++++++++ i18n/de.tsv | 13 +++++++++++++ i18n/es.tsv | 13 +++++++++++++ i18n/fa.tsv | 13 +++++++++++++ i18n/fr.tsv | 13 +++++++++++++ i18n/he.tsv | 13 +++++++++++++ i18n/hi.tsv | 13 +++++++++++++ i18n/ja.tsv | 13 +++++++++++++ i18n/ko.tsv | 13 +++++++++++++ i18n/ru.tsv | 13 +++++++++++++ i18n/ur.tsv | 13 +++++++++++++ i18n/zh.tsv | 13 +++++++++++++ 13 files changed, 157 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/template_catalog.rs b/crates/ui-egui/tests/template_catalog.rs index a93a42d7..8968f4dd 100644 --- a/crates/ui-egui/tests/template_catalog.rs +++ b/crates/ui-egui/tests/template_catalog.rs @@ -14,7 +14,7 @@ const LANGUAGES: [&str; 16] = ["ar", "ar-XB", "de", "en", "en-XA", "es", "fa", " /// The catalog keys a template pane needs: one per category and one per built-in template. fn required_keys() -> Vec { let mut keys: Vec = Category::ALL.iter().map(|c| format!("ui.template_category_{}", c.id())).collect(); - keys.extend(BUILT_IN.iter().map(|b| format!("ui.template_name_{}", b.id.replace('-', "_")))); + keys.extend(BUILT_IN.iter().map(|b| format!("ui.template_{}", b.id.replace('-', "_")))); keys } diff --git a/i18n/ar.tsv b/i18n/ar.tsv index 8afa0369..5e9e5e30 100644 --- a/i18n/ar.tsv +++ b/i18n/ar.tsv @@ -829,3 +829,16 @@ @id ui.could_not_save_the_notebooks_folder_error تعذّر حفظ مجلد الدفاتر: {error} @id ui.page_version_comparison_truncated تُقارَن أول ٤٠٠٠ سطر غير فارغ فقط من كل نسخة. قد توجد تغييرات في الأسطر التالية. @id ui.could_not_open_the_notebooks_folder_error تعذّر فتح مجلد الدفاتر: {error} +@id ui.template_study_guide دليل الدراسة +@id ui.template_category_mine قوالبي +@id ui.template_meeting_notes ملاحظات الاجتماع +@id ui.template_category_academic الأكاديمية +@id ui.template_category_blank فارغ +@id ui.template_category_planners المخططات +@id ui.template_to_do_list قائمة المهام +@id ui.template_grid شبكة +@id ui.template_lecture_notes ملاحظات المحاضرة +@id ui.template_project_overview نظرة عامة على المشروع +@id ui.template_college_ruled ورق بأسطر +@id ui.template_weekly_planner المخطط الأسبوعي +@id ui.template_category_business الأعمال diff --git a/i18n/de.tsv b/i18n/de.tsv index ca5f054a..c5f5b71d 100644 --- a/i18n/de.tsv +++ b/i18n/de.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed Der Notizbuch-Ordner ist jetzt {folder}. @id ui.could_not_save_the_notebooks_folder_error Der Notizbuch-Ordner konnte nicht gespeichert werden: {error} @id ui.could_not_open_the_notebooks_folder_error Der Notizbuch-Ordner konnte nicht geöffnet werden: {error} +@id ui.template_study_guide Lernleitfaden +@id ui.template_category_mine Meine Vorlagen +@id ui.template_meeting_notes Besprechungsnotizen +@id ui.template_category_academic Akademisch +@id ui.template_category_blank Leer +@id ui.template_category_planners Planer +@id ui.template_to_do_list To-do-Liste +@id ui.template_grid Raster +@id ui.template_lecture_notes Vorlesungsnotizen +@id ui.template_project_overview Projektübersicht +@id ui.template_college_ruled Liniert +@id ui.template_weekly_planner Wochenplaner +@id ui.template_category_business Geschäft diff --git a/i18n/es.tsv b/i18n/es.tsv index 4d6ad646..e137fb7b 100644 --- a/i18n/es.tsv +++ b/i18n/es.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed La carpeta de cuadernos es ahora {folder}. @id ui.could_not_save_the_notebooks_folder_error No se pudo guardar la carpeta de cuadernos: {error} @id ui.could_not_open_the_notebooks_folder_error No se pudo abrir la carpeta de cuadernos: {error} +@id ui.template_study_guide Guía de estudio +@id ui.template_category_mine Mis plantillas +@id ui.template_meeting_notes Notas de reunión +@id ui.template_category_academic Académico +@id ui.template_category_blank En blanco +@id ui.template_category_planners Planificadores +@id ui.template_to_do_list Lista de tareas +@id ui.template_grid Cuadrícula +@id ui.template_lecture_notes Apuntes de clase +@id ui.template_project_overview Resumen del proyecto +@id ui.template_college_ruled Con renglones +@id ui.template_weekly_planner Planificador semanal +@id ui.template_category_business Negocios diff --git a/i18n/fa.tsv b/i18n/fa.tsv index 02e563db..554ea441 100644 --- a/i18n/fa.tsv +++ b/i18n/fa.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed پوشه دفترچه‌ها اکنون {folder} است. @id ui.could_not_save_the_notebooks_folder_error پوشه دفترچه‌ها ذخیره نشد: {error} @id ui.could_not_open_the_notebooks_folder_error پوشه دفترچه‌ها باز نشد: {error} +@id ui.template_study_guide راهنمای مطالعه +@id ui.template_category_mine الگوهای من +@id ui.template_meeting_notes یادداشت جلسه +@id ui.template_category_academic آکادمیک +@id ui.template_category_blank خالی +@id ui.template_category_planners برنامه‌ریزها +@id ui.template_to_do_list فهرست کارها +@id ui.template_grid شبکه +@id ui.template_lecture_notes یادداشت درس +@id ui.template_project_overview مرور پروژه +@id ui.template_college_ruled خط‌دار +@id ui.template_weekly_planner برنامه هفتگی +@id ui.template_category_business کسب‌وکار diff --git a/i18n/fr.tsv b/i18n/fr.tsv index e62e223d..055eb1f6 100644 --- a/i18n/fr.tsv +++ b/i18n/fr.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed Le dossier des carnets est maintenant {folder}. @id ui.could_not_save_the_notebooks_folder_error Impossible d’enregistrer le dossier des carnets : {error} @id ui.could_not_open_the_notebooks_folder_error Impossible d’ouvrir le dossier des carnets : {error} +@id ui.template_study_guide Guide d'étude +@id ui.template_category_mine Mes modèles +@id ui.template_meeting_notes Notes de réunion +@id ui.template_category_academic Universitaire +@id ui.template_category_blank Vierge +@id ui.template_category_planners Planificateurs +@id ui.template_to_do_list Liste de tâches +@id ui.template_grid Quadrillé +@id ui.template_lecture_notes Notes de cours +@id ui.template_project_overview Vue d'ensemble du projet +@id ui.template_college_ruled Ligné +@id ui.template_weekly_planner Planificateur hebdomadaire +@id ui.template_category_business Affaires diff --git a/i18n/he.tsv b/i18n/he.tsv index c936ddb8..63357ac7 100644 --- a/i18n/he.tsv +++ b/i18n/he.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed תיקיית המחברות עכשיו היא {folder}. @id ui.could_not_save_the_notebooks_folder_error לא ניתן לשמור את תיקיית המחברות: {error} @id ui.could_not_open_the_notebooks_folder_error לא ניתן לפתוח את תיקיית המחברות: {error} +@id ui.template_study_guide מדריך לימוד +@id ui.template_category_mine התבניות שלי +@id ui.template_meeting_notes הערות פגישה +@id ui.template_category_academic אקדמי +@id ui.template_category_blank ריק +@id ui.template_category_planners מתכננים +@id ui.template_to_do_list רשימת משימות +@id ui.template_grid רשת +@id ui.template_lecture_notes הערות הרצאה +@id ui.template_project_overview סקירת פרויקט +@id ui.template_college_ruled משובץ שורות +@id ui.template_weekly_planner מתכנן שבועי +@id ui.template_category_business עסקים diff --git a/i18n/hi.tsv b/i18n/hi.tsv index bc5cfb0e..c62ca91c 100644 --- a/i18n/hi.tsv +++ b/i18n/hi.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed नोटबुक फ़ोल्डर अब {folder} है। @id ui.could_not_save_the_notebooks_folder_error नोटबुक फ़ोल्डर सहेजा नहीं जा सका: {error} @id ui.could_not_open_the_notebooks_folder_error नोटबुक फ़ोल्डर खोला नहीं जा सका: {error} +@id ui.template_study_guide अध्ययन मार्गदर्शिका +@id ui.template_category_mine मेरे टेम्पलेट +@id ui.template_meeting_notes बैठक नोट्स +@id ui.template_category_academic शैक्षणिक +@id ui.template_category_blank खाली +@id ui.template_category_planners योजनाकार +@id ui.template_to_do_list करने की सूची +@id ui.template_grid ग्रिड +@id ui.template_lecture_notes व्याख्यान नोट्स +@id ui.template_project_overview परियोजना अवलोकन +@id ui.template_college_ruled रूल्ड +@id ui.template_weekly_planner साप्ताहिक योजनाकार +@id ui.template_category_business व्यवसाय diff --git a/i18n/ja.tsv b/i18n/ja.tsv index c1693d52..664ff3f6 100644 --- a/i18n/ja.tsv +++ b/i18n/ja.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed ノートブックのフォルダは {folder} になりました。 @id ui.could_not_save_the_notebooks_folder_error ノートブックのフォルダを保存できませんでした: {error} @id ui.could_not_open_the_notebooks_folder_error ノートブックのフォルダを開けませんでした: {error} +@id ui.template_study_guide 学習ガイド +@id ui.template_category_mine マイテンプレート +@id ui.template_meeting_notes 会議メモ +@id ui.template_category_academic 学術 +@id ui.template_category_blank 白紙 +@id ui.template_category_planners プランナー +@id ui.template_to_do_list ToDoリスト +@id ui.template_grid グリッド +@id ui.template_lecture_notes 講義ノート +@id ui.template_project_overview プロジェクト概要 +@id ui.template_college_ruled 罫線 +@id ui.template_weekly_planner 週間プランナー +@id ui.template_category_business ビジネス diff --git a/i18n/ko.tsv b/i18n/ko.tsv index bfc7e65d..d9c8ed95 100644 --- a/i18n/ko.tsv +++ b/i18n/ko.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed 노트북 폴더가 이제 {folder}입니다. @id ui.could_not_save_the_notebooks_folder_error 노트북 폴더를 저장할 수 없습니다: {error} @id ui.could_not_open_the_notebooks_folder_error 노트북 폴더를 열 수 없습니다: {error} +@id ui.template_study_guide 학습 가이드 +@id ui.template_category_mine 내 템플릿 +@id ui.template_meeting_notes 회의 노트 +@id ui.template_category_academic 학술 +@id ui.template_category_blank 빈 페이지 +@id ui.template_category_planners 플래너 +@id ui.template_to_do_list 할 일 목록 +@id ui.template_grid 격자 +@id ui.template_lecture_notes 강의 노트 +@id ui.template_project_overview 프로젝트 개요 +@id ui.template_college_ruled 줄 노트 +@id ui.template_weekly_planner 주간 플래너 +@id ui.template_category_business 비즈니스 diff --git a/i18n/ru.tsv b/i18n/ru.tsv index de9be636..c712685a 100644 --- a/i18n/ru.tsv +++ b/i18n/ru.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed Папка блокнотов теперь: {folder}. @id ui.could_not_save_the_notebooks_folder_error Не удалось сохранить папку блокнотов: {error} @id ui.could_not_open_the_notebooks_folder_error Не удалось открыть папку блокнотов: {error} +@id ui.template_study_guide Учебное пособие +@id ui.template_category_mine Мои шаблоны +@id ui.template_meeting_notes Заметки о встрече +@id ui.template_category_academic Академические +@id ui.template_category_blank Пустые +@id ui.template_category_planners Планировщики +@id ui.template_to_do_list Список дел +@id ui.template_grid Клетка +@id ui.template_lecture_notes Конспект лекции +@id ui.template_project_overview Обзор проекта +@id ui.template_college_ruled В линейку +@id ui.template_weekly_planner Недельный планировщик +@id ui.template_category_business Деловые diff --git a/i18n/ur.tsv b/i18n/ur.tsv index 0b58a9e8..26034f7b 100644 --- a/i18n/ur.tsv +++ b/i18n/ur.tsv @@ -825,3 +825,16 @@ @id ui.notebooks_folder_changed نوٹ بکس کا فولڈر اب {folder} ہے۔ @id ui.could_not_save_the_notebooks_folder_error نوٹ بکس کا فولڈر محفوظ نہیں ہو سکا: {error} @id ui.could_not_open_the_notebooks_folder_error نوٹ بکس کا فولڈر نہیں کھولا جا سکا: {error} +@id ui.template_study_guide مطالعاتی رہنما +@id ui.template_category_mine میرے ٹیمپلیٹس +@id ui.template_meeting_notes میٹنگ نوٹس +@id ui.template_category_academic تعلیمی +@id ui.template_category_blank خالی +@id ui.template_category_planners منصوبہ بندی +@id ui.template_to_do_list کاموں کی فہرست +@id ui.template_grid گرڈ +@id ui.template_lecture_notes لیکچر نوٹس +@id ui.template_project_overview منصوبے کا جائزہ +@id ui.template_college_ruled لکیر دار +@id ui.template_weekly_planner ہفتہ وار منصوبہ ساز +@id ui.template_category_business کاروبار diff --git a/i18n/zh.tsv b/i18n/zh.tsv index 20d13d3b..c902741f 100644 --- a/i18n/zh.tsv +++ b/i18n/zh.tsv @@ -828,3 +828,16 @@ @id ui.notebooks_folder_changed 笔记本文件夹现在是 {folder}。 @id ui.could_not_save_the_notebooks_folder_error 无法保存笔记本文件夹:{error} @id ui.could_not_open_the_notebooks_folder_error 无法打开笔记本文件夹:{error} +@id ui.template_study_guide 学习指南 +@id ui.template_category_mine 我的模板 +@id ui.template_meeting_notes 会议记录 +@id ui.template_category_academic 学术 +@id ui.template_category_blank 空白 +@id ui.template_category_planners 计划 +@id ui.template_to_do_list 待办清单 +@id ui.template_grid 网格 +@id ui.template_lecture_notes 课堂笔记 +@id ui.template_project_overview 项目概览 +@id ui.template_college_ruled 横线 +@id ui.template_weekly_planner 周计划 +@id ui.template_category_business 商务 From 3bea87eac262d83e3ae4199133bfbc65f543f4b2 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 08:52:27 -0800 Subject: [PATCH 03/19] feat(ui): page thumbnails in the Templates pane Each template in the Templates pane shows a small page drawn from its own words and paper, in theme colours. The layout is read from the template's Markdown, so it matches the page the template makes. The list scrolls; the page test scrolls it to the new template before picking it. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/src/app.rs | 38 +++-- crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/template_thumb.rs | 208 +++++++++++++++++++++++++++ crates/ui-egui/tests/ui.rs | 13 ++ 4 files changed, 251 insertions(+), 9 deletions(-) create mode 100644 crates/ui-egui/src/template_thumb.rs diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index f2296a59..9e33e7c9 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -12215,7 +12215,9 @@ impl NoteCraftApp { }); ui.label(egui::RichText::new(crate::tl_id!("ui.page_templates_hint")).small().color(tokens.muted)); ui.separator(); - let list_height = (ui.available_height() - 110.0).max(120.0); + // The sections under the list (the section's default template, and saving a page as a + // template) need about 230 points, so the list gives them that room. + let list_height = (ui.available_height() - 230.0).max(120.0); egui::ScrollArea::vertical().id_salt("page-templates-list").max_height(list_height).auto_shrink([false, true]).show(ui, |ui| { for category in notecraft_store::page_templates::Category::ALL { let mut items = pane.templates.iter().filter(|t| t.category == category).peekable(); @@ -12231,18 +12233,36 @@ impl NoteCraftApp { for template in items { let label = if mine { template.name.clone() } else { crate::tl!(&template.name).to_string() }; let width = ui.available_width().max(60.0); - let (rect, row) = ui.allocate_exact_size(vec2(width, 24.0), Sense::click()); + let (rect, row) = ui.allocate_exact_size(vec2(width, 44.0), Sense::click()); row.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label.clone())); if row.hovered() { ui.painter().rect_filled(rect, 3.0, tokens.row_hover); } - ui.painter().text( - rect.left_center() + vec2(10.0, 0.0), - egui::Align2::LEFT_CENTER, - &label, - egui::FontId::proportional(13.5), - tokens.text, - ); + // The thumbnail is the page the template makes: its own words and paper. + let (body, paper) = match &template.source { + notecraft_store::page_templates::Source::BuiltIn(b) => (b.body, b.paper), + notecraft_store::page_templates::Source::Saved(_) => ("", None), + }; + let rtl = ui.layout().prefer_right_to_left(); + let colours = crate::template_thumb::Colours { + page: tokens.editor, + rule: tokens.rule_line, + words: tokens.muted, + heading: tokens.accent, + edge: tokens.container_border, + }; + let thumb = if rtl { + egui::Rect::from_min_size(rect.right_top() + vec2(-40.0, 3.0), vec2(32.0, 38.0)) + } else { + egui::Rect::from_min_size(rect.left_top() + vec2(6.0, 3.0), vec2(32.0, 38.0)) + }; + crate::template_thumb::paint(ui.painter(), thumb, body, crate::template_thumb::paper_for(paper), colours, rtl); + let (anchor, align) = if rtl { + (rect.right_center() - vec2(50.0, 0.0), egui::Align2::RIGHT_CENTER) + } else { + (rect.left_center() + vec2(50.0, 0.0), egui::Align2::LEFT_CENTER) + }; + ui.painter().text(anchor, align, &label, egui::FontId::proportional(13.5), tokens.text); if row.on_hover_text(crate::tl_id!("ui.add_a_page_from_this_template")).clicked() { chosen = Some((template.id.clone(), label)); } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4e7f2b00..424c14a2 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -82,6 +82,7 @@ pub mod sectiontabs; pub mod snippets; pub mod stylus; pub mod telemetry_export; +pub mod template_thumb; #[cfg(test)] mod testing_dir; pub mod textcolour; diff --git a/crates/ui-egui/src/template_thumb.rs b/crates/ui-egui/src/template_thumb.rs new file mode 100644 index 00000000..78ed2290 --- /dev/null +++ b/crates/ui-egui/src/template_thumb.rs @@ -0,0 +1,208 @@ +//! Thumbnails for the Templates pane: a small page drawn from a template's own words and paper, +//! in NoteCraft's colours, so the pane shows what a new page will look like without any image +//! files. The layout comes from the template's Markdown body, so a thumbnail always matches the +//! page the template makes. + +use egui::{Color32, Painter, Pos2, Rect, Stroke, pos2, vec2}; + +/// One thing on the thumbnail, from one line of the template's words. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Mark { + /// A `#` or `##` heading: a short, dark bar. + Heading, + /// A plain line of words: a long, light bar. + Line, + /// A bullet point, as a dot and a bar. + Bullet, + /// A numbered item, as a small number and a bar. + Number, + /// A to-do item: a box, filled when checked. + Check { checked: bool }, + /// A table, as the number of rows it has. + Table { rows: usize }, + /// A blank line: a gap. + Gap, +} + +/// The marks for a template's Markdown body, in order. A table's rows are one mark. +pub fn marks(body: &str) -> Vec { + let mut out: Vec = Vec::new(); + for raw in body.lines() { + let line = raw.trim(); + if line.starts_with('|') { + match out.last_mut() { + Some(Mark::Table { rows }) => *rows += 1, + _ => out.push(Mark::Table { rows: 1 }), + } + continue; + } + let mark = if line.is_empty() { + Mark::Gap + } else if line.starts_with("# ") || line.starts_with("## ") || line == "#" || line == "##" { + Mark::Heading + } else if line.starts_with("- [ ]") { + Mark::Check { checked: false } + } else if line.starts_with("- [x]") || line.starts_with("- [X]") { + Mark::Check { checked: true } + } else if line.starts_with("- ") || line == "-" { + Mark::Bullet + } else if line.split_once(". ").is_some_and(|(n, _)| !n.is_empty() && n.chars().all(|c| c.is_ascii_digit())) { + Mark::Number + } else { + Mark::Line + }; + out.push(mark); + } + out +} + +/// The paper a thumbnail is drawn on. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Paper { + Plain, + Ruled, + Grid, +} + +/// The paper for a template's paper name, as `page.paper` writes it. +pub fn paper_for(name: Option<&str>) -> Paper { + match name { + Some("grid-medium") | Some("grid") => Paper::Grid, + Some(_) => Paper::Ruled, + None => Paper::Plain, + } +} + +/// The colours a thumbnail is drawn in. They come from the theme, so every theme gets a readable +/// thumbnail. +#[derive(Clone, Copy, Debug)] +pub struct Colours { + pub page: Color32, + pub rule: Color32, + pub words: Color32, + pub heading: Color32, + pub edge: Color32, +} + +/// Paints the template's page into `rect`: the paper, then its marks from the top down, stopping +/// where the page ends. A right-to-left layout draws the marks from the right edge. +pub fn paint(painter: &Painter, rect: Rect, body: &str, paper: Paper, colours: Colours, rtl: bool) { + painter.rect_filled(rect, 2.0, colours.page); + painter.rect_stroke(rect, 2.0, Stroke::new(1.0, colours.edge), egui::StrokeKind::Inside); + let step = 6.0; + let inner = rect.shrink(4.0); + match paper { + Paper::Plain => {} + Paper::Ruled => { + let mut y = inner.top() + 12.0; + while y < inner.bottom() { + painter.line_segment([pos2(inner.left(), y), pos2(inner.right(), y)], Stroke::new(0.5, colours.rule)); + y += step; + } + } + Paper::Grid => { + let mut y = inner.top(); + while y < inner.bottom() { + painter.line_segment([pos2(inner.left(), y), pos2(inner.right(), y)], Stroke::new(0.5, colours.rule)); + y += step; + } + let mut x = inner.left(); + while x < inner.right() { + painter.line_segment([pos2(x, inner.top()), pos2(x, inner.bottom())], Stroke::new(0.5, colours.rule)); + x += step; + } + } + } + let mut y = inner.top() + 2.0; + let x_at = |offset: f32| -> f32 { if rtl { inner.right() - offset } else { inner.left() + offset } }; + // The bar for one line of words, starting `from` in from the margin and `len` long, at height `at`. + let span = |at: f32, from: f32, len: f32| -> [Pos2; 2] { + let a = x_at(from); + let b = if rtl { a - len } else { a + len }; + [pos2(a, at + 2.0), pos2(b, at + 2.0)] + }; + for mark in marks(body) { + if y > inner.bottom() - 3.0 { + break; + } + match mark { + Mark::Gap => y += 3.0, + Mark::Heading => { + painter.line_segment(span(y, 0.0, inner.width() * 0.7), Stroke::new(2.4, colours.heading)); + y += 6.0; + } + Mark::Line => { + painter.line_segment(span(y, 0.0, inner.width()), Stroke::new(1.2, colours.words)); + y += 4.0; + } + Mark::Bullet => { + painter.circle_filled(pos2(x_at(1.5), y + 2.0), 1.2, colours.words); + painter.line_segment(span(y, 5.0, inner.width() - 5.0), Stroke::new(1.2, colours.words)); + y += 4.5; + } + Mark::Number => { + painter.line_segment(span(y, 6.0, inner.width() - 6.0), Stroke::new(1.2, colours.words)); + y += 4.5; + } + Mark::Check { checked } => { + let b = if rtl { + Rect::from_min_size(pos2(x_at(4.0) - 3.0, y), vec2(3.0, 3.0)) + } else { + Rect::from_min_size(pos2(x_at(0.0), y), vec2(3.0, 3.0)) + }; + painter.rect_stroke(b, 0.5, Stroke::new(0.8, colours.words), egui::StrokeKind::Inside); + if checked { + painter.rect_filled(b.shrink(0.8), 0.0, colours.heading); + } + painter.line_segment(span(y, 5.0, inner.width() - 5.0), Stroke::new(1.2, colours.words)); + y += 4.5; + } + Mark::Table { rows } => { + let h = (rows as f32) * 3.0; + let table = Rect::from_min_max(pos2(inner.left(), y), pos2(inner.right(), (y + h).min(inner.bottom()))); + painter.rect_stroke(table, 0.0, Stroke::new(0.6, colours.words), egui::StrokeKind::Inside); + y += h + 2.0; + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use notecraft_store::page_templates::BUILT_IN; + + #[test] + fn headings_bullets_and_checks_are_read_from_the_words() { + let got = marks("## Key ideas\n\n- one\n- [ ] two\n- [x] three\n1. four\nplain words\n"); + assert_eq!( + got, + vec![Mark::Heading, Mark::Gap, Mark::Bullet, Mark::Check { checked: false }, Mark::Check { checked: true }, Mark::Number, Mark::Line,] + ); + } + + #[test] + fn a_table_is_one_mark_with_its_rows_counted() { + let got = marks("| Term | Meaning |\n| --- | --- |\n| | |\n"); + assert_eq!(got, vec![Mark::Table { rows: 3 }]); + } + + #[test] + fn every_built_in_template_has_a_thumbnail_to_draw() { + for template in BUILT_IN { + let got = marks(template.body); + if template.body.is_empty() { + assert!(got.is_empty(), "{} is only paper", template.id); + } else { + assert!(!got.is_empty(), "{} has words, so it has marks", template.id); + } + } + } + + #[test] + fn paper_names_map_to_the_three_papers() { + assert_eq!(paper_for(None), Paper::Plain); + assert_eq!(paper_for(Some("college")), Paper::Ruled); + assert_eq!(paper_for(Some("grid-medium")), Paper::Grid); + } +} diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 98c17046..76abc8c9 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -13695,6 +13695,19 @@ fn page_templates_add_pages_and_keep_this_page_as_one() { assert_eq!(mine[0]["name"], json!("Idea board")); review(&mut h, "page_templates_saved"); + // The list of templates scrolls: the new template is at its end, so scroll it into view as a + // person would, with the pointer over the list (above the name field). + let field = h.get_by_label("Template name").rect().center(); + h.input_mut().events.push(egui::Event::PointerMoved(egui::pos2(field.x, field.y - 120.0))); + pump(&mut h); + h.input_mut().events.push(egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(0.0, -2000.0), + phase: egui::TouchPhase::Move, + source: egui::MouseWheelSource::Wheel, + modifiers: egui::Modifiers::NONE, + }); + settle(&mut h); h.get_by_label("Idea board").click(); settle(&mut h); let (copy, _, _) = page(&mut h); From 397d3134ed135a735de298d6787f68efdf71e125 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 09:30:33 -0800 Subject: [PATCH 04/19] feat(ui): language button shows a globe and the code The title bar's language button is a monochrome Fluent globe in the band's text colour, with the two-letter code beside it, in place of the flag chip. The menu is unchanged. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/assets/fluent/globe.svg | 3 +++ crates/ui-egui/src/app.rs | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 crates/ui-egui/assets/fluent/globe.svg diff --git a/crates/ui-egui/assets/fluent/globe.svg b/crates/ui-egui/assets/fluent/globe.svg new file mode 100644 index 00000000..fff4c4e7 --- /dev/null +++ b/crates/ui-egui/assets/fluent/globe.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 9e33e7c9..43efbc31 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -11364,13 +11364,18 @@ impl NoteCraftApp { let active_name = languages.iter().find(|language| language.code == active_code).map_or_else(|| active_code.clone(), |language| language.name.clone()); let label = crate::i18n::format_message_id("ui.interface_language_language", &[("language", &active_name)]); - let (rect, resp) = ui.allocate_exact_size(vec2(30.0, 24.0), Sense::click()); + let (rect, resp) = ui.allocate_exact_size(vec2(58.0, 24.0), Sense::click()); if resp.hovered() { ui.painter().rect_filled(rect, 4.0, tokens.row_hover); } - // Centred in the button, so the chip sits with equal space on each side. - let flag_rect = egui::Rect::from_center_size(rect.center(), vec2(20.0, 14.0)); - crate::language_flag::paint_at(ui, flag_rect, &active_code); + // A monochrome Fluent globe in the title bar's text colour, then the language's two-letter + // code (the part before any dash, so "en-XA" shows "EN"). + let globe = egui::Rect::from_min_size(rect.left_top() + vec2(6.0, 4.0), vec2(16.0, 16.0)); + crate::icons::coloured_svg("globe", include_bytes!("../assets/fluent/globe.svg"), tokens.band_text) + .fit_to_exact_size(globe.size()) + .paint_at(ui, globe); + let short = active_code.split('-').next().unwrap_or(&active_code).to_uppercase(); + ui.painter().text(rect.left_center() + vec2(26.0, 0.0), egui::Align2::LEFT_CENTER, short, egui::FontId::proportional(12.5), tokens.band_text); let enabled = ui.is_enabled(); resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, &label)); let tip = crate::i18n::format_message_id("ui.language_click_to_change_it", &[("language", &active_name)]); From 6644e6a02113a555f70851ddb7f89c47c45b8bc9 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 10:04:57 -0800 Subject: [PATCH 05/19] feat(ui): Fluent icons for Cut, Copy and Format Painter Format Painter uses the Fluent colour paint brush. Cut and Copy use the Fluent 16px monochrome icons, which are drawn for small controls. Co-Authored-By: Claude Haiku 5.5 --- .../assets/fluent-color/paint_brush.svg | 29 +++++++++++++++++++ crates/ui-egui/assets/fluent/copy16.svg | 3 ++ crates/ui-egui/assets/fluent/cut16.svg | 3 ++ crates/ui-egui/src/icons.rs | 12 ++++++++ crates/ui-egui/src/ribbon.rs | 9 +++++- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/assets/fluent-color/paint_brush.svg create mode 100644 crates/ui-egui/assets/fluent/copy16.svg create mode 100644 crates/ui-egui/assets/fluent/cut16.svg diff --git a/crates/ui-egui/assets/fluent-color/paint_brush.svg b/crates/ui-egui/assets/fluent-color/paint_brush.svg new file mode 100644 index 00000000..c7504ed6 --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/paint_brush.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/ui-egui/assets/fluent/copy16.svg b/crates/ui-egui/assets/fluent/copy16.svg new file mode 100644 index 00000000..ff9bcc0e --- /dev/null +++ b/crates/ui-egui/assets/fluent/copy16.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui-egui/assets/fluent/cut16.svg b/crates/ui-egui/assets/fluent/cut16.svg new file mode 100644 index 00000000..5cd955e3 --- /dev/null +++ b/crates/ui-egui/assets/fluent/cut16.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 8b9fa38c..6cc11ec0 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -656,6 +656,18 @@ pub fn paint_paste(ui: &Ui, rect: Rect, enabled: bool) { .paint_at(ui, rect); } +/// A Fluent colour icon in its own colours, for a small control. It is only faded when the control +/// is disabled. +pub fn paint_colour_svg(ui: &Ui, rect: Rect, name: &'static str, bytes: &'static [u8], enabled: bool) { + let tint = if enabled { Color32::WHITE } else { Color32::from_white_alpha(90) }; + egui::Image::from_bytes(format!("bytes://notecraft-fluent-color/{name}.svg"), bytes).fit_to_exact_size(rect.size()).tint(tint).paint_at(ui, rect); +} + +/// A monochrome Fluent icon in `colour`, for a small control. +pub fn paint_mono_svg(ui: &Ui, rect: Rect, name: &str, bytes: &[u8], colour: Color32) { + coloured_svg(name, bytes, colour).fit_to_exact_size(rect.size()).paint_at(ui, rect); +} + /// A monochrome Fluent icon drawn in `colour`. The SVG is drawn in one near-black, and a tint /// can only multiply that, so it can never show a light icon. The colour is written into the /// file instead, and the picture is keyed by that colour so each colour is loaded once. diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 43301051..9f9d8413 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -2801,7 +2801,14 @@ fn mark_row_on(ui: &mut Ui, mark: Mark, label: &str, tip: &str, on: bool, t: &To let painter = ui.painter_at(rect); small_back(&painter, rect, &resp, on, t); let left = Rect::from_center_size(egui::pos2(rect.min.x + 11.0, rect.center().y), vec2(15.0, 15.0)); - ribbon_icons::paint(&painter, left, mark, mark.color(t.text, t.accent)); + // Fluent icons where NoteCraft has them: Format Painter in colour, Cut and Copy in monochrome + // at the 16px size Fluent draws for small controls. + match mark { + Mark::Painter => icons::paint_colour_svg(ui, left, "paint_brush", include_bytes!("../assets/fluent-color/paint_brush.svg"), ui.is_enabled()), + Mark::Cut => icons::paint_mono_svg(ui, left, "cut16", include_bytes!("../assets/fluent/cut16.svg"), t.text), + Mark::Copy => icons::paint_mono_svg(ui, left, "copy16", include_bytes!("../assets/fluent/copy16.svg"), t.text), + _ => ribbon_icons::paint(&painter, left, mark, mark.color(t.text, t.accent)), + } painter.text(egui::pos2(rect.min.x + 23.0, rect.center().y), Align2::LEFT_CENTER, label, font, t.text); let enabled = ui.is_enabled(); let name = label.to_string(); From 9971122175b99b4776152797aa2d2b30e03c7496 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 10:54:38 -0800 Subject: [PATCH 06/19] docs(demo): page templates page in all 14 languages Adds a Page templates page to the demo notebook in each of its 14 languages, in both HTML and CMGFM, and updates the parity test's page count. Co-Authored-By: Claude Haiku 5.5 --- crates/formats/tests/format_parity.rs | 4 +-- .../10-en/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../11-es/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../12-fr/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../13-de/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../14-hi/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../15-ru/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../16-zh/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../17-ja/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../18-ko/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../19-tr/how-to/page-templates/index.md | 26 ++++++++++++++++++ .../20-ar/how-to/page-templates/index.md | 27 +++++++++++++++++++ .../21-fa/how-to/page-templates/index.md | 27 +++++++++++++++++++ .../22-ur/how-to/page-templates/index.md | 27 +++++++++++++++++++ .../23-he/how-to/page-templates/index.md | 27 +++++++++++++++++++ .../10-en/how-to/page-templates/index.html | 22 +++++++++++++++ .../11-es/how-to/page-templates/index.html | 22 +++++++++++++++ .../12-fr/how-to/page-templates/index.html | 22 +++++++++++++++ .../13-de/how-to/page-templates/index.html | 22 +++++++++++++++ .../14-hi/how-to/page-templates/index.html | 22 +++++++++++++++ .../15-ru/how-to/page-templates/index.html | 22 +++++++++++++++ .../16-zh/how-to/page-templates/index.html | 22 +++++++++++++++ .../17-ja/how-to/page-templates/index.html | 22 +++++++++++++++ .../18-ko/how-to/page-templates/index.html | 22 +++++++++++++++ .../19-tr/how-to/page-templates/index.html | 22 +++++++++++++++ .../20-ar/how-to/page-templates/index.html | 23 ++++++++++++++++ .../21-fa/how-to/page-templates/index.html | 23 ++++++++++++++++ .../22-ur/how-to/page-templates/index.html | 23 ++++++++++++++++ .../23-he/how-to/page-templates/index.html | 23 ++++++++++++++++ .../scripts/content/ar/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/de/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/en/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/es/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/fa/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/fr/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/he/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/hi/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/ja/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/ko/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/ru/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/tr/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/ur/28-page-templates.md | 23 ++++++++++++++++ .../scripts/content/zh/28-page-templates.md | 23 ++++++++++++++++ 43 files changed, 1004 insertions(+), 2 deletions(-) create mode 100644 docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-templates/index.md create mode 100644 docs/demo/DemoNotebook/html/10-en/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/11-es/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/12-fr/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/13-de/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/14-hi/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/15-ru/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/16-zh/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/17-ja/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/18-ko/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/19-tr/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/20-ar/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/21-fa/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/22-ur/how-to/page-templates/index.html create mode 100644 docs/demo/DemoNotebook/html/23-he/how-to/page-templates/index.html create mode 100644 docs/demo/scripts/content/ar/28-page-templates.md create mode 100644 docs/demo/scripts/content/de/28-page-templates.md create mode 100644 docs/demo/scripts/content/en/28-page-templates.md create mode 100644 docs/demo/scripts/content/es/28-page-templates.md create mode 100644 docs/demo/scripts/content/fa/28-page-templates.md create mode 100644 docs/demo/scripts/content/fr/28-page-templates.md create mode 100644 docs/demo/scripts/content/he/28-page-templates.md create mode 100644 docs/demo/scripts/content/hi/28-page-templates.md create mode 100644 docs/demo/scripts/content/ja/28-page-templates.md create mode 100644 docs/demo/scripts/content/ko/28-page-templates.md create mode 100644 docs/demo/scripts/content/ru/28-page-templates.md create mode 100644 docs/demo/scripts/content/tr/28-page-templates.md create mode 100644 docs/demo/scripts/content/ur/28-page-templates.md create mode 100644 docs/demo/scripts/content/zh/28-page-templates.md diff --git a/crates/formats/tests/format_parity.rs b/crates/formats/tests/format_parity.rs index 078117a4..314dad50 100644 --- a/crates/formats/tests/format_parity.rs +++ b/crates/formats/tests/format_parity.rs @@ -54,8 +54,8 @@ fn the_full_demo_notebooks_have_matching_pages_and_blocks() { let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("..").join("docs").join("demo").join("DemoNotebook"); let html = pages(&root.join("html")); let cmgfm = pages(&root.join("cmgfm")); - // The demo has 240 base pages, 182 OCR pages (13 per language with OCR content), and a menus page in each of its 14 languages. - assert_eq!(html.len(), 436, "expected every page from the 14-language demo"); + // The demo has 254 base pages (including the Page templates page in each of its 14 languages), 182 OCR pages (13 per language with OCR content), and a menus page in each of its 14 languages. + assert_eq!(html.len(), 450, "expected every page from the 14-language demo"); assert_eq!(html.len(), cmgfm.len(), "both notebooks must have the same number of pages"); assert_eq!(html.keys().collect::>(), cmgfm.keys().collect::>(), "page paths must match"); for language in ["10-en", "11-es", "12-fr", "13-de", "14-hi", "15-ru", "16-zh", "17-ja", "18-ko", "19-tr", "20-ar", "21-fa", "22-ur", "23-he"] { diff --git a/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-templates/index.md new file mode 100644 index 00000000..9b326b1c --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 2560ca3512ffce4381e3 +title: "Page templates" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Insert > Page Templates adds a page that already has its structure: lecture notes, a to-do list, a weekly planner, and more. Each template shows a small picture of its page, so you can see the layout before you pick it. + +## Start from a template + +Click **Insert**, then **Page Templates**. The templates are grouped as Academic, Blank, Business and Planners. Click one to add a page to the open section. + +## Keep your own + +Open a page you like, type a name under **Save current page as a template**, and press **Save as template**. Your templates appear under **My Templates**. + +A template is a copy of its page, so the words, pictures and files come with it. Subpages do not. + +## Always use a template + +The **Always use a template** box in the pane picks the template that every new page in the section starts from. + +Templates are plain files too, so you can read and copy them like any other page. diff --git a/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-templates/index.md new file mode 100644 index 00000000..eac9636b --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: f987798b8268b889bc6d +title: "Plantillas de página" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Insertar > Plantillas de página añade una página que ya tiene su estructura: apuntes de clase, una lista de tareas, un planificador semanal y más. Cada plantilla muestra una imagen pequeña de su página para que veas el diseño antes de elegirla. + +## Empezar desde una plantilla + +Haz clic en **Insertar** y luego en **Plantillas de página**. Las plantillas están agrupadas en Académico, En blanco, Negocios y Planificadores. Haz clic en una para añadir una página a la sección abierta. + +## Guardar las tuyas + +Abre una página que te guste, escribe un nombre debajo de **Guardar la página actual como plantilla** y pulsa **Guardar como plantilla**. Tus plantillas aparecen en **Mis plantillas**. + +Una plantilla es una copia de su página, así que las palabras, imágenes y archivos vienen con ella. Las subpáginas no. + +## Usar siempre una plantilla + +El cuadro **Usar siempre una plantilla** del panel elige la plantilla desde la que empieza cada página nueva de la sección. + +Las plantillas también son archivos normales, así que puedes leerlas y copiarlas como cualquier otra página. diff --git a/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-templates/index.md new file mode 100644 index 00000000..f6d2342d --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: ff92a7c27aac06f2083a +title: "Modèles de page" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Insertion > Modèles de page ajoute une page qui a déjà sa structure : notes de cours, liste de tâches, planificateur hebdomadaire et autres. Chaque modèle montre une petite image de sa page, pour que vous voyiez la mise en page avant de le choisir. + +## Partir d'un modèle + +Cliquez sur **Insertion**, puis sur **Modèles de page**. Les modèles sont regroupés en Universitaire, Vierge, Affaires et Planificateurs. Cliquez sur l'un d'eux pour ajouter une page à la section ouverte. + +## Garder les vôtres + +Ouvrez une page qui vous plaît, tapez un nom sous **Enregistrer la page actuelle comme modèle**, puis appuyez sur **Enregistrer comme modèle**. Vos modèles apparaissent sous **Mes modèles**. + +Un modèle est une copie de sa page : les mots, images et fichiers sont copiés avec lui. Les sous-pages ne le sont pas. + +## Toujours utiliser un modèle + +La zone **Toujours utiliser un modèle** du volet choisit le modèle à partir duquel chaque nouvelle page de la section est créée. + +Les modèles sont aussi des fichiers ordinaires : vous pouvez les lire et les copier comme n'importe quelle page. diff --git a/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-templates/index.md new file mode 100644 index 00000000..c81afad6 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: c5f8747a141d0530abac +title: "Seitenvorlagen" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Einfügen > Seitenvorlagen fügt eine Seite mit fertiger Struktur ein: Vorlesungsnotizen, eine Aufgabenliste, ein Wochenplaner und mehr. Jede Vorlage zeigt ein kleines Bild ihrer Seite, damit Sie das Layout sehen, bevor Sie wählen. + +## Mit einer Vorlage beginnen + +Klicken Sie auf **Einfügen** und dann auf **Seitenvorlagen**. Die Vorlagen sind nach Akademisch, Leer, Geschäftlich und Planer geordnet. Klicken Sie auf eine, um dem geöffneten Abschnitt eine Seite hinzuzufügen. + +## Eigene Vorlagen speichern + +Öffnen Sie eine Seite, die Ihnen gefällt, schreiben Sie unter **Aktuelle Seite als Vorlage speichern** einen Namen und drücken Sie **Als Vorlage speichern**. Ihre Vorlagen erscheinen unter **Meine Vorlagen**. + +Eine Vorlage ist eine Kopie ihrer Seite, Texte, Bilder und Dateien kommen also mit. Unterseiten nicht. + +## Immer eine Vorlage verwenden + +Das Feld **Immer eine Vorlage verwenden** im Bereich wählt die Vorlage, mit der jede neue Seite des Abschnitts beginnt. + +Vorlagen sind auch normale Dateien, Sie können sie also wie jede andere Seite lesen und kopieren. diff --git a/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-templates/index.md new file mode 100644 index 00000000..a6f4bede --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 1cfc1616f7cb9c0b04ab +title: "पेज टेम्पलेट" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +इन्सर्ट > पेज टेम्पलेट एक ऐसा पेज जोड़ता है जिसकी संरचना पहले से तैयार है: लेक्चर नोट्स, टू-डू सूची, साप्ताहिक योजना और भी बहुत कुछ। हर टेम्पलेट अपने पेज की एक छोटी तस्वीर दिखाता है, ताकि चुनने से पहले आप लेआउट देख सकें। + +## किसी टेम्पलेट से शुरू करें + +**इन्सर्ट** पर क्लिक करें, फिर **पेज टेम्पलेट** पर। टेम्पलेट शैक्षणिक, खाली, व्यवसाय और योजनाकार में बँटे हैं। खुले सेक्शन में पेज जोड़ने के लिए किसी एक पर क्लिक करें। + +## अपने टेम्पलेट रखें + +कोई पसंदीदा पेज खोलें, **मौजूदा पेज को टेम्पलेट के रूप में सहेजें** के नीचे नाम लिखें और **टेम्पलेट के रूप में सहेजें** दबाएँ। आपके टेम्पलेट **मेरे टेम्पलेट** में दिखेंगे। + +टेम्पलेट अपने पेज की प्रति होता है, इसलिए शब्द, तस्वीरें और फ़ाइलें उसके साथ आती हैं। उप-पेज नहीं आते। + +## हमेशा एक टेम्पलेट इस्तेमाल करें + +पैन का **हमेशा एक टेम्पलेट इस्तेमाल करें** बॉक्स चुनता है कि सेक्शन के हर नए पेज की शुरुआत किस टेम्पलेट से हो। + +टेम्पलेट भी सामान्य फ़ाइलें हैं, इसलिए आप उन्हें किसी दूसरे पेज की तरह पढ़ और कॉपी कर सकते हैं। diff --git a/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-templates/index.md new file mode 100644 index 00000000..798c051f --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: ae9da6029cf96014a420 +title: "Шаблоны страниц" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Вставка > Шаблоны страниц добавляет страницу, у которой уже есть структура: конспект лекции, список дел, недельный планировщик и другие. Каждый шаблон показывает небольшую картинку своей страницы, так что макет виден до выбора. + +## Начать с шаблона + +Нажмите **Вставка**, затем **Шаблоны страниц**. Шаблоны разделены на группы: Академические, Пустые, Деловые и Планировщики. Нажмите на шаблон, чтобы добавить страницу в открытый раздел. + +## Сохраните свои + +Откройте понравившуюся страницу, введите имя под **Сохранить текущую страницу как шаблон** и нажмите **Сохранить как шаблон**. Ваши шаблоны появятся в разделе **Мои шаблоны**. + +Шаблон - это копия страницы, поэтому слова, картинки и файлы попадают в него тоже. Вложенные страницы - нет. + +## Всегда использовать шаблон + +Поле **Всегда использовать шаблон** в панели выбирает шаблон, с которого начинается каждая новая страница раздела. + +Шаблоны - это обычные файлы, их можно читать и копировать, как любую другую страницу. diff --git a/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-templates/index.md new file mode 100644 index 00000000..df5e4d70 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 4ff71db0322a0d380d1c +title: "页面模板" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +插入 > 页面模板会添加一个已有结构的页面:讲座笔记、待办清单、每周计划等等。每个模板都显示其页面的小图,让你在选择前看到版式。 + +## 从模板开始 + +点击**插入**,然后点击**页面模板**。模板分为学术、空白、商务和计划四类。点击一个模板即可在打开的分区中添加页面。 + +## 保存你自己的模板 + +打开一个你喜欢的页面,在**将当前页面保存为模板**下输入名称,然后按**保存为模板**。你的模板会出现在**我的模板**下。 + +模板是页面的副本,所以其中的文字、图片和文件都会一起带上。子页面则不会。 + +## 始终使用模板 + +面板中的**始终使用模板**框决定该分区中每个新页面以哪个模板开始。 + +模板也是普通文件,你可以像阅读和复制其他页面一样读取和复制它们。 diff --git a/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-templates/index.md new file mode 100644 index 00000000..749b543b --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 6d2c4684489c4462873a +title: "ページテンプレート" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +挿入 > ページテンプレートでは、構成がすでに用意されたページを追加できます。講義ノート、ToDoリスト、週間プランナーなどがあります。各テンプレートにはページの小さな画像が表示されるので、選ぶ前にレイアウトを確認できます。 + +## テンプレートから始める + +**挿入**をクリックし、次に**ページテンプレート**をクリックします。テンプレートは学術、白紙、ビジネス、プランナーに分かれています。どれかをクリックすると、開いているセクションにページが追加されます。 + +## 自分のテンプレートを保存する + +気に入ったページを開き、**現在のページをテンプレートとして保存**の下に名前を入力して、**テンプレートとして保存**を押します。自分のテンプレートは**マイテンプレート**に表示されます。 + +テンプレートはページのコピーなので、文字、画像、ファイルも一緒に入ります。サブページは入りません。 + +## 常にテンプレートを使う + +パネルの**常にテンプレートを使う**欄で、そのセクションの新しいページがどのテンプレートから始まるかを選びます。 + +テンプレートも普通のファイルなので、ほかのページと同じように読んだりコピーしたりできます。 diff --git a/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-templates/index.md new file mode 100644 index 00000000..3eb7e3ed --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 50502efa36428d46068a +title: "페이지 템플릿" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +삽입 > 페이지 템플릿은 이미 구조가 갖춰진 페이지를 추가합니다. 강의 노트, 할 일 목록, 주간 계획표 등이 있습니다. 각 템플릿은 해당 페이지의 작은 그림을 보여 주므로, 고르기 전에 배치를 볼 수 있습니다. + +## 템플릿으로 시작하기 + +**삽입**을 클릭한 다음 **페이지 템플릿**을 클릭하세요. 템플릿은 학술, 빈 페이지, 비즈니스, 플래너로 나뉩니다. 하나를 클릭하면 열려 있는 섹션에 페이지가 추가됩니다. + +## 내 템플릿 저장하기 + +마음에 드는 페이지를 열고 **현재 페이지를 템플릿으로 저장** 아래에 이름을 입력한 다음 **템플릿으로 저장**을 누르세요. 저장한 템플릿은 **내 템플릿**에 나타납니다. + +템플릿은 페이지의 복사본이므로 글, 그림, 파일도 함께 들어갑니다. 하위 페이지는 들어가지 않습니다. + +## 항상 템플릿 사용 + +패널의 **항상 템플릿 사용** 상자는 섹션의 새 페이지가 어떤 템플릿으로 시작할지 정합니다. + +템플릿도 일반 파일이므로 다른 페이지처럼 읽고 복사할 수 있습니다. diff --git a/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-templates/index.md new file mode 100644 index 00000000..d1860746 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-templates/index.md @@ -0,0 +1,26 @@ +--- +id: 7cf063e431e6b7f3f18b +title: "Sayfa şablonları" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +tags: [] +--- + +Ekle > Sayfa Şablonları, zaten yapısı hazır bir sayfa ekler: ders notları, yapılacaklar listesi, haftalık planlayıcı ve daha fazlası. Her şablon sayfasının küçük bir resmini gösterir, böylece seçmeden önce düzeni görebilirsiniz. + +## Bir şablonla başlayın + +**Ekle** menüsünden **Sayfa Şablonları**'na tıklayın. Şablonlar Akademik, Boş, İş ve Planlayıcılar olarak gruplanmıştır. Açık bölüme sayfa eklemek için birine tıklayın. + +## Kendi şablonlarınızı saklayın + +Beğendiğiniz bir sayfayı açın, **Geçerli sayfayı şablon olarak kaydet** altına bir ad yazın ve **Şablon olarak kaydet**'e basın. Şablonlarınız **Şablonlarım** altında görünür. + +Bir şablon, sayfasının bir kopyasıdır; bu yüzden sözcükler, resimler ve dosyalar da onunla birlikte gelir. Alt sayfalar gelmez. + +## Her zaman bir şablon kullan + +Bölümdeki her yeni sayfanın hangi şablonla başlayacağını panelin **Her zaman bir şablon kullan** kutusu seçer. + +Şablonlar da sıradan dosyalardır; diğer sayfalar gibi okuyabilir ve kopyalayabilirsiniz. diff --git a/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-templates/index.md new file mode 100644 index 00000000..dd0c1f85 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-templates/index.md @@ -0,0 +1,27 @@ +--- +id: 910ef07c3a7401a6286e +title: "قوالب الصفحات" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +tags: [] +--- + +إدراج > قوالب الصفحات يضيف صفحة جاهزة البنية: ملاحظات محاضرة، وقائمة مهام، ومخطط أسبوعي، وغيرها. يعرض كل قالب صورة صغيرة لصفحته، فترى التخطيط قبل أن تختار. + +## ابدأ من قالب + +انقر **إدراج**، ثم **قوالب الصفحات**. القوالب مجمعة في أكاديمي وفارغ وأعمال ومخططات. انقر قالبًا لإضافة صفحة إلى القسم المفتوح. + +## احفظ قوالبك + +افتح صفحة تعجبك، واكتب اسمًا تحت **حفظ الصفحة الحالية كقالب**، ثم اضغط **حفظ كقالب**. تظهر قوالبك تحت **قوالبي**. + +القالب نسخة من صفحته، لذلك تأتي معه الكلمات والصور والملفات. الصفحات الفرعية لا تأتي. + +## استخدم قالبًا دائمًا + +يحدد المربع **استخدم قالبًا دائمًا** في اللوحة القالب الذي تبدأ منه كل صفحة جديدة في القسم. + +القوالب ملفات عادية أيضًا، يمكنك قراءتها ونسخها مثل أي صفحة أخرى. diff --git a/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-templates/index.md new file mode 100644 index 00000000..80b27a1a --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-templates/index.md @@ -0,0 +1,27 @@ +--- +id: 6b56ec0ce1110bbd14c5 +title: "الگوهای صفحه" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +tags: [] +--- + +درج > الگوهای صفحه صفحه‌ای می‌افزاید که ساختارش از پیش آماده است: یادداشت درس، فهرست کارها، برنامه‌ریز هفتگی و موارد دیگر. هر الگو تصویر کوچکی از صفحه‌اش را نشان می‌دهد تا پیش از انتخاب، چیدمان را ببینید. + +## از یک الگو شروع کنید + +روی **درج** و سپس **الگوهای صفحه** کلیک کنید. الگوها در دسته‌های آکادمیک، خالی، کسب‌وکار و برنامه‌ریزها قرار دارند. برای افزودن صفحه به بخش باز، روی یکی کلیک کنید. + +## الگوهای خودتان را نگه دارید + +صفحه‌ای را که دوست دارید باز کنید، زیر **ذخیره صفحه فعلی به‌عنوان الگو** نامی بنویسید و **ذخیره به‌عنوان الگو** را بزنید. الگوهای شما زیر **الگوهای من** ظاهر می‌شوند. + +الگو رونوشت صفحه‌اش است، پس متن‌ها، تصویرها و فایل‌ها همراهش می‌آیند. زیرصفحه‌ها نمی‌آیند. + +## همیشه از یک الگو استفاده کن + +کادر **همیشه از یک الگو استفاده کن** در پنل مشخص می‌کند که هر صفحه تازه در بخش با کدام الگو شروع شود. + +الگوها هم فایل‌های معمولی هستند، پس مانند هر صفحه دیگری می‌توانید آن‌ها را بخوانید و رونوشت کنید. diff --git a/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-templates/index.md new file mode 100644 index 00000000..f1483eef --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-templates/index.md @@ -0,0 +1,27 @@ +--- +id: f3f2013ae802df6474a8 +title: "صفحہ کے ٹیمپلیٹس" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +tags: [] +--- + +داخل کریں > صفحہ کے ٹیمپلیٹس ایک ایسا صفحہ شامل کرتا ہے جس کا ڈھانچہ پہلے سے تیار ہوتا ہے: لیکچر نوٹس، کاموں کی فہرست، ہفتہ وار منصوبہ اور مزید۔ ہر ٹیمپلیٹ اپنے صفحے کی ایک چھوٹی تصویر دکھاتا ہے تاکہ آپ انتخاب سے پہلے ترتیب دیکھ سکیں۔ + +## ٹیمپلیٹ سے شروع کریں + +**داخل کریں** پر کلک کریں، پھر **صفحہ کے ٹیمپلیٹس** پر۔ ٹیمپلیٹس تعلیمی، خالی، کاروباری اور منصوبہ بندی کے زمروں میں ہیں۔ کھلے سیکشن میں صفحہ شامل کرنے کے لیے کسی ایک پر کلک کریں۔ + +## اپنے ٹیمپلیٹس محفوظ کریں + +کوئی پسندیدہ صفحہ کھولیں، **موجودہ صفحہ کو ٹیمپلیٹ کے طور پر محفوظ کریں** کے نیچے نام لکھیں اور **ٹیمپلیٹ کے طور پر محفوظ کریں** دبائیں۔ آپ کے ٹیمپلیٹس **میرے ٹیمپلیٹس** میں ظاہر ہوں گے۔ + +ٹیمپلیٹ اپنے صفحے کی نقل ہوتا ہے، اس لیے اس کے الفاظ، تصویریں اور فائلیں بھی ساتھ آتی ہیں۔ ذیلی صفحات نہیں آتے۔ + +## ہمیشہ ٹیمپلیٹ استعمال کریں + +پینل کا **ہمیشہ ٹیمپلیٹ استعمال کریں** والا خانہ طے کرتا ہے کہ سیکشن کا ہر نیا صفحہ کس ٹیمپلیٹ سے شروع ہو۔ + +ٹیمپلیٹس بھی عام فائلیں ہیں، اس لیے آپ انہیں کسی بھی دوسرے صفحے کی طرح پڑھ اور نقل کر سکتے ہیں۔ diff --git a/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-templates/index.md b/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-templates/index.md new file mode 100644 index 00000000..61537c82 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-templates/index.md @@ -0,0 +1,27 @@ +--- +id: e37524abe17056813d89 +title: "תבניות עמוד" +order: 28 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +tags: [] +--- + +הוספה > תבניות עמוד מוסיף עמוד שהמבנה שלו כבר מוכן: הערות הרצאה, רשימת משימות, מתכנן שבועי ועוד. לכל תבנית יש תמונה קטנה של העמוד שלה, כדי שתראו את הפריסה לפני הבחירה. + +## התחלה מתבנית + +לחצו על **הוספה** ואחר כך על **תבניות עמוד**. התבניות מחולקות לקבוצות: אקדמי, ריק, עסקים ומתכננים. לחצו על אחת כדי להוסיף עמוד לקטע הפתוח. + +## שמרו את התבניות שלכם + +פתחו עמוד שאתם אוהבים, כתבו שם מתחת ל**שמירת העמוד הנוכחי כתבנית** ולחצו על **שמירה כתבנית**. התבניות שלכם יופיעו תחת **התבניות שלי**. + +תבנית היא עותק של העמוד שלה, ולכן המילים, התמונות והקבצים מגיעים איתה. תת-העמודים לא. + +## השתמשו תמיד בתבנית + +תיבת **השתמשו תמיד בתבנית** בחלונית קובעת את התבנית שממנה מתחיל כל עמוד חדש בקטע. + +גם התבניות הן קבצים רגילים, ואפשר לקרוא ולהעתיק אותן כמו כל עמוד אחר. diff --git a/docs/demo/DemoNotebook/html/10-en/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/10-en/how-to/page-templates/index.html new file mode 100644 index 00000000..d7bbcc76 --- /dev/null +++ b/docs/demo/DemoNotebook/html/10-en/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Page templates + + + + + + +

Insert > Page Templates adds a page that already has its structure: lecture notes, a to-do list, a weekly planner, and more. Each template shows a small picture of its page, so you can see the layout before you pick it.

+

Start from a template

+

Click Insert, then Page Templates. The templates are grouped as Academic, Blank, Business and Planners. Click one to add a page to the open section.

+

Keep your own

+

Open a page you like, type a name under Save current page as a template, and press Save as template. Your templates appear under My Templates.

+

A template is a copy of its page, so the words, pictures and files come with it. Subpages do not.

+

Always use a template

+

The Always use a template box in the pane picks the template that every new page in the section starts from.

+

Templates are plain files too, so you can read and copy them like any other page.

+ + diff --git a/docs/demo/DemoNotebook/html/11-es/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/11-es/how-to/page-templates/index.html new file mode 100644 index 00000000..43b339bf --- /dev/null +++ b/docs/demo/DemoNotebook/html/11-es/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Plantillas de página + + + + + + +

Insertar > Plantillas de página añade una página que ya tiene su estructura: apuntes de clase, una lista de tareas, un planificador semanal y más. Cada plantilla muestra una imagen pequeña de su página para que veas el diseño antes de elegirla.

+

Empezar desde una plantilla

+

Haz clic en Insertar y luego en Plantillas de página. Las plantillas están agrupadas en Académico, En blanco, Negocios y Planificadores. Haz clic en una para añadir una página a la sección abierta.

+

Guardar las tuyas

+

Abre una página que te guste, escribe un nombre debajo de Guardar la página actual como plantilla y pulsa Guardar como plantilla. Tus plantillas aparecen en Mis plantillas.

+

Una plantilla es una copia de su página, así que las palabras, imágenes y archivos vienen con ella. Las subpáginas no.

+

Usar siempre una plantilla

+

El cuadro Usar siempre una plantilla del panel elige la plantilla desde la que empieza cada página nueva de la sección.

+

Las plantillas también son archivos normales, así que puedes leerlas y copiarlas como cualquier otra página.

+ + diff --git a/docs/demo/DemoNotebook/html/12-fr/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/12-fr/how-to/page-templates/index.html new file mode 100644 index 00000000..522eb717 --- /dev/null +++ b/docs/demo/DemoNotebook/html/12-fr/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Modèles de page + + + + + + +

Insertion > Modèles de page ajoute une page qui a déjà sa structure : notes de cours, liste de tâches, planificateur hebdomadaire et autres. Chaque modèle montre une petite image de sa page, pour que vous voyiez la mise en page avant de le choisir.

+

Partir d'un modèle

+

Cliquez sur Insertion, puis sur Modèles de page. Les modèles sont regroupés en Universitaire, Vierge, Affaires et Planificateurs. Cliquez sur l'un d'eux pour ajouter une page à la section ouverte.

+

Garder les vôtres

+

Ouvrez une page qui vous plaît, tapez un nom sous Enregistrer la page actuelle comme modèle, puis appuyez sur Enregistrer comme modèle. Vos modèles apparaissent sous Mes modèles.

+

Un modèle est une copie de sa page : les mots, images et fichiers sont copiés avec lui. Les sous-pages ne le sont pas.

+

Toujours utiliser un modèle

+

La zone Toujours utiliser un modèle du volet choisit le modèle à partir duquel chaque nouvelle page de la section est créée.

+

Les modèles sont aussi des fichiers ordinaires : vous pouvez les lire et les copier comme n'importe quelle page.

+ + diff --git a/docs/demo/DemoNotebook/html/13-de/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/13-de/how-to/page-templates/index.html new file mode 100644 index 00000000..98fd70d4 --- /dev/null +++ b/docs/demo/DemoNotebook/html/13-de/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Seitenvorlagen + + + + + + +

Einfügen > Seitenvorlagen fügt eine Seite mit fertiger Struktur ein: Vorlesungsnotizen, eine Aufgabenliste, ein Wochenplaner und mehr. Jede Vorlage zeigt ein kleines Bild ihrer Seite, damit Sie das Layout sehen, bevor Sie wählen.

+

Mit einer Vorlage beginnen

+

Klicken Sie auf Einfügen und dann auf Seitenvorlagen. Die Vorlagen sind nach Akademisch, Leer, Geschäftlich und Planer geordnet. Klicken Sie auf eine, um dem geöffneten Abschnitt eine Seite hinzuzufügen.

+

Eigene Vorlagen speichern

+

Öffnen Sie eine Seite, die Ihnen gefällt, schreiben Sie unter Aktuelle Seite als Vorlage speichern einen Namen und drücken Sie Als Vorlage speichern. Ihre Vorlagen erscheinen unter Meine Vorlagen.

+

Eine Vorlage ist eine Kopie ihrer Seite, Texte, Bilder und Dateien kommen also mit. Unterseiten nicht.

+

Immer eine Vorlage verwenden

+

Das Feld Immer eine Vorlage verwenden im Bereich wählt die Vorlage, mit der jede neue Seite des Abschnitts beginnt.

+

Vorlagen sind auch normale Dateien, Sie können sie also wie jede andere Seite lesen und kopieren.

+ + diff --git a/docs/demo/DemoNotebook/html/14-hi/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/14-hi/how-to/page-templates/index.html new file mode 100644 index 00000000..e7819c8f --- /dev/null +++ b/docs/demo/DemoNotebook/html/14-hi/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +पेज टेम्पलेट + + + + + + +

इन्सर्ट > पेज टेम्पलेट एक ऐसा पेज जोड़ता है जिसकी संरचना पहले से तैयार है: लेक्चर नोट्स, टू-डू सूची, साप्ताहिक योजना और भी बहुत कुछ। हर टेम्पलेट अपने पेज की एक छोटी तस्वीर दिखाता है, ताकि चुनने से पहले आप लेआउट देख सकें।

+

किसी टेम्पलेट से शुरू करें

+

इन्सर्ट पर क्लिक करें, फिर पेज टेम्पलेट पर। टेम्पलेट शैक्षणिक, खाली, व्यवसाय और योजनाकार में बँटे हैं। खुले सेक्शन में पेज जोड़ने के लिए किसी एक पर क्लिक करें।

+

अपने टेम्पलेट रखें

+

कोई पसंदीदा पेज खोलें, मौजूदा पेज को टेम्पलेट के रूप में सहेजें के नीचे नाम लिखें और टेम्पलेट के रूप में सहेजें दबाएँ। आपके टेम्पलेट मेरे टेम्पलेट में दिखेंगे।

+

टेम्पलेट अपने पेज की प्रति होता है, इसलिए शब्द, तस्वीरें और फ़ाइलें उसके साथ आती हैं। उप-पेज नहीं आते।

+

हमेशा एक टेम्पलेट इस्तेमाल करें

+

पैन का हमेशा एक टेम्पलेट इस्तेमाल करें बॉक्स चुनता है कि सेक्शन के हर नए पेज की शुरुआत किस टेम्पलेट से हो।

+

टेम्पलेट भी सामान्य फ़ाइलें हैं, इसलिए आप उन्हें किसी दूसरे पेज की तरह पढ़ और कॉपी कर सकते हैं।

+ + diff --git a/docs/demo/DemoNotebook/html/15-ru/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/15-ru/how-to/page-templates/index.html new file mode 100644 index 00000000..5c5f58f3 --- /dev/null +++ b/docs/demo/DemoNotebook/html/15-ru/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Шаблоны страниц + + + + + + +

Вставка > Шаблоны страниц добавляет страницу, у которой уже есть структура: конспект лекции, список дел, недельный планировщик и другие. Каждый шаблон показывает небольшую картинку своей страницы, так что макет виден до выбора.

+

Начать с шаблона

+

Нажмите Вставка, затем Шаблоны страниц. Шаблоны разделены на группы: Академические, Пустые, Деловые и Планировщики. Нажмите на шаблон, чтобы добавить страницу в открытый раздел.

+

Сохраните свои

+

Откройте понравившуюся страницу, введите имя под Сохранить текущую страницу как шаблон и нажмите Сохранить как шаблон. Ваши шаблоны появятся в разделе Мои шаблоны.

+

Шаблон - это копия страницы, поэтому слова, картинки и файлы попадают в него тоже. Вложенные страницы - нет.

+

Всегда использовать шаблон

+

Поле Всегда использовать шаблон в панели выбирает шаблон, с которого начинается каждая новая страница раздела.

+

Шаблоны - это обычные файлы, их можно читать и копировать, как любую другую страницу.

+ + diff --git a/docs/demo/DemoNotebook/html/16-zh/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/16-zh/how-to/page-templates/index.html new file mode 100644 index 00000000..0b98e503 --- /dev/null +++ b/docs/demo/DemoNotebook/html/16-zh/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +页面模板 + + + + + + +

插入 > 页面模板会添加一个已有结构的页面:讲座笔记、待办清单、每周计划等等。每个模板都显示其页面的小图,让你在选择前看到版式。

+

从模板开始

+

点击插入,然后点击页面模板。模板分为学术、空白、商务和计划四类。点击一个模板即可在打开的分区中添加页面。

+

保存你自己的模板

+

打开一个你喜欢的页面,在将当前页面保存为模板下输入名称,然后按保存为模板。你的模板会出现在我的模板下。

+

模板是页面的副本,所以其中的文字、图片和文件都会一起带上。子页面则不会。

+

始终使用模板

+

面板中的始终使用模板框决定该分区中每个新页面以哪个模板开始。

+

模板也是普通文件,你可以像阅读和复制其他页面一样读取和复制它们。

+ + diff --git a/docs/demo/DemoNotebook/html/17-ja/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/17-ja/how-to/page-templates/index.html new file mode 100644 index 00000000..0e3b07c9 --- /dev/null +++ b/docs/demo/DemoNotebook/html/17-ja/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +ページテンプレート + + + + + + +

挿入 > ページテンプレートでは、構成がすでに用意されたページを追加できます。講義ノート、ToDoリスト、週間プランナーなどがあります。各テンプレートにはページの小さな画像が表示されるので、選ぶ前にレイアウトを確認できます。

+

テンプレートから始める

+

挿入をクリックし、次にページテンプレートをクリックします。テンプレートは学術、白紙、ビジネス、プランナーに分かれています。どれかをクリックすると、開いているセクションにページが追加されます。

+

自分のテンプレートを保存する

+

気に入ったページを開き、現在のページをテンプレートとして保存の下に名前を入力して、テンプレートとして保存を押します。自分のテンプレートはマイテンプレートに表示されます。

+

テンプレートはページのコピーなので、文字、画像、ファイルも一緒に入ります。サブページは入りません。

+

常にテンプレートを使う

+

パネルの常にテンプレートを使う欄で、そのセクションの新しいページがどのテンプレートから始まるかを選びます。

+

テンプレートも普通のファイルなので、ほかのページと同じように読んだりコピーしたりできます。

+ + diff --git a/docs/demo/DemoNotebook/html/18-ko/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/18-ko/how-to/page-templates/index.html new file mode 100644 index 00000000..8fa47dbf --- /dev/null +++ b/docs/demo/DemoNotebook/html/18-ko/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +페이지 템플릿 + + + + + + +

삽입 > 페이지 템플릿은 이미 구조가 갖춰진 페이지를 추가합니다. 강의 노트, 할 일 목록, 주간 계획표 등이 있습니다. 각 템플릿은 해당 페이지의 작은 그림을 보여 주므로, 고르기 전에 배치를 볼 수 있습니다.

+

템플릿으로 시작하기

+

삽입을 클릭한 다음 페이지 템플릿을 클릭하세요. 템플릿은 학술, 빈 페이지, 비즈니스, 플래너로 나뉩니다. 하나를 클릭하면 열려 있는 섹션에 페이지가 추가됩니다.

+

내 템플릿 저장하기

+

마음에 드는 페이지를 열고 현재 페이지를 템플릿으로 저장 아래에 이름을 입력한 다음 템플릿으로 저장을 누르세요. 저장한 템플릿은 내 템플릿에 나타납니다.

+

템플릿은 페이지의 복사본이므로 글, 그림, 파일도 함께 들어갑니다. 하위 페이지는 들어가지 않습니다.

+

항상 템플릿 사용

+

패널의 항상 템플릿 사용 상자는 섹션의 새 페이지가 어떤 템플릿으로 시작할지 정합니다.

+

템플릿도 일반 파일이므로 다른 페이지처럼 읽고 복사할 수 있습니다.

+ + diff --git a/docs/demo/DemoNotebook/html/19-tr/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/19-tr/how-to/page-templates/index.html new file mode 100644 index 00000000..2e6baa9a --- /dev/null +++ b/docs/demo/DemoNotebook/html/19-tr/how-to/page-templates/index.html @@ -0,0 +1,22 @@ + + + + +Sayfa şablonları + + + + + + +

Ekle > Sayfa Şablonları, zaten yapısı hazır bir sayfa ekler: ders notları, yapılacaklar listesi, haftalık planlayıcı ve daha fazlası. Her şablon sayfasının küçük bir resmini gösterir, böylece seçmeden önce düzeni görebilirsiniz.

+

Bir şablonla başlayın

+

Ekle menüsünden Sayfa Şablonları'na tıklayın. Şablonlar Akademik, Boş, İş ve Planlayıcılar olarak gruplanmıştır. Açık bölüme sayfa eklemek için birine tıklayın.

+

Kendi şablonlarınızı saklayın

+

Beğendiğiniz bir sayfayı açın, Geçerli sayfayı şablon olarak kaydet altına bir ad yazın ve Şablon olarak kaydet'e basın. Şablonlarınız Şablonlarım altında görünür.

+

Bir şablon, sayfasının bir kopyasıdır; bu yüzden sözcükler, resimler ve dosyalar da onunla birlikte gelir. Alt sayfalar gelmez.

+

Her zaman bir şablon kullan

+

Bölümdeki her yeni sayfanın hangi şablonla başlayacağını panelin Her zaman bir şablon kullan kutusu seçer.

+

Şablonlar da sıradan dosyalardır; diğer sayfalar gibi okuyabilir ve kopyalayabilirsiniz.

+ + diff --git a/docs/demo/DemoNotebook/html/20-ar/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/20-ar/how-to/page-templates/index.html new file mode 100644 index 00000000..e8f8007a --- /dev/null +++ b/docs/demo/DemoNotebook/html/20-ar/how-to/page-templates/index.html @@ -0,0 +1,23 @@ + + + + +قوالب الصفحات + + + + + + + +

إدراج > قوالب الصفحات يضيف صفحة جاهزة البنية: ملاحظات محاضرة، وقائمة مهام، ومخطط أسبوعي، وغيرها. يعرض كل قالب صورة صغيرة لصفحته، فترى التخطيط قبل أن تختار.

+

ابدأ من قالب

+

انقر إدراج، ثم قوالب الصفحات. القوالب مجمعة في أكاديمي وفارغ وأعمال ومخططات. انقر قالبًا لإضافة صفحة إلى القسم المفتوح.

+

احفظ قوالبك

+

افتح صفحة تعجبك، واكتب اسمًا تحت حفظ الصفحة الحالية كقالب، ثم اضغط حفظ كقالب. تظهر قوالبك تحت قوالبي.

+

القالب نسخة من صفحته، لذلك تأتي معه الكلمات والصور والملفات. الصفحات الفرعية لا تأتي.

+

استخدم قالبًا دائمًا

+

يحدد المربع استخدم قالبًا دائمًا في اللوحة القالب الذي تبدأ منه كل صفحة جديدة في القسم.

+

القوالب ملفات عادية أيضًا، يمكنك قراءتها ونسخها مثل أي صفحة أخرى.

+ + diff --git a/docs/demo/DemoNotebook/html/21-fa/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/21-fa/how-to/page-templates/index.html new file mode 100644 index 00000000..036ef7f9 --- /dev/null +++ b/docs/demo/DemoNotebook/html/21-fa/how-to/page-templates/index.html @@ -0,0 +1,23 @@ + + + + +الگوهای صفحه + + + + + + + +

درج > الگوهای صفحه صفحه‌ای می‌افزاید که ساختارش از پیش آماده است: یادداشت درس، فهرست کارها، برنامه‌ریز هفتگی و موارد دیگر. هر الگو تصویر کوچکی از صفحه‌اش را نشان می‌دهد تا پیش از انتخاب، چیدمان را ببینید.

+

از یک الگو شروع کنید

+

روی درج و سپس الگوهای صفحه کلیک کنید. الگوها در دسته‌های آکادمیک، خالی، کسب‌وکار و برنامه‌ریزها قرار دارند. برای افزودن صفحه به بخش باز، روی یکی کلیک کنید.

+

الگوهای خودتان را نگه دارید

+

صفحه‌ای را که دوست دارید باز کنید، زیر ذخیره صفحه فعلی به‌عنوان الگو نامی بنویسید و ذخیره به‌عنوان الگو را بزنید. الگوهای شما زیر الگوهای من ظاهر می‌شوند.

+

الگو رونوشت صفحه‌اش است، پس متن‌ها، تصویرها و فایل‌ها همراهش می‌آیند. زیرصفحه‌ها نمی‌آیند.

+

همیشه از یک الگو استفاده کن

+

کادر همیشه از یک الگو استفاده کن در پنل مشخص می‌کند که هر صفحه تازه در بخش با کدام الگو شروع شود.

+

الگوها هم فایل‌های معمولی هستند، پس مانند هر صفحه دیگری می‌توانید آن‌ها را بخوانید و رونوشت کنید.

+ + diff --git a/docs/demo/DemoNotebook/html/22-ur/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/22-ur/how-to/page-templates/index.html new file mode 100644 index 00000000..caf62337 --- /dev/null +++ b/docs/demo/DemoNotebook/html/22-ur/how-to/page-templates/index.html @@ -0,0 +1,23 @@ + + + + +صفحہ کے ٹیمپلیٹس + + + + + + + +

داخل کریں > صفحہ کے ٹیمپلیٹس ایک ایسا صفحہ شامل کرتا ہے جس کا ڈھانچہ پہلے سے تیار ہوتا ہے: لیکچر نوٹس، کاموں کی فہرست، ہفتہ وار منصوبہ اور مزید۔ ہر ٹیمپلیٹ اپنے صفحے کی ایک چھوٹی تصویر دکھاتا ہے تاکہ آپ انتخاب سے پہلے ترتیب دیکھ سکیں۔

+

ٹیمپلیٹ سے شروع کریں

+

داخل کریں پر کلک کریں، پھر صفحہ کے ٹیمپلیٹس پر۔ ٹیمپلیٹس تعلیمی، خالی، کاروباری اور منصوبہ بندی کے زمروں میں ہیں۔ کھلے سیکشن میں صفحہ شامل کرنے کے لیے کسی ایک پر کلک کریں۔

+

اپنے ٹیمپلیٹس محفوظ کریں

+

کوئی پسندیدہ صفحہ کھولیں، موجودہ صفحہ کو ٹیمپلیٹ کے طور پر محفوظ کریں کے نیچے نام لکھیں اور ٹیمپلیٹ کے طور پر محفوظ کریں دبائیں۔ آپ کے ٹیمپلیٹس میرے ٹیمپلیٹس میں ظاہر ہوں گے۔

+

ٹیمپلیٹ اپنے صفحے کی نقل ہوتا ہے، اس لیے اس کے الفاظ، تصویریں اور فائلیں بھی ساتھ آتی ہیں۔ ذیلی صفحات نہیں آتے۔

+

ہمیشہ ٹیمپلیٹ استعمال کریں

+

پینل کا ہمیشہ ٹیمپلیٹ استعمال کریں والا خانہ طے کرتا ہے کہ سیکشن کا ہر نیا صفحہ کس ٹیمپلیٹ سے شروع ہو۔

+

ٹیمپلیٹس بھی عام فائلیں ہیں، اس لیے آپ انہیں کسی بھی دوسرے صفحے کی طرح پڑھ اور نقل کر سکتے ہیں۔

+ + diff --git a/docs/demo/DemoNotebook/html/23-he/how-to/page-templates/index.html b/docs/demo/DemoNotebook/html/23-he/how-to/page-templates/index.html new file mode 100644 index 00000000..120a25de --- /dev/null +++ b/docs/demo/DemoNotebook/html/23-he/how-to/page-templates/index.html @@ -0,0 +1,23 @@ + + + + +תבניות עמוד + + + + + + + +

הוספה > תבניות עמוד מוסיף עמוד שהמבנה שלו כבר מוכן: הערות הרצאה, רשימת משימות, מתכנן שבועי ועוד. לכל תבנית יש תמונה קטנה של העמוד שלה, כדי שתראו את הפריסה לפני הבחירה.

+

התחלה מתבנית

+

לחצו על הוספה ואחר כך על תבניות עמוד. התבניות מחולקות לקבוצות: אקדמי, ריק, עסקים ומתכננים. לחצו על אחת כדי להוסיף עמוד לקטע הפתוח.

+

שמרו את התבניות שלכם

+

פתחו עמוד שאתם אוהבים, כתבו שם מתחת לשמירת העמוד הנוכחי כתבנית ולחצו על שמירה כתבנית. התבניות שלכם יופיעו תחת התבניות שלי.

+

תבנית היא עותק של העמוד שלה, ולכן המילים, התמונות והקבצים מגיעים איתה. תת-העמודים לא.

+

השתמשו תמיד בתבנית

+

תיבת השתמשו תמיד בתבנית בחלונית קובעת את התבנית שממנה מתחיל כל עמוד חדש בקטע.

+

גם התבניות הן קבצים רגילים, ואפשר לקרוא ולהעתיק אותן כמו כל עמוד אחר.

+ + diff --git a/docs/demo/scripts/content/ar/28-page-templates.md b/docs/demo/scripts/content/ar/28-page-templates.md new file mode 100644 index 00000000..5efa556d --- /dev/null +++ b/docs/demo/scripts/content/ar/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: قوالب الصفحات +--- + +# قوالب الصفحات + +إدراج > قوالب الصفحات يضيف صفحة جاهزة البنية: ملاحظات محاضرة، وقائمة مهام، ومخطط أسبوعي، وغيرها. يعرض كل قالب صورة صغيرة لصفحته، فترى التخطيط قبل أن تختار. + +## ابدأ من قالب + +انقر **إدراج**، ثم **قوالب الصفحات**. القوالب مجمعة في أكاديمي وفارغ وأعمال ومخططات. انقر قالبًا لإضافة صفحة إلى القسم المفتوح. + +## احفظ قوالبك + +افتح صفحة تعجبك، واكتب اسمًا تحت **حفظ الصفحة الحالية كقالب**، ثم اضغط **حفظ كقالب**. تظهر قوالبك تحت **قوالبي**. + +القالب نسخة من صفحته، لذلك تأتي معه الكلمات والصور والملفات. الصفحات الفرعية لا تأتي. + +## استخدم قالبًا دائمًا + +يحدد المربع **استخدم قالبًا دائمًا** في اللوحة القالب الذي تبدأ منه كل صفحة جديدة في القسم. + +القوالب ملفات عادية أيضًا، يمكنك قراءتها ونسخها مثل أي صفحة أخرى. diff --git a/docs/demo/scripts/content/de/28-page-templates.md b/docs/demo/scripts/content/de/28-page-templates.md new file mode 100644 index 00000000..c4df03d0 --- /dev/null +++ b/docs/demo/scripts/content/de/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Seitenvorlagen +--- + +# Seitenvorlagen + +Einfügen > Seitenvorlagen fügt eine Seite mit fertiger Struktur ein: Vorlesungsnotizen, eine Aufgabenliste, ein Wochenplaner und mehr. Jede Vorlage zeigt ein kleines Bild ihrer Seite, damit Sie das Layout sehen, bevor Sie wählen. + +## Mit einer Vorlage beginnen + +Klicken Sie auf **Einfügen** und dann auf **Seitenvorlagen**. Die Vorlagen sind nach Akademisch, Leer, Geschäftlich und Planer geordnet. Klicken Sie auf eine, um dem geöffneten Abschnitt eine Seite hinzuzufügen. + +## Eigene Vorlagen speichern + +Öffnen Sie eine Seite, die Ihnen gefällt, schreiben Sie unter **Aktuelle Seite als Vorlage speichern** einen Namen und drücken Sie **Als Vorlage speichern**. Ihre Vorlagen erscheinen unter **Meine Vorlagen**. + +Eine Vorlage ist eine Kopie ihrer Seite, Texte, Bilder und Dateien kommen also mit. Unterseiten nicht. + +## Immer eine Vorlage verwenden + +Das Feld **Immer eine Vorlage verwenden** im Bereich wählt die Vorlage, mit der jede neue Seite des Abschnitts beginnt. + +Vorlagen sind auch normale Dateien, Sie können sie also wie jede andere Seite lesen und kopieren. diff --git a/docs/demo/scripts/content/en/28-page-templates.md b/docs/demo/scripts/content/en/28-page-templates.md new file mode 100644 index 00000000..6ffd0c0f --- /dev/null +++ b/docs/demo/scripts/content/en/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Page templates +--- + +# Page templates + +Insert > Page Templates adds a page that already has its structure: lecture notes, a to-do list, a weekly planner, and more. Each template shows a small picture of its page, so you can see the layout before you pick it. + +## Start from a template + +Click **Insert**, then **Page Templates**. The templates are grouped as Academic, Blank, Business and Planners. Click one to add a page to the open section. + +## Keep your own + +Open a page you like, type a name under **Save current page as a template**, and press **Save as template**. Your templates appear under **My Templates**. + +A template is a copy of its page, so the words, pictures and files come with it. Subpages do not. + +## Always use a template + +The **Always use a template** box in the pane picks the template that every new page in the section starts from. + +Templates are plain files too, so you can read and copy them like any other page. \ No newline at end of file diff --git a/docs/demo/scripts/content/es/28-page-templates.md b/docs/demo/scripts/content/es/28-page-templates.md new file mode 100644 index 00000000..457d462d --- /dev/null +++ b/docs/demo/scripts/content/es/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Plantillas de página +--- + +# Plantillas de página + +Insertar > Plantillas de página añade una página que ya tiene su estructura: apuntes de clase, una lista de tareas, un planificador semanal y más. Cada plantilla muestra una imagen pequeña de su página para que veas el diseño antes de elegirla. + +## Empezar desde una plantilla + +Haz clic en **Insertar** y luego en **Plantillas de página**. Las plantillas están agrupadas en Académico, En blanco, Negocios y Planificadores. Haz clic en una para añadir una página a la sección abierta. + +## Guardar las tuyas + +Abre una página que te guste, escribe un nombre debajo de **Guardar la página actual como plantilla** y pulsa **Guardar como plantilla**. Tus plantillas aparecen en **Mis plantillas**. + +Una plantilla es una copia de su página, así que las palabras, imágenes y archivos vienen con ella. Las subpáginas no. + +## Usar siempre una plantilla + +El cuadro **Usar siempre una plantilla** del panel elige la plantilla desde la que empieza cada página nueva de la sección. + +Las plantillas también son archivos normales, así que puedes leerlas y copiarlas como cualquier otra página. diff --git a/docs/demo/scripts/content/fa/28-page-templates.md b/docs/demo/scripts/content/fa/28-page-templates.md new file mode 100644 index 00000000..66eafbe8 --- /dev/null +++ b/docs/demo/scripts/content/fa/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: الگوهای صفحه +--- + +# الگوهای صفحه + +درج > الگوهای صفحه صفحه‌ای می‌افزاید که ساختارش از پیش آماده است: یادداشت درس، فهرست کارها، برنامه‌ریز هفتگی و موارد دیگر. هر الگو تصویر کوچکی از صفحه‌اش را نشان می‌دهد تا پیش از انتخاب، چیدمان را ببینید. + +## از یک الگو شروع کنید + +روی **درج** و سپس **الگوهای صفحه** کلیک کنید. الگوها در دسته‌های آکادمیک، خالی، کسب‌وکار و برنامه‌ریزها قرار دارند. برای افزودن صفحه به بخش باز، روی یکی کلیک کنید. + +## الگوهای خودتان را نگه دارید + +صفحه‌ای را که دوست دارید باز کنید، زیر **ذخیره صفحه فعلی به‌عنوان الگو** نامی بنویسید و **ذخیره به‌عنوان الگو** را بزنید. الگوهای شما زیر **الگوهای من** ظاهر می‌شوند. + +الگو رونوشت صفحه‌اش است، پس متن‌ها، تصویرها و فایل‌ها همراهش می‌آیند. زیرصفحه‌ها نمی‌آیند. + +## همیشه از یک الگو استفاده کن + +کادر **همیشه از یک الگو استفاده کن** در پنل مشخص می‌کند که هر صفحه تازه در بخش با کدام الگو شروع شود. + +الگوها هم فایل‌های معمولی هستند، پس مانند هر صفحه دیگری می‌توانید آن‌ها را بخوانید و رونوشت کنید. diff --git a/docs/demo/scripts/content/fr/28-page-templates.md b/docs/demo/scripts/content/fr/28-page-templates.md new file mode 100644 index 00000000..e1400743 --- /dev/null +++ b/docs/demo/scripts/content/fr/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Modèles de page +--- + +# Modèles de page + +Insertion > Modèles de page ajoute une page qui a déjà sa structure : notes de cours, liste de tâches, planificateur hebdomadaire et autres. Chaque modèle montre une petite image de sa page, pour que vous voyiez la mise en page avant de le choisir. + +## Partir d'un modèle + +Cliquez sur **Insertion**, puis sur **Modèles de page**. Les modèles sont regroupés en Universitaire, Vierge, Affaires et Planificateurs. Cliquez sur l'un d'eux pour ajouter une page à la section ouverte. + +## Garder les vôtres + +Ouvrez une page qui vous plaît, tapez un nom sous **Enregistrer la page actuelle comme modèle**, puis appuyez sur **Enregistrer comme modèle**. Vos modèles apparaissent sous **Mes modèles**. + +Un modèle est une copie de sa page : les mots, images et fichiers sont copiés avec lui. Les sous-pages ne le sont pas. + +## Toujours utiliser un modèle + +La zone **Toujours utiliser un modèle** du volet choisit le modèle à partir duquel chaque nouvelle page de la section est créée. + +Les modèles sont aussi des fichiers ordinaires : vous pouvez les lire et les copier comme n'importe quelle page. diff --git a/docs/demo/scripts/content/he/28-page-templates.md b/docs/demo/scripts/content/he/28-page-templates.md new file mode 100644 index 00000000..c9134fce --- /dev/null +++ b/docs/demo/scripts/content/he/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: תבניות עמוד +--- + +# תבניות עמוד + +הוספה > תבניות עמוד מוסיף עמוד שהמבנה שלו כבר מוכן: הערות הרצאה, רשימת משימות, מתכנן שבועי ועוד. לכל תבנית יש תמונה קטנה של העמוד שלה, כדי שתראו את הפריסה לפני הבחירה. + +## התחלה מתבנית + +לחצו על **הוספה** ואחר כך על **תבניות עמוד**. התבניות מחולקות לקבוצות: אקדמי, ריק, עסקים ומתכננים. לחצו על אחת כדי להוסיף עמוד לקטע הפתוח. + +## שמרו את התבניות שלכם + +פתחו עמוד שאתם אוהבים, כתבו שם מתחת ל**שמירת העמוד הנוכחי כתבנית** ולחצו על **שמירה כתבנית**. התבניות שלכם יופיעו תחת **התבניות שלי**. + +תבנית היא עותק של העמוד שלה, ולכן המילים, התמונות והקבצים מגיעים איתה. תת-העמודים לא. + +## השתמשו תמיד בתבנית + +תיבת **השתמשו תמיד בתבנית** בחלונית קובעת את התבנית שממנה מתחיל כל עמוד חדש בקטע. + +גם התבניות הן קבצים רגילים, ואפשר לקרוא ולהעתיק אותן כמו כל עמוד אחר. diff --git a/docs/demo/scripts/content/hi/28-page-templates.md b/docs/demo/scripts/content/hi/28-page-templates.md new file mode 100644 index 00000000..19ffb57a --- /dev/null +++ b/docs/demo/scripts/content/hi/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: पेज टेम्पलेट +--- + +# पेज टेम्पलेट + +इन्सर्ट > पेज टेम्पलेट एक ऐसा पेज जोड़ता है जिसकी संरचना पहले से तैयार है: लेक्चर नोट्स, टू-डू सूची, साप्ताहिक योजना और भी बहुत कुछ। हर टेम्पलेट अपने पेज की एक छोटी तस्वीर दिखाता है, ताकि चुनने से पहले आप लेआउट देख सकें। + +## किसी टेम्पलेट से शुरू करें + +**इन्सर्ट** पर क्लिक करें, फिर **पेज टेम्पलेट** पर। टेम्पलेट शैक्षणिक, खाली, व्यवसाय और योजनाकार में बँटे हैं। खुले सेक्शन में पेज जोड़ने के लिए किसी एक पर क्लिक करें। + +## अपने टेम्पलेट रखें + +कोई पसंदीदा पेज खोलें, **मौजूदा पेज को टेम्पलेट के रूप में सहेजें** के नीचे नाम लिखें और **टेम्पलेट के रूप में सहेजें** दबाएँ। आपके टेम्पलेट **मेरे टेम्पलेट** में दिखेंगे। + +टेम्पलेट अपने पेज की प्रति होता है, इसलिए शब्द, तस्वीरें और फ़ाइलें उसके साथ आती हैं। उप-पेज नहीं आते। + +## हमेशा एक टेम्पलेट इस्तेमाल करें + +पैन का **हमेशा एक टेम्पलेट इस्तेमाल करें** बॉक्स चुनता है कि सेक्शन के हर नए पेज की शुरुआत किस टेम्पलेट से हो। + +टेम्पलेट भी सामान्य फ़ाइलें हैं, इसलिए आप उन्हें किसी दूसरे पेज की तरह पढ़ और कॉपी कर सकते हैं। diff --git a/docs/demo/scripts/content/ja/28-page-templates.md b/docs/demo/scripts/content/ja/28-page-templates.md new file mode 100644 index 00000000..b11bfa1c --- /dev/null +++ b/docs/demo/scripts/content/ja/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: ページテンプレート +--- + +# ページテンプレート + +挿入 > ページテンプレートでは、構成がすでに用意されたページを追加できます。講義ノート、ToDoリスト、週間プランナーなどがあります。各テンプレートにはページの小さな画像が表示されるので、選ぶ前にレイアウトを確認できます。 + +## テンプレートから始める + +**挿入**をクリックし、次に**ページテンプレート**をクリックします。テンプレートは学術、白紙、ビジネス、プランナーに分かれています。どれかをクリックすると、開いているセクションにページが追加されます。 + +## 自分のテンプレートを保存する + +気に入ったページを開き、**現在のページをテンプレートとして保存**の下に名前を入力して、**テンプレートとして保存**を押します。自分のテンプレートは**マイテンプレート**に表示されます。 + +テンプレートはページのコピーなので、文字、画像、ファイルも一緒に入ります。サブページは入りません。 + +## 常にテンプレートを使う + +パネルの**常にテンプレートを使う**欄で、そのセクションの新しいページがどのテンプレートから始まるかを選びます。 + +テンプレートも普通のファイルなので、ほかのページと同じように読んだりコピーしたりできます。 diff --git a/docs/demo/scripts/content/ko/28-page-templates.md b/docs/demo/scripts/content/ko/28-page-templates.md new file mode 100644 index 00000000..6526f7a6 --- /dev/null +++ b/docs/demo/scripts/content/ko/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: 페이지 템플릿 +--- + +# 페이지 템플릿 + +삽입 > 페이지 템플릿은 이미 구조가 갖춰진 페이지를 추가합니다. 강의 노트, 할 일 목록, 주간 계획표 등이 있습니다. 각 템플릿은 해당 페이지의 작은 그림을 보여 주므로, 고르기 전에 배치를 볼 수 있습니다. + +## 템플릿으로 시작하기 + +**삽입**을 클릭한 다음 **페이지 템플릿**을 클릭하세요. 템플릿은 학술, 빈 페이지, 비즈니스, 플래너로 나뉩니다. 하나를 클릭하면 열려 있는 섹션에 페이지가 추가됩니다. + +## 내 템플릿 저장하기 + +마음에 드는 페이지를 열고 **현재 페이지를 템플릿으로 저장** 아래에 이름을 입력한 다음 **템플릿으로 저장**을 누르세요. 저장한 템플릿은 **내 템플릿**에 나타납니다. + +템플릿은 페이지의 복사본이므로 글, 그림, 파일도 함께 들어갑니다. 하위 페이지는 들어가지 않습니다. + +## 항상 템플릿 사용 + +패널의 **항상 템플릿 사용** 상자는 섹션의 새 페이지가 어떤 템플릿으로 시작할지 정합니다. + +템플릿도 일반 파일이므로 다른 페이지처럼 읽고 복사할 수 있습니다. diff --git a/docs/demo/scripts/content/ru/28-page-templates.md b/docs/demo/scripts/content/ru/28-page-templates.md new file mode 100644 index 00000000..182a6058 --- /dev/null +++ b/docs/demo/scripts/content/ru/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Шаблоны страниц +--- + +# Шаблоны страниц + +Вставка > Шаблоны страниц добавляет страницу, у которой уже есть структура: конспект лекции, список дел, недельный планировщик и другие. Каждый шаблон показывает небольшую картинку своей страницы, так что макет виден до выбора. + +## Начать с шаблона + +Нажмите **Вставка**, затем **Шаблоны страниц**. Шаблоны разделены на группы: Академические, Пустые, Деловые и Планировщики. Нажмите на шаблон, чтобы добавить страницу в открытый раздел. + +## Сохраните свои + +Откройте понравившуюся страницу, введите имя под **Сохранить текущую страницу как шаблон** и нажмите **Сохранить как шаблон**. Ваши шаблоны появятся в разделе **Мои шаблоны**. + +Шаблон - это копия страницы, поэтому слова, картинки и файлы попадают в него тоже. Вложенные страницы - нет. + +## Всегда использовать шаблон + +Поле **Всегда использовать шаблон** в панели выбирает шаблон, с которого начинается каждая новая страница раздела. + +Шаблоны - это обычные файлы, их можно читать и копировать, как любую другую страницу. diff --git a/docs/demo/scripts/content/tr/28-page-templates.md b/docs/demo/scripts/content/tr/28-page-templates.md new file mode 100644 index 00000000..6e6b0f06 --- /dev/null +++ b/docs/demo/scripts/content/tr/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: Sayfa şablonları +--- + +# Sayfa şablonları + +Ekle > Sayfa Şablonları, zaten yapısı hazır bir sayfa ekler: ders notları, yapılacaklar listesi, haftalık planlayıcı ve daha fazlası. Her şablon sayfasının küçük bir resmini gösterir, böylece seçmeden önce düzeni görebilirsiniz. + +## Bir şablonla başlayın + +**Ekle** menüsünden **Sayfa Şablonları**'na tıklayın. Şablonlar Akademik, Boş, İş ve Planlayıcılar olarak gruplanmıştır. Açık bölüme sayfa eklemek için birine tıklayın. + +## Kendi şablonlarınızı saklayın + +Beğendiğiniz bir sayfayı açın, **Geçerli sayfayı şablon olarak kaydet** altına bir ad yazın ve **Şablon olarak kaydet**'e basın. Şablonlarınız **Şablonlarım** altında görünür. + +Bir şablon, sayfasının bir kopyasıdır; bu yüzden sözcükler, resimler ve dosyalar da onunla birlikte gelir. Alt sayfalar gelmez. + +## Her zaman bir şablon kullan + +Bölümdeki her yeni sayfanın hangi şablonla başlayacağını panelin **Her zaman bir şablon kullan** kutusu seçer. + +Şablonlar da sıradan dosyalardır; diğer sayfalar gibi okuyabilir ve kopyalayabilirsiniz. diff --git a/docs/demo/scripts/content/ur/28-page-templates.md b/docs/demo/scripts/content/ur/28-page-templates.md new file mode 100644 index 00000000..011ee264 --- /dev/null +++ b/docs/demo/scripts/content/ur/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: صفحہ کے ٹیمپلیٹس +--- + +# صفحہ کے ٹیمپلیٹس + +داخل کریں > صفحہ کے ٹیمپلیٹس ایک ایسا صفحہ شامل کرتا ہے جس کا ڈھانچہ پہلے سے تیار ہوتا ہے: لیکچر نوٹس، کاموں کی فہرست، ہفتہ وار منصوبہ اور مزید۔ ہر ٹیمپلیٹ اپنے صفحے کی ایک چھوٹی تصویر دکھاتا ہے تاکہ آپ انتخاب سے پہلے ترتیب دیکھ سکیں۔ + +## ٹیمپلیٹ سے شروع کریں + +**داخل کریں** پر کلک کریں، پھر **صفحہ کے ٹیمپلیٹس** پر۔ ٹیمپلیٹس تعلیمی، خالی، کاروباری اور منصوبہ بندی کے زمروں میں ہیں۔ کھلے سیکشن میں صفحہ شامل کرنے کے لیے کسی ایک پر کلک کریں۔ + +## اپنے ٹیمپلیٹس محفوظ کریں + +کوئی پسندیدہ صفحہ کھولیں، **موجودہ صفحہ کو ٹیمپلیٹ کے طور پر محفوظ کریں** کے نیچے نام لکھیں اور **ٹیمپلیٹ کے طور پر محفوظ کریں** دبائیں۔ آپ کے ٹیمپلیٹس **میرے ٹیمپلیٹس** میں ظاہر ہوں گے۔ + +ٹیمپلیٹ اپنے صفحے کی نقل ہوتا ہے، اس لیے اس کے الفاظ، تصویریں اور فائلیں بھی ساتھ آتی ہیں۔ ذیلی صفحات نہیں آتے۔ + +## ہمیشہ ٹیمپلیٹ استعمال کریں + +پینل کا **ہمیشہ ٹیمپلیٹ استعمال کریں** والا خانہ طے کرتا ہے کہ سیکشن کا ہر نیا صفحہ کس ٹیمپلیٹ سے شروع ہو۔ + +ٹیمپلیٹس بھی عام فائلیں ہیں، اس لیے آپ انہیں کسی بھی دوسرے صفحے کی طرح پڑھ اور نقل کر سکتے ہیں۔ diff --git a/docs/demo/scripts/content/zh/28-page-templates.md b/docs/demo/scripts/content/zh/28-page-templates.md new file mode 100644 index 00000000..1a4657fb --- /dev/null +++ b/docs/demo/scripts/content/zh/28-page-templates.md @@ -0,0 +1,23 @@ +--- +title: 页面模板 +--- + +# 页面模板 + +插入 > 页面模板会添加一个已有结构的页面:讲座笔记、待办清单、每周计划等等。每个模板都显示其页面的小图,让你在选择前看到版式。 + +## 从模板开始 + +点击**插入**,然后点击**页面模板**。模板分为学术、空白、商务和计划四类。点击一个模板即可在打开的分区中添加页面。 + +## 保存你自己的模板 + +打开一个你喜欢的页面,在**将当前页面保存为模板**下输入名称,然后按**保存为模板**。你的模板会出现在**我的模板**下。 + +模板是页面的副本,所以其中的文字、图片和文件都会一起带上。子页面则不会。 + +## 始终使用模板 + +面板中的**始终使用模板**框决定该分区中每个新页面以哪个模板开始。 + +模板也是普通文件,你可以像阅读和复制其他页面一样读取和复制它们。 From 290b9771a870d69395f0d164e0aa70285f1cad52 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 11:15:39 -0800 Subject: [PATCH 07/19] feat(ui): colour Paste icon in the How to paste menu Keep source formatting uses the Fluent colour clipboard. Menu rows can now draw colour icons. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/src/floating.rs | 6 ++++++ crates/ui-egui/src/ribbon.rs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/floating.rs b/crates/ui-egui/src/floating.rs index 7e060097..fe93bf66 100644 --- a/crates/ui-egui/src/floating.rs +++ b/crates/ui-egui/src/floating.rs @@ -22,6 +22,9 @@ use notecraft_model::Tag; pub enum Glyph { Mark(Mark), Icon(Icon), + /// A Fluent colour icon, in its own colours (the file name and its SVG). Drawn only on a menu + /// row, which has the `Ui` a colour image needs. + Colour(&'static str, &'static [u8]), } impl Glyph { @@ -29,6 +32,8 @@ impl Glyph { match self { Glyph::Mark(m) => ribbon_icons::paint(painter, rect, m, m.color(t.text, t.accent)), Glyph::Icon(i) => icons::paint(painter, rect, i, t.text), + // Not drawn here: a painter alone cannot show a colour image. Menu rows draw it. + Glyph::Colour(..) => {} } } } @@ -272,6 +277,7 @@ pub fn menu_row_danger(ui: &mut Ui, glyph: Option, label: &str, t: &Token match glyph { Some(Glyph::Mark(m)) => ribbon_icons::paint(&painter, icon, m, t.warn), Some(Glyph::Icon(i)) => icons::paint(&painter, icon, i, t.warn), + Some(Glyph::Colour(name, bytes)) => icons::paint_colour_svg(ui, icon, name, bytes, ui.is_enabled()), None => {} } painter.text(egui::pos2(rect.min.x + ICON_COL + 2.0, rect.center().y), Align2::LEFT_CENTER, label, egui::FontId::proportional(13.0), t.warn); diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 9f9d8413..7e2730d2 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -2149,7 +2149,13 @@ fn paste_buttons(ui: &mut Ui, paste: egui::Response, options: egui::Response, t: egui::Popup::menu(&options).show(|ui| { picker_title(ui, crate::tl_id!("ui.paste_options"), t); let (rich, plain) = if cfg!(target_os = "macos") { ("Cmd+V", "Cmd+Shift+V") } else { ("Ctrl+V", "Ctrl+Shift+V") }; - let keep = floating::menu_row_shortcut(ui, Some(Glyph::Mark(Mark::Paste)), crate::tl_id!("ui.keep_source_formatting"), rich, t); + let keep = floating::menu_row_shortcut( + ui, + Some(Glyph::Colour("clipboard", include_bytes!("../assets/fluent-color/clipboard.svg"))), + crate::tl_id!("ui.keep_source_formatting"), + rich, + t, + ); first_choice(ui, popup_id, &keep); if keep.clicked() { acts.push(Act::Paste); From 043bcb7dd00bde243ae7da6d6daede264052fb53 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 11:38:51 -0800 Subject: [PATCH 08/19] feat(ui): template thumbnail cards that wrap with the pane Templates are cards: the thumbnail with the name under it, in rows that wrap to the pane's width. The Page Templates button uses the Fluent colour Document Text icon. Co-Authored-By: Claude Haiku 5.5 --- .../assets/fluent-color/document_text.svg | 24 ++++++ crates/ui-egui/src/app.rs | 77 ++++++++++--------- crates/ui-egui/src/icons.rs | 1 + 3 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 crates/ui-egui/assets/fluent-color/document_text.svg diff --git a/crates/ui-egui/assets/fluent-color/document_text.svg b/crates/ui-egui/assets/fluent-color/document_text.svg new file mode 100644 index 00000000..47dfa6f9 --- /dev/null +++ b/crates/ui-egui/assets/fluent-color/document_text.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 43efbc31..2072ea22 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -814,6 +814,12 @@ fn tag_groups(found: &[notecraft_store::tags::Tagged], by: TagGroup, tree: &[Nod } } +/// A template card in the pane: its thumbnail, with the name under it. +const CARD_W: f32 = 92.0; +const CARD_H: f32 = 104.0; +const THUMB_W: f32 = 56.0; +const THUMB_H: f32 = 70.0; + /// The Page Templates pane (issue #173): every template, by category, each one a new page in /// the section; and a way to keep the open page as a template of its own. struct TemplatesPane { @@ -12235,43 +12241,42 @@ impl NoteCraftApp { if items.peek().is_none() { ui.weak(crate::tl_id!("ui.no_saved_templates")); } - for template in items { - let label = if mine { template.name.clone() } else { crate::tl!(&template.name).to_string() }; - let width = ui.available_width().max(60.0); - let (rect, row) = ui.allocate_exact_size(vec2(width, 44.0), Sense::click()); - row.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label.clone())); - if row.hovered() { - ui.painter().rect_filled(rect, 3.0, tokens.row_hover); - } - // The thumbnail is the page the template makes: its own words and paper. - let (body, paper) = match &template.source { - notecraft_store::page_templates::Source::BuiltIn(b) => (b.body, b.paper), - notecraft_store::page_templates::Source::Saved(_) => ("", None), - }; - let rtl = ui.layout().prefer_right_to_left(); - let colours = crate::template_thumb::Colours { - page: tokens.editor, - rule: tokens.rule_line, - words: tokens.muted, - heading: tokens.accent, - edge: tokens.container_border, - }; - let thumb = if rtl { - egui::Rect::from_min_size(rect.right_top() + vec2(-40.0, 3.0), vec2(32.0, 38.0)) - } else { - egui::Rect::from_min_size(rect.left_top() + vec2(6.0, 3.0), vec2(32.0, 38.0)) - }; - crate::template_thumb::paint(ui.painter(), thumb, body, crate::template_thumb::paper_for(paper), colours, rtl); - let (anchor, align) = if rtl { - (rect.right_center() - vec2(50.0, 0.0), egui::Align2::RIGHT_CENTER) - } else { - (rect.left_center() + vec2(50.0, 0.0), egui::Align2::LEFT_CENTER) - }; - ui.painter().text(anchor, align, &label, egui::FontId::proportional(13.5), tokens.text); - if row.on_hover_text(crate::tl_id!("ui.add_a_page_from_this_template")).clicked() { - chosen = Some((template.id.clone(), label)); + // Cards in a wrapping row: as many across as the pane is wide, so more templates + // later flow onto new rows without a change here. + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = vec2(8.0, 8.0); + for template in items { + let label = if mine { template.name.clone() } else { crate::tl!(&template.name).to_string() }; + let (rect, card) = ui.allocate_exact_size(vec2(CARD_W, CARD_H), Sense::click()); + card.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label.clone())); + if card.hovered() { + ui.painter().rect_filled(rect, 4.0, tokens.row_hover); + } + // The thumbnail is the page the template makes: its own words and paper. + let (body, paper) = match &template.source { + notecraft_store::page_templates::Source::BuiltIn(b) => (b.body, b.paper), + notecraft_store::page_templates::Source::Saved(_) => ("", None), + }; + let rtl = ui.layout().prefer_right_to_left(); + let colours = crate::template_thumb::Colours { + page: tokens.editor, + rule: tokens.rule_line, + words: tokens.muted, + heading: tokens.accent, + edge: tokens.container_border, + }; + let thumb = + egui::Rect::from_center_size(egui::pos2(rect.center().x, rect.top() + 6.0 + THUMB_H / 2.0), vec2(THUMB_W, THUMB_H)); + crate::template_thumb::paint(ui.painter(), thumb, body, crate::template_thumb::paper_for(paper), colours, rtl); + // The name under the thumbnail, wrapped to the card's width. + let galley = ui.painter().layout(label.clone(), egui::FontId::proportional(12.0), tokens.text, CARD_W - 10.0); + let at = egui::pos2(rect.center().x - galley.size().x / 2.0, thumb.bottom() + 4.0); + ui.painter().galley(at, galley, tokens.text); + if card.on_hover_text(crate::tl_id!("ui.add_a_page_from_this_template")).clicked() { + chosen = Some((template.id.clone(), label)); + } } - } + }); } }); // Issue #519: the template every new page in the open section starts from. diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 6cc11ec0..bf444fa6 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -693,6 +693,7 @@ fn fluent_color_asset(icon: Icon) -> Option<(&'static str, &'static [u8])> { Icon::Code => ("code", include_bytes!("../assets/fluent-color/code.svg")), Icon::Lock => ("lock_closed", include_bytes!("../assets/fluent-color/lock_closed.svg")), Icon::Help => ("question_circle", include_bytes!("../assets/fluent-color/question_circle.svg")), + Icon::PageStack => ("document_text", include_bytes!("../assets/fluent-color/document_text.svg")), Icon::Pen => ("pen", include_bytes!("../assets/notecraft-color/pen.svg")), Icon::Unlock => ("unlock", include_bytes!("../assets/notecraft-color/unlock.svg")), _ => return None, From eeebe0509a19eda850821425dccf43765d739636 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 11:54:04 -0800 Subject: [PATCH 09/19] feat(ui): colour icons for Equation, Symbol, Diagram and Sticker Fluent has no colour versions of these four, so they are NoteCraft drawings in the same 24px style, recorded in ATTRIBUTION.md. Co-Authored-By: Claude Haiku 5.5 --- ATTRIBUTION.md | 2 +- crates/ui-egui/assets/notecraft-color/diagram.svg | 1 + crates/ui-egui/assets/notecraft-color/equation.svg | 1 + crates/ui-egui/assets/notecraft-color/sticker.svg | 1 + crates/ui-egui/assets/notecraft-color/symbol.svg | 1 + crates/ui-egui/src/icons.rs | 4 ++++ 6 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/assets/notecraft-color/diagram.svg create mode 100644 crates/ui-egui/assets/notecraft-color/equation.svg create mode 100644 crates/ui-egui/assets/notecraft-color/sticker.svg create mode 100644 crates/ui-egui/assets/notecraft-color/symbol.svg diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index eae1381a..af3d8a84 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -151,7 +151,7 @@ data. | \crates/ui-egui/assets/fluent/*.svg\ | Selected Fluent UI System Icons used by the ribbon | Microsoft Fluent UI System Icons, MIT licensed; source: https://github.com/microsoft/fluentui-system-icons | Microsoft Corporation and contributors | | \crates/ui-egui/assets/fluent-color/*.svg\ | Selected Fluent UI System Icons colour versions (calendar, clock, link, image, table, video, mic, document, notebook, code, lock closed, question circle, clipboard) used by the ribbon | Microsoft Fluent UI System Icons, MIT licensed; source: https://github.com/microsoft/fluentui-system-icons (`assets//SVG/ic_fluent__24_color.svg`) | Microsoft Corporation and contributors | -| \crates/ui-egui/assets/notecraft-color/*.svg\ | Pen and unlocked padlock colour icons used by the ribbon. Not Fluent: Fluent has no colour version of these two, so they were drawn for NoteCraft in the same 24px style | Drawn for this project | The project's own work, under its MIT OR Apache-2.0 licence | +| \crates/ui-egui/assets/notecraft-color/*.svg\ | Colour icons used by the ribbon that Fluent has no colour version of: pen, unlocked padlock, equation, symbol, diagram and sticker. Drawn for NoteCraft in the same 24px style | Drawn for this project | The project's own work, under its MIT OR Apache-2.0 licence | ## OCR demo pictures diff --git a/crates/ui-egui/assets/notecraft-color/diagram.svg b/crates/ui-egui/assets/notecraft-color/diagram.svg new file mode 100644 index 00000000..218ee4f7 --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/diagram.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/notecraft-color/equation.svg b/crates/ui-egui/assets/notecraft-color/equation.svg new file mode 100644 index 00000000..76790ee3 --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/equation.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/notecraft-color/sticker.svg b/crates/ui-egui/assets/notecraft-color/sticker.svg new file mode 100644 index 00000000..e7fa8f08 --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/sticker.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/notecraft-color/symbol.svg b/crates/ui-egui/assets/notecraft-color/symbol.svg new file mode 100644 index 00000000..7b23b1f9 --- /dev/null +++ b/crates/ui-egui/assets/notecraft-color/symbol.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index bf444fa6..a2188542 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -694,6 +694,10 @@ fn fluent_color_asset(icon: Icon) -> Option<(&'static str, &'static [u8])> { Icon::Lock => ("lock_closed", include_bytes!("../assets/fluent-color/lock_closed.svg")), Icon::Help => ("question_circle", include_bytes!("../assets/fluent-color/question_circle.svg")), Icon::PageStack => ("document_text", include_bytes!("../assets/fluent-color/document_text.svg")), + Icon::Equation => ("equation", include_bytes!("../assets/notecraft-color/equation.svg")), + Icon::Symbol => ("symbol", include_bytes!("../assets/notecraft-color/symbol.svg")), + Icon::Diagram => ("diagram", include_bytes!("../assets/notecraft-color/diagram.svg")), + Icon::Sticker => ("sticker", include_bytes!("../assets/notecraft-color/sticker.svg")), Icon::Pen => ("pen", include_bytes!("../assets/notecraft-color/pen.svg")), Icon::Unlock => ("unlock", include_bytes!("../assets/notecraft-color/unlock.svg")), _ => return None, From 385c4d0be45b4601870e185c304da8c34ca980ff Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 12:05:10 -0800 Subject: [PATCH 10/19] feat(templates): colour page templates Five templates whose page is a colour (pale yellow, mint, sky blue, pink, grey), with names translated in every language. Co-Authored-By: Claude Haiku 5.5 --- crates/store/src/page_templates.rs | 25 ++++++++++++++++++++----- i18n/ar-XB.tsv | 5 +++++ i18n/ar.tsv | 5 +++++ i18n/de.tsv | 5 +++++ i18n/en-XA.tsv | 5 +++++ i18n/en.tsv | 5 +++++ i18n/es.tsv | 5 +++++ i18n/fa.tsv | 5 +++++ i18n/fr.tsv | 5 +++++ i18n/he.tsv | 5 +++++ i18n/hi.tsv | 5 +++++ i18n/ja.tsv | 5 +++++ i18n/ko.tsv | 5 +++++ i18n/ru.tsv | 5 +++++ i18n/tr.tsv | 5 +++++ i18n/ur.tsv | 5 +++++ i18n/zh.tsv | 5 +++++ 17 files changed, 100 insertions(+), 5 deletions(-) diff --git a/crates/store/src/page_templates.rs b/crates/store/src/page_templates.rs index e5d6c5d9..e6c90854 100644 --- a/crates/store/src/page_templates.rs +++ b/crates/store/src/page_templates.rs @@ -34,6 +34,8 @@ pub struct BuiltIn { pub category: Category, /// The paper it is drawn on (see `page.paper`), if it has one. pub paper: Option<&'static str>, + /// The page colour it is given (see `page.page-color`), if it has one. + pub colour: Option<&'static str>, /// Its words, as Markdown. Empty for a template that is only paper. pub body: &'static str, } @@ -79,6 +81,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "lecture-notes", name: "Lecture Notes", category: Category::Academic, + colour: None, paper: Some("college"), body: "## Course and lecture\n\n## Key ideas\n\n- \n\n## Notes\n\n## Questions to follow up\n\n- [ ] \n\n## Summary\n", }, @@ -86,15 +89,17 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "study-guide", name: "Study Guide", category: Category::Academic, + colour: None, paper: None, body: "## Topic\n\n## Terms to know\n\n| Term | Meaning |\n| --- | --- |\n| | |\n\n## Main points\n\n1. \n\n## Practice\n\n- [ ] \n", }, - BuiltIn { id: "college-ruled", name: "College Ruled", category: Category::Blank, paper: Some("college"), body: "" }, - BuiltIn { id: "grid", name: "Grid", category: Category::Blank, paper: Some("grid-medium"), body: "" }, + BuiltIn { id: "college-ruled", name: "College Ruled", category: Category::Blank, colour: None, paper: Some("college"), body: "" }, + BuiltIn { id: "grid", name: "Grid", category: Category::Blank, colour: None, paper: Some("grid-medium"), body: "" }, BuiltIn { id: "meeting-notes", name: "Meeting Notes", category: Category::Business, + colour: None, paper: None, body: "## Attendees\n\n- \n\n## Agenda\n\n1. \n\n## Notes\n\n## Decisions\n\n- \n\n## Action items\n\n- [ ] \n", }, @@ -102,6 +107,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "project-overview", name: "Project Overview", category: Category::Business, + colour: None, paper: None, body: "## Goal\n\n## Scope\n\n## Milestones\n\n| Milestone | Owner | Due |\n| --- | --- | --- |\n| | | |\n\n## Risks\n\n- \n\n## Next steps\n\n- [ ] \n", }, @@ -109,6 +115,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "to-do-list", name: "To Do List", category: Category::Planners, + colour: None, paper: None, body: "## Today\n\n- [ ] \n\n## This week\n\n- [ ] \n\n## Later\n\n- [ ] \n", }, @@ -116,9 +123,16 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "weekly-planner", name: "Weekly Planner", category: Category::Planners, + colour: None, paper: None, body: "## Monday\n\n- [ ] \n\n## Tuesday\n\n- [ ] \n\n## Wednesday\n\n- [ ] \n\n## Thursday\n\n- [ ] \n\n## Friday\n\n- [ ] \n\n## Weekend\n\n- [ ] \n", }, + // Coloured pages: the page itself is the colour, with no lines. + BuiltIn { id: "pale-yellow-page", name: "Pale Yellow Page", category: Category::Blank, colour: Some("pale yellow"), paper: None, body: "" }, + BuiltIn { id: "mint-page", name: "Mint Page", category: Category::Blank, colour: Some("mint"), paper: None, body: "" }, + BuiltIn { id: "sky-blue-page", name: "Sky Blue Page", category: Category::Blank, colour: Some("light blue"), paper: None, body: "" }, + BuiltIn { id: "pink-page", name: "Pink Page", category: Category::Blank, colour: Some("light pink"), paper: None, body: "" }, + BuiltIn { id: "grey-page", name: "Grey Page", category: Category::Blank, colour: Some("pale grey"), paper: None, body: "" }, ]; /// A template that can be picked. @@ -213,8 +227,8 @@ pub fn new_page(template: &Template, parent: &Path, settings: &Settings) -> Resu if !b.body.is_empty() { fill(&page, b.body)?; } - if b.paper.is_some() { - set_appearance(&page, b.paper, None)?; + if b.paper.is_some() || b.colour.is_some() { + set_appearance(&page, b.paper, b.colour)?; } Ok(()) })(); @@ -348,8 +362,9 @@ mod tests { assert_eq!(read_node(&page).expect("a page").kind, NodeKind::Page); assert!(!crate::page::load_page(&page).expect("load").has_title, "{}: a new page has no title yet", template.name); let Source::BuiltIn(b) = template.source else { continue }; - let (paper, _) = crate::page::appearance(&page).expect("appearance"); + let (paper, colour) = crate::page::appearance(&page).expect("appearance"); assert_eq!(paper.as_deref(), b.paper, "{}", b.name); + assert_eq!(colour.as_deref(), b.colour, "{}: the page colour the template gives", b.name); let text = crate::page::load_page(&page).expect("load").body; if let Some(first) = b.body.lines().find(|l| l.starts_with("## ")) { assert!(text.contains(first.trim_start_matches("## ")), "{} in {format:?}: {text}", b.name); diff --git a/i18n/ar-XB.tsv b/i18n/ar-XB.tsv index 98d36fd4..d13361a2 100644 --- a/i18n/ar-XB.tsv +++ b/i18n/ar-XB.tsv @@ -1803,3 +1803,8 @@ @id ui.colour_green_field [[RLI]]$$$Green:@@@[[PDI]] @id ui.colour_blue_field [[RLI]]$$$Blue:@@@[[PDI]] @id ui.colour_hex_field [[RLI]]$$$Hex:@@@[[PDI]] +@id ui.template_pale_yellow_page [[RLI]]$$$Pale Yellow Page@@@[[PDI]] +@id ui.template_mint_page [[RLI]]$$$Mint Page@@@[[PDI]] +@id ui.template_sky_blue_page [[RLI]]$$$Sky Blue Page@@@[[PDI]] +@id ui.template_pink_page [[RLI]]$$$Pink Page@@@[[PDI]] +@id ui.template_grey_page [[RLI]]$$$Grey Page@@@[[PDI]] diff --git a/i18n/ar.tsv b/i18n/ar.tsv index 5e9e5e30..0e41e54e 100644 --- a/i18n/ar.tsv +++ b/i18n/ar.tsv @@ -842,3 +842,8 @@ @id ui.template_college_ruled ورق بأسطر @id ui.template_weekly_planner المخطط الأسبوعي @id ui.template_category_business الأعمال +@id ui.template_pale_yellow_page صفحة صفراء فاتحة +@id ui.template_mint_page صفحة نعناعية +@id ui.template_sky_blue_page صفحة زرقاء سماوية +@id ui.template_pink_page صفحة وردية +@id ui.template_grey_page صفحة رمادية diff --git a/i18n/de.tsv b/i18n/de.tsv index c5f5b71d..1544b3c3 100644 --- a/i18n/de.tsv +++ b/i18n/de.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled Liniert @id ui.template_weekly_planner Wochenplaner @id ui.template_category_business Geschäft +@id ui.template_pale_yellow_page Gelbe Seite +@id ui.template_mint_page Minzseite +@id ui.template_sky_blue_page Himmelblaue Seite +@id ui.template_pink_page Rosa Seite +@id ui.template_grey_page Graue Seite diff --git a/i18n/en-XA.tsv b/i18n/en-XA.tsv index 1ee241a5..3ecffa1c 100644 --- a/i18n/en-XA.tsv +++ b/i18n/en-XA.tsv @@ -1803,3 +1803,8 @@ @id ui.colour_green_field $$$Green:@@@ @id ui.colour_blue_field $$$Blue:@@@ @id ui.colour_hex_field $$$Hex:@@@ +@id ui.template_pale_yellow_page $$$Pale Yellow Page@@@ +@id ui.template_mint_page $$$Mint Page@@@ +@id ui.template_sky_blue_page $$$Sky Blue Page@@@ +@id ui.template_pink_page $$$Pink Page@@@ +@id ui.template_grey_page $$$Grey Page@@@ diff --git a/i18n/en.tsv b/i18n/en.tsv index 303b3ed7..481fa677 100644 --- a/i18n/en.tsv +++ b/i18n/en.tsv @@ -1803,3 +1803,8 @@ @id ui.colour_green_field Green: @id ui.colour_blue_field Blue: @id ui.colour_hex_field Hex: +@id ui.template_pale_yellow_page Pale Yellow Page +@id ui.template_mint_page Mint Page +@id ui.template_sky_blue_page Sky Blue Page +@id ui.template_pink_page Pink Page +@id ui.template_grey_page Grey Page diff --git a/i18n/es.tsv b/i18n/es.tsv index e137fb7b..e5fbe7b1 100644 --- a/i18n/es.tsv +++ b/i18n/es.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled Con renglones @id ui.template_weekly_planner Planificador semanal @id ui.template_category_business Negocios +@id ui.template_pale_yellow_page Página amarilla +@id ui.template_mint_page Página menta +@id ui.template_sky_blue_page Página azul cielo +@id ui.template_pink_page Página rosa +@id ui.template_grey_page Página gris diff --git a/i18n/fa.tsv b/i18n/fa.tsv index 554ea441..c0453c69 100644 --- a/i18n/fa.tsv +++ b/i18n/fa.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled خط‌دار @id ui.template_weekly_planner برنامه هفتگی @id ui.template_category_business کسب‌وکار +@id ui.template_pale_yellow_page صفحه زرد روشن +@id ui.template_mint_page صفحه نعنایی +@id ui.template_sky_blue_page صفحه آبی آسمانی +@id ui.template_pink_page صفحه صورتی +@id ui.template_grey_page صفحه خاکستری diff --git a/i18n/fr.tsv b/i18n/fr.tsv index 055eb1f6..b1f82378 100644 --- a/i18n/fr.tsv +++ b/i18n/fr.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled Ligné @id ui.template_weekly_planner Planificateur hebdomadaire @id ui.template_category_business Affaires +@id ui.template_pale_yellow_page Page jaune pâle +@id ui.template_mint_page Page menthe +@id ui.template_sky_blue_page Page bleu ciel +@id ui.template_pink_page Page rose +@id ui.template_grey_page Page grise diff --git a/i18n/he.tsv b/i18n/he.tsv index 63357ac7..38841fe5 100644 --- a/i18n/he.tsv +++ b/i18n/he.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled משובץ שורות @id ui.template_weekly_planner מתכנן שבועי @id ui.template_category_business עסקים +@id ui.template_pale_yellow_page דף צהוב בהיר +@id ui.template_mint_page דף מנטה +@id ui.template_sky_blue_page דף כחול שמיים +@id ui.template_pink_page דף ורוד +@id ui.template_grey_page דף אפור diff --git a/i18n/hi.tsv b/i18n/hi.tsv index c62ca91c..63c85a36 100644 --- a/i18n/hi.tsv +++ b/i18n/hi.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled रूल्ड @id ui.template_weekly_planner साप्ताहिक योजनाकार @id ui.template_category_business व्यवसाय +@id ui.template_pale_yellow_page हल्का पीला पेज +@id ui.template_mint_page पुदीना पेज +@id ui.template_sky_blue_page आसमानी पेज +@id ui.template_pink_page गुलाबी पेज +@id ui.template_grey_page भूरा पेज diff --git a/i18n/ja.tsv b/i18n/ja.tsv index 664ff3f6..77f0c1bb 100644 --- a/i18n/ja.tsv +++ b/i18n/ja.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled 罫線 @id ui.template_weekly_planner 週間プランナー @id ui.template_category_business ビジネス +@id ui.template_pale_yellow_page 薄黄色のページ +@id ui.template_mint_page ミント色のページ +@id ui.template_sky_blue_page 空色のページ +@id ui.template_pink_page ピンクのページ +@id ui.template_grey_page グレーのページ diff --git a/i18n/ko.tsv b/i18n/ko.tsv index d9c8ed95..e223feac 100644 --- a/i18n/ko.tsv +++ b/i18n/ko.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled 줄 노트 @id ui.template_weekly_planner 주간 플래너 @id ui.template_category_business 비즈니스 +@id ui.template_pale_yellow_page 연노랑 페이지 +@id ui.template_mint_page 민트 페이지 +@id ui.template_sky_blue_page 하늘색 페이지 +@id ui.template_pink_page 분홍 페이지 +@id ui.template_grey_page 회색 페이지 diff --git a/i18n/ru.tsv b/i18n/ru.tsv index c712685a..1275e426 100644 --- a/i18n/ru.tsv +++ b/i18n/ru.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled В линейку @id ui.template_weekly_planner Недельный планировщик @id ui.template_category_business Деловые +@id ui.template_pale_yellow_page Бледно-жёлтая страница +@id ui.template_mint_page Мятная страница +@id ui.template_sky_blue_page Голубая страница +@id ui.template_pink_page Розовая страница +@id ui.template_grey_page Серая страница diff --git a/i18n/tr.tsv b/i18n/tr.tsv index 26256dda..049bc33b 100644 --- a/i18n/tr.tsv +++ b/i18n/tr.tsv @@ -1434,3 +1434,8 @@ @id ui.the_window_is_docked Ekranın sağına yerleştirildi. Diğer pencereler kenara kaydırılmadı; Masaüstüne yerleştir'i yeniden seçmek pencereyi eski hâline döndürür. @id ui.the_window_is_undocked Pencere eski hâline döndü. @id ui.the_screen_size_is_not_known_so_the_window_cannot_be_docked Ekran boyutu burada bilinmediğinden pencere yerleştirilemiyor. +@id ui.template_pale_yellow_page Açık sarı sayfa +@id ui.template_mint_page Nane yeşili sayfa +@id ui.template_sky_blue_page Gök mavisi sayfa +@id ui.template_pink_page Pembe sayfa +@id ui.template_grey_page Gri sayfa diff --git a/i18n/ur.tsv b/i18n/ur.tsv index 26034f7b..8e193277 100644 --- a/i18n/ur.tsv +++ b/i18n/ur.tsv @@ -838,3 +838,8 @@ @id ui.template_college_ruled لکیر دار @id ui.template_weekly_planner ہفتہ وار منصوبہ ساز @id ui.template_category_business کاروبار +@id ui.template_pale_yellow_page ہلکا پیلا صفحہ +@id ui.template_mint_page پودینہ صفحہ +@id ui.template_sky_blue_page آسمانی نیلا صفحہ +@id ui.template_pink_page گلابی صفحہ +@id ui.template_grey_page خاکستری صفحہ diff --git a/i18n/zh.tsv b/i18n/zh.tsv index c902741f..8c1a0506 100644 --- a/i18n/zh.tsv +++ b/i18n/zh.tsv @@ -841,3 +841,8 @@ @id ui.template_college_ruled 横线 @id ui.template_weekly_planner 周计划 @id ui.template_category_business 商务 +@id ui.template_pale_yellow_page 浅黄页面 +@id ui.template_mint_page 薄荷页面 +@id ui.template_sky_blue_page 天蓝页面 +@id ui.template_pink_page 粉色页面 +@id ui.template_grey_page 灰色页面 From 1eb08ea994f37f04d6cbf9db8898e9c64c81bb22 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 12:14:36 -0800 Subject: [PATCH 11/19] feat(templates): picture background templates A page can carry a background picture, stored in its own file in both formats, and drawn repeated behind the words. A Decorative category adds five templates: Leaves, Butterflies, Cats, Dogs and Bows. The pictures are NoteCraft drawings in the same style as the icons. Co-Authored-By: Claude Haiku 5.5 --- crates/store/src/page.rs | 38 ++++++++ crates/store/src/page_templates.rs | 87 +++++++++++++++++-- .../ui-egui/assets/page-backgrounds/bows.svg | 1 + .../assets/page-backgrounds/butterflies.svg | 1 + .../ui-egui/assets/page-backgrounds/cats.svg | 1 + .../ui-egui/assets/page-backgrounds/dogs.svg | 1 + .../assets/page-backgrounds/leaves.svg | 1 + crates/ui-egui/src/app.rs | 7 ++ crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/page_background.rs | 60 +++++++++++++ i18n/ar-XB.tsv | 6 ++ i18n/ar.tsv | 6 ++ i18n/de.tsv | 6 ++ i18n/en-XA.tsv | 6 ++ i18n/en.tsv | 6 ++ i18n/es.tsv | 6 ++ i18n/fa.tsv | 6 ++ i18n/fr.tsv | 6 ++ i18n/he.tsv | 6 ++ i18n/hi.tsv | 6 ++ i18n/ja.tsv | 6 ++ i18n/ko.tsv | 6 ++ i18n/ru.tsv | 6 ++ i18n/tr.tsv | 6 ++ i18n/ur.tsv | 6 ++ i18n/zh.tsv | 6 ++ 26 files changed, 286 insertions(+), 8 deletions(-) create mode 100644 crates/ui-egui/assets/page-backgrounds/bows.svg create mode 100644 crates/ui-egui/assets/page-backgrounds/butterflies.svg create mode 100644 crates/ui-egui/assets/page-backgrounds/cats.svg create mode 100644 crates/ui-egui/assets/page-backgrounds/dogs.svg create mode 100644 crates/ui-egui/assets/page-backgrounds/leaves.svg create mode 100644 crates/ui-egui/src/page_background.rs diff --git a/crates/store/src/page.rs b/crates/store/src/page.rs index c6cfbb0e..237917bc 100644 --- a/crates/store/src/page.rs +++ b/crates/store/src/page.rs @@ -800,6 +800,44 @@ pub fn set_appearance(dir: &Path, paper: Option<&str>, colour: Option<&str>) -> write_atomic(&file, &out) } +const BACKGROUND_KEY: &str = "background"; +const BACKGROUND_META: &str = "notecraft:background"; + +/// The background picture a page is drawn over, as it is written (a name such as `leaves`), or +/// `None` when the page has none. +pub fn background(dir: &Path) -> Result> { + let (format, file) = page_file(dir).ok_or_else(|| StoreError::NotFound(format!("{} is not a page", dir.display())))?; + let text = fs::read_to_string(&file).map_err(|e| StoreError::io("read", &file, e))?; + let raw = match format { + PageFormat::Html => html::meta(&text, BACKGROUND_META), + PageFormat::Cmgfm => frontmatter::value(&frontmatter::split_front(&text).0, BACKGROUND_KEY), + }; + Ok(raw.map(|v| v.trim().to_string()).filter(|v| !v.is_empty())) +} + +/// Writes the background picture into the page's own file. `None` takes the line out again. +pub fn set_background(dir: &Path, name: Option<&str>) -> Result<()> { + let writer = crate::coordination::page_writer(dir)?; + let _guard = writer.lock().map_err(|_| StoreError::invalid("the page writer is unavailable"))?; + let (format, file) = page_file(dir).ok_or_else(|| StoreError::NotFound(format!("{} is not a page", dir.display())))?; + let text = fs::read_to_string(&file).map_err(|e| StoreError::io("read", &file, e))?; + if read_only_in(format, &text) { + return Err(StoreError::invalid("this page is locked read only")); + } + let out = match format { + PageFormat::Html => html::set_meta(&text, BACKGROUND_META, name.unwrap_or_default()), + PageFormat::Cmgfm => { + let (front, rest) = frontmatter::split_front(&text); + let front = match name { + Some(n) => frontmatter::set_value(&front, BACKGROUND_KEY, n), + None => frontmatter::remove_value(&front, BACKGROUND_KEY), + }; + format!("{front}{rest}") + } + }; + write_atomic(&file, &out) +} + const RULES_KEY: &str = "rule-color"; const RULES_META: &str = "notecraft:rule-color"; diff --git a/crates/store/src/page_templates.rs b/crates/store/src/page_templates.rs index e6c90854..af7e72cf 100644 --- a/crates/store/src/page_templates.rs +++ b/crates/store/src/page_templates.rs @@ -34,6 +34,8 @@ pub struct BuiltIn { pub category: Category, /// The paper it is drawn on (see `page.paper`), if it has one. pub paper: Option<&'static str>, + /// The background picture it is drawn over (see `page.background`), if it has one. + pub background: Option<&'static str>, /// The page colour it is given (see `page.page-color`), if it has one. pub colour: Option<&'static str>, /// Its words, as Markdown. Empty for a template that is only paper. @@ -47,12 +49,15 @@ pub enum Category { Blank, Business, Planners, + /// Pages with a colour or a picture behind them. + Decorative, /// Pages saved as templates. Mine, } impl Category { - pub const ALL: [Category; 5] = [Category::Academic, Category::Blank, Category::Business, Category::Planners, Category::Mine]; + pub const ALL: [Category; 6] = + [Category::Academic, Category::Blank, Category::Business, Category::Planners, Category::Decorative, Category::Mine]; pub fn id(self) -> &'static str { match self { @@ -60,6 +65,7 @@ impl Category { Category::Blank => "blank", Category::Business => "business", Category::Planners => "planners", + Category::Decorative => "decorative", Category::Mine => "mine", } } @@ -71,6 +77,7 @@ impl Category { Category::Blank => "Blank", Category::Business => "Business", Category::Planners => "Planners", + Category::Decorative => "Decorative", Category::Mine => "My Templates", } } @@ -82,6 +89,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Lecture Notes", category: Category::Academic, colour: None, + background: None, paper: Some("college"), body: "## Course and lecture\n\n## Key ideas\n\n- \n\n## Notes\n\n## Questions to follow up\n\n- [ ] \n\n## Summary\n", }, @@ -90,16 +98,26 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Study Guide", category: Category::Academic, colour: None, + background: None, paper: None, body: "## Topic\n\n## Terms to know\n\n| Term | Meaning |\n| --- | --- |\n| | |\n\n## Main points\n\n1. \n\n## Practice\n\n- [ ] \n", }, - BuiltIn { id: "college-ruled", name: "College Ruled", category: Category::Blank, colour: None, paper: Some("college"), body: "" }, - BuiltIn { id: "grid", name: "Grid", category: Category::Blank, colour: None, paper: Some("grid-medium"), body: "" }, + BuiltIn { + id: "college-ruled", + name: "College Ruled", + category: Category::Blank, + colour: None, + background: None, + paper: Some("college"), + body: "", + }, + BuiltIn { id: "grid", name: "Grid", category: Category::Blank, colour: None, background: None, paper: Some("grid-medium"), body: "" }, BuiltIn { id: "meeting-notes", name: "Meeting Notes", category: Category::Business, colour: None, + background: None, paper: None, body: "## Attendees\n\n- \n\n## Agenda\n\n1. \n\n## Notes\n\n## Decisions\n\n- \n\n## Action items\n\n- [ ] \n", }, @@ -108,6 +126,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Project Overview", category: Category::Business, colour: None, + background: None, paper: None, body: "## Goal\n\n## Scope\n\n## Milestones\n\n| Milestone | Owner | Due |\n| --- | --- | --- |\n| | | |\n\n## Risks\n\n- \n\n## Next steps\n\n- [ ] \n", }, @@ -116,6 +135,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "To Do List", category: Category::Planners, colour: None, + background: None, paper: None, body: "## Today\n\n- [ ] \n\n## This week\n\n- [ ] \n\n## Later\n\n- [ ] \n", }, @@ -124,15 +144,62 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Weekly Planner", category: Category::Planners, colour: None, + background: None, paper: None, body: "## Monday\n\n- [ ] \n\n## Tuesday\n\n- [ ] \n\n## Wednesday\n\n- [ ] \n\n## Thursday\n\n- [ ] \n\n## Friday\n\n- [ ] \n\n## Weekend\n\n- [ ] \n", }, // Coloured pages: the page itself is the colour, with no lines. - BuiltIn { id: "pale-yellow-page", name: "Pale Yellow Page", category: Category::Blank, colour: Some("pale yellow"), paper: None, body: "" }, - BuiltIn { id: "mint-page", name: "Mint Page", category: Category::Blank, colour: Some("mint"), paper: None, body: "" }, - BuiltIn { id: "sky-blue-page", name: "Sky Blue Page", category: Category::Blank, colour: Some("light blue"), paper: None, body: "" }, - BuiltIn { id: "pink-page", name: "Pink Page", category: Category::Blank, colour: Some("light pink"), paper: None, body: "" }, - BuiltIn { id: "grey-page", name: "Grey Page", category: Category::Blank, colour: Some("pale grey"), paper: None, body: "" }, + BuiltIn { + id: "pale-yellow-page", + name: "Pale Yellow Page", + category: Category::Blank, + colour: Some("pale yellow"), + background: None, + paper: None, + body: "", + }, + BuiltIn { id: "mint-page", name: "Mint Page", category: Category::Decorative, colour: Some("mint"), background: None, paper: None, body: "" }, + BuiltIn { + id: "sky-blue-page", + name: "Sky Blue Page", + category: Category::Blank, + colour: Some("light blue"), + background: None, + paper: None, + body: "", + }, + BuiltIn { + id: "pink-page", + name: "Pink Page", + category: Category::Decorative, + colour: Some("light pink"), + background: None, + paper: None, + body: "", + }, + BuiltIn { + id: "grey-page", + name: "Grey Page", + category: Category::Decorative, + colour: Some("pale grey"), + background: None, + paper: None, + body: "", + }, + // Pages with a repeating picture behind the words. The picture is a name the app draws. + BuiltIn { id: "leaves-page", name: "Leaves", category: Category::Decorative, colour: None, background: Some("leaves"), paper: None, body: "" }, + BuiltIn { + id: "butterflies-page", + name: "Butterflies", + category: Category::Decorative, + colour: None, + background: Some("butterflies"), + paper: None, + body: "", + }, + BuiltIn { id: "cats-page", name: "Cats", category: Category::Decorative, colour: None, background: Some("cats"), paper: None, body: "" }, + BuiltIn { id: "dogs-page", name: "Dogs", category: Category::Decorative, colour: None, background: Some("dogs"), paper: None, body: "" }, + BuiltIn { id: "bows-page", name: "Bows", category: Category::Decorative, colour: None, background: Some("bows"), paper: None, body: "" }, ]; /// A template that can be picked. @@ -227,6 +294,9 @@ pub fn new_page(template: &Template, parent: &Path, settings: &Settings) -> Resu if !b.body.is_empty() { fill(&page, b.body)?; } + if let Some(picture) = b.background { + crate::page::set_background(&page, Some(picture))?; + } if b.paper.is_some() || b.colour.is_some() { set_appearance(&page, b.paper, b.colour)?; } @@ -365,6 +435,7 @@ mod tests { let (paper, colour) = crate::page::appearance(&page).expect("appearance"); assert_eq!(paper.as_deref(), b.paper, "{}", b.name); assert_eq!(colour.as_deref(), b.colour, "{}: the page colour the template gives", b.name); + assert_eq!(crate::page::background(&page).expect("background").as_deref(), b.background, "{}: the picture it gives", b.name); let text = crate::page::load_page(&page).expect("load").body; if let Some(first) = b.body.lines().find(|l| l.starts_with("## ")) { assert!(text.contains(first.trim_start_matches("## ")), "{} in {format:?}: {text}", b.name); diff --git a/crates/ui-egui/assets/page-backgrounds/bows.svg b/crates/ui-egui/assets/page-backgrounds/bows.svg new file mode 100644 index 00000000..178da133 --- /dev/null +++ b/crates/ui-egui/assets/page-backgrounds/bows.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/page-backgrounds/butterflies.svg b/crates/ui-egui/assets/page-backgrounds/butterflies.svg new file mode 100644 index 00000000..869c5527 --- /dev/null +++ b/crates/ui-egui/assets/page-backgrounds/butterflies.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/page-backgrounds/cats.svg b/crates/ui-egui/assets/page-backgrounds/cats.svg new file mode 100644 index 00000000..c6571aef --- /dev/null +++ b/crates/ui-egui/assets/page-backgrounds/cats.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/page-backgrounds/dogs.svg b/crates/ui-egui/assets/page-backgrounds/dogs.svg new file mode 100644 index 00000000..30de327e --- /dev/null +++ b/crates/ui-egui/assets/page-backgrounds/dogs.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/assets/page-backgrounds/leaves.svg b/crates/ui-egui/assets/page-backgrounds/leaves.svg new file mode 100644 index 00000000..86b060bd --- /dev/null +++ b/crates/ui-egui/assets/page-backgrounds/leaves.svg @@ -0,0 +1 @@ + diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 2072ea22..0363e092 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -1138,6 +1138,8 @@ struct Editor { colour: Option, /// The colour of this page's rule and grid lines, when it was given one (issue #288). rule_colour: Option, + /// The picture repeated behind the page (a name such as `leaves`), when the page has one. + background: Option, /// The sheet the page is written for; `None` is Auto (issue #269). paper_size: Option, /// What the page looked like before each change, so a change can be taken back. @@ -4942,6 +4944,7 @@ impl NoteCraftApp { paper: appearance.0, colour: appearance.1, rule_colour: notecraft_store::page::rule_colour(dir).ok().flatten().and_then(|c| notecraft_model::NodeColor::parse(&c)), + background: notecraft_store::page::background(dir).ok().flatten(), paper_size: notecraft_store::page::paper_size(dir).ok().flatten(), history: crate::history::History::new(crate::history::Step::new(first.0, first.1, first.2, None, crate::history::Kind::Edit)), origin: egui::Pos2::ZERO, @@ -13470,6 +13473,10 @@ impl NoteCraftApp { let visible_paper = viewport.intersect(ui.clip_rect()); if wide { ui.painter_at(viewport).rect_filled(viewport, 0.0, page_colour.unwrap_or(tokens.editor)); + // The picture repeats behind the words, over the colour. + if let Some(picture) = ed.background.as_deref() { + crate::page_background::paint(ui, viewport, picture); + } } if wide && rules.on() { let lines = crate::theme::rule_lines_in(&tokens, ed.rule_colour); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 424c14a2..958f3c27 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -62,6 +62,7 @@ pub mod mathview; pub mod navdrag; pub mod navhistory; pub mod onlinevideo; +pub mod page_background; pub mod pageedit; pub mod pagemenu; pub mod pagetext; diff --git a/crates/ui-egui/src/page_background.rs b/crates/ui-egui/src/page_background.rs new file mode 100644 index 00000000..a2392abb --- /dev/null +++ b/crates/ui-egui/src/page_background.rs @@ -0,0 +1,60 @@ +//! Page backgrounds: a small picture repeated across a page, behind the words. The page file +//! names the picture (`leaves`, `cats` and so on); this module draws it, from the pictures +//! bundled with the app, one tile after another over the page's area. + +use egui::{Rect, Ui, UiBuilder, pos2, vec2}; + +/// The side of one tile, in points. +pub const TILE: f32 = 120.0; + +/// The bundled picture a page file names, with the key its image is cached under. `None` for a +/// name the app does not have, so an unknown picture draws nothing rather than failing. +fn picture(name: &str) -> Option<(&'static str, &'static [u8])> { + Some(match name { + "leaves" => ("leaves", include_bytes!("../assets/page-backgrounds/leaves.svg")), + "butterflies" => ("butterflies", include_bytes!("../assets/page-backgrounds/butterflies.svg")), + "cats" => ("cats", include_bytes!("../assets/page-backgrounds/cats.svg")), + "dogs" => ("dogs", include_bytes!("../assets/page-backgrounds/dogs.svg")), + "bows" => ("bows", include_bytes!("../assets/page-backgrounds/bows.svg")), + _ => return None, + }) +} + +/// Repeats the picture `name` across `area`, clipped to it, so the tiles stay on the page. +pub fn paint(ui: &mut Ui, area: Rect, name: &str) { + let Some((key, bytes)) = picture(name) else { return }; + ui.scope_builder(UiBuilder::new().id_salt("page-background").max_rect(area), |ui| { + ui.set_clip_rect(area); + let mut y = area.top(); + while y < area.bottom() { + let mut x = area.left(); + while x < area.right() { + let tile = Rect::from_min_size(pos2(x, y), vec2(TILE, TILE)); + egui::Image::from_bytes(format!("bytes://notecraft-page-background/{key}.svg"), bytes) + .fit_to_exact_size(vec2(TILE, TILE)) + .paint_at(ui, tile); + x += TILE; + } + y += TILE; + } + }); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn every_picture_a_template_names_is_bundled() { + for name in ["leaves", "butterflies", "cats", "dogs", "bows"] { + assert!(picture(name).is_some(), "{name} has a bundled picture"); + let (_, bytes) = picture(name).expect("picture"); + assert!(String::from_utf8_lossy(bytes).contains(" Date: Sun, 29 Nov 2026 12:30:38 -0800 Subject: [PATCH 12/19] feat(templates): margin pictures, real thumbnails, exact page colours Leaves and Cats draw down the margin (left, or right in right-to-left). Thumbnails show each template's colour and picture. More Colors in Page Color picks any exact colour, stored as hex without a hash (a hash starts a comment in front matter). Co-Authored-By: Claude Haiku 5.5 --- crates/store/src/page.rs | 7 +- crates/store/src/page_templates.rs | 30 +++----- crates/ui-egui/src/app.rs | 98 +++++++++++++++++++++++---- crates/ui-egui/src/page_background.rs | 73 ++++++++++++++++---- crates/ui-egui/src/ribbon.rs | 9 +++ crates/ui-egui/src/template_thumb.rs | 10 ++- 6 files changed, 175 insertions(+), 52 deletions(-) diff --git a/crates/store/src/page.rs b/crates/store/src/page.rs index 237917bc..c5f5b346 100644 --- a/crates/store/src/page.rs +++ b/crates/store/src/page.rs @@ -767,11 +767,16 @@ pub fn appearance(dir: &Path) -> Result<(Option, Option)> { .map(|v| v.trim().to_string()) .filter(|v| !v.is_empty()) }; - Ok((read(PAPER_META, PAPER_KEY), read(COLOUR_META, COLOUR_KEY))) + // A hex colour is written without its `#` (in front matter a `#` starts a comment), so it is + // given back with one. + let colour = read(COLOUR_META, COLOUR_KEY).map(|c| if c.len() == 6 && c.chars().all(|x| x.is_ascii_hexdigit()) { format!("#{c}") } else { c }); + Ok((read(PAPER_META, PAPER_KEY), colour)) } /// Writes them into the page's own file. `None` takes the line out again. pub fn set_appearance(dir: &Path, paper: Option<&str>, colour: Option<&str>) -> Result<()> { + // A hex colour is written without its `#`: see `appearance`. + let colour = colour.map(|c| c.trim_start_matches('#')); let writer = crate::coordination::page_writer(dir)?; let _guard = writer.lock().map_err(|_| StoreError::invalid("the page writer is unavailable"))?; let (format, file) = page_file(dir).ok_or_else(|| StoreError::NotFound(format!("{} is not a page", dir.display())))?; diff --git a/crates/store/src/page_templates.rs b/crates/store/src/page_templates.rs index af7e72cf..ea112278 100644 --- a/crates/store/src/page_templates.rs +++ b/crates/store/src/page_templates.rs @@ -153,41 +153,33 @@ pub const BUILT_IN: &[BuiltIn] = &[ id: "pale-yellow-page", name: "Pale Yellow Page", category: Category::Blank, - colour: Some("pale yellow"), + colour: Some("#FFF4B8"), background: None, paper: None, body: "", }, - BuiltIn { id: "mint-page", name: "Mint Page", category: Category::Decorative, colour: Some("mint"), background: None, paper: None, body: "" }, + BuiltIn { id: "mint-page", name: "Mint Page", category: Category::Decorative, colour: Some("#D8F3E4"), background: None, paper: None, body: "" }, BuiltIn { id: "sky-blue-page", name: "Sky Blue Page", category: Category::Blank, - colour: Some("light blue"), - background: None, - paper: None, - body: "", - }, - BuiltIn { - id: "pink-page", - name: "Pink Page", - category: Category::Decorative, - colour: Some("light pink"), + colour: Some("#D6EBFA"), background: None, paper: None, body: "", }, + BuiltIn { id: "pink-page", name: "Pink Page", category: Category::Decorative, colour: Some("#FADCE8"), background: None, paper: None, body: "" }, + BuiltIn { id: "grey-page", name: "Grey Page", category: Category::Decorative, colour: Some("#E6E8EB"), background: None, paper: None, body: "" }, + // Pages with a repeating picture behind the words. The picture is a name the app draws. BuiltIn { - id: "grey-page", - name: "Grey Page", + id: "leaves-page", + name: "Leaves", category: Category::Decorative, - colour: Some("pale grey"), - background: None, + colour: None, + background: Some("leaves-margin"), paper: None, body: "", }, - // Pages with a repeating picture behind the words. The picture is a name the app draws. - BuiltIn { id: "leaves-page", name: "Leaves", category: Category::Decorative, colour: None, background: Some("leaves"), paper: None, body: "" }, BuiltIn { id: "butterflies-page", name: "Butterflies", @@ -197,7 +189,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ paper: None, body: "", }, - BuiltIn { id: "cats-page", name: "Cats", category: Category::Decorative, colour: None, background: Some("cats"), paper: None, body: "" }, + BuiltIn { id: "cats-page", name: "Cats", category: Category::Decorative, colour: None, background: Some("cats-margin"), paper: None, body: "" }, BuiltIn { id: "dogs-page", name: "Dogs", category: Category::Decorative, colour: None, background: Some("dogs"), paper: None, body: "" }, BuiltIn { id: "bows-page", name: "Bows", category: Category::Decorative, colour: None, background: Some("bows"), paper: None, body: "" }, ]; diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 0363e092..80f94b34 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -1136,6 +1136,9 @@ struct Editor { /// keeps them. `None` means the page says nothing and the window's own choice stands. paper: Option, colour: Option, + /// A colour chosen with More Colors, which the page is drawn in exactly; `None` when the page + /// has one of the named colours (or none). + custom_colour: Option, /// The colour of this page's rule and grid lines, when it was given one (issue #288). rule_colour: Option, /// The picture repeated behind the page (a name such as `leaves`), when the page has one. @@ -1540,6 +1543,10 @@ enum Dialog { highlight: bool, colour: egui::Color32, }, + /// Page Color > More Colors: the same picker, for any colour behind the open page. + MorePageColours { + colour: egui::Color32, + }, Link { block: usize, cell: Option<(usize, usize)>, @@ -4943,6 +4950,11 @@ impl NoteCraftApp { ink_files: notecraft_store::page::ink_files(dir), paper: appearance.0, colour: appearance.1, + custom_colour: notecraft_store::page::appearance(dir) + .ok() + .and_then(|(_, c)| c) + .filter(|c| c.starts_with('#')) + .and_then(|c| crate::textcolour::parse(&c)), rule_colour: notecraft_store::page::rule_colour(dir).ok().flatten().and_then(|c| notecraft_model::NodeColor::parse(&c)), background: notecraft_store::page::background(dir).ok().flatten(), paper_size: notecraft_store::page::paper_size(dir).ok().flatten(), @@ -7745,6 +7757,9 @@ impl NoteCraftApp { let colour = current.as_deref().and_then(crate::textcolour::parse).unwrap_or(egui::Color32::BLACK); self.dialog = Some(Dialog::MoreColours { highlight, colour }); } + ribbon::Act::OpenMorePageColours { current } => { + self.dialog = Some(Dialog::MorePageColours { colour: current.unwrap_or(egui::Color32::WHITE) }); + } ribbon::Act::SetLayout(layout) => { let p = params(&[("layout", layout.as_setting())]); if self.run("ribbon.layout", &p).is_some() { @@ -9032,17 +9047,55 @@ impl NoteCraftApp { self.say(crate::tl_id!("ui.page_is_read_only")); return; } + // A named colour replaces a custom one; a paper change alone keeps the custom colour. + let named = colour.is_some(); + let kept_custom = if named { None } else { ed.custom_colour }; + let dir = ed.dir.clone(); let (path, paper, colour) = (path_str(&ed.dir), paper.or(ed.paper), colour.unwrap_or(ed.colour)); let pairs: Vec<(&str, &str)> = vec![ ("path", path.as_str()), ("paper", paper.map(ribbon::RuleLines::id).unwrap_or("none")), ("color", colour.map(notecraft_model::NodeColor::id).unwrap_or("none")), ]; - if self.run("page.paper", ¶ms(&pairs)).is_some() - && let Some(ed) = self.editor.as_mut() - { - ed.paper = paper; - ed.colour = colour; + if self.run("page.paper", ¶ms(&pairs)).is_some() { + if let Some(c) = kept_custom { + // The command above wrote the named colour, which removed the custom one from the + // page's file: put it back. + let hex = crate::colour_picker::hex(c); + let _ = notecraft_store::page::set_appearance(&dir, paper.map(ribbon::RuleLines::id), Some(&hex)); + } + if let Some(ed) = self.editor.as_mut() { + ed.paper = paper; + ed.colour = colour; + if named { + ed.custom_colour = None; + } + } + } + } + + /// Page Color > More Colors: gives the open page the colour the picker chose, exactly, and + /// writes it into the page's file as its hex value. + fn set_page_custom_colour(&mut self, c: egui::Color32) { + let Some(ed) = self.editor.as_mut() else { + self.say("Open a page first"); + return; + }; + if ed.locked { + self.say(crate::tl_id!("ui.page_is_read_only")); + return; + } + let dir = ed.dir.clone(); + let paper = ed.paper.map(ribbon::RuleLines::id); + let hex = crate::colour_picker::hex(c); + match notecraft_store::page::set_appearance(&dir, paper, Some(&hex)) { + Ok(()) => { + if let Some(ed) = self.editor.as_mut() { + ed.custom_colour = Some(c); + ed.colour = None; + } + } + Err(_) => self.say(crate::tl_id!("ui.page_is_read_only")), } } @@ -12256,13 +12309,15 @@ impl NoteCraftApp { ui.painter().rect_filled(rect, 4.0, tokens.row_hover); } // The thumbnail is the page the template makes: its own words and paper. - let (body, paper) = match &template.source { - notecraft_store::page_templates::Source::BuiltIn(b) => (b.body, b.paper), - notecraft_store::page_templates::Source::Saved(_) => ("", None), + let (body, paper, picture, page_colour) = match &template.source { + notecraft_store::page_templates::Source::BuiltIn(b) => { + (b.body, b.paper, b.background, b.colour.and_then(crate::textcolour::parse)) + } + notecraft_store::page_templates::Source::Saved(_) => ("", None, None, None), }; let rtl = ui.layout().prefer_right_to_left(); let colours = crate::template_thumb::Colours { - page: tokens.editor, + page: page_colour.unwrap_or(tokens.editor), rule: tokens.rule_line, words: tokens.muted, heading: tokens.accent, @@ -12270,7 +12325,7 @@ impl NoteCraftApp { }; let thumb = egui::Rect::from_center_size(egui::pos2(rect.center().x, rect.top() + 6.0 + THUMB_H / 2.0), vec2(THUMB_W, THUMB_H)); - crate::template_thumb::paint(ui.painter(), thumb, body, crate::template_thumb::paper_for(paper), colours, rtl); + crate::template_thumb::paint(ui, thumb, body, crate::template_thumb::paper_for(paper), colours, rtl, picture); // The name under the thumbnail, wrapped to the card's width. let galley = ui.painter().layout(label.clone(), egui::FontId::proportional(12.0), tokens.text, CARD_W - 10.0); let at = egui::pos2(rect.center().x - galley.size().x / 2.0, thumb.bottom() + 4.0); @@ -13361,10 +13416,14 @@ impl NoteCraftApp { let snap = self.snap_to_grid.then(|| if rules.on() { rules.step() } else { PLAIN_SNAP_STEP }); // The wash behind this page, if it carries a colour: a pale tint of it over the // page's own background, so the words keep their contrast whatever is chosen. - let page_colour = self.editor.as_ref().and_then(|e| e.colour).map(|c| { - let dark = self.theme().mode == crate::theme::Mode::Dark; - let (r, g, b) = c.rgb(dark); - crate::theme::mix(self.tokens.editor, egui::Color32::from_rgb(r, g, b), 0.16) + // A colour from More Colors is drawn exactly; a named colour is washed as before. + let custom_colour = self.editor.as_ref().and_then(|e| e.custom_colour); + let page_colour = custom_colour.or_else(|| { + self.editor.as_ref().and_then(|e| e.colour).map(|c| { + let dark = self.theme().mode == crate::theme::Mode::Dark; + let (r, g, b) = c.rgb(dark); + crate::theme::mix(self.tokens.editor, egui::Color32::from_rgb(r, g, b), 0.16) + }) }); // What the title area is showing, so the page's words do not say it again. let shown_title = self.editor.as_ref().map(|e| e.title.clone()).unwrap_or_default(); @@ -13475,7 +13534,8 @@ impl NoteCraftApp { ui.painter_at(viewport).rect_filled(viewport, 0.0, page_colour.unwrap_or(tokens.editor)); // The picture repeats behind the words, over the colour. if let Some(picture) = ed.background.as_deref() { - crate::page_background::paint(ui, viewport, picture); + let rtl = ui.layout().prefer_right_to_left(); + crate::page_background::paint(ui, viewport, picture, rtl); } } if wide && rules.on() { @@ -15056,6 +15116,14 @@ impl NoteCraftApp { crate::colour_picker::Outcome::Pending => {} } } + Dialog::MorePageColours { colour } => match crate::colour_picker::window(ctx, crate::tl_id!("ui.colours_title"), colour, &self.tokens) { + crate::colour_picker::Outcome::Apply(c) => { + self.set_page_custom_colour(c); + keep = false; + } + crate::colour_picker::Outcome::Cancel => keep = false, + crate::colour_picker::Outcome::Pending => {} + }, Dialog::Link { block, cell, range, text, address, editing, first, find } => { let (mut go, mut remove) = (false, false); // Every notebook, section group, section and page there is, as "title" over where diff --git a/crates/ui-egui/src/page_background.rs b/crates/ui-egui/src/page_background.rs index a2392abb..7187dd83 100644 --- a/crates/ui-egui/src/page_background.rs +++ b/crates/ui-egui/src/page_background.rs @@ -1,13 +1,16 @@ -//! Page backgrounds: a small picture repeated across a page, behind the words. The page file -//! names the picture (`leaves`, `cats` and so on); this module draws it, from the pictures -//! bundled with the app, one tile after another over the page's area. +//! Page backgrounds: a small picture drawn on a page behind the words. The page file names the +//! picture (`leaves`, `cats` and so on). A name ending in `-margin` draws the picture as a strip +//! down the page's margin (the left edge, or the right in a right-to-left layout); any other name +//! repeats it across the whole page. Pictures are bundled with the app. use egui::{Rect, Ui, UiBuilder, pos2, vec2}; -/// The side of one tile, in points. +/// The side of one tile across the whole page, in points. pub const TILE: f32 = 120.0; +/// The width of the margin strip, in points. +pub const MARGIN_W: f32 = 56.0; -/// The bundled picture a page file names, with the key its image is cached under. `None` for a +/// The bundled picture a name refers to, with the key its image is cached under. `None` for a /// name the app does not have, so an unknown picture draws nothing rather than failing. fn picture(name: &str) -> Option<(&'static str, &'static [u8])> { Some(match name { @@ -20,22 +23,56 @@ fn picture(name: &str) -> Option<(&'static str, &'static [u8])> { }) } -/// Repeats the picture `name` across `area`, clipped to it, so the tiles stay on the page. -pub fn paint(ui: &mut Ui, area: Rect, name: &str) { - let Some((key, bytes)) = picture(name) else { return }; - ui.scope_builder(UiBuilder::new().id_salt("page-background").max_rect(area), |ui| { +/// How a picture name is drawn: which picture, and whether it is the margin strip. +pub fn placement(name: &str) -> Option<(&str, bool)> { + match name.strip_suffix("-margin") { + Some(base) => Some((base, true)), + None => Some((name, false)), + } +} + +/// Draws the picture `name` on the page area `area`: as a margin strip on the page's start edge +/// when the name says so, otherwise repeated across the whole area. Clipped to `area`. +pub fn paint(ui: &mut Ui, area: Rect, name: &str, rtl: bool) { + paint_scaled(ui, area, name, rtl, 1.0); +} + +/// [`paint`] with every size multiplied by `scale`, for a thumbnail of a page. +pub fn paint_scaled(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32) { + let Some((base, margin)) = placement(name) else { return }; + let Some((key, bytes)) = picture(base) else { return }; + if margin { + let width = MARGIN_W * scale; + let column = if rtl { + Rect::from_min_max(pos2(area.right() - width, area.top()), pos2(area.right(), area.bottom())) + } else { + Rect::from_min_max(pos2(area.left(), area.top()), pos2(area.left() + width, area.bottom())) + }; + tile(ui, column, key, bytes, width, true); + } else { + tile(ui, area, key, bytes, TILE * scale, false); + } +} + +/// Repeats one picture across `area` at `side` points a tile, clipped to `area`. A margin strip +/// repeats down the column only; a page is covered in both directions. +fn tile(ui: &mut Ui, area: Rect, key: &'static str, bytes: &'static [u8], side: f32, down_only: bool) { + ui.scope_builder(UiBuilder::new().id_salt(("page-background", key, down_only)).max_rect(area), |ui| { ui.set_clip_rect(area); let mut y = area.top(); while y < area.bottom() { let mut x = area.left(); - while x < area.right() { - let tile = Rect::from_min_size(pos2(x, y), vec2(TILE, TILE)); + loop { + let tile = Rect::from_min_size(pos2(x, y), vec2(side, side)); egui::Image::from_bytes(format!("bytes://notecraft-page-background/{key}.svg"), bytes) - .fit_to_exact_size(vec2(TILE, TILE)) + .fit_to_exact_size(vec2(side, side)) .paint_at(ui, tile); - x += TILE; + x += side; + if down_only || x >= area.right() { + break; + } } - y += TILE; + y += side; } }); } @@ -47,7 +84,6 @@ mod tests { #[test] fn every_picture_a_template_names_is_bundled() { for name in ["leaves", "butterflies", "cats", "dogs", "bows"] { - assert!(picture(name).is_some(), "{name} has a bundled picture"); let (_, bytes) = picture(name).expect("picture"); assert!(String::from_utf8_lossy(bytes).contains(", }, + /// Page Color > More Colors: open the colour picker for the page's own colour. + OpenMorePageColours { + current: Option, + }, SetLayout(Layout), /// Sort the table's rows by the caret's column: true for descending (issue #171). TableSort(bool), @@ -3238,6 +3242,11 @@ fn page_colour_palette(ui: &mut Ui, view: &View<'_>, t: &Tokens, acts: &mut Vec< } }); ui.label(egui::RichText::new(crate::tl_id!("ui.the_paper_and_colour_apply_to_this_page_only")).small().color(t.muted)); + // Any other colour, from the same picker Font Colour uses. + if ui.button(crate::tl_id!("ui.more_colours")).clicked() { + acts.push(Act::OpenMorePageColours { current: None }); + picked = true; + } picked } diff --git a/crates/ui-egui/src/template_thumb.rs b/crates/ui-egui/src/template_thumb.rs index 78ed2290..f05e9866 100644 --- a/crates/ui-egui/src/template_thumb.rs +++ b/crates/ui-egui/src/template_thumb.rs @@ -3,7 +3,7 @@ //! files. The layout comes from the template's Markdown body, so a thumbnail always matches the //! page the template makes. -use egui::{Color32, Painter, Pos2, Rect, Stroke, pos2, vec2}; +use egui::{Color32, Pos2, Rect, Stroke, pos2, vec2}; /// One thing on the thumbnail, from one line of the template's words. #[derive(Clone, Debug, PartialEq, Eq)] @@ -86,8 +86,14 @@ pub struct Colours { /// Paints the template's page into `rect`: the paper, then its marks from the top down, stopping /// where the page ends. A right-to-left layout draws the marks from the right edge. -pub fn paint(painter: &Painter, rect: Rect, body: &str, paper: Paper, colours: Colours, rtl: bool) { +pub fn paint(ui: &mut egui::Ui, rect: Rect, body: &str, paper: Paper, colours: Colours, rtl: bool, picture: Option<&str>) { + let painter = ui.painter().clone(); painter.rect_filled(rect, 2.0, colours.page); + // The picture a template gives its page, drawn at thumbnail scale over the colour. + if let Some(name) = picture { + crate::page_background::paint_scaled(ui, rect, name, rtl, rect.width() / 240.0); + } + let painter = ui.painter().clone(); painter.rect_stroke(rect, 2.0, Stroke::new(1.0, colours.edge), egui::StrokeKind::Inside); let step = 6.0; let inner = rect.shrink(4.0); From 537b77df3c35861e06d31fc626f1c557a77d3ee5 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 12:51:43 -0800 Subject: [PATCH 13/19] feat(ui): Set Picture as Background, and the demo page that shows it Right-click a picture and choose Set Picture as Background. The picture is kept in the page's own assets and named in the page (HTML meta or front matter), and it repeats behind the page. The demo notebook has a page in each of its 14 languages that already has a leaf margin, and the page explains how to set one. Co-Authored-By: Claude Haiku 5.5 --- crates/formats/tests/format_parity.rs | 4 +- crates/ui-egui/src/app.rs | 45 +++++++++++++++-- crates/ui-egui/src/imagemenu.rs | 5 ++ crates/ui-egui/src/page_background.rs | 50 +++++++++++-------- crates/ui-egui/src/ribbon.rs | 2 + crates/ui-egui/tests/ui.rs | 2 +- .../10-en/how-to/page-background/index.md | 22 ++++++++ .../11-es/how-to/page-background/index.md | 22 ++++++++ .../12-fr/how-to/page-background/index.md | 22 ++++++++ .../13-de/how-to/page-background/index.md | 22 ++++++++ .../14-hi/how-to/page-background/index.md | 22 ++++++++ .../15-ru/how-to/page-background/index.md | 22 ++++++++ .../16-zh/how-to/page-background/index.md | 22 ++++++++ .../17-ja/how-to/page-background/index.md | 22 ++++++++ .../18-ko/how-to/page-background/index.md | 22 ++++++++ .../19-tr/how-to/page-background/index.md | 22 ++++++++ .../20-ar/how-to/page-background/index.md | 23 +++++++++ .../21-fa/how-to/page-background/index.md | 23 +++++++++ .../22-ur/how-to/page-background/index.md | 23 +++++++++ .../23-he/how-to/page-background/index.md | 23 +++++++++ .../10-en/how-to/page-background/index.html | 23 +++++++++ .../11-es/how-to/page-background/index.html | 23 +++++++++ .../12-fr/how-to/page-background/index.html | 23 +++++++++ .../13-de/how-to/page-background/index.html | 23 +++++++++ .../14-hi/how-to/page-background/index.html | 23 +++++++++ .../15-ru/how-to/page-background/index.html | 23 +++++++++ .../16-zh/how-to/page-background/index.html | 23 +++++++++ .../17-ja/how-to/page-background/index.html | 23 +++++++++ .../18-ko/how-to/page-background/index.html | 23 +++++++++ .../19-tr/how-to/page-background/index.html | 23 +++++++++ .../20-ar/how-to/page-background/index.html | 24 +++++++++ .../21-fa/how-to/page-background/index.html | 24 +++++++++ .../22-ur/how-to/page-background/index.html | 24 +++++++++ .../23-he/how-to/page-background/index.html | 24 +++++++++ .../scripts/content/ar/29-page-background.md | 18 +++++++ .../scripts/content/de/29-page-background.md | 18 +++++++ .../scripts/content/en/29-page-background.md | 18 +++++++ .../scripts/content/es/29-page-background.md | 18 +++++++ .../scripts/content/fa/29-page-background.md | 18 +++++++ .../scripts/content/fr/29-page-background.md | 18 +++++++ .../scripts/content/he/29-page-background.md | 18 +++++++ .../scripts/content/hi/29-page-background.md | 18 +++++++ .../scripts/content/ja/29-page-background.md | 18 +++++++ .../scripts/content/ko/29-page-background.md | 18 +++++++ .../scripts/content/ru/29-page-background.md | 18 +++++++ .../scripts/content/tr/29-page-background.md | 18 +++++++ .../scripts/content/ur/29-page-background.md | 18 +++++++ .../scripts/content/zh/29-page-background.md | 18 +++++++ docs/demo/scripts/src/generator.rs | 20 ++++++-- i18n/ar-XB.tsv | 1 + i18n/en-XA.tsv | 1 + i18n/en.tsv | 1 + 52 files changed, 990 insertions(+), 31 deletions(-) create mode 100644 docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-background/index.md create mode 100644 docs/demo/DemoNotebook/html/10-en/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/11-es/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/12-fr/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/13-de/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/14-hi/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/15-ru/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/16-zh/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/17-ja/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/18-ko/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/19-tr/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/20-ar/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/21-fa/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/22-ur/how-to/page-background/index.html create mode 100644 docs/demo/DemoNotebook/html/23-he/how-to/page-background/index.html create mode 100644 docs/demo/scripts/content/ar/29-page-background.md create mode 100644 docs/demo/scripts/content/de/29-page-background.md create mode 100644 docs/demo/scripts/content/en/29-page-background.md create mode 100644 docs/demo/scripts/content/es/29-page-background.md create mode 100644 docs/demo/scripts/content/fa/29-page-background.md create mode 100644 docs/demo/scripts/content/fr/29-page-background.md create mode 100644 docs/demo/scripts/content/he/29-page-background.md create mode 100644 docs/demo/scripts/content/hi/29-page-background.md create mode 100644 docs/demo/scripts/content/ja/29-page-background.md create mode 100644 docs/demo/scripts/content/ko/29-page-background.md create mode 100644 docs/demo/scripts/content/ru/29-page-background.md create mode 100644 docs/demo/scripts/content/tr/29-page-background.md create mode 100644 docs/demo/scripts/content/ur/29-page-background.md create mode 100644 docs/demo/scripts/content/zh/29-page-background.md diff --git a/crates/formats/tests/format_parity.rs b/crates/formats/tests/format_parity.rs index 314dad50..f62dcdb8 100644 --- a/crates/formats/tests/format_parity.rs +++ b/crates/formats/tests/format_parity.rs @@ -54,8 +54,8 @@ fn the_full_demo_notebooks_have_matching_pages_and_blocks() { let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("..").join("docs").join("demo").join("DemoNotebook"); let html = pages(&root.join("html")); let cmgfm = pages(&root.join("cmgfm")); - // The demo has 254 base pages (including the Page templates page in each of its 14 languages), 182 OCR pages (13 per language with OCR content), and a menus page in each of its 14 languages. - assert_eq!(html.len(), 450, "expected every page from the 14-language demo"); + // The demo has 268 base pages (including the Page templates and Page background pages in each of its 14 languages), 182 OCR pages (13 per language with OCR content), and a menus page in each of its 14 languages. + assert_eq!(html.len(), 464, "expected every page from the 14-language demo"); assert_eq!(html.len(), cmgfm.len(), "both notebooks must have the same number of pages"); assert_eq!(html.keys().collect::>(), cmgfm.keys().collect::>(), "page paths must match"); for language in ["10-en", "11-es", "12-fr", "13-de", "14-hi", "15-ru", "16-zh", "17-ja", "18-ko", "19-tr", "20-ar", "21-fa", "22-ur", "23-he"] { diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index a8e67782..57175b02 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -1141,8 +1141,12 @@ struct Editor { custom_colour: Option, /// The colour of this page's rule and grid lines, when it was given one (issue #288). rule_colour: Option, - /// The picture repeated behind the page (a name such as `leaves`), when the page has one. + /// The picture repeated behind the page (a name such as `leaves`, or a picture in the page's + /// own assets), when the page has one. background: Option, + /// The bytes of a picture in the page's own assets, read once when the page opens, so the + /// page is drawn without reading the file every frame. + background_image: Option, /// The sheet the page is written for; `None` is Auto (issue #269). paper_size: Option, /// What the page looked like before each change, so a change can be taken back. @@ -4958,6 +4962,12 @@ impl NoteCraftApp { .and_then(|c| crate::textcolour::parse(&c)), rule_colour: notecraft_store::page::rule_colour(dir).ok().flatten().and_then(|c| notecraft_model::NodeColor::parse(&c)), background: notecraft_store::page::background(dir).ok().flatten(), + background_image: notecraft_store::page::background(dir) + .ok() + .flatten() + .filter(|name| name.starts_with("assets/")) + .and_then(|name| crate::imagemenu::validate_and_read_image(dir, &name).ok()) + .map(|(_, _, bytes)| egui::load::Bytes::from(bytes)), paper_size: notecraft_store::page::paper_size(dir).ok().flatten(), history: crate::history::History::new(crate::history::Step::new(first.0, first.1, first.2, None, crate::history::Kind::Edit)), origin: egui::Pos2::ZERO, @@ -7766,6 +7776,7 @@ impl NoteCraftApp { ribbon::Act::OpenMorePageColours { current } => { self.dialog = Some(Dialog::MorePageColours { colour: current.unwrap_or(egui::Color32::WHITE) }); } + ribbon::Act::SetPictureBackground(src) => self.set_picture_background(src), ribbon::Act::SetLayout(layout) => { let p = params(&[("layout", layout.as_setting())]); if self.run("ribbon.layout", &p).is_some() { @@ -9080,6 +9091,30 @@ impl NoteCraftApp { } } + /// A picture in the open page becomes its background, in whichever format the page is in: the + /// page file names the picture's path, and the picture is read once for drawing. + fn set_picture_background(&mut self, src: String) { + let Some(ed) = self.editor.as_mut() else { + self.say("Open a page first"); + return; + }; + if ed.locked { + self.say(crate::tl_id!("ui.page_is_read_only")); + return; + } + let dir = ed.dir.clone(); + match notecraft_store::page::set_background(&dir, Some(&src)) { + Ok(()) => { + let bytes = crate::imagemenu::validate_and_read_image(&dir, &src).ok().map(|(_, _, bytes)| egui::load::Bytes::from(bytes)); + if let Some(ed) = self.editor.as_mut() { + ed.background = Some(src); + ed.background_image = bytes; + } + } + Err(_) => self.say(crate::tl_id!("ui.page_is_read_only")), + } + } + /// Page Color > More Colors: gives the open page the colour the picker chose, exactly, and /// writes it into the page's file as its hex value. fn set_page_custom_colour(&mut self, c: egui::Color32) { @@ -13557,8 +13592,12 @@ impl NoteCraftApp { ui.painter_at(viewport).rect_filled(viewport, 0.0, page_colour.unwrap_or(tokens.editor)); // The picture repeats behind the words, over the colour. if let Some(picture) = ed.background.as_deref() { - let rtl = ui.layout().prefer_right_to_left(); - crate::page_background::paint(ui, viewport, picture, rtl); + if let Some(bytes) = ed.background_image.clone() { + crate::page_background::paint_image(ui, viewport, picture, bytes); + } else { + let rtl = ui.layout().prefer_right_to_left(); + crate::page_background::paint(ui, viewport, picture, rtl); + } } } if wide && rules.on() { diff --git a/crates/ui-egui/src/imagemenu.rs b/crates/ui-egui/src/imagemenu.rs index 4b36c68a..18046469 100644 --- a/crates/ui-egui/src/imagemenu.rs +++ b/crates/ui-egui/src/imagemenu.rs @@ -92,6 +92,11 @@ pub fn show(ui: &mut Ui, body: egui::Rect, page: &Path, acts: &mut Vec, t: acts.push(Act::SavePictureAs(src.clone())); picked = true; } + // The picture becomes the page's background, in both page formats. + if floating::menu_row(ui, None, crate::tl_id!("ui.set_picture_as_background"), t).clicked() { + acts.push(Act::SetPictureBackground(src.clone())); + picked = true; + } // The printed text of the picture, or of a printout's page or every page (issue #274). if crate::picture_text::printout_source(&src).is_some() { if floating::menu_row(ui, None, crate::tl_id!("ui.copy_text_from_this_printout_page"), t).clicked() { diff --git a/crates/ui-egui/src/page_background.rs b/crates/ui-egui/src/page_background.rs index 7187dd83..ba7668e7 100644 --- a/crates/ui-egui/src/page_background.rs +++ b/crates/ui-egui/src/page_background.rs @@ -1,8 +1,10 @@ -//! Page backgrounds: a small picture drawn on a page behind the words. The page file names the -//! picture (`leaves`, `cats` and so on). A name ending in `-margin` draws the picture as a strip -//! down the page's margin (the left edge, or the right in a right-to-left layout); any other name -//! repeats it across the whole page. Pictures are bundled with the app. +//! Page backgrounds: a picture drawn on a page behind the words. The page file names the +//! picture. A bundled name (`leaves`, `cats` and so on) draws one of the pictures the app ships; +//! a name ending in `-margin` draws it as a strip down the page's margin (the left edge, or the +//! right in a right-to-left layout); any other name repeats it across the whole page. A picture +//! the user chose (`assets/`) is read by the page and repeats across it. +use egui::load::Bytes; use egui::{Rect, Ui, UiBuilder, pos2, vec2}; /// The side of one tile across the whole page, in points. @@ -31,8 +33,8 @@ pub fn placement(name: &str) -> Option<(&str, bool)> { } } -/// Draws the picture `name` on the page area `area`: as a margin strip on the page's start edge -/// when the name says so, otherwise repeated across the whole area. Clipped to `area`. +/// Draws the bundled picture `name` on the page area `area`: as a margin strip on the page's +/// start edge when the name says so, otherwise repeated across the whole area. Clipped to `area`. pub fn paint(ui: &mut Ui, area: Rect, name: &str, rtl: bool) { paint_scaled(ui, area, name, rtl, 1.0); } @@ -43,30 +45,39 @@ pub fn paint_scaled(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32) let Some((key, bytes)) = picture(base) else { return }; if margin { let width = MARGIN_W * scale; - let column = if rtl { - Rect::from_min_max(pos2(area.right() - width, area.top()), pos2(area.right(), area.bottom())) - } else { - Rect::from_min_max(pos2(area.left(), area.top()), pos2(area.left() + width, area.bottom())) - }; - tile(ui, column, key, bytes, width, true); + let column = margin_column(area, width, rtl); + tile(ui, column, key, Bytes::from(bytes), width, true); } else { - tile(ui, area, key, bytes, TILE * scale, false); + tile(ui, area, key, Bytes::from(bytes), TILE * scale, false); + } +} + +/// A picture the user chose for the page, repeated across the page. `key` is the picture's name +/// in the page (its path), which tells the image loader its file type. +pub fn paint_image(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes) { + tile(ui, area, key, bytes, TILE, false); +} + +fn margin_column(area: Rect, width: f32, rtl: bool) -> Rect { + if rtl { + Rect::from_min_max(pos2(area.right() - width, area.top()), pos2(area.right(), area.bottom())) + } else { + Rect::from_min_max(pos2(area.left(), area.top()), pos2(area.left() + width, area.bottom())) } } /// Repeats one picture across `area` at `side` points a tile, clipped to `area`. A margin strip /// repeats down the column only; a page is covered in both directions. -fn tile(ui: &mut Ui, area: Rect, key: &'static str, bytes: &'static [u8], side: f32, down_only: bool) { +fn tile(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, side: f32, down_only: bool) { + let uri = format!("bytes://notecraft-page-background/{key}"); ui.scope_builder(UiBuilder::new().id_salt(("page-background", key, down_only)).max_rect(area), |ui| { ui.set_clip_rect(area); let mut y = area.top(); while y < area.bottom() { let mut x = area.left(); loop { - let tile = Rect::from_min_size(pos2(x, y), vec2(side, side)); - egui::Image::from_bytes(format!("bytes://notecraft-page-background/{key}.svg"), bytes) - .fit_to_exact_size(vec2(side, side)) - .paint_at(ui, tile); + let cell = Rect::from_min_size(pos2(x, y), vec2(side, side)); + egui::Image::from_bytes(uri.clone(), bytes.clone()).fit_to_exact_size(vec2(side, side)).paint_at(ui, cell); x += side; if down_only || x >= area.right() { break; @@ -82,7 +93,7 @@ mod tests { use super::*; #[test] - fn every_picture_a_template_names_is_bundled() { + fn every_bundled_picture_is_an_svg() { for name in ["leaves", "butterflies", "cats", "dogs", "bows"] { let (_, bytes) = picture(name).expect("picture"); assert!(String::from_utf8_lossy(bytes).contains(", }, + /// A picture's menu: Set Picture as Background, with the picture's path in the page. + SetPictureBackground(String), /// Page Color > More Colors: open the colour picker for the page's own colour. OpenMorePageColours { current: Option, diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 77768f7b..6c2deeca 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -17683,7 +17683,7 @@ fn a_selected_picture_and_box_open_their_menus_from_the_keyboard() { // The arrows move through the menu; they do not move off the picture behind it. h.key_press(egui::Key::ArrowDown); settle(&mut h); - assert_eq!(focused_label(&h).as_deref(), Some("Copy Text from Picture"), "Down moves to the next row"); + assert_eq!(focused_label(&h).as_deref(), Some("Set Picture as Background"), "Down moves to the next row"); assert_eq!(look_at(&mut h).pointer("/page/selectedImage").and_then(Value::as_u64), Some(0), "and the picture stays selected"); assert!(h.query_by_label("Save picture as...").is_some(), "with its menu open"); h.key_press(egui::Key::Escape); diff --git a/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-background/index.md new file mode 100644 index 00000000..f0a2705e --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/10-en/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 835cac87c80e6e2c129a +title: "Set a picture as the background" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +A picture can sit behind the words of a page, the way wallpaper sits behind a room. This page already has one: the leaves down its left margin. + +## How to set one + +- Right-click the picture (or Control-click on a Mac). +- Select **Set Picture as Background**. + +The picture is copied into the page's own assets folder, so the page keeps it when you move or share it. It works in both HTML and Markdown pages. + +## This page + +This page was given a leaf margin when it was made, the way a template in the Decorative group gives one. diff --git a/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-background/index.md new file mode 100644 index 00000000..79bbe276 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/11-es/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: c43cb26f10e3bc268e48 +title: "Establecer una imagen como fondo" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +Una imagen puede ir detrás del texto de una página, como el papel de pared detrás de una habitación. Esta página ya tiene una: las hojas en su margen izquierdo. + +## Cómo hacerlo + +- Haz clic derecho en la imagen (o Control-clic en un Mac). +- Elige **Establecer imagen como fondo**. + +La imagen se copia en la carpeta de recursos de la página, así que la página la conserva al moverla o compartirla. Funciona en páginas HTML y Markdown. + +## Esta página + +Esta página tenía un margen de hojas al crearse, como lo da una plantilla del grupo Decorativas. diff --git a/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-background/index.md new file mode 100644 index 00000000..24a9398f --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/12-fr/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: ef8d5f68cec80e3bf803 +title: "Définir une image comme arrière-plan" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +Une image peut figurer derrière le texte d'une page, comme un papier peint derrière une pièce. Cette page en a déjà une : les feuilles sur sa marge gauche. + +## Comment faire + +- Cliquez avec le bouton droit sur l'image (ou Ctrl+clic sur Mac). +- Choisissez **Définir l'image comme arrière-plan**. + +L'image est copiée dans le dossier de ressources de la page, ainsi la page la conserve lorsque vous la déplacez ou la partagez. Cela fonctionne dans les pages HTML et Markdown. + +## Cette page + +Cette page a reçu une marge de feuilles à sa création, comme le fait un modèle du groupe Décoratifs. diff --git a/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-background/index.md new file mode 100644 index 00000000..734c987b --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/13-de/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: f854626ed2080c455475 +title: "Bild als Hintergrund festlegen" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +Ein Bild kann hinter dem Text einer Seite liegen, wie eine Tapete hinter den Wänden. Diese Seite hat schon eines: die Blätter am linken Rand. + +## So geht es + +- Klicken Sie mit der rechten Maustaste auf das Bild (auf dem Mac mit Ctrl-Klick). +- Wählen Sie **Bild als Hintergrund festlegen**. + +Das Bild wird in den Ressourcenordner der Seite kopiert, daher bleibt es erhalten, wenn Sie die Seite verschieben oder teilen. Es funktioniert in HTML- und Markdown-Seiten. + +## Diese Seite + +Diese Seite hat beim Erstellen einen Blätterrand bekommen, wie eine Vorlage aus der Gruppe Dekorativ. diff --git a/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-background/index.md new file mode 100644 index 00000000..2925fd4e --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/14-hi/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 4a35a29c1dd56b74110a +title: "तस्वीर को पृष्ठभूमि बनाएँ" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +किसी पेज के शब्दों के पीछे एक तस्वीर रखी जा सकती है, जैसे दीवार पर कागज़ लगा होता है। इस पेज पर पहले से एक है: बाईं ओर के हाशिये में पत्तियाँ। + +## ऐसे करें + +- तस्वीर पर राइट-क्लिक करें (Mac पर Control-क्लिक करें)। +- **तस्वीर को पृष्ठभूमि बनाएँ** चुनें। + +तस्वीर पेज के अपने संसाधन फ़ोल्डर में कॉपी होती है, इसलिए पेज को ले जाने या साझा करने पर भी वह बनी रहती है। यह HTML और Markdown दोनों पेजों पर काम करती है। + +## यह पेज + +यह पेज बनते समय पत्तियों वाले हाशिये के साथ बना था, जैसा सजावटी समूह का टेम्पलेट देता है। diff --git a/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-background/index.md new file mode 100644 index 00000000..c65ef0d7 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/15-ru/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 606c369a3d3a49992bb9 +title: "Сделать картинку фоном" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +Картинка может лежать за текстом страницы, как обои за мебелью. У этой страницы уже есть такая: листья на левом поле. + +## Как это сделать + +- Щёлкните картинку правой кнопкой (на Mac: Control-щелчок). +- Выберите **Сделать картинку фоном**. + +Картинка копируется в папку ресурсов страницы, поэтому она сохраняется при переносе и отправке страницы. Работает в страницах HTML и Markdown. + +## Эта страница + +Эта страница создана с листьями на поле, как даёт шаблон из группы «Декоративные». diff --git a/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-background/index.md new file mode 100644 index 00000000..6155e05e --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/16-zh/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 6608d9c6215c0c4d2181 +title: "将图片设为背景" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +图片可以像墙纸一样放在页面文字的后面。本页已经有一张:左侧页边的树叶。 + +## 操作方法 + +- 右键单击图片(Mac 上按住 Control 单击)。 +- 选择**将图片设为背景**。 + +图片会复制到页面自己的资源文件夹中,因此移动或分享页面时它仍会保留。HTML 和 Markdown 页面都支持。 + +## 本页 + +本页创建时就带有左侧页边的树叶,与「装饰」类模板的效果相同。 diff --git a/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-background/index.md new file mode 100644 index 00000000..1966a1d6 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/17-ja/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 4191c0cf0b22234bea2b +title: "画像を背景に設定" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +画像はページの文字の後ろに置けます。壁紙のようなものです。このページにはすでに一つあります。左の余白に並んだ葉です。 + +## 設定の方法 + +- 画像を右クリックします(Mac では Control キーを押しながらクリック)。 +- **画像を背景に設定**を選びます。 + +画像はページ自身のアセットフォルダにコピーされるため、ページを移動したり共有したりしても残ります。HTML と Markdown のどちらのページでも使えます。 + +## このページ + +このページは作成時に葉の余白が付いています。装飾カテゴリのテンプレートと同じ仕組みです。 diff --git a/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-background/index.md new file mode 100644 index 00000000..a16a8d85 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/18-ko/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: b4fac85b5a14023ffa97 +title: "그림을 배경으로 설정" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +그림을 페이지의 글 뒤에 둘 수 있습니다. 벽지처럼요. 이 페이지에는 이미 하나 있습니다. 왼쪽 여백의 나뭇잎입니다. + +## 설정 방법 + +- 그림을 마우스 오른쪽 버튼으로 클릭하세요(Mac에서는 Control-클릭). +- **그림을 배경으로 설정**을 고르세요. + +그림은 페이지 자체의 자산 폴더에 복사되므로, 페이지를 옮기거나 공유해도 남아 있습니다. HTML과 Markdown 페이지 모두에서 작동합니다. + +## 이 페이지 + +이 페이지는 만들 때 장식 그룹 템플릿처럼 왼쪽 여백에 나뭇잎이 들어가 있습니다. diff --git a/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-background/index.md new file mode 100644 index 00000000..f6228d10 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/19-tr/how-to/page-background/index.md @@ -0,0 +1,22 @@ +--- +id: 09d13d446a8c00bc51a2 +title: "Resmi arka plan yap" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +background: leaves-margin +tags: [] +--- + +Bir resim, duvardaki kağıt gibi sayfanın yazılarının arkasında durabilir. Bu sayfada zaten bir tane var: sol kenar boşluğundaki yapraklar. + +## Nasıl yapılır + +- Resme sağ tıklayın (Mac'te Control+tıklama). +- **Resmi arka plan yap**'ı seçin. + +Resim sayfanın kendi kaynak klasörüne kopyalanır, bu yüzden sayfayı taşıdığınızda ya da paylaştığınızda da kalır. HTML ve Markdown sayfalarında çalışır. + +## Bu sayfa + +Bu sayfa oluşturulurken sol kenarında yapraklar vardı; Dekoratif grubundaki şablonlarla aynı. diff --git a/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-background/index.md new file mode 100644 index 00000000..911ad239 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/20-ar/how-to/page-background/index.md @@ -0,0 +1,23 @@ +--- +id: 352d8d5d8591391f5dc7 +title: "تعيين صورة خلفية" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +background: leaves-margin +tags: [] +--- + +يمكن أن تقع صورة خلف كلمات الصفحة، كما تقع ورقة الجدران خلف الغرفة. هذه الصفحة فيها واحدة بالفعل: الأوراق في هامشها الأيسر. + +## كيفية التعيين + +- انقر بزر الفأرة الأيمن على الصورة (أو Control مع النقر على Mac). +- اختر **تعيين الصورة كخلفية**. + +تُنسخ الصورة إلى مجلد ملفات الصفحة نفسها، فتبقى معها عند نقلها أو مشاركتها. تعمل في صفحات HTML وMarkdown معًا. + +## هذه الصفحة + +أُنشئت هذه الصفحة بهامش من الأوراق، كما تفعل قوالب مجموعة الزخرفية. diff --git a/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-background/index.md new file mode 100644 index 00000000..9ae84f17 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/21-fa/how-to/page-background/index.md @@ -0,0 +1,23 @@ +--- +id: 256afc68bccecf7abdcc +title: "تنظیم یک تصویر به‌عنوان پس‌زمینه" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +background: leaves-margin +tags: [] +--- + +یک تصویر می‌تواند پشت متن صفحه قرار گیرد، مثل کاغذ دیواری پشت اتاق. این صفحه از قبل یکی دارد: برگ‌ها در حاشیه چپ. + +## روش کار + +- روی تصویر کلیک راست کنید (در مک با نگه داشتن Control و کلیک). +- **تنظیم تصویر به‌عنوان پس‌زمینه** را انتخاب کنید. + +تصویر در پوشه منابع خود صفحه کپی می‌شود، پس با جابه‌جایی یا اشتراک‌گذاری صفحه هم باقی می‌ماند. در صفحات HTML و Markdown کار می‌کند. + +## این صفحه + +این صفحه هنگام ساخته شدن حاشیه‌ای از برگ داشت، همان‌طور که الگوهای گروه تزئینی می‌دهند. diff --git a/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-background/index.md new file mode 100644 index 00000000..200c1b04 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/22-ur/how-to/page-background/index.md @@ -0,0 +1,23 @@ +--- +id: bb984307761186c91b99 +title: "تصویر کو پس منظر بنائیں" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +background: leaves-margin +tags: [] +--- + +کسی صفحے کے الفاظ کے پیچھے تصویر رکھی جا سکتی ہے، جیسے دیوار پر کاغذ ہوتا ہے۔ اس صفحے پر پہلے سے ایک ہے: بائیں حاشیے پر پتے۔ + +## ایسے کریں + +- تصویر پر دائیں کلک کریں (Mac پر Control دبا کر کلک کریں)۔ +- **تصویر کو پس منظر بنائیں** چنیں۔ + +تصویر صفحے کے اپنے اثاثوں کے فولڈر میں نقل ہوتی ہے، اس لیے صفحہ منتقل کرنے یا شیئر کرنے پر بھی برقرار رہتی ہے۔ یہ HTML اور Markdown دونوں صفحات پر کام کرتی ہے۔ + +## یہ صفحہ + +یہ صفحہ بنتے وقت بائیں حاشیے پر پتوں کے ساتھ بنا تھا، جیسے آرائشی گروپ کے ٹیمپلیٹس دیتے ہیں۔ diff --git a/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-background/index.md b/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-background/index.md new file mode 100644 index 00000000..cbcf22b1 --- /dev/null +++ b/docs/demo/DemoNotebook/cmgfm/23-he/how-to/page-background/index.md @@ -0,0 +1,23 @@ +--- +id: 307fe7d25dcc4b7eb430 +title: "הגדרת תמונה כרקע" +order: 29 +created: 2026-10-18T00:00:00Z +updated: 2026-10-18T00:00:00Z +dir: rtl +background: leaves-margin +tags: [] +--- + +אפשר להניח תמונה מאחורי המילים של עמוד, כמו טפט מאחורי קיר. לעמוד הזה כבר יש אחת: עלים בשוליים השמאליים. + +## איך עושים את זה + +- לחצו לחיצה ימנית על התמונה (ב-Mac: Control ולחיצה). +- בחרו **הגדרת התמונה כרקע**. + +התמונה מועתקת לתיקיית המשאבים של העמוד, לכן היא נשארת כשמעבירים או משתפים את העמוד. זה פועל בעמודי HTML ו-Markdown כאחד. + +## העמוד הזה + +העמוד נוצר עם שוליים של עלים, כמו שתבנית מקבוצת דקורטיביות נותנת. diff --git a/docs/demo/DemoNotebook/html/10-en/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/10-en/how-to/page-background/index.html new file mode 100644 index 00000000..8388c5be --- /dev/null +++ b/docs/demo/DemoNotebook/html/10-en/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Set a picture as the background + + + + + + + +

A picture can sit behind the words of a page, the way wallpaper sits behind a room. This page already has one: the leaves down its left margin.

+

How to set one

+
    +
  • Right-click the picture (or Control-click on a Mac).
  • +
  • Select Set Picture as Background.
  • +
+

The picture is copied into the page's own assets folder, so the page keeps it when you move or share it. It works in both HTML and Markdown pages.

+

This page

+

This page was given a leaf margin when it was made, the way a template in the Decorative group gives one.

+ + diff --git a/docs/demo/DemoNotebook/html/11-es/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/11-es/how-to/page-background/index.html new file mode 100644 index 00000000..c5fb5dbe --- /dev/null +++ b/docs/demo/DemoNotebook/html/11-es/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Establecer una imagen como fondo + + + + + + + +

Una imagen puede ir detrás del texto de una página, como el papel de pared detrás de una habitación. Esta página ya tiene una: las hojas en su margen izquierdo.

+

Cómo hacerlo

+
    +
  • Haz clic derecho en la imagen (o Control-clic en un Mac).
  • +
  • Elige Establecer imagen como fondo.
  • +
+

La imagen se copia en la carpeta de recursos de la página, así que la página la conserva al moverla o compartirla. Funciona en páginas HTML y Markdown.

+

Esta página

+

Esta página tenía un margen de hojas al crearse, como lo da una plantilla del grupo Decorativas.

+ + diff --git a/docs/demo/DemoNotebook/html/12-fr/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/12-fr/how-to/page-background/index.html new file mode 100644 index 00000000..9813b611 --- /dev/null +++ b/docs/demo/DemoNotebook/html/12-fr/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Définir une image comme arrière-plan + + + + + + + +

Une image peut figurer derrière le texte d'une page, comme un papier peint derrière une pièce. Cette page en a déjà une : les feuilles sur sa marge gauche.

+

Comment faire

+
    +
  • Cliquez avec le bouton droit sur l'image (ou Ctrl+clic sur Mac).
  • +
  • Choisissez Définir l'image comme arrière-plan.
  • +
+

L'image est copiée dans le dossier de ressources de la page, ainsi la page la conserve lorsque vous la déplacez ou la partagez. Cela fonctionne dans les pages HTML et Markdown.

+

Cette page

+

Cette page a reçu une marge de feuilles à sa création, comme le fait un modèle du groupe Décoratifs.

+ + diff --git a/docs/demo/DemoNotebook/html/13-de/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/13-de/how-to/page-background/index.html new file mode 100644 index 00000000..bf2f1946 --- /dev/null +++ b/docs/demo/DemoNotebook/html/13-de/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Bild als Hintergrund festlegen + + + + + + + +

Ein Bild kann hinter dem Text einer Seite liegen, wie eine Tapete hinter den Wänden. Diese Seite hat schon eines: die Blätter am linken Rand.

+

So geht es

+
    +
  • Klicken Sie mit der rechten Maustaste auf das Bild (auf dem Mac mit Ctrl-Klick).
  • +
  • Wählen Sie Bild als Hintergrund festlegen.
  • +
+

Das Bild wird in den Ressourcenordner der Seite kopiert, daher bleibt es erhalten, wenn Sie die Seite verschieben oder teilen. Es funktioniert in HTML- und Markdown-Seiten.

+

Diese Seite

+

Diese Seite hat beim Erstellen einen Blätterrand bekommen, wie eine Vorlage aus der Gruppe Dekorativ.

+ + diff --git a/docs/demo/DemoNotebook/html/14-hi/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/14-hi/how-to/page-background/index.html new file mode 100644 index 00000000..f27c4480 --- /dev/null +++ b/docs/demo/DemoNotebook/html/14-hi/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +तस्वीर को पृष्ठभूमि बनाएँ + + + + + + + +

किसी पेज के शब्दों के पीछे एक तस्वीर रखी जा सकती है, जैसे दीवार पर कागज़ लगा होता है। इस पेज पर पहले से एक है: बाईं ओर के हाशिये में पत्तियाँ।

+

ऐसे करें

+
    +
  • तस्वीर पर राइट-क्लिक करें (Mac पर Control-क्लिक करें)।
  • +
  • तस्वीर को पृष्ठभूमि बनाएँ चुनें।
  • +
+

तस्वीर पेज के अपने संसाधन फ़ोल्डर में कॉपी होती है, इसलिए पेज को ले जाने या साझा करने पर भी वह बनी रहती है। यह HTML और Markdown दोनों पेजों पर काम करती है।

+

यह पेज

+

यह पेज बनते समय पत्तियों वाले हाशिये के साथ बना था, जैसा सजावटी समूह का टेम्पलेट देता है।

+ + diff --git a/docs/demo/DemoNotebook/html/15-ru/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/15-ru/how-to/page-background/index.html new file mode 100644 index 00000000..63404179 --- /dev/null +++ b/docs/demo/DemoNotebook/html/15-ru/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Сделать картинку фоном + + + + + + + +

Картинка может лежать за текстом страницы, как обои за мебелью. У этой страницы уже есть такая: листья на левом поле.

+

Как это сделать

+
    +
  • Щёлкните картинку правой кнопкой (на Mac: Control-щелчок).
  • +
  • Выберите Сделать картинку фоном.
  • +
+

Картинка копируется в папку ресурсов страницы, поэтому она сохраняется при переносе и отправке страницы. Работает в страницах HTML и Markdown.

+

Эта страница

+

Эта страница создана с листьями на поле, как даёт шаблон из группы «Декоративные».

+ + diff --git a/docs/demo/DemoNotebook/html/16-zh/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/16-zh/how-to/page-background/index.html new file mode 100644 index 00000000..bc0ee1dd --- /dev/null +++ b/docs/demo/DemoNotebook/html/16-zh/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +将图片设为背景 + + + + + + + +

图片可以像墙纸一样放在页面文字的后面。本页已经有一张:左侧页边的树叶。

+

操作方法

+
    +
  • 右键单击图片(Mac 上按住 Control 单击)。
  • +
  • 选择将图片设为背景。
  • +
+

图片会复制到页面自己的资源文件夹中,因此移动或分享页面时它仍会保留。HTML 和 Markdown 页面都支持。

+

本页

+

本页创建时就带有左侧页边的树叶,与「装饰」类模板的效果相同。

+ + diff --git a/docs/demo/DemoNotebook/html/17-ja/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/17-ja/how-to/page-background/index.html new file mode 100644 index 00000000..2db06061 --- /dev/null +++ b/docs/demo/DemoNotebook/html/17-ja/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +画像を背景に設定 + + + + + + + +

画像はページの文字の後ろに置けます。壁紙のようなものです。このページにはすでに一つあります。左の余白に並んだ葉です。

+

設定の方法

+
    +
  • 画像を右クリックします(Mac では Control キーを押しながらクリック)。
  • +
  • 画像を背景に設定を選びます。
  • +
+

画像はページ自身のアセットフォルダにコピーされるため、ページを移動したり共有したりしても残ります。HTML と Markdown のどちらのページでも使えます。

+

このページ

+

このページは作成時に葉の余白が付いています。装飾カテゴリのテンプレートと同じ仕組みです。

+ + diff --git a/docs/demo/DemoNotebook/html/18-ko/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/18-ko/how-to/page-background/index.html new file mode 100644 index 00000000..3de290a8 --- /dev/null +++ b/docs/demo/DemoNotebook/html/18-ko/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +그림을 배경으로 설정 + + + + + + + +

그림을 페이지의 글 뒤에 둘 수 있습니다. 벽지처럼요. 이 페이지에는 이미 하나 있습니다. 왼쪽 여백의 나뭇잎입니다.

+

설정 방법

+
    +
  • 그림을 마우스 오른쪽 버튼으로 클릭하세요(Mac에서는 Control-클릭).
  • +
  • 그림을 배경으로 설정을 고르세요.
  • +
+

그림은 페이지 자체의 자산 폴더에 복사되므로, 페이지를 옮기거나 공유해도 남아 있습니다. HTML과 Markdown 페이지 모두에서 작동합니다.

+

이 페이지

+

이 페이지는 만들 때 장식 그룹 템플릿처럼 왼쪽 여백에 나뭇잎이 들어가 있습니다.

+ + diff --git a/docs/demo/DemoNotebook/html/19-tr/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/19-tr/how-to/page-background/index.html new file mode 100644 index 00000000..19121b1c --- /dev/null +++ b/docs/demo/DemoNotebook/html/19-tr/how-to/page-background/index.html @@ -0,0 +1,23 @@ + + + + +Resmi arka plan yap + + + + + + + +

Bir resim, duvardaki kağıt gibi sayfanın yazılarının arkasında durabilir. Bu sayfada zaten bir tane var: sol kenar boşluğundaki yapraklar.

+

Nasıl yapılır

+
    +
  • Resme sağ tıklayın (Mac'te Control+tıklama).
  • +
  • Resmi arka plan yap'ı seçin.
  • +
+

Resim sayfanın kendi kaynak klasörüne kopyalanır, bu yüzden sayfayı taşıdığınızda ya da paylaştığınızda da kalır. HTML ve Markdown sayfalarında çalışır.

+

Bu sayfa

+

Bu sayfa oluşturulurken sol kenarında yapraklar vardı; Dekoratif grubundaki şablonlarla aynı.

+ + diff --git a/docs/demo/DemoNotebook/html/20-ar/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/20-ar/how-to/page-background/index.html new file mode 100644 index 00000000..188df72c --- /dev/null +++ b/docs/demo/DemoNotebook/html/20-ar/how-to/page-background/index.html @@ -0,0 +1,24 @@ + + + + +تعيين صورة خلفية + + + + + + + + +

يمكن أن تقع صورة خلف كلمات الصفحة، كما تقع ورقة الجدران خلف الغرفة. هذه الصفحة فيها واحدة بالفعل: الأوراق في هامشها الأيسر.

+

كيفية التعيين

+
    +
  • انقر بزر الفأرة الأيمن على الصورة (أو Control مع النقر على Mac).
  • +
  • اختر تعيين الصورة كخلفية.
  • +
+

تُنسخ الصورة إلى مجلد ملفات الصفحة نفسها، فتبقى معها عند نقلها أو مشاركتها. تعمل في صفحات HTML وMarkdown معًا.

+

هذه الصفحة

+

أُنشئت هذه الصفحة بهامش من الأوراق، كما تفعل قوالب مجموعة الزخرفية.

+ + diff --git a/docs/demo/DemoNotebook/html/21-fa/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/21-fa/how-to/page-background/index.html new file mode 100644 index 00000000..255e2baf --- /dev/null +++ b/docs/demo/DemoNotebook/html/21-fa/how-to/page-background/index.html @@ -0,0 +1,24 @@ + + + + +تنظیم یک تصویر به‌عنوان پس‌زمینه + + + + + + + + +

یک تصویر می‌تواند پشت متن صفحه قرار گیرد، مثل کاغذ دیواری پشت اتاق. این صفحه از قبل یکی دارد: برگ‌ها در حاشیه چپ.

+

روش کار

+
    +
  • روی تصویر کلیک راست کنید (در مک با نگه داشتن Control و کلیک).
  • +
  • تنظیم تصویر به‌عنوان پس‌زمینه را انتخاب کنید.
  • +
+

تصویر در پوشه منابع خود صفحه کپی می‌شود، پس با جابه‌جایی یا اشتراک‌گذاری صفحه هم باقی می‌ماند. در صفحات HTML و Markdown کار می‌کند.

+

این صفحه

+

این صفحه هنگام ساخته شدن حاشیه‌ای از برگ داشت، همان‌طور که الگوهای گروه تزئینی می‌دهند.

+ + diff --git a/docs/demo/DemoNotebook/html/22-ur/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/22-ur/how-to/page-background/index.html new file mode 100644 index 00000000..8c1468f5 --- /dev/null +++ b/docs/demo/DemoNotebook/html/22-ur/how-to/page-background/index.html @@ -0,0 +1,24 @@ + + + + +تصویر کو پس منظر بنائیں + + + + + + + + +

کسی صفحے کے الفاظ کے پیچھے تصویر رکھی جا سکتی ہے، جیسے دیوار پر کاغذ ہوتا ہے۔ اس صفحے پر پہلے سے ایک ہے: بائیں حاشیے پر پتے۔

+

ایسے کریں

+
    +
  • تصویر پر دائیں کلک کریں (Mac پر Control دبا کر کلک کریں)۔
  • +
  • تصویر کو پس منظر بنائیں چنیں۔
  • +
+

تصویر صفحے کے اپنے اثاثوں کے فولڈر میں نقل ہوتی ہے، اس لیے صفحہ منتقل کرنے یا شیئر کرنے پر بھی برقرار رہتی ہے۔ یہ HTML اور Markdown دونوں صفحات پر کام کرتی ہے۔

+

یہ صفحہ

+

یہ صفحہ بنتے وقت بائیں حاشیے پر پتوں کے ساتھ بنا تھا، جیسے آرائشی گروپ کے ٹیمپلیٹس دیتے ہیں۔

+ + diff --git a/docs/demo/DemoNotebook/html/23-he/how-to/page-background/index.html b/docs/demo/DemoNotebook/html/23-he/how-to/page-background/index.html new file mode 100644 index 00000000..8747773e --- /dev/null +++ b/docs/demo/DemoNotebook/html/23-he/how-to/page-background/index.html @@ -0,0 +1,24 @@ + + + + +הגדרת תמונה כרקע + + + + + + + + +

אפשר להניח תמונה מאחורי המילים של עמוד, כמו טפט מאחורי קיר. לעמוד הזה כבר יש אחת: עלים בשוליים השמאליים.

+

איך עושים את זה

+
    +
  • לחצו לחיצה ימנית על התמונה (ב-Mac: Control ולחיצה).
  • +
  • בחרו הגדרת התמונה כרקע.
  • +
+

התמונה מועתקת לתיקיית המשאבים של העמוד, לכן היא נשארת כשמעבירים או משתפים את העמוד. זה פועל בעמודי HTML ו-Markdown כאחד.

+

העמוד הזה

+

העמוד נוצר עם שוליים של עלים, כמו שתבנית מקבוצת דקורטיביות נותנת.

+ + diff --git a/docs/demo/scripts/content/ar/29-page-background.md b/docs/demo/scripts/content/ar/29-page-background.md new file mode 100644 index 00000000..2f5011b7 --- /dev/null +++ b/docs/demo/scripts/content/ar/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: تعيين صورة خلفية +--- + +# تعيين صورة خلفية + +يمكن أن تقع صورة خلف كلمات الصفحة، كما تقع ورقة الجدران خلف الغرفة. هذه الصفحة فيها واحدة بالفعل: الأوراق في هامشها الأيسر. + +## كيفية التعيين + +- انقر بزر الفأرة الأيمن على الصورة (أو Control مع النقر على Mac). +- اختر **تعيين الصورة كخلفية**. + +تُنسخ الصورة إلى مجلد ملفات الصفحة نفسها، فتبقى معها عند نقلها أو مشاركتها. تعمل في صفحات HTML وMarkdown معًا. + +## هذه الصفحة + +أُنشئت هذه الصفحة بهامش من الأوراق، كما تفعل قوالب مجموعة الزخرفية. diff --git a/docs/demo/scripts/content/de/29-page-background.md b/docs/demo/scripts/content/de/29-page-background.md new file mode 100644 index 00000000..f9f73a7b --- /dev/null +++ b/docs/demo/scripts/content/de/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Bild als Hintergrund festlegen +--- + +# Bild als Hintergrund festlegen + +Ein Bild kann hinter dem Text einer Seite liegen, wie eine Tapete hinter den Wänden. Diese Seite hat schon eines: die Blätter am linken Rand. + +## So geht es + +- Klicken Sie mit der rechten Maustaste auf das Bild (auf dem Mac mit Ctrl-Klick). +- Wählen Sie **Bild als Hintergrund festlegen**. + +Das Bild wird in den Ressourcenordner der Seite kopiert, daher bleibt es erhalten, wenn Sie die Seite verschieben oder teilen. Es funktioniert in HTML- und Markdown-Seiten. + +## Diese Seite + +Diese Seite hat beim Erstellen einen Blätterrand bekommen, wie eine Vorlage aus der Gruppe Dekorativ. diff --git a/docs/demo/scripts/content/en/29-page-background.md b/docs/demo/scripts/content/en/29-page-background.md new file mode 100644 index 00000000..f6ab6fe6 --- /dev/null +++ b/docs/demo/scripts/content/en/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Set a picture as the background +--- + +# Set a picture as the background + +A picture can sit behind the words of a page, the way wallpaper sits behind a room. This page already has one: the leaves down its left margin. + +## How to set one + +- Right-click the picture (or Control-click on a Mac). +- Select **Set Picture as Background**. + +The picture is copied into the page's own assets folder, so the page keeps it when you move or share it. It works in both HTML and Markdown pages. + +## This page + +This page was given a leaf margin when it was made, the way a template in the Decorative group gives one. diff --git a/docs/demo/scripts/content/es/29-page-background.md b/docs/demo/scripts/content/es/29-page-background.md new file mode 100644 index 00000000..bc115c1c --- /dev/null +++ b/docs/demo/scripts/content/es/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Establecer una imagen como fondo +--- + +# Establecer una imagen como fondo + +Una imagen puede ir detrás del texto de una página, como el papel de pared detrás de una habitación. Esta página ya tiene una: las hojas en su margen izquierdo. + +## Cómo hacerlo + +- Haz clic derecho en la imagen (o Control-clic en un Mac). +- Elige **Establecer imagen como fondo**. + +La imagen se copia en la carpeta de recursos de la página, así que la página la conserva al moverla o compartirla. Funciona en páginas HTML y Markdown. + +## Esta página + +Esta página tenía un margen de hojas al crearse, como lo da una plantilla del grupo Decorativas. diff --git a/docs/demo/scripts/content/fa/29-page-background.md b/docs/demo/scripts/content/fa/29-page-background.md new file mode 100644 index 00000000..ed5d3f5f --- /dev/null +++ b/docs/demo/scripts/content/fa/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: تنظیم یک تصویر به‌عنوان پس‌زمینه +--- + +# تنظیم یک تصویر به‌عنوان پس‌زمینه + +یک تصویر می‌تواند پشت متن صفحه قرار گیرد، مثل کاغذ دیواری پشت اتاق. این صفحه از قبل یکی دارد: برگ‌ها در حاشیه چپ. + +## روش کار + +- روی تصویر کلیک راست کنید (در مک با نگه داشتن Control و کلیک). +- **تنظیم تصویر به‌عنوان پس‌زمینه** را انتخاب کنید. + +تصویر در پوشه منابع خود صفحه کپی می‌شود، پس با جابه‌جایی یا اشتراک‌گذاری صفحه هم باقی می‌ماند. در صفحات HTML و Markdown کار می‌کند. + +## این صفحه + +این صفحه هنگام ساخته شدن حاشیه‌ای از برگ داشت، همان‌طور که الگوهای گروه تزئینی می‌دهند. diff --git a/docs/demo/scripts/content/fr/29-page-background.md b/docs/demo/scripts/content/fr/29-page-background.md new file mode 100644 index 00000000..b607acce --- /dev/null +++ b/docs/demo/scripts/content/fr/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Définir une image comme arrière-plan +--- + +# Définir une image comme arrière-plan + +Une image peut figurer derrière le texte d'une page, comme un papier peint derrière une pièce. Cette page en a déjà une : les feuilles sur sa marge gauche. + +## Comment faire + +- Cliquez avec le bouton droit sur l'image (ou Ctrl+clic sur Mac). +- Choisissez **Définir l'image comme arrière-plan**. + +L'image est copiée dans le dossier de ressources de la page, ainsi la page la conserve lorsque vous la déplacez ou la partagez. Cela fonctionne dans les pages HTML et Markdown. + +## Cette page + +Cette page a reçu une marge de feuilles à sa création, comme le fait un modèle du groupe Décoratifs. diff --git a/docs/demo/scripts/content/he/29-page-background.md b/docs/demo/scripts/content/he/29-page-background.md new file mode 100644 index 00000000..6ab3d303 --- /dev/null +++ b/docs/demo/scripts/content/he/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: הגדרת תמונה כרקע +--- + +# הגדרת תמונה כרקע + +אפשר להניח תמונה מאחורי המילים של עמוד, כמו טפט מאחורי קיר. לעמוד הזה כבר יש אחת: עלים בשוליים השמאליים. + +## איך עושים את זה + +- לחצו לחיצה ימנית על התמונה (ב-Mac: Control ולחיצה). +- בחרו **הגדרת התמונה כרקע**. + +התמונה מועתקת לתיקיית המשאבים של העמוד, לכן היא נשארת כשמעבירים או משתפים את העמוד. זה פועל בעמודי HTML ו-Markdown כאחד. + +## העמוד הזה + +העמוד נוצר עם שוליים של עלים, כמו שתבנית מקבוצת דקורטיביות נותנת. diff --git a/docs/demo/scripts/content/hi/29-page-background.md b/docs/demo/scripts/content/hi/29-page-background.md new file mode 100644 index 00000000..91e5214b --- /dev/null +++ b/docs/demo/scripts/content/hi/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: तस्वीर को पृष्ठभूमि बनाएँ +--- + +# तस्वीर को पृष्ठभूमि बनाएँ + +किसी पेज के शब्दों के पीछे एक तस्वीर रखी जा सकती है, जैसे दीवार पर कागज़ लगा होता है। इस पेज पर पहले से एक है: बाईं ओर के हाशिये में पत्तियाँ। + +## ऐसे करें + +- तस्वीर पर राइट-क्लिक करें (Mac पर Control-क्लिक करें)। +- **तस्वीर को पृष्ठभूमि बनाएँ** चुनें। + +तस्वीर पेज के अपने संसाधन फ़ोल्डर में कॉपी होती है, इसलिए पेज को ले जाने या साझा करने पर भी वह बनी रहती है। यह HTML और Markdown दोनों पेजों पर काम करती है। + +## यह पेज + +यह पेज बनते समय पत्तियों वाले हाशिये के साथ बना था, जैसा सजावटी समूह का टेम्पलेट देता है। diff --git a/docs/demo/scripts/content/ja/29-page-background.md b/docs/demo/scripts/content/ja/29-page-background.md new file mode 100644 index 00000000..c070ea31 --- /dev/null +++ b/docs/demo/scripts/content/ja/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: 画像を背景に設定 +--- + +# 画像を背景に設定 + +画像はページの文字の後ろに置けます。壁紙のようなものです。このページにはすでに一つあります。左の余白に並んだ葉です。 + +## 設定の方法 + +- 画像を右クリックします(Mac では Control キーを押しながらクリック)。 +- **画像を背景に設定**を選びます。 + +画像はページ自身のアセットフォルダにコピーされるため、ページを移動したり共有したりしても残ります。HTML と Markdown のどちらのページでも使えます。 + +## このページ + +このページは作成時に葉の余白が付いています。装飾カテゴリのテンプレートと同じ仕組みです。 diff --git a/docs/demo/scripts/content/ko/29-page-background.md b/docs/demo/scripts/content/ko/29-page-background.md new file mode 100644 index 00000000..30fdb480 --- /dev/null +++ b/docs/demo/scripts/content/ko/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: 그림을 배경으로 설정 +--- + +# 그림을 배경으로 설정 + +그림을 페이지의 글 뒤에 둘 수 있습니다. 벽지처럼요. 이 페이지에는 이미 하나 있습니다. 왼쪽 여백의 나뭇잎입니다. + +## 설정 방법 + +- 그림을 마우스 오른쪽 버튼으로 클릭하세요(Mac에서는 Control-클릭). +- **그림을 배경으로 설정**을 고르세요. + +그림은 페이지 자체의 자산 폴더에 복사되므로, 페이지를 옮기거나 공유해도 남아 있습니다. HTML과 Markdown 페이지 모두에서 작동합니다. + +## 이 페이지 + +이 페이지는 만들 때 장식 그룹 템플릿처럼 왼쪽 여백에 나뭇잎이 들어가 있습니다. diff --git a/docs/demo/scripts/content/ru/29-page-background.md b/docs/demo/scripts/content/ru/29-page-background.md new file mode 100644 index 00000000..41797907 --- /dev/null +++ b/docs/demo/scripts/content/ru/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Сделать картинку фоном +--- + +# Сделать картинку фоном + +Картинка может лежать за текстом страницы, как обои за мебелью. У этой страницы уже есть такая: листья на левом поле. + +## Как это сделать + +- Щёлкните картинку правой кнопкой (на Mac: Control-щелчок). +- Выберите **Сделать картинку фоном**. + +Картинка копируется в папку ресурсов страницы, поэтому она сохраняется при переносе и отправке страницы. Работает в страницах HTML и Markdown. + +## Эта страница + +Эта страница создана с листьями на поле, как даёт шаблон из группы «Декоративные». diff --git a/docs/demo/scripts/content/tr/29-page-background.md b/docs/demo/scripts/content/tr/29-page-background.md new file mode 100644 index 00000000..38915b3c --- /dev/null +++ b/docs/demo/scripts/content/tr/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: Resmi arka plan yap +--- + +# Resmi arka plan yap + +Bir resim, duvardaki kağıt gibi sayfanın yazılarının arkasında durabilir. Bu sayfada zaten bir tane var: sol kenar boşluğundaki yapraklar. + +## Nasıl yapılır + +- Resme sağ tıklayın (Mac'te Control+tıklama). +- **Resmi arka plan yap**'ı seçin. + +Resim sayfanın kendi kaynak klasörüne kopyalanır, bu yüzden sayfayı taşıdığınızda ya da paylaştığınızda da kalır. HTML ve Markdown sayfalarında çalışır. + +## Bu sayfa + +Bu sayfa oluşturulurken sol kenarında yapraklar vardı; Dekoratif grubundaki şablonlarla aynı. diff --git a/docs/demo/scripts/content/ur/29-page-background.md b/docs/demo/scripts/content/ur/29-page-background.md new file mode 100644 index 00000000..0285c8b5 --- /dev/null +++ b/docs/demo/scripts/content/ur/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: تصویر کو پس منظر بنائیں +--- + +# تصویر کو پس منظر بنائیں + +کسی صفحے کے الفاظ کے پیچھے تصویر رکھی جا سکتی ہے، جیسے دیوار پر کاغذ ہوتا ہے۔ اس صفحے پر پہلے سے ایک ہے: بائیں حاشیے پر پتے۔ + +## ایسے کریں + +- تصویر پر دائیں کلک کریں (Mac پر Control دبا کر کلک کریں)۔ +- **تصویر کو پس منظر بنائیں** چنیں۔ + +تصویر صفحے کے اپنے اثاثوں کے فولڈر میں نقل ہوتی ہے، اس لیے صفحہ منتقل کرنے یا شیئر کرنے پر بھی برقرار رہتی ہے۔ یہ HTML اور Markdown دونوں صفحات پر کام کرتی ہے۔ + +## یہ صفحہ + +یہ صفحہ بنتے وقت بائیں حاشیے پر پتوں کے ساتھ بنا تھا، جیسے آرائشی گروپ کے ٹیمپلیٹس دیتے ہیں۔ diff --git a/docs/demo/scripts/content/zh/29-page-background.md b/docs/demo/scripts/content/zh/29-page-background.md new file mode 100644 index 00000000..9fad7144 --- /dev/null +++ b/docs/demo/scripts/content/zh/29-page-background.md @@ -0,0 +1,18 @@ +--- +title: 将图片设为背景 +--- + +# 将图片设为背景 + +图片可以像墙纸一样放在页面文字的后面。本页已经有一张:左侧页边的树叶。 + +## 操作方法 + +- 右键单击图片(Mac 上按住 Control 单击)。 +- 选择**将图片设为背景**。 + +图片会复制到页面自己的资源文件夹中,因此移动或分享页面时它仍会保留。HTML 和 Markdown 页面都支持。 + +## 本页 + +本页创建时就带有左侧页边的树叶,与「装饰」类模板的效果相同。 diff --git a/docs/demo/scripts/src/generator.rs b/docs/demo/scripts/src/generator.rs index 8c4b6b1e..a7039419 100644 --- a/docs/demo/scripts/src/generator.rs +++ b/docs/demo/scripts/src/generator.rs @@ -691,6 +691,9 @@ fn markdown_page(title: &str, id: &str, order: u32, dir: Option<&str>, body: &st if let Some(c) = look.colour { front.push_str(&format!("page-color: {c}\n")); } + if let Some(b) = look.background { + front.push_str(&format!("background: {b}\n")); + } front.push_str("tags: []\n---\n\n"); format!("{front}{}\n", body.trim_end()) } @@ -701,6 +704,7 @@ fn markdown_page(title: &str, id: &str, order: u32, dir: Option<&str>, body: &st struct Look { paper: Option<&'static str>, colour: Option<&'static str>, + background: Option<&'static str>, } /// Which pages are given paper of their own, by the folder they are written to. The rest @@ -708,12 +712,15 @@ struct Look { fn look_of(slug: &str) -> Look { match slug { // The page about writing is on ruled paper, as a page for writing on would be. - "write-a-page" => Look { paper: Some("college"), colour: None }, + "write-a-page" => Look { paper: Some("college"), colour: None, background: None }, // The one about tags is squared, and a little warm, so the two show side by side // in the tree what paper and page colour do. - "tag-a-line" => Look { paper: Some("grid-medium"), colour: Some("yellow") }, + "tag-a-line" => Look { paper: Some("grid-medium"), colour: Some("yellow"), background: None }, // The one about making it yours is coloured, with no lines. - "make-it-yours" => Look { paper: None, colour: Some("teal") }, + "make-it-yours" => Look { paper: None, colour: Some("teal"), background: None }, + // The one about setting a picture as the background already has one: a leaf margin, + // so the notebook shows the result, not only the steps. + "page-background" => Look { paper: None, colour: None, background: Some("leaves-margin") }, _ => Look::default(), } } @@ -736,6 +743,9 @@ fn html_page(title: &str, id: &str, order: u32, dir: Option<&str>, body: &str, l if let Some(c) = look.colour { head.push_str(&format!("\n")); } + if let Some(b) = look.background { + head.push_str(&format!("\n")); + } format!("{head}\n\n{}\n\n\n", body.trim()) } @@ -1039,7 +1049,7 @@ mod tests { None, "words ", - Look { paper: Some("college"), colour: Some("yellow") }, + Look { paper: Some("college"), colour: Some("yellow"), background: None }, None, ); assert!( @@ -1054,7 +1064,7 @@ page-color: yellow ), "{dressed}" ); - let dressed_html = html_page("T", "id", 10, None, "

x

", Look { paper: Some("grid-medium"), colour: None }, None); + let dressed_html = html_page("T", "id", 10, None, "

x

", Look { paper: Some("grid-medium"), colour: None, background: None }, None); assert!(dressed_html.contains("notecraft:paper"), "{dressed_html}"); assert!(!dressed_html.contains("page-color"), "and says nothing about a colour it was not given"); assert!(html.contains("A <b>")); diff --git a/i18n/ar-XB.tsv b/i18n/ar-XB.tsv index 4ae1b2a1..792185cf 100644 --- a/i18n/ar-XB.tsv +++ b/i18n/ar-XB.tsv @@ -1814,3 +1814,4 @@ @id ui.template_cats_page [[RLI]]$$$Cats@@@[[PDI]] @id ui.template_dogs_page [[RLI]]$$$Dogs@@@[[PDI]] @id ui.template_bows_page [[RLI]]$$$Bows@@@[[PDI]] +@id ui.set_picture_as_background [[RLI]]$$$Set Picture as Background@@@[[PDI]] diff --git a/i18n/en-XA.tsv b/i18n/en-XA.tsv index 7bbd1edc..4a7530ac 100644 --- a/i18n/en-XA.tsv +++ b/i18n/en-XA.tsv @@ -1814,3 +1814,4 @@ @id ui.template_cats_page $$$Cats@@@ @id ui.template_dogs_page $$$Dogs@@@ @id ui.template_bows_page $$$Bows@@@ +@id ui.set_picture_as_background $$$Set Picture as Background@@@ diff --git a/i18n/en.tsv b/i18n/en.tsv index 7c8d8db5..b6f2da57 100644 --- a/i18n/en.tsv +++ b/i18n/en.tsv @@ -1814,3 +1814,4 @@ @id ui.template_cats_page Cats @id ui.template_dogs_page Dogs @id ui.template_bows_page Bows +@id ui.set_picture_as_background Set Picture as Background From a8b09adfe7be719d66b84ead5eb996297827f1cd Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 13:23:59 -0800 Subject: [PATCH 14/19] feat(model): a box can be the page background Adds a background flag to a box, written as an optional fifth field, so pages without one read and write as before. Co-Authored-By: Claude Haiku 5.5 --- crates/model/src/container.rs | 35 +++++++++++++++++++++++++++----- crates/ui-egui/src/containers.rs | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/crates/model/src/container.rs b/crates/model/src/container.rs index da0be1e9..59043eea 100644 --- a/crates/model/src/container.rs +++ b/crates/model/src/container.rs @@ -23,6 +23,10 @@ pub struct Container { pub width: f32, /// How many of the page's blocks, in order, are in this box. pub blocks: usize, + /// Whether this box is the page's background (Set Picture as Background): its picture is + /// drawn behind the page, where a normal click does not reach it. Cleared, the box is an + /// ordinary one again, in the same place. + pub background: bool, } /// The narrowest a container may be, so one cannot be dragged into nothing. @@ -30,12 +34,14 @@ pub const MIN_WIDTH: f32 = 120.0; impl Container { pub fn new(x: f32, y: f32, width: f32, blocks: usize) -> Container { - Container { x: x.max(0.0), y: y.max(0.0), width: width.max(MIN_WIDTH), blocks } + Container { x: x.max(0.0), y: y.max(0.0), width: width.max(MIN_WIDTH), blocks, background: false } } } -/// Reads the line a page keeps its containers on: `x,y,width,blocks` per box, separated by -/// semicolons. Anything that does not parse is skipped rather than guessed at. +/// Reads the line a page keeps its containers on: `x,y,width,blocks[,background]` per box, +/// separated by semicolons. The fifth field is `1` for a background box and is left out +/// otherwise, so a page without one reads and writes as it always did. Anything that does not +/// parse is skipped rather than guessed at. pub fn parse(text: &str) -> Vec { text.split(';') .filter_map(|part| { @@ -44,10 +50,16 @@ pub fn parse(text: &str) -> Vec { let y: f32 = fields.next()?.parse().ok()?; let width: f32 = fields.next()?.parse().ok()?; let blocks: usize = fields.next()?.parse().ok()?; + let background = match fields.next() { + None => false, + Some("1") => true, + Some("0") => false, + Some(_) => return None, + }; if fields.next().is_some() || !x.is_finite() || !y.is_finite() || !width.is_finite() { return None; } - Some(Container::new(x, y, width, blocks)) + Some(Container { background, ..Container::new(x, y, width, blocks) }) }) .collect() } @@ -57,7 +69,10 @@ pub fn parse(text: &str) -> Vec { pub fn write(containers: &[Container]) -> String { containers .iter() - .map(|c| format!("{},{},{},{}", c.x.round() as i64, c.y.round() as i64, c.width.round() as i64, c.blocks)) + .map(|c| { + let base = format!("{},{},{},{}", c.x.round() as i64, c.y.round() as i64, c.width.round() as i64, c.blocks); + if c.background { format!("{base},1") } else { base } + }) .collect::>() .join("; ") } @@ -145,6 +160,16 @@ mod tests { assert_eq!(parse(&line), boxes); } + #[test] + fn a_background_box_keeps_its_flag_and_an_ordinary_one_keeps_its_line() { + let back = Container { background: true, ..Container::new(10.0, 20.0, 300.0, 1) }; + let line = write(&[back, Container::new(0.0, 0.0, 420.0, 2)]); + assert_eq!(line, "10,20,300,1,1; 0,0,420,2", "only a background box carries the extra field"); + assert_eq!(parse(&line), vec![back, Container::new(0.0, 0.0, 420.0, 2)]); + assert_eq!(parse("1,2,3,4,0")[0].background, false); + assert!(parse("1,2,3,4,yes").is_empty(), "the flag is 1 or 0, nothing else"); + } + #[test] fn nonsense_is_skipped_not_guessed_at() { assert!(parse("").is_empty()); diff --git a/crates/ui-egui/src/containers.rs b/crates/ui-egui/src/containers.rs index d635e1b8..93a5f65d 100644 --- a/crates/ui-egui/src/containers.rs +++ b/crates/ui-egui/src/containers.rs @@ -2185,7 +2185,7 @@ fn start_a_box(blocks: &mut Vec, boxes: &mut Vec, caret: &mut blocks.push(Block::Paragraph(Vec::new(), Vec::new())); let block_idx = blocks.len() - 1; let box_idx = boxes.len(); - boxes.push(Container { x: at.x, y: at.y, width, blocks: 1 }); + boxes.push(Container { x: at.x, y: at.y, width, blocks: 1, background: false }); log::debug!("CREATE_BOX: i={} at_pos=({:.0},{:.0}) width={:.0} holds_block={} (triggered by click)", box_idx, at.x, at.y, width, block_idx); *caret = Some(pageedit::Caret { block: block_idx, From 1c01d7f913018be7ae20fc5494ae82346078e915 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 13:31:24 -0800 Subject: [PATCH 15/19] feat(templates): LTR and RTL margin pictures, and the picture repeat fix Leaves, Cats and Butterflies come as left-margin (LTR) and right-margin (RTL) templates. Background pictures use an SVG extension on their URI, so they load instead of showing the missing-image mark. Co-Authored-By: Claude Haiku 5.5 --- crates/store/src/page_templates.rs | 41 +++++++++++++++-- crates/ui-egui/src/page_background.rs | 63 +++++++++++++++++++-------- i18n/ar-XB.tsv | 3 ++ i18n/ar.tsv | 3 ++ i18n/de.tsv | 3 ++ i18n/en-XA.tsv | 3 ++ i18n/en.tsv | 3 ++ i18n/es.tsv | 3 ++ i18n/fa.tsv | 3 ++ i18n/fr.tsv | 3 ++ i18n/he.tsv | 3 ++ i18n/hi.tsv | 3 ++ i18n/ja.tsv | 3 ++ i18n/ko.tsv | 3 ++ i18n/ru.tsv | 3 ++ i18n/tr.tsv | 3 ++ i18n/ur.tsv | 3 ++ i18n/zh.tsv | 3 ++ 18 files changed, 132 insertions(+), 20 deletions(-) diff --git a/crates/store/src/page_templates.rs b/crates/store/src/page_templates.rs index ea112278..438692c4 100644 --- a/crates/store/src/page_templates.rs +++ b/crates/store/src/page_templates.rs @@ -176,7 +176,7 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Leaves", category: Category::Decorative, colour: None, - background: Some("leaves-margin"), + background: Some("leaves-margin-ltr"), paper: None, body: "", }, @@ -185,13 +185,48 @@ pub const BUILT_IN: &[BuiltIn] = &[ name: "Butterflies", category: Category::Decorative, colour: None, - background: Some("butterflies"), + background: Some("butterflies-margin-ltr"), + paper: None, + body: "", + }, + BuiltIn { + id: "cats-page", + name: "Cats", + category: Category::Decorative, + colour: None, + background: Some("cats-margin-ltr"), paper: None, body: "", }, - BuiltIn { id: "cats-page", name: "Cats", category: Category::Decorative, colour: None, background: Some("cats-margin"), paper: None, body: "" }, BuiltIn { id: "dogs-page", name: "Dogs", category: Category::Decorative, colour: None, background: Some("dogs"), paper: None, body: "" }, BuiltIn { id: "bows-page", name: "Bows", category: Category::Decorative, colour: None, background: Some("bows"), paper: None, body: "" }, + BuiltIn { + id: "leaves-rtl-page", + name: "Leaves (RTL)", + category: Category::Decorative, + colour: None, + background: Some("leaves-margin-rtl"), + paper: None, + body: "", + }, + BuiltIn { + id: "cats-rtl-page", + name: "Cats (RTL)", + category: Category::Decorative, + colour: None, + background: Some("cats-margin-rtl"), + paper: None, + body: "", + }, + BuiltIn { + id: "butterflies-rtl-page", + name: "Butterflies (RTL)", + category: Category::Decorative, + colour: None, + background: Some("butterflies-margin-rtl"), + paper: None, + body: "", + }, ]; /// A template that can be picked. diff --git a/crates/ui-egui/src/page_background.rs b/crates/ui-egui/src/page_background.rs index ba7668e7..47e4718c 100644 --- a/crates/ui-egui/src/page_background.rs +++ b/crates/ui-egui/src/page_background.rs @@ -25,11 +25,29 @@ fn picture(name: &str) -> Option<(&'static str, &'static [u8])> { }) } -/// How a picture name is drawn: which picture, and whether it is the margin strip. -pub fn placement(name: &str) -> Option<(&str, bool)> { - match name.strip_suffix("-margin") { - Some(base) => Some((base, true)), - None => Some((name, false)), +/// Where a picture is drawn on the page. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Edge { + /// Repeated across the whole page. + Tiled, + /// A strip down the left edge (`-margin-ltr`). + Left, + /// A strip down the right edge (`-margin-rtl`). + Right, + /// A strip down the page's start edge: left, or right in a right-to-left layout (`-margin`). + Start, +} + +/// How a picture name is drawn: which picture, and on which edge. +pub fn placement(name: &str) -> Option<(&str, Edge)> { + if let Some(base) = name.strip_suffix("-margin-ltr") { + Some((base, Edge::Left)) + } else if let Some(base) = name.strip_suffix("-margin-rtl") { + Some((base, Edge::Right)) + } else if let Some(base) = name.strip_suffix("-margin") { + Some((base, Edge::Start)) + } else { + Some((name, Edge::Tiled)) } } @@ -41,15 +59,20 @@ pub fn paint(ui: &mut Ui, area: Rect, name: &str, rtl: bool) { /// [`paint`] with every size multiplied by `scale`, for a thumbnail of a page. pub fn paint_scaled(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32) { - let Some((base, margin)) = placement(name) else { return }; + let Some((base, edge)) = placement(name) else { return }; let Some((key, bytes)) = picture(base) else { return }; - if margin { - let width = MARGIN_W * scale; - let column = margin_column(area, width, rtl); - tile(ui, column, key, Bytes::from(bytes), width, true); - } else { - tile(ui, area, key, Bytes::from(bytes), TILE * scale, false); - } + let right = match edge { + Edge::Tiled => { + tile(ui, area, key, Bytes::from(bytes), TILE * scale, false); + return; + } + Edge::Left => false, + Edge::Right => true, + Edge::Start => rtl, + }; + let width = MARGIN_W * scale; + let column = margin_column(area, width, right); + tile(ui, column, key, Bytes::from(bytes), width, true); } /// A picture the user chose for the page, repeated across the page. `key` is the picture's name @@ -69,7 +92,11 @@ fn margin_column(area: Rect, width: f32, rtl: bool) -> Rect { /// Repeats one picture across `area` at `side` points a tile, clipped to `area`. A margin strip /// repeats down the column only; a page is covered in both directions. fn tile(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, side: f32, down_only: bool) { - let uri = format!("bytes://notecraft-page-background/{key}"); + // egui picks the image loader from the extension, so a bundled SVG needs `.svg` on its URI + // (without it every tile shows the missing-image mark). A picture the user chose keeps its + // own file name, which already has one. + let uri = + if key.contains('.') { format!("bytes://notecraft-page-background/{key}") } else { format!("bytes://notecraft-page-background/{key}.svg") }; ui.scope_builder(UiBuilder::new().id_salt(("page-background", key, down_only)).max_rect(area), |ui| { ui.set_clip_rect(area); let mut y = area.top(); @@ -106,8 +133,10 @@ mod tests { } #[test] - fn a_margin_name_says_margin_and_a_plain_name_does_not() { - assert_eq!(placement("cats-margin"), Some(("cats", true))); - assert_eq!(placement("dogs"), Some(("dogs", false))); + fn each_margin_name_says_its_edge() { + assert_eq!(placement("cats-margin-ltr"), Some(("cats", Edge::Left))); + assert_eq!(placement("cats-margin-rtl"), Some(("cats", Edge::Right))); + assert_eq!(placement("cats-margin"), Some(("cats", Edge::Start))); + assert_eq!(placement("dogs"), Some(("dogs", Edge::Tiled))); } } diff --git a/i18n/ar-XB.tsv b/i18n/ar-XB.tsv index 792185cf..b0eae4a9 100644 --- a/i18n/ar-XB.tsv +++ b/i18n/ar-XB.tsv @@ -1815,3 +1815,6 @@ @id ui.template_dogs_page [[RLI]]$$$Dogs@@@[[PDI]] @id ui.template_bows_page [[RLI]]$$$Bows@@@[[PDI]] @id ui.set_picture_as_background [[RLI]]$$$Set Picture as Background@@@[[PDI]] +@id ui.template_leaves_rtl_page [[RLI]]$$$Leaves (RTL)@@@[[PDI]] +@id ui.template_cats_rtl_page [[RLI]]$$$Cats (RTL)@@@[[PDI]] +@id ui.template_butterflies_rtl_page [[RLI]]$$$Butterflies (RTL)@@@[[PDI]] diff --git a/i18n/ar.tsv b/i18n/ar.tsv index 27f7dc85..f4547b24 100644 --- a/i18n/ar.tsv +++ b/i18n/ar.tsv @@ -853,3 +853,6 @@ @id ui.template_cats_page قطط @id ui.template_dogs_page كلاب @id ui.template_bows_page فيونكات +@id ui.template_leaves_rtl_page أوراق (RTL) +@id ui.template_cats_rtl_page قطط (RTL) +@id ui.template_butterflies_rtl_page فراشات (RTL) diff --git a/i18n/de.tsv b/i18n/de.tsv index 0072769f..fdb688a7 100644 --- a/i18n/de.tsv +++ b/i18n/de.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page Katzen @id ui.template_dogs_page Hunde @id ui.template_bows_page Schleifen +@id ui.template_leaves_rtl_page Blätter (RTL) +@id ui.template_cats_rtl_page Katzen (RTL) +@id ui.template_butterflies_rtl_page Schmetterlinge (RTL) diff --git a/i18n/en-XA.tsv b/i18n/en-XA.tsv index 4a7530ac..b84f28c8 100644 --- a/i18n/en-XA.tsv +++ b/i18n/en-XA.tsv @@ -1815,3 +1815,6 @@ @id ui.template_dogs_page $$$Dogs@@@ @id ui.template_bows_page $$$Bows@@@ @id ui.set_picture_as_background $$$Set Picture as Background@@@ +@id ui.template_leaves_rtl_page $$$Leaves (RTL)@@@ +@id ui.template_cats_rtl_page $$$Cats (RTL)@@@ +@id ui.template_butterflies_rtl_page $$$Butterflies (RTL)@@@ diff --git a/i18n/en.tsv b/i18n/en.tsv index b6f2da57..2923143a 100644 --- a/i18n/en.tsv +++ b/i18n/en.tsv @@ -1815,3 +1815,6 @@ @id ui.template_dogs_page Dogs @id ui.template_bows_page Bows @id ui.set_picture_as_background Set Picture as Background +@id ui.template_leaves_rtl_page Leaves (RTL) +@id ui.template_cats_rtl_page Cats (RTL) +@id ui.template_butterflies_rtl_page Butterflies (RTL) diff --git a/i18n/es.tsv b/i18n/es.tsv index 64ab003d..a3562e29 100644 --- a/i18n/es.tsv +++ b/i18n/es.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page Gatos @id ui.template_dogs_page Perros @id ui.template_bows_page Lazos +@id ui.template_leaves_rtl_page Hojas (RTL) +@id ui.template_cats_rtl_page Gatos (RTL) +@id ui.template_butterflies_rtl_page Mariposas (RTL) diff --git a/i18n/fa.tsv b/i18n/fa.tsv index 7a0f8e59..86a9c6e6 100644 --- a/i18n/fa.tsv +++ b/i18n/fa.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page گربه‌ها @id ui.template_dogs_page سگ‌ها @id ui.template_bows_page پاپیون‌ها +@id ui.template_leaves_rtl_page برگ‌ها (RTL) +@id ui.template_cats_rtl_page گربه‌ها (RTL) +@id ui.template_butterflies_rtl_page پروانه‌ها (RTL) diff --git a/i18n/fr.tsv b/i18n/fr.tsv index f6cf47a9..ae3fc974 100644 --- a/i18n/fr.tsv +++ b/i18n/fr.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page Chats @id ui.template_dogs_page Chiens @id ui.template_bows_page Nœuds +@id ui.template_leaves_rtl_page Feuilles (RTL) +@id ui.template_cats_rtl_page Chats (RTL) +@id ui.template_butterflies_rtl_page Papillons (RTL) diff --git a/i18n/he.tsv b/i18n/he.tsv index 2723df7a..656f183b 100644 --- a/i18n/he.tsv +++ b/i18n/he.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page חתולים @id ui.template_dogs_page כלבים @id ui.template_bows_page פפיונים +@id ui.template_leaves_rtl_page עלים (RTL) +@id ui.template_cats_rtl_page חתולים (RTL) +@id ui.template_butterflies_rtl_page פרפרים (RTL) diff --git a/i18n/hi.tsv b/i18n/hi.tsv index 0f645bdd..222eafb1 100644 --- a/i18n/hi.tsv +++ b/i18n/hi.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page बिल्लियाँ @id ui.template_dogs_page कुत्ते @id ui.template_bows_page फ़ीते +@id ui.template_leaves_rtl_page पत्तियाँ (RTL) +@id ui.template_cats_rtl_page बिल्लियाँ (RTL) +@id ui.template_butterflies_rtl_page तितलियाँ (RTL) diff --git a/i18n/ja.tsv b/i18n/ja.tsv index 0b52ca1b..ab47234c 100644 --- a/i18n/ja.tsv +++ b/i18n/ja.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page 猫 @id ui.template_dogs_page 犬 @id ui.template_bows_page リボン +@id ui.template_leaves_rtl_page 葉 (RTL) +@id ui.template_cats_rtl_page 猫 (RTL) +@id ui.template_butterflies_rtl_page 蝶 (RTL) diff --git a/i18n/ko.tsv b/i18n/ko.tsv index 97b015c8..b81abcdd 100644 --- a/i18n/ko.tsv +++ b/i18n/ko.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page 고양이 @id ui.template_dogs_page 강아지 @id ui.template_bows_page 리본 +@id ui.template_leaves_rtl_page 나뭇잎 (RTL) +@id ui.template_cats_rtl_page 고양이 (RTL) +@id ui.template_butterflies_rtl_page 나비 (RTL) diff --git a/i18n/ru.tsv b/i18n/ru.tsv index ec13e7a0..8d26c0df 100644 --- a/i18n/ru.tsv +++ b/i18n/ru.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page Кошки @id ui.template_dogs_page Собаки @id ui.template_bows_page Банты +@id ui.template_leaves_rtl_page Листья (RTL) +@id ui.template_cats_rtl_page Кошки (RTL) +@id ui.template_butterflies_rtl_page Бабочки (RTL) diff --git a/i18n/tr.tsv b/i18n/tr.tsv index f3f0f86d..20d6eb0c 100644 --- a/i18n/tr.tsv +++ b/i18n/tr.tsv @@ -1445,3 +1445,6 @@ @id ui.template_cats_page Kediler @id ui.template_dogs_page Köpekler @id ui.template_bows_page Fiyonklar +@id ui.template_leaves_rtl_page Yapraklar (RTL) +@id ui.template_cats_rtl_page Kediler (RTL) +@id ui.template_butterflies_rtl_page Kelebekler (RTL) diff --git a/i18n/ur.tsv b/i18n/ur.tsv index 35c3f2cd..a7f5796b 100644 --- a/i18n/ur.tsv +++ b/i18n/ur.tsv @@ -849,3 +849,6 @@ @id ui.template_cats_page بلیاں @id ui.template_dogs_page کتے @id ui.template_bows_page فیتے +@id ui.template_leaves_rtl_page پتے (RTL) +@id ui.template_cats_rtl_page بلیاں (RTL) +@id ui.template_butterflies_rtl_page تتلیاں (RTL) diff --git a/i18n/zh.tsv b/i18n/zh.tsv index 248ddbfb..245769fc 100644 --- a/i18n/zh.tsv +++ b/i18n/zh.tsv @@ -852,3 +852,6 @@ @id ui.template_cats_page 猫 @id ui.template_dogs_page 狗 @id ui.template_bows_page 蝴蝶结 +@id ui.template_leaves_rtl_page 树叶 (RTL) +@id ui.template_cats_rtl_page 猫 (RTL) +@id ui.template_butterflies_rtl_page 蝴蝶 (RTL) From 189a82cea8016816585ae0d78a3fe5be9599ac2d Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 13:31:53 -0800 Subject: [PATCH 16/19] chore(model): assert a bool directly in the container test Co-Authored-By: Claude Haiku 5.5 --- crates/model/src/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/model/src/container.rs b/crates/model/src/container.rs index 59043eea..48b135de 100644 --- a/crates/model/src/container.rs +++ b/crates/model/src/container.rs @@ -166,7 +166,7 @@ mod tests { let line = write(&[back, Container::new(0.0, 0.0, 420.0, 2)]); assert_eq!(line, "10,20,300,1,1; 0,0,420,2", "only a background box carries the extra field"); assert_eq!(parse(&line), vec![back, Container::new(0.0, 0.0, 420.0, 2)]); - assert_eq!(parse("1,2,3,4,0")[0].background, false); + assert!(!parse("1,2,3,4,0")[0].background); assert!(parse("1,2,3,4,yes").is_empty(), "the flag is 1 or 0, nothing else"); } From 73712580a5b4276b4a4fcb5d1cd8a5b8d7f2c733 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 14:03:30 -0800 Subject: [PATCH 17/19] fix(templates): saved previews, RTL checks, bidi names, focus Saved templates show their own words, paper and colour in the pane. RTL checkboxes sit at the margin edge. Template names use the bidi painter. Cards show keyboard focus. The page background moves with the page when the canvas is panned. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/src/app.rs | 51 ++++++++++++++++++++------- crates/ui-egui/src/page_background.rs | 29 +++++++++------ crates/ui-egui/src/template_thumb.rs | 48 ++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 24 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 57175b02..3b24fabc 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -12366,13 +12366,32 @@ impl NoteCraftApp { if card.hovered() { ui.painter().rect_filled(rect, 4.0, tokens.row_hover); } + // The keyboard's place is ringed as well as lit, as in the menus. + if card.has_focus() { + ui.painter().rect_stroke(rect.shrink(0.5), 4.0, egui::Stroke::new(1.5, tokens.accent), egui::StrokeKind::Inside); + } // The thumbnail is the page the template makes: its own words and paper. - let (body, paper, picture, page_colour) = match &template.source { - notecraft_store::page_templates::Source::BuiltIn(b) => { - (b.body, b.paper, b.background, b.colour.and_then(crate::textcolour::parse)) - } - notecraft_store::page_templates::Source::Saved(_) => ("", None, None, None), - }; + // A saved template's thumbnail is its own page: its words, paper and colour. + let (body, paper_name, picture, page_colour): (String, Option, Option<&str>, Option) = + match &template.source { + notecraft_store::page_templates::Source::BuiltIn(b) => { + (b.body.to_string(), b.paper.map(str::to_string), b.background, b.colour.and_then(crate::textcolour::parse)) + } + notecraft_store::page_templates::Source::Saved(dir) => match notecraft_store::page::load_page(dir) { + Ok(page) => { + let (paper, colour) = notecraft_store::page::appearance(dir).unwrap_or((None, None)); + let html = page.format == notecraft_model::PageFormat::Html; + let page_colour = colour.as_deref().and_then(crate::textcolour::parse).or_else(|| { + colour.as_deref().and_then(notecraft_model::NodeColor::parse).map(|c| { + let (r, g, b) = c.rgb(false); + egui::Color32::from_rgb(r, g, b) + }) + }); + (crate::template_thumb::plain_words(&page.body, html), paper, None, page_colour) + } + Err(_) => (String::new(), None, None, None), + }, + }; let rtl = ui.layout().prefer_right_to_left(); let colours = crate::template_thumb::Colours { page: page_colour.unwrap_or(tokens.editor), @@ -12383,11 +12402,19 @@ impl NoteCraftApp { }; let thumb = egui::Rect::from_center_size(egui::pos2(rect.center().x, rect.top() + 6.0 + THUMB_H / 2.0), vec2(THUMB_W, THUMB_H)); - crate::template_thumb::paint(ui, thumb, body, crate::template_thumb::paper_for(paper), colours, rtl, picture); + crate::template_thumb::paint( + ui, + thumb, + &body, + crate::template_thumb::paper_for(paper_name.as_deref()), + colours, + rtl, + picture, + ); // The name under the thumbnail, wrapped to the card's width. - let galley = ui.painter().layout(label.clone(), egui::FontId::proportional(12.0), tokens.text, CARD_W - 10.0); - let at = egui::pos2(rect.center().x - galley.size().x / 2.0, thumb.bottom() + 4.0); - ui.painter().galley(at, galley, tokens.text); + // Drawn by the bidi painter, so a name that mixes directions reads in order. + let at = egui::pos2(rect.center().x, thumb.bottom() + 9.0); + crate::bidi::line_at(ui, ui.painter(), at, egui::Align2::CENTER_CENTER, &label, 12.0, tokens.text, None); if card.on_hover_text(crate::tl_id!("ui.add_a_page_from_this_template")).clicked() { chosen = Some((template.id.clone(), label)); } @@ -13593,10 +13620,10 @@ impl NoteCraftApp { // The picture repeats behind the words, over the colour. if let Some(picture) = ed.background.as_deref() { if let Some(bytes) = ed.background_image.clone() { - crate::page_background::paint_image(ui, viewport, picture, bytes); + crate::page_background::paint_image(ui, viewport, picture, bytes, self.canvas_pan); } else { let rtl = ui.layout().prefer_right_to_left(); - crate::page_background::paint(ui, viewport, picture, rtl); + crate::page_background::paint(ui, viewport, picture, rtl, self.canvas_pan); } } } diff --git a/crates/ui-egui/src/page_background.rs b/crates/ui-egui/src/page_background.rs index 47e4718c..7d971316 100644 --- a/crates/ui-egui/src/page_background.rs +++ b/crates/ui-egui/src/page_background.rs @@ -5,7 +5,7 @@ //! the user chose (`assets/`) is read by the page and repeats across it. use egui::load::Bytes; -use egui::{Rect, Ui, UiBuilder, pos2, vec2}; +use egui::{Rect, Ui, UiBuilder, Vec2, pos2, vec2}; /// The side of one tile across the whole page, in points. pub const TILE: f32 = 120.0; @@ -53,17 +53,22 @@ pub fn placement(name: &str) -> Option<(&str, Edge)> { /// Draws the bundled picture `name` on the page area `area`: as a margin strip on the page's /// start edge when the name says so, otherwise repeated across the whole area. Clipped to `area`. -pub fn paint(ui: &mut Ui, area: Rect, name: &str, rtl: bool) { - paint_scaled(ui, area, name, rtl, 1.0); +pub fn paint(ui: &mut Ui, area: Rect, name: &str, rtl: bool, pan: Vec2) { + paint_scaled_at(ui, area, name, rtl, 1.0, pan); } -/// [`paint`] with every size multiplied by `scale`, for a thumbnail of a page. +/// [`paint`] with every size multiplied by `scale`, for a thumbnail of a page (which does not +/// scroll, so it takes no pan). pub fn paint_scaled(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32) { + paint_scaled_at(ui, area, name, rtl, scale, Vec2::ZERO); +} + +fn paint_scaled_at(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32, pan: Vec2) { let Some((base, edge)) = placement(name) else { return }; let Some((key, bytes)) = picture(base) else { return }; let right = match edge { Edge::Tiled => { - tile(ui, area, key, Bytes::from(bytes), TILE * scale, false); + tile(ui, area, key, Bytes::from(bytes), TILE * scale, false, pan); return; } Edge::Left => false, @@ -72,13 +77,13 @@ pub fn paint_scaled(ui: &mut Ui, area: Rect, name: &str, rtl: bool, scale: f32) }; let width = MARGIN_W * scale; let column = margin_column(area, width, right); - tile(ui, column, key, Bytes::from(bytes), width, true); + tile(ui, column, key, Bytes::from(bytes), width, true, pan); } /// A picture the user chose for the page, repeated across the page. `key` is the picture's name /// in the page (its path), which tells the image loader its file type. -pub fn paint_image(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes) { - tile(ui, area, key, bytes, TILE, false); +pub fn paint_image(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, pan: Vec2) { + tile(ui, area, key, bytes, TILE, false, pan); } fn margin_column(area: Rect, width: f32, rtl: bool) -> Rect { @@ -91,7 +96,7 @@ fn margin_column(area: Rect, width: f32, rtl: bool) -> Rect { /// Repeats one picture across `area` at `side` points a tile, clipped to `area`. A margin strip /// repeats down the column only; a page is covered in both directions. -fn tile(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, side: f32, down_only: bool) { +fn tile(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, side: f32, down_only: bool, pan: Vec2) { // egui picks the image loader from the extension, so a bundled SVG needs `.svg` on its URI // (without it every tile shows the missing-image mark). A picture the user chose keeps its // own file name, which already has one. @@ -99,9 +104,11 @@ fn tile(ui: &mut Ui, area: Rect, key: &str, bytes: Bytes, side: f32, down_only: if key.contains('.') { format!("bytes://notecraft-page-background/{key}") } else { format!("bytes://notecraft-page-background/{key}.svg") }; ui.scope_builder(UiBuilder::new().id_salt(("page-background", key, down_only)).max_rect(area), |ui| { ui.set_clip_rect(area); - let mut y = area.top(); + // The tiles move with the page's words when the canvas is panned: the first tile starts + // one tile above or to the left of the area, at the phase the pan puts it in. + let mut y = area.top() + pan.y.rem_euclid(side) - side; while y < area.bottom() { - let mut x = area.left(); + let mut x = if down_only { area.left() } else { area.left() + pan.x.rem_euclid(side) - side }; loop { let cell = Rect::from_min_size(pos2(x, y), vec2(side, side)); egui::Image::from_bytes(uri.clone(), bytes.clone()).fit_to_exact_size(vec2(side, side)).paint_at(ui, cell); diff --git a/crates/ui-egui/src/template_thumb.rs b/crates/ui-egui/src/template_thumb.rs index f05e9866..51ed8ff4 100644 --- a/crates/ui-egui/src/template_thumb.rs +++ b/crates/ui-egui/src/template_thumb.rs @@ -152,7 +152,8 @@ pub fn paint(ui: &mut egui::Ui, rect: Rect, body: &str, paper: Paper, colours: C } Mark::Check { checked } => { let b = if rtl { - Rect::from_min_size(pos2(x_at(4.0) - 3.0, y), vec2(3.0, 3.0)) + // The box sits at the margin edge, so the text bar that starts 5 points in does not run into it. + Rect::from_min_size(pos2(x_at(0.0) - 3.0, y), vec2(3.0, 3.0)) } else { Rect::from_min_size(pos2(x_at(0.0), y), vec2(3.0, 3.0)) }; @@ -173,6 +174,41 @@ pub fn paint(ui: &mut egui::Ui, rect: Rect, body: &str, paper: Paper, colours: C } } +/// The words of a saved page as the marks above read them. A Markdown page is already that. An +/// HTML page has its tags turned into the same lines: headings and list items keep their shape, +/// and every other tag goes. +pub fn plain_words(text: &str, html: bool) -> String { + if !html { + return text.to_string(); + } + let mut out = String::new(); + let mut tag = String::new(); + let mut in_tag = false; + for ch in text.chars() { + if in_tag { + if ch == '>' { + in_tag = false; + let closing = tag.starts_with('/'); + let name = tag.trim_start_matches('/').split_whitespace().next().unwrap_or("").to_ascii_lowercase(); + match (name.as_str(), closing) { + ("h1" | "h2" | "h3" | "h4" | "h5" | "h6", false) => out.push_str("\n## "), + ("li", false) => out.push_str("\n- "), + ("p" | "div" | "li" | "tr" | "br" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6", _) => out.push('\n'), + _ => {} + } + tag.clear(); + } else { + tag.push(ch); + } + } else if ch == '<' { + in_tag = true; + } else { + out.push(ch); + } + } + out +} + #[cfg(test)] mod tests { use super::*; @@ -205,6 +241,16 @@ mod tests { } } + #[test] + fn html_words_keep_their_shape_and_lose_their_tags() { + let words = plain_words("

Title

Some bold text

  • one
", true); + assert!(words.contains("## Title"), "{words:?}"); + assert!(words.contains("Some bold text"), "{words:?}"); + assert!(words.contains("- one"), "{words:?}"); + assert!(!words.contains('<'), "no tags are left: {words:?}"); + assert_eq!(plain_words("## kept", false), "## kept"); + } + #[test] fn paper_names_map_to_the_three_papers() { assert_eq!(paper_for(None), Paper::Plain); From 02a7fc26d744bacd808835e4d251c71c4b5059c5 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 14:24:29 -0800 Subject: [PATCH 18/19] feat(ui): Set Picture as Background toggles a box The picture menu toggles the box that holds the picture. A background box is drawn behind the page at its place and is not selectable by a click; its menu opens on right-click, and it shows a check mark. Clearing it returns the same box to normal. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/src/app.rs | 28 +++++++++-------- crates/ui-egui/src/containers.rs | 53 ++++++++++++++++++++++++++++++++ crates/ui-egui/src/imagemenu.rs | 22 ++++++++++--- crates/ui-egui/src/ribbon.rs | 5 +-- i18n/ar-XB.tsv | 1 + i18n/en-XA.tsv | 1 + i18n/en.tsv | 1 + 7 files changed, 92 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 3b24fabc..80f0b0fb 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -9091,9 +9091,11 @@ impl NoteCraftApp { } } - /// A picture in the open page becomes its background, in whichever format the page is in: the - /// page file names the picture's path, and the picture is read once for drawing. - fn set_picture_background(&mut self, src: String) { + /// Set Picture as Background, toggled: the box that holds the picture becomes the page's + /// background (its picture is drawn behind the page, where a click does not reach it), or + /// becomes an ordinary box again. The box keeps its place either way, and is saved with the + /// page's arrangement, in both page formats. + fn set_picture_background(&mut self, block: usize) { let Some(ed) = self.editor.as_mut() else { self.say("Open a page first"); return; @@ -9102,17 +9104,17 @@ impl NoteCraftApp { self.say(crate::tl_id!("ui.page_is_read_only")); return; } - let dir = ed.dir.clone(); - match notecraft_store::page::set_background(&dir, Some(&src)) { - Ok(()) => { - let bytes = crate::imagemenu::validate_and_read_image(&dir, &src).ok().map(|(_, _, bytes)| egui::load::Bytes::from(bytes)); - if let Some(ed) = self.editor.as_mut() { - ed.background = Some(src); - ed.background_image = bytes; - } - } - Err(_) => self.say(crate::tl_id!("ui.page_is_read_only")), + let Some((at, _)) = notecraft_model::container::place(&ed.boxes, block) else { return }; + // A background box is only its picture: a box with words or other blocks in it would hide them. + if !ed.boxes[at].background && ed.boxes[at].blocks != 1 { + self.say(crate::tl_id!("ui.picture_background_needs_own_box")); + return; } + ed.boxes[at].background = !ed.boxes[at].background; + ed.arranged = true; + ed.rebuild_body(); + Self::mark_dirty_from_blocks(ed); + Self::remember(ed, false, None); } /// Page Color > More Colors: gives the open page the colour the picker chose, exactly, and diff --git a/crates/ui-egui/src/containers.rs b/crates/ui-egui/src/containers.rs index 93a5f65d..3e1d01a1 100644 --- a/crates/ui-egui/src/containers.rs +++ b/crates/ui-egui/src/containers.rs @@ -442,6 +442,28 @@ pub fn show( } let mut frames: Vec = Vec::with_capacity(boxes.len()); + // Background boxes (Set Picture as Background) are drawn first, so the words of every other + // box are drawn over them. Each picture is recorded for the right-click menu, and the list of + // those pictures' blocks is kept for the menu's check mark. + let mut background_blocks: Vec = Vec::new(); + for (i, b) in boxes.iter().enumerate().filter(|(_, b)| b.background) { + let range = container::blocks_of(boxes, i); + let Some(block) = background_picture(blocks, &range) else { continue }; + background_blocks.push(block); + let frame = background_frame(area, b, zoom, blocks.get(block)); + if let Some(Block::Image { src, .. }) = blocks.get(block) + && let Ok((_, _, bytes)) = crate::imagemenu::validate_and_read_image(page_dir, src) + { + let pad = PAD * zoom; + let rect = frame.shrink(pad); + egui::Image::from_bytes(format!("bytes://notecraft-background-box/{src}"), egui::load::Bytes::from(bytes)) + .fit_to_exact_size(rect.size()) + .paint_at(ui, rect); + crate::preview::record_rendered_image(ui.ctx(), block, rect, src); + } + } + ui.data_mut(|d| d.insert_temp(background_blocks_id(), background_blocks)); + for i in 0..boxes.len() { let Some(b) = boxes.get(i).copied() else { continue }; let range = container::blocks_of(boxes, i); @@ -464,6 +486,16 @@ pub fn show( let first_drawn = range.clone().find(|&n| blocks.get(n).is_some() && !pageedit::is_title_echo(blocks, n, shown_title)); let head = if first_drawn.is_some() { crate::block_emoji::HEADER_ROW * zoom } else { 0.0 }; let at = pos2(area.min.x + b.x * zoom, area.min.y + b.y * zoom + head); + // A background box's picture was drawn behind the page above. It is not a block to select, + // move or type into: only its right-click menu is reached, through the recorded picture. + if b.background && background_picture(blocks, &range).is_some() { + let frame = background_frame(area, &b, zoom, background_picture(blocks, &range).and_then(|n| blocks.get(n))); + out.shown_widths.push(b.width); + frames.push(frame); + bottom = bottom.max(frame.max.y); + right = right.max(frame.max.x); + continue; + } if let Some(first) = first_drawn { let row = Rect::from_min_size(pos2(at.x + PAD * zoom, at.y - head), vec2(b.width * zoom, head)); let mut head_ui = ui.new_child(egui::UiBuilder::new().max_rect(row)); @@ -1840,6 +1872,27 @@ fn page_points_right(area: Rect, right: f32, zoom: f32) -> f32 { if zoom > 0.0 { ((right - area.min.x) / zoom).max(0.0) } else { 0.0 } } +/// The list of blocks that are pictures of background boxes, kept for the picture menu's check mark. +pub fn background_blocks_id() -> egui::Id { + egui::Id::new("background-picture-blocks") +} + +/// The first picture block of a box, if the box holds one. +fn background_picture(blocks: &[Block], range: &std::ops::Range) -> Option { + range.clone().find(|&n| matches!(blocks.get(n), Some(Block::Image { .. }))) +} + +/// Where a background box is drawn: at its place and width, as tall as its picture (or two thirds +/// of its width when the picture has no height of its own). +fn background_frame(area: Rect, b: ¬ecraft_model::Container, zoom: f32, picture: Option<&Block>) -> Rect { + let pad = PAD * zoom; + let height = match picture { + Some(Block::Image { height: Some(h), .. }) => *h, + _ => b.width * 0.66, + }; + Rect::from_min_size(pos2(area.min.x + b.x * zoom, area.min.y + b.y * zoom), vec2(b.width * zoom + 2.0 * pad, height * zoom + 2.0 * pad)) +} + fn block_has_image(block: &Block) -> bool { match block { Block::Image { .. } => true, diff --git a/crates/ui-egui/src/imagemenu.rs b/crates/ui-egui/src/imagemenu.rs index 18046469..252c5db4 100644 --- a/crates/ui-egui/src/imagemenu.rs +++ b/crates/ui-egui/src/imagemenu.rs @@ -86,16 +86,30 @@ pub fn show(ui: &mut Ui, body: egui::Rect, page: &Path, acts: &mut Vec, t: let Some((at, src)) = state(ui.ctx()) else { return }; let mut picked = false; + let picture_block = ui.data(|d| d.get_temp::(block_id())); + let backgrounds = ui.data(|d| d.get_temp::>(crate::containers::background_blocks_id())).unwrap_or_default(); let Some(menu) = floating::point_menu(ui.ctx(), id(), egui::Rect::from_pos(at), |ui| { floating::menu_heading(ui, crate::tl_id!("ui.this_picture"), t); if floating::menu_row(ui, Some(Glyph::Icon(Icon::Picture)), crate::tl_id!("ui.save_picture_as"), t).clicked() { acts.push(Act::SavePictureAs(src.clone())); picked = true; } - // The picture becomes the page's background, in both page formats. - if floating::menu_row(ui, None, crate::tl_id!("ui.set_picture_as_background"), t).clicked() { - acts.push(Act::SetPictureBackground(src.clone())); - picked = true; + // Set Picture as Background: a check mark while the picture's box is the page's background. + // Choosing it again clears the background, and the picture is an ordinary one again. + if let Some(picture) = picture_block { + let on = backgrounds.contains(&picture); + let row = floating::menu_row(ui, None, crate::tl_id!("ui.set_picture_as_background"), t); + if on { + let c = row.rect; + let (x, y) = (c.left() + 12.0, c.center().y); + let stroke = egui::Stroke::new(1.6, t.accent); + ui.painter().line_segment([egui::pos2(x - 4.0, y), egui::pos2(x - 1.0, y + 3.0)], stroke); + ui.painter().line_segment([egui::pos2(x - 1.0, y + 3.0), egui::pos2(x + 4.0, y - 3.5)], stroke); + } + if row.clicked() { + acts.push(Act::SetPictureBackground(picture)); + picked = true; + } } // The printed text of the picture, or of a printout's page or every page (issue #274). if crate::picture_text::printout_source(&src).is_some() { diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 845e730f..c614f006 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -261,8 +261,9 @@ pub enum Act { highlight: bool, current: Option, }, - /// A picture's menu: Set Picture as Background, with the picture's path in the page. - SetPictureBackground(String), + /// A picture's menu: Set Picture as Background, toggled for the box that holds the picture + /// (given by the picture's block). + SetPictureBackground(usize), /// Page Color > More Colors: open the colour picker for the page's own colour. OpenMorePageColours { current: Option, diff --git a/i18n/ar-XB.tsv b/i18n/ar-XB.tsv index b0eae4a9..f94b0093 100644 --- a/i18n/ar-XB.tsv +++ b/i18n/ar-XB.tsv @@ -1818,3 +1818,4 @@ @id ui.template_leaves_rtl_page [[RLI]]$$$Leaves (RTL)@@@[[PDI]] @id ui.template_cats_rtl_page [[RLI]]$$$Cats (RTL)@@@[[PDI]] @id ui.template_butterflies_rtl_page [[RLI]]$$$Butterflies (RTL)@@@[[PDI]] +@id ui.picture_background_needs_own_box [[RLI]]$$$A picture can be the background only when it is alone in its box@@@[[PDI]] diff --git a/i18n/en-XA.tsv b/i18n/en-XA.tsv index b84f28c8..f2f6195d 100644 --- a/i18n/en-XA.tsv +++ b/i18n/en-XA.tsv @@ -1818,3 +1818,4 @@ @id ui.template_leaves_rtl_page $$$Leaves (RTL)@@@ @id ui.template_cats_rtl_page $$$Cats (RTL)@@@ @id ui.template_butterflies_rtl_page $$$Butterflies (RTL)@@@ +@id ui.picture_background_needs_own_box $$$A picture can be the background only when it is alone in its box@@@ diff --git a/i18n/en.tsv b/i18n/en.tsv index 2923143a..b929b7e0 100644 --- a/i18n/en.tsv +++ b/i18n/en.tsv @@ -1818,3 +1818,4 @@ @id ui.template_leaves_rtl_page Leaves (RTL) @id ui.template_cats_rtl_page Cats (RTL) @id ui.template_butterflies_rtl_page Butterflies (RTL) +@id ui.picture_background_needs_own_box A picture can be the background only when it is alone in its box From e1150d68cddc6dcecdd3f2afe1b891e091462680 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Sun, 29 Nov 2026 15:03:06 -0800 Subject: [PATCH 19/19] test(model): the background toggle is a tested function The decision for Set Picture as Background moves into the model as toggle_background, with tests for setting, clearing, a box with words, and a block in no box. The app uses it. Co-Authored-By: Claude Haiku 5.5 --- crates/model/src/container.rs | 58 +++++++++++++++++++++++++++++++++++ crates/ui-egui/src/app.rs | 14 +++++---- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/crates/model/src/container.rs b/crates/model/src/container.rs index 48b135de..eb6b31c8 100644 --- a/crates/model/src/container.rs +++ b/crates/model/src/container.rs @@ -77,6 +77,36 @@ pub fn write(containers: &[Container]) -> String { .join("; ") } +/// What Set Picture as Background did to a box. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum BackgroundChange { + /// The box is now the page's background. + Set, + /// The box is an ordinary box again. + Cleared, + /// The box holds more than its picture, so it cannot be the background: the words and other + /// blocks in it would be hidden. Nothing changed. + NeedsOwnBox, + /// The block is not in any box. Nothing changed. + NoBox, +} + +/// Set Picture as Background, toggled for the box that holds `block` (the picture). A box that +/// is the background is cleared; any other box becomes one, if it holds only its picture. +pub fn toggle_background(boxes: &mut [Container], block: usize) -> BackgroundChange { + let Some((at, _)) = place(boxes, block) else { return BackgroundChange::NoBox }; + let b = &mut boxes[at]; + if b.background { + b.background = false; + BackgroundChange::Cleared + } else if b.blocks != 1 { + BackgroundChange::NeedsOwnBox + } else { + b.background = true; + BackgroundChange::Set + } +} + /// The containers to use for a page with `blocks` blocks in it. /// /// This is where honesty about a count-based layer lives. If the containers account for @@ -207,6 +237,34 @@ mod tests { assert_eq!(fit(&[Container::new(0.0, 0.0, 400.0, 0)], 0, 700.0).len(), 1); } + #[test] + fn set_picture_as_background_toggles_a_box_that_holds_only_its_picture() { + let mut boxes = vec![Container::new(0.0, 0.0, 300.0, 1), Container::new(400.0, 0.0, 300.0, 2)]; + // The first box holds one block, its picture: it becomes the background, and keeps its place. + assert_eq!(toggle_background(&mut boxes, 0), BackgroundChange::Set); + assert!(boxes[0].background); + assert_eq!((boxes[0].x, boxes[0].y, boxes[0].width), (0.0, 0.0, 300.0)); + // Choosing it again clears it: an ordinary box, still in the same place. + assert_eq!(toggle_background(&mut boxes, 0), BackgroundChange::Cleared); + assert!(!boxes[0].background); + assert_eq!((boxes[0].x, boxes[0].y), (0.0, 0.0)); + } + + #[test] + fn a_box_with_words_in_it_cannot_become_the_background() { + // Block 1 shares its box with block 2: making the box a background would hide the words. + let mut boxes = vec![Container::new(0.0, 0.0, 300.0, 1), Container::new(400.0, 0.0, 300.0, 2)]; + assert_eq!(toggle_background(&mut boxes, 1), BackgroundChange::NeedsOwnBox); + assert!(boxes.iter().all(|c| !c.background), "nothing changed"); + } + + #[test] + fn a_block_in_no_box_changes_nothing() { + let mut boxes = vec![Container::new(0.0, 0.0, 300.0, 1)]; + assert_eq!(toggle_background(&mut boxes, 9), BackgroundChange::NoBox); + assert!(!boxes[0].background); + } + #[test] fn a_block_knows_which_box_it_is_in() { let boxes = vec![Container::new(0.0, 0.0, 400.0, 2), Container::new(420.0, 0.0, 200.0, 3)]; diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 80f0b0fb..a9f61fa4 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -9104,13 +9104,15 @@ impl NoteCraftApp { self.say(crate::tl_id!("ui.page_is_read_only")); return; } - let Some((at, _)) = notecraft_model::container::place(&ed.boxes, block) else { return }; - // A background box is only its picture: a box with words or other blocks in it would hide them. - if !ed.boxes[at].background && ed.boxes[at].blocks != 1 { - self.say(crate::tl_id!("ui.picture_background_needs_own_box")); - return; + use notecraft_model::container::BackgroundChange; + match notecraft_model::container::toggle_background(&mut ed.boxes, block) { + BackgroundChange::NoBox => return, + BackgroundChange::NeedsOwnBox => { + self.say(crate::tl_id!("ui.picture_background_needs_own_box")); + return; + } + BackgroundChange::Set | BackgroundChange::Cleared => {} } - ed.boxes[at].background = !ed.boxes[at].background; ed.arranged = true; ed.rebuild_body(); Self::mark_dirty_from_blocks(ed);