diff --git a/README.md b/README.md index c771ae9..5edfbc4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ A lightweight and modern Markdown editor built with JavaFX. - **Syntax Highlighting** - Code blocks with automatic language detection and theme-aware syntax coloring (via [highlight.js](https://highlightjs.org/)); each app theme maps to a matching highlight.js style - **Code Block Copy Button** - One-click copy for code blocks in preview, with visual "✓ Copied" feedback - **Markdown Tables** - Full GFM table support with styled rendering -- **PlantUML Diagrams** - Render PlantUML diagrams directly in preview; supports both the **official PlantUML online server** and a **local PlantUML jar** (configurable in Options → Tools); when local rendering is active a spinning ⚙ gear icon and a status indicator are shown in the status bar during generation +- **PlantUML Diagrams** - Render PlantUML diagrams directly in preview; supports both the **official PlantUML online server** and a **local PlantUML jar** (configurable in Options → Tools); when local rendering is active a spinning ⚙ gear icon and a status indicator are shown in the status bar during generation; **in-memory SVG cache** based on source hash avoids regenerating unchanged diagrams - **Mermaid Diagrams** - Render Mermaid diagrams (flowcharts, sequences, etc.) directly in preview; Mermaid theme auto-matches app theme - **Math Equations** - LaTeX/MathML support via KaTeX for inline (`$...$`) and block (`$$...$$`) equations - **Front Matter Panel** - Collapsible panel above the editor for visual editing of YAML front matter (title, tags, authors, summary, UUID, created date, draft); supports custom fields and UUID-based document linking via drag & drop @@ -54,13 +54,13 @@ A lightweight and modern Markdown editor built with JavaFX. MarkNote is available in 5 languages: -| Language | Locale | -|----------|--------| -| Français (French) | `fr` | -| English | `en` | -| Deutsch (German) | `de` | -| Español (Spanish) | `es` | -| Italiano (Italian) | `it` | +| Language | Locale | +| ------------------ | ------ | +| Français (French) | `fr` | +| English | `en` | +| Deutsch (German) | `de` | +| Español (Spanish) | `es` | +| Italiano (Italian) | `it` | The application automatically uses your system's locale. @@ -81,13 +81,13 @@ cd marknote ### Build Commands -| Command | Description | -|---------|-------------| -| `./build` | Compile the project and create the JAR | -| `./build run` | Compile and run the application | -| `./build test` | Run unit tests | -| `./build package` | Create a distributable package for the **current platform** with embedded JRE | -| `./build package-all` | Create distributable packages for **all platforms** (linux, mac, win) | +| Command | Description | +| --------------------- | ----------------------------------------------------------------------------- | +| `./build` | Compile the project and create the JAR | +| `./build run` | Compile and run the application | +| `./build test` | Run unit tests | +| `./build package` | Create a distributable package for the **current platform** with embedded JRE | +| `./build package-all` | Create distributable packages for **all platforms** (linux, mac, win) | ## Running @@ -137,11 +137,11 @@ Create packages for **all three platforms** in one shot: This produces three ZIP archives in `target/`: -| Archive | Platform | -|---------|----------| -| `MarkNote-{version}-linux.zip` | Linux x64 | -| `MarkNote-{version}-mac.zip` | macOS | -| `MarkNote-{version}-win.zip` | Windows x64 | +| Archive | Platform | +| ------------------------------ | ----------- | +| `MarkNote-{version}-linux.zip` | Linux x64 | +| `MarkNote-{version}-mac.zip` | macOS | +| `MarkNote-{version}-win.zip` | Windows x64 | > **Note:** A minimal embedded JRE (via `jlink`) is bundled only for the current host platform. > Cross-platform packages include all required JARs but require a compatible Java runtime already diff --git a/src/docs/user-guide-en.md b/src/docs/user-guide-en.md index 7d48682..e448cda 100644 --- a/src/docs/user-guide-en.md +++ b/src/docs/user-guide-en.md @@ -52,7 +52,7 @@ MarkNote is a cross-platform Markdown editor designed for writers, developers, a - **Markdown Tables** - Full GFM table support with styled rendering - **Task Lists** - GitHub-style checkboxes (`[ ]` / `[x]`) rendered in preview - **GitHub Alerts** - Styled blockquotes for `[!NOTE]`, `[!TIP]`, `[!IMPORTANT]`, `[!WARNING]`, `[!CAUTION]` -- **PlantUML Diagrams** - Render PlantUML diagrams directly in the preview; switch between the **online PlantUML server** (default) or a **local `plantuml.jar`** configured in Options → Tools; local rendering is asynchronous (per-block background threads) and shows a ⚙ spinning gear icon in the status bar during generation +- **PlantUML Diagrams** - Render PlantUML diagrams directly in the preview; switch between the **online PlantUML server** (default) or a **local `plantuml.jar`** configured in Options → Tools; local rendering is asynchronous (per-block background threads) and shows a ⚙ spinning gear icon in the status bar during generation; **in-memory SVG cache** avoids regenerating unchanged diagrams - **Mermaid Diagrams** - Render Mermaid flowcharts, sequences, and more in the preview (theme auto-matches app theme) - **Math Equations** - LaTeX/MathML support via KaTeX (`$...$` inline, `$$...$$` block) - **Front Matter Panel** - Collapsible panel above the editor showing and editing YAML front matter metadata, with UUID-based document linking via drag & drop @@ -889,6 +889,7 @@ When local rendering is active: - The **⚙ spinning gear** icon in the status bar is visible during rendering - On completion the placeholders are replaced inline with the SVG (no page reload) - If the local jar fails, the diagram falls back silently to the online server +- **SVG Cache:** Generated SVG images are cached in memory using a SHA-256 hash of the diagram source; unchanged diagrams are served instantly from cache without invoking the jar, significantly improving preview responsiveness during editing See [Options → Tools Tab](#tools-tab) to configure the local jar. diff --git a/src/main/java/ui/PreviewPanel.java b/src/main/java/ui/PreviewPanel.java index 9093680..596bef5 100644 --- a/src/main/java/ui/PreviewPanel.java +++ b/src/main/java/ui/PreviewPanel.java @@ -8,6 +8,7 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.security.MessageDigest; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -17,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -95,6 +97,9 @@ public class PreviewPanel extends BasePanel { "
(.*?)",
Pattern.DOTALL);
+ /** Cache des SVG PlantUML générés (clé = hash SHA-256 du code source). */
+ private static final Map