diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 36e06c2..7cd9925 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -633,6 +633,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "pure-rust-locales", "serde", "wasm-bindgen", "windows-link 0.2.1", @@ -1867,6 +1868,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", + "sys-locale", "tantivy", "tauri", "tauri-build", @@ -3589,6 +3591,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pure-rust-locales" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869675ad2d7541aea90c6d88c81f46a7f4ea9af8cd0395d38f11a95126998a0d" + [[package]] name = "pxfm" version = "0.1.27" @@ -4770,6 +4778,15 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "sys-locale" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" +dependencies = [ + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 9e2f0aa..76da04c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,7 +26,8 @@ serde_yaml = "0.9" log = "0.4" notify = "8" walkdir = "2" -chrono = { version = "0.4", features = ["serde"] } +chrono = { version = "0.4", features = ["serde", "unstable-locales"] } +sys-locale = "0.3" uuid = { version = "1", features = ["v4"] } tantivy = "0.22" gray_matter = "0.2" diff --git a/src-tauri/src/vault/operations.rs b/src-tauri/src/vault/operations.rs index 37fa055..a9f8a28 100644 --- a/src-tauri/src/vault/operations.rs +++ b/src-tauri/src/vault/operations.rs @@ -1,6 +1,6 @@ use crate::types::{NoteContent, NoteEntry, NoteMeta, NotebookEntry, VaultState}; use crate::vault::frontmatter; -use chrono::{Local, Utc}; +use chrono::{Local, Locale, Utc}; use rayon::prelude::*; use std::fs; use std::io::Read; @@ -449,10 +449,62 @@ pub fn create_note( }) } +fn get_system_locale() -> Locale { + let sys = sys_locale::get_locale().unwrap_or_else(|| "en-US".to_string()); + let lang = sys.split(&['-', '_', '.'][..]).next().unwrap_or("en"); + match lang { + "af" => Locale::af_ZA, + "ar" => Locale::ar_SA, + "be" => Locale::be_BY, + "bg" => Locale::bg_BG, + "ca" => Locale::ca_ES, + "cs" => Locale::cs_CZ, + "da" => Locale::da_DK, + "de" => Locale::de_DE, + "el" => Locale::el_GR, + "es" => Locale::es_ES, + "et" => Locale::et_EE, + "fi" => Locale::fi_FI, + "fr" => Locale::fr_FR, + "he" => Locale::he_IL, + "hi" => Locale::hi_IN, + "hr" => Locale::hr_HR, + "hu" => Locale::hu_HU, + "id" => Locale::id_ID, + "is" => Locale::is_IS, + "it" => Locale::it_IT, + "ja" => Locale::ja_JP, + "ka" => Locale::ka_GE, + "ko" => Locale::ko_KR, + "lt" => Locale::lt_LT, + "lv" => Locale::lv_LV, + "mk" => Locale::mk_MK, + "nb" | "no" => Locale::nb_NO, + "nl" => Locale::nl_NL, + "nn" => Locale::nn_NO, + "pl" => Locale::pl_PL, + "pt" => Locale::pt_BR, + "ro" => Locale::ro_RO, + "ru" => Locale::ru_RU, + "sk" => Locale::sk_SK, + "sl" => Locale::sl_SI, + "sq" => Locale::sq_AL, + "sr" => Locale::sr_RS, + "sv" => Locale::sv_SE, + "th" => Locale::th_TH, + "tr" => Locale::tr_TR, + "uk" => Locale::uk_UA, + "vi" => Locale::vi_VN, + "zh" => Locale::zh_CN, + _ => Locale::en_US, + } +} + pub fn create_daily_note(vault_path: &str) -> Result { let today = Local::now(); let date_str = today.format("%Y-%m-%d").to_string(); - let title = today.format("%B %d, %Y").to_string(); + let locale = get_system_locale(); + let title = today.format_localized("%B %d, %Y", locale).to_string(); let dir = Path::new(vault_path).join("Daily"); fs::create_dir_all(&dir).map_err(|e| e.to_string())?; diff --git a/src/app.css b/src/app.css index d7da013..d938f01 100644 --- a/src/app.css +++ b/src/app.css @@ -179,3 +179,94 @@ body.resizing { display: none !important; } } + +/* ── Print / Export PDF ── */ +@media print { + /* Hide everything except editor content */ + .titlebar, + .sidebar-panel, + .notelist-panel, + .resize-handle, + .toolbar-actions, + .editor-body-wrapper .note-search-bar, + .formatting-toolbar, + .editor-formatting-bar, + .history-panel, + .outline-panel, + .graph-panel, + .ai-panel, + .link-context-menu, + .image-toolbar, + .selection-bar { + display: none !important; + } + + /* Force light theme colors for PDF */ + :root, :root.dark { + --bg-primary: #ffffff !important; + --bg-secondary: #f8f9fa !important; + --bg-tertiary: #f0f1f3 !important; + --bg-editor: #ffffff !important; + --text-primary: #1a1a2e !important; + --text-secondary: #495057 !important; + --text-tertiary: #868e96 !important; + --text-accent: #5b6abf !important; + --accent: #5b6abf !important; + --border-color: #e2e5e9 !important; + --border-light: #f0f1f3 !important; + } + + html, body { + height: auto; + overflow: visible; + background: white !important; + color: #1a1a2e !important; + font-size: 12pt; + padding: 0; + } + + /* Override all scoped height/overflow constraints for print flow */ + * { + overflow: visible !important; + height: auto !important; + max-height: none !important; + min-height: 0 !important; + } + + .app-layout { + display: block !important; + } + + .editor-panel { + width: 100% !important; + min-width: 0 !important; + } + + .ProseMirror { + padding: 0 !important; + max-width: 100% !important; + background: white !important; + color: #1a1a2e !important; + } + + /* Ensure images fit within page */ + .ProseMirror img { + max-width: 100% !important; + page-break-inside: avoid; + } + + /* Avoid breaking inside these elements */ + h1, h2, h3, h4, h5, h6 { + page-break-after: avoid; + } + + pre, blockquote, table, figure { + page-break-inside: avoid; + } + + /* Code blocks with light background */ + .ProseMirror pre, .ProseMirror code { + background: #f8f9fa !important; + color: #1a1a2e !important; + } +} diff --git a/src/lib/components/NoteList.svelte b/src/lib/components/NoteList.svelte index c6af3f7..8a22e4b 100644 --- a/src/lib/components/NoteList.svelte +++ b/src/lib/components/NoteList.svelte @@ -1073,6 +1073,14 @@ Move to... + {#if !isMobile} + + {/if}