pdf, image viewer, markdown editor #22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
we need an markdown editor (2 pane, edit left, preview right, syntax highlighting)
use same editor from any component where we need it
so we need ability to link back for save to where it was from (Timur is good in these tricks)
e.g. in CRM we want to edit the description as markdown, we have ability to break it out into a separate editor (not the default is option), where we now can work in a nice editor, if we do save it goes back to the right field in the CRM
same for pdf viewer, so we can use same viewer everywhere
same for image viewer (full screen)
Implementation Plan: PDF Viewer, Image Viewer, Markdown Editor
Current State
The
hero_archipelagosrepo already has:viewerarchipelago — read-only views for Image (zoom/rotate), PDF (native iframe), Markdown (custom parser), Text (syntax highlighting). All Panel-only, no Row/Card variants.editorarchipelago — text/markdown editing with 2-pane split view (edit + preview), WebDAV save. Panel-only.Both are monolithic single-island archipelagos. They lack Row/Card size variants, editable toggle, and the "link back" save mechanism.
Architecture: 3 Dedicated Archipelagos + Core Media Components
Create 3 new focused archipelagos, one per media type, each with proper
IslandSizehandling (Row/Card/Panel) andIslandModetoggle (Read/Write where applicable). Lift reusable rendering components intocore/src/components/media/so any archipelago can embed them.Phase 1: Core Media Components (
core/src/components/media/)Add reusable, stateless view components to
corethat any archipelago can import:MarkdownRendererviewer/markdown_view.rs)MarkdownEditorPaneeditor/split_view.rs)ImageDisplayviewer/image_view.rs)PdfEmbedviewer/pdf_view.rs)MediaThumbnailAlso add to core:
MediaCallbacktype — standardized save-back pattern:Phase 2: Markdown Archipelago (
archipelagos/markdown/)IslandSize variants:
MediaThumbnail(markdown icon + filename + first line preview)IslandMode:Read→MarkdownRenderer(full rendered preview)Write→MarkdownEditorPane(2-pane: edit left, preview right, syntax highlighting)Props:
Link-back flow:
MarkdownIsland { content: description, mode: Write, on_save: move |new_content| { update_crm_field(new_content) } }on_savefires with new content → CRM field updatesCustomEvent("media-save", { detail: { source_id, content } })Phase 3: Image Archipelago (
archipelagos/image/)IslandSize variants:
ImageDisplaywith zoom, rotate, full-screen buttonFull-screen: Overlay modal (
position: fixed; inset: 0; z-index: 9999) with the image centered, zoom/rotate controls, and Escape to close.Read-only (no Write mode for images).
Phase 4: PDF Archipelago (
archipelagos/pdf/)IslandSize variants:
<canvas>or placeholder + filenamePdfEmbed(native browser PDF viewer iframe)Read-only (no Write mode for PDFs).
Phase 5: Integration & "Break Out to Editor" Pattern
Add a reusable
EditButtoncomponent to core that any archipelago can place next to a text field:Clicking this either:
MarkdownIsland(mode=Write) in placeCustomEventThe mode (inline vs windowed) can be a user preference or configurable prop.
Registration
Each new archipelago gets:
Cargo.tomlmembersserver/Cargo.tomldependencies[package.metadata.island]+[package.metadata.archipelago]in its own Cargo.tomlserver/src/archipelagos.rsbuild.rsExisting Viewer/Editor
Keep as-is. They serve as the "file browser opens any file" use case. The new dedicated archipelagos are for embedding per-type media components within other apps (CRM, contacts, etc.) with proper size variants and save-back.
Summary of Deliverables
core/src/components/media/archipelagos/markdown/archipelagos/image/archipelagos/pdf/core/src/components/media/core/src/components/media/Order of Implementation
Updated Plan: No Core Media Components — Each Archipelago Owns Its Components
Per feedback: no need to put reusable components in
core/. Each archipelago owns its rendering components and other archipelagos import directly from them.Import pattern:
Revised Architecture
archipelagos/markdown/— owns all markdown componentsExports (pub):
MarkdownRenderer— renders markdown string → styled HTMLMarkdownEditor— 2-pane editor (edit left, preview right, syntax highlighting)MarkdownArchipelagoApp— full island with routing, size variants, mode toggleStructure:
IslandSize → rendering:
MarkdownRendererMarkdownEditor(2-pane)Props include
on_save: EventHandler<String>for link-back to calling component.archipelagos/image/— owns all image componentsExports (pub):
ImageDisplay— image with zoom/rotate controlsImageThumbnail— compact thumbnail componentImageFullscreen— full-screen overlay modalImageArchipelagoApp— full islandStructure:
IslandSize → rendering:
ImageThumbnail(48px) + filenameImageDisplaywith zoom/rotate + full-screen buttonRead-only (no Write mode).
archipelagos/pdf/— owns all PDF componentsExports (pub):
PdfEmbed— native browser PDF viewer iframePdfArchipelagoApp— full islandStructure:
IslandSize → rendering:
PdfEmbed(native browser PDF viewer)Read-only.
Cross-archipelago usage example
CRM contact description field with "break out to editor":
Existing viewer/editor archipelagos
Keep as-is — they serve as "open any file" general-purpose tools. The new dedicated archipelagos are the reusable building blocks other apps import.
Order of implementation
Testing & Verification Plan
What's been implemented
3 new archipelagos created and registered:
archipelagos/markdown/— MarkdownRenderer, MarkdownEditor (2-pane), MarkdownIsland (Row/Card/Panel + Read/Write toggle), on_save callbackarchipelagos/image/— ImageThumbnail, ImageDisplay (zoom/rotate), ImageFullscreen (overlay), ImageIsland (Row/Card/Panel)archipelagos/pdf/— PdfEmbed (native iframe), PdfIsland (Row/Card/Panel)All registered in workspace
Cargo.toml,server/Cargo.toml,server/src/registry.rs(props, WASM paths, archipelago entries). Auto-generated intoisland_content.rsby build.rs.All compile cleanly (zero warnings), markdown unit tests pass (5/5).
How to verify
1. Showcase Server (manual visual testing)
Open
http://localhost:8200— the 3 new archipelagos (Markdown, Image, PDF) should appear in the Archipelago Directory. Click each to open its playground. Configurefile_pathandwebdav_urlprops in the left panel to point to actual files.What to check:
Requires: A running WebDAV server (hero_fossil) with test files, or point
webdav_urlto a server with accessible markdown/image/pdf files.2. Unit tests
Image and PDF are pure view components with no parsing logic — their testing is visual.
3. Integration tests with hero_browser_mcp
hero_browser_mcpprovides headless browser automation with MCP support. Integration tests would:dx serve --port 8200)http://localhost:8200Proposed test flow (using hero_browser_mcp REST API):
TODO to make this work:
tests/directory toserver/with a test harness that startsdx serveandhero_browser_mcpdata-testidattributes to key elements in the new archipelagos for reliable selector targetinginitial_contentprop for markdown,data:URL for image)make test-e2etarget to the Makefile4. Quick smoke test (no browser needed)
What's NOT yet verified / needs follow-up
cargo checkpasses butdx build(full WASM compilation) hasn't been tested due to disk space. Need to verify WASM target compiles.pub useexports (MarkdownRenderer,MarkdownEditor,ImageDisplay,PdfEmbed) haven't been tested from a consuming crate yet. This would be verified when e.g. CRM importsMarkdownEditor.