feat(rich): RichEditorState + RenderPreferences palette (#43, #46) #155

Closed
charles wants to merge 5 commits from feat/43-46-rich-editor-prefs into main
Owner

Summary

Implements issues #43 and #46 in the fractal-rich crate.

Issue #43 — Rich editor block insertion palette (editor.rs)

  • BlockType enum with 12 variants: Chart, Quiz, Card, Carousel, Timeline, Math, Mermaid, Canvas, CodeRun, Progress, Accordion, TableSort
  • BlockTypeInfo struct: block_type, display_name, description, icon_name
  • fn all_block_types() -> &'static [BlockTypeInfo] — static list via OnceLock
  • RichEditorState with open, selected_block, config_json fields and methods:
    • toggle_palette() — opens/closes, clears selection on close
    • select_block(BlockType) — sets selection and opens palette
    • update_config(String) — updates JSON config
    • generate_html() -> String — emits <div data-fx-type="…" data-fx-config='…'>fallback</div>

Issue #46 — Render preferences (prefs.rs)

  • RenderPreferences with level: RenderLevel, rich_editor_enabled: bool, code_run_enabled: bool
  • Default: Standard, rich_editor_enabled: true, code_run_enabled: false
  • to_toml_value() -> toml::Value / from_toml_value(v: &toml::Value) -> Self
  • RichEditorInsertionPalette { available_types, render_prefs } with filter_by_prefs():
    • returns empty vec if rich_editor_enabled is false
    • excludes CodeRun unless code_run_enabled is true

Cargo changes

  • Added serde, serde_json, toml (all workspace) to fractal-rich/Cargo.toml

lib.rs

  • Added pub mod editor and pub mod prefs alongside existing modules
  • Re-exported all new public types

Closes #43
Closes #46

## Summary Implements issues #43 and #46 in the `fractal-rich` crate. ### Issue #43 — Rich editor block insertion palette (`editor.rs`) - `BlockType` enum with 12 variants: `Chart`, `Quiz`, `Card`, `Carousel`, `Timeline`, `Math`, `Mermaid`, `Canvas`, `CodeRun`, `Progress`, `Accordion`, `TableSort` - `BlockTypeInfo` struct: `block_type`, `display_name`, `description`, `icon_name` - `fn all_block_types() -> &'static [BlockTypeInfo]` — static list via `OnceLock` - `RichEditorState` with `open`, `selected_block`, `config_json` fields and methods: - `toggle_palette()` — opens/closes, clears selection on close - `select_block(BlockType)` — sets selection and opens palette - `update_config(String)` — updates JSON config - `generate_html() -> String` — emits `<div data-fx-type="…" data-fx-config='…'>fallback</div>` ### Issue #46 — Render preferences (`prefs.rs`) - `RenderPreferences` with `level: RenderLevel`, `rich_editor_enabled: bool`, `code_run_enabled: bool` - `Default`: `Standard`, `rich_editor_enabled: true`, `code_run_enabled: false` - `to_toml_value() -> toml::Value` / `from_toml_value(v: &toml::Value) -> Self` - `RichEditorInsertionPalette { available_types, render_prefs }` with `filter_by_prefs()`: - returns empty vec if `rich_editor_enabled` is false - excludes `CodeRun` unless `code_run_enabled` is true ### Cargo changes - Added `serde`, `serde_json`, `toml` (all workspace) to `fractal-rich/Cargo.toml` ### `lib.rs` - Added `pub mod editor` and `pub mod prefs` alongside existing modules - Re-exported all new public types Closes #43 Closes #46
fix(merge): update lib.rs to include all modules from main (#146)
Some checks failed
CI / cargo check (pull_request) Has been cancelled
CI / cargo test (pull_request) Has been cancelled
CI / clippy + rustfmt (pull_request) Has been cancelled
ffe417d867
charles closed this pull request 2026-04-06 02:31:32 +00:00
Some checks are pending
CI / cargo check (pull_request) Has been cancelled
CI / cargo test (pull_request) Has been cancelled
CI / clippy + rustfmt (pull_request) Has been cancelled
qa
Required

Pull request closed

Sign in to join this conversation.
No description provided.