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>
5.7 KiB
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.
-
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/hslawith 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. -
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-ishandboredgive none; each name maps to the exact CSS rgb. -
3. Detect tree blocks
Files:crates/editor/src/preview/tree.rs
Done when: tests pass:detect_tree(label, body)accepts an empty,textortreelabel 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). -
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.setofeditor.previews.colors/editor.previews.named_colorsround-trips throughconfig.toml, bad types are refused. -
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;#123tags 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; noNoteEditis ever produced. -
6. Swatches in fenced code
Files:crates/ui-egui/src/views/note_view/blocks/code_card.rs
Done when: tests pass: acss,scss,less,html,xml,svg,json,yaml,tomlorinifence draws swatches for its colors, arustfence draws none. -
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 runssettings.setand the setting survives reload; the menu opens only inside a swatch rect. -
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 tohttp://orhttps://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 sameclicked_link. -
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. -
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. -
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,treeare green and the test suites of the touched crates pass; ROADMAP and ARCHITECTURE describe the new module and settings.