Implement drag-and-drop image import into the post editor #46

Closed
opened 2026-07-20 10:50:23 +00:00 by hugo · 1 comment
Owner

Context

specs/editor_post.allium requires drag-and-drop image import into the post editor: @guarantee DragDropImages (line ~169, "Drop image file onto editor area triggers import chain"), surface event ImageDroppedOnEditor(editor.post_id, file_path) (line ~115), and rule PostDragDropImage (line ~305) which chains through action_patterns.allium DragDropImageChain. The GUI has no implementation: there is no iced::window::Event::FileDropped (or equivalent) handling anywhere in crates/bds-ui and no drop-target logic in crates/bds-ui/src/views/post_editor.rs. bDS2 implements this behavior (baseline in ../bDS2).

The import chain itself already exists and is used by the Gallery workflow and media import: image import into the media library, post-media linking, thumbnail generation, optional AI enrichment, and Markdown insertion (see crates/bds-core/src/engine/gallery_import.rs and the post editor gallery/InsertMedia handlers in crates/bds-ui).

Task

  1. Subscribe to window file-drop events in the Iced app (iced::Event::Window(window::Event::FileDropped(path)) in the app subscription; Iced 0.13 delivers one event per file).
  2. When the active tab is a post editor and the dropped file has a supported image extension, run the existing import chain per action_patterns.allium DragDropImageChain: import into the media library, link to the current post, then insert the Markdown image reference at the cursor position in the editor buffer. Reuse the same engine paths as the Gallery workflow — no new import logic.
  3. Non-image files and drops outside a post editor are ignored (or produce a localized toast explaining why nothing happened — check bDS2 behavior in ../bDS2 and match it).
  4. Multiple files dropped together are imported sequentially in the shared managed-task style used by the gallery import, with progress in the task panel.
  5. Respect airplane mode for AI enrichment exactly like the gallery pipeline (skip enrichment with the standard toast when unavailable).
  6. i18n for any new user-visible strings in all five locales/ui/*.ftl files.
  7. Red/green TDD: unit-test the drop-routing decision (active tab type + extension filter → action) and the Markdown insertion at cursor; use the existing editor-state test patterns in crates/bds-ui.
  8. Update DOCUMENTATION.md (Working with media) to document drag-and-drop import once it exists.

Definition of done

  • Dropping image files onto an open post editor imports, links, and inserts them; progress is visible; airplane rules respected.
  • cargo test --workspace passes.
## Context `specs/editor_post.allium` requires drag-and-drop image import into the post editor: `@guarantee DragDropImages` (line ~169, "Drop image file onto editor area triggers import chain"), surface event `ImageDroppedOnEditor(editor.post_id, file_path)` (line ~115), and rule `PostDragDropImage` (line ~305) which chains through `action_patterns.allium` `DragDropImageChain`. The GUI has no implementation: there is no `iced::window::Event::FileDropped` (or equivalent) handling anywhere in `crates/bds-ui` and no drop-target logic in `crates/bds-ui/src/views/post_editor.rs`. bDS2 implements this behavior (baseline in `../bDS2`). The import chain itself already exists and is used by the Gallery workflow and media import: image import into the media library, post-media linking, thumbnail generation, optional AI enrichment, and Markdown insertion (see `crates/bds-core/src/engine/gallery_import.rs` and the post editor gallery/InsertMedia handlers in `crates/bds-ui`). ## Task 1. Subscribe to window file-drop events in the Iced app (`iced::Event::Window(window::Event::FileDropped(path))` in the app subscription; Iced 0.13 delivers one event per file). 2. When the active tab is a post editor and the dropped file has a supported image extension, run the existing import chain per `action_patterns.allium` `DragDropImageChain`: import into the media library, link to the current post, then insert the Markdown image reference at the cursor position in the editor buffer. Reuse the same engine paths as the Gallery workflow — no new import logic. 3. Non-image files and drops outside a post editor are ignored (or produce a localized toast explaining why nothing happened — check bDS2 behavior in `../bDS2` and match it). 4. Multiple files dropped together are imported sequentially in the shared managed-task style used by the gallery import, with progress in the task panel. 5. Respect airplane mode for AI enrichment exactly like the gallery pipeline (skip enrichment with the standard toast when unavailable). 6. i18n for any new user-visible strings in all five `locales/ui/*.ftl` files. 7. Red/green TDD: unit-test the drop-routing decision (active tab type + extension filter → action) and the Markdown insertion at cursor; use the existing editor-state test patterns in `crates/bds-ui`. 8. Update `DOCUMENTATION.md` (Working with media) to document drag-and-drop import once it exists. ## Definition of done - Dropping image files onto an open post editor imports, links, and inserts them; progress is visible; airplane rules respected. - `cargo test --workspace` passes.
hugo added the enhancement label 2026-07-20 11:03:05 +00:00
Author
Owner

Implemented drag-and-drop image import for active post editors. Supported images now queue sequential import/link tasks, insert host-absolute /media/... Markdown at the buffer cursor, persist the post, refresh relationships and media, and run optional AI enrichment and metadata translation as background tasks. Airplane mode and unavailable endpoints skip enrichment with localized warning toasts while preserving the import. Unsupported files and drops outside an active post editor are ignored. The existing Insert Media action now also writes host-absolute URLs; legacy bds-media:// parsing remains read-only compatibility. Added five-locale UI copy, user documentation, README coverage, Allium contract updates, and isolated routing, queueing, cursor, persistence/linking, URL, and airplane-mode tests. Neutral review against issue #46, bDS2, and Allium found no missing behavior. Verified with cargo fmt --all -- --check; cargo clippy --workspace --all-targets -- -D warnings; cargo build --workspace; cargo machete --with-metadata; cargo outdated --workspace --root-deps-only --exit-code 1; cargo test --workspace; allium check specs/.allium; and allium analyse specs/.allium. Commit: 29cdd01.

Implemented drag-and-drop image import for active post editors. Supported images now queue sequential import/link tasks, insert host-absolute /media/... Markdown at the buffer cursor, persist the post, refresh relationships and media, and run optional AI enrichment and metadata translation as background tasks. Airplane mode and unavailable endpoints skip enrichment with localized warning toasts while preserving the import. Unsupported files and drops outside an active post editor are ignored. The existing Insert Media action now also writes host-absolute URLs; legacy bds-media:// parsing remains read-only compatibility. Added five-locale UI copy, user documentation, README coverage, Allium contract updates, and isolated routing, queueing, cursor, persistence/linking, URL, and airplane-mode tests. Neutral review against issue #46, bDS2, and Allium found no missing behavior. Verified with cargo fmt --all -- --check; cargo clippy --workspace --all-targets -- -D warnings; cargo build --workspace; cargo machete --with-metadata; cargo outdated --workspace --root-deps-only --exit-code 1; cargo test --workspace; allium check specs/*.allium; and allium analyse specs/*.allium. Commit: 29cdd01.
hugo closed this issue 2026-07-20 14:20:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#46