Files
Marcos Paulo 5e8020aa38
ci / ci (macos-latest) (push) Has been cancelled
ci / ci (ubuntu-latest) (push) Has been cancelled
ci / ci (windows-latest) (push) Has been cancelled
feat: Obsidian basics, editor previews, graph rework, query blocks, stacked tabs, pop-out windows
Editor previews (colour swatches, arrows, embeds), the 18 obsidian-basics tasks (find and replace
with regex, back/forward, auto-pair, footnotes, folding, search operators, split view, PDF/audio/
video embeds, spelling, drag and drop, pinned tabs, settings) and round 2: ```query blocks, stacked
tabs, pop-out windows, tasks ticked inside embeds, text around an embed, embeds that follow edits,
block menu shortcut. New crates: notescraft-regex (linear-time engine) and notescraft-syntax.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 11:21:19 -03:00

48 lines
5.7 KiB
Markdown

# Tasks: Editor previews: colors, external links, fenced diagrams and trees
Rules: each task is independently testable. Order = execution order. Every task ends with `cargo test -p <crate>`, `cargo clippy -p <crate> --all-targets -- -D warnings` and `cargo fmt -p <crate>` for the crates it touched; the last task runs `cargo xtask ci` (parts) and `cargo xtask i18n`.
- [x] 1. Detect colors in text
Files: `crates/editor/src/preview/{mod.rs,color.rs}`, `crates/editor/src/lib.rs`
Done when: tests pass: hex 3/4/6/8 accepted, wrong lengths and non-hex rejected; `rgb`/`rgba`/`hsl`/`hsla` with valid arguments (alpha as 0-1 or percent) accepted, out-of-range or malformed arguments give none; `Detected { range, rgb, alpha }` ranges lie on char boundaries of accented and emoji text; a hex preceded or followed by an alphanumeric (`word#abc123x`) is skipped; lines over 4 KiB and notes over 2,000 colors are cut off without panic; a 1 MiB line is bounded.
- [x] 2. Detect named colors in inline code
Files: `crates/editor/src/preview/named.rs`
Done when: tests pass: the 16 basic CSS names match as whole words (case-insensitive) only when the caller says the run is inline code and named colors are on; `reddish`, `Red-ish` and `bored` give none; each name maps to the exact CSS rgb.
- [x] 3. Detect tree blocks
Files: `crates/editor/src/preview/tree.rs`
Done when: tests pass: `detect_tree(label, body)` accepts an empty, `text` or `tree` label with at least 2 lines of which at least 2 have a tree glyph (`│ ├ └ ─` or the ASCII forms `|--`, `'--`, `` `-- ``) followed by a name, returns rows `{ prefix, name, folder }` (folder when the name ends in `/` or the next row is deeper); box-drawing tables, ASCII art and other labels are rejected; body over 64 KiB or 2,000 lines is rejected; copy text is not part of the result (the caller keeps the source).
- [x] 4. Add preview settings
Files: `crates/engine/src/prefs/app_settings.rs`, `crates/engine/src/prefs/settings.rs` (only if validation needs it), `crates/engine/tests/settings.rs`
Done when: tests pass: `EditorSettings.previews { colors: true, named_colors: false }`, serde defaults for old files, `settings.set` of `editor.previews.colors` / `editor.previews.named_colors` round-trips through `config.toml`, bad types are refused.
- [x] 5. Swatches in rendered rows
Files: `crates/ui-egui/src/views/note_view/{inlines.rs,painting.rs,select.rs,edit.rs}`, `crates/ui-egui/src/widgets/previews.rs`, `crates/ui-egui/src/shell/app/editor/blocks.rs`
Done when: tests pass: a plain-text or inline-code color gets a 12 pt rounded swatch (radius 3, one border, alpha composited) before it; `#123` tags and invalid values get none; previews off draws none and skips detection; selecting across a swatch copies exactly the source and the caret byte offset equals the source; rows with inline math draw none; no `NoteEdit` is ever produced.
- [x] 6. Swatches in fenced code
Files: `crates/ui-egui/src/views/note_view/blocks/code_card.rs`
Done when: tests pass: a `css`, `scss`, `less`, `html`, `xml`, `svg`, `json`, `yaml`, `toml` or `ini` fence draws swatches for its colors, a `rust` fence draws none.
- [x] 7. Right-click color menu
Files: `crates/ui-egui/src/widgets/color_menu.rs`, `crates/ui-egui/src/text/views/note_view.rs`, `crates/i18n/locales/en.toml`
Done when: tests pass: secondary click on a swatch opens a menu with the color and hex, Copy color, Copy as rgb (clipboard text exact), Color previews switch and Named colors switch; each switch runs `settings.set` and the setting survives reload; the menu opens only inside a swatch rect.
- [x] 8. External link arrow
Files: `crates/ui-egui/src/views/note_view/{inlines.rs,painting.rs}`, `crates/ui-egui/src/widgets/previews.rs`
Done when: tests pass: a markdown link to `http://` or `https://` is followed by a 16 pt up-right arrow in the link color, wikilinks and vault-relative links get none, clicking the link still returns the same `clicked_link`.
- [x] 9. Tree card
Files: `crates/ui-egui/src/views/note_view/blocks/tree_card.rs`, `crates/ui-egui/src/views/note_view.rs`, `crates/ui-egui/src/text/views/note_view.rs`
Done when: tests pass: a qualifying fence draws a TREE card with Copy (clipboard equals the source bytes) and a folder or file icon per row; box-drawing tables and other fences stay ordinary code cards.
- [x] 10. Mermaid Source/Diagram toggle, chips and fallbacks
Files: `crates/ui-egui/src/views/diagram_view.rs`, `crates/ui-egui/src/views/diagram_view/paint.rs`, `crates/ui-egui/src/views/note_view.rs`, `crates/ui-egui/src/views/center.rs`, `crates/ui-egui/src/shell/app/window/views.rs`, `crates/ui-egui/src/text/views/diagram_view.rs`
Done when: tests pass: a parseable mermaid fence shows as a diagram with a Source/Diagram toggle (default Diagram); Source shows the original text through the code card and edits go through the normal editing path; the choice is remembered per block while the note is open and survives an edit above the block; a parse error shows an error chip with the first message line, an unknown diagram kind an unsupported chip, and an over-limit diagram a size message, each leaving the source visible.
- [x] 11. Docs, snapshot check and the gate
Files: `ROADMAP.md`, `docs/ARCHITECTURE.md`
Done when: a snapshot of a fixture note (colors, links, mermaid, tree) at 1440x900 in Mocha and Latte shows every preview; a 1,000-color note's detection stays under 10 ms (measured); `cargo fmt --check`, workspace clippy, `cargo xtask layers`, `i18n`, `tree` are green and the test suites of the touched crates pass; ROADMAP and ARCHITECTURE describe the new module and settings.