Files
tolaria/design/drag-drop-images.pen
Luca Rossi 9d0c549041 fix: drag-and-drop images into editor — add drop overlay and copy-to-attachments (#150)
* feat: add copy_image_to_vault Rust command for native drag-drop

Adds a new Tauri command that copies an image file from a source path
(provided by Tauri's drag-drop event) directly into vault/attachments/.
More efficient than base64 encoding for filesystem drag-drop.

Also adds core:webview:allow-on-drag-drop-event permission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: handle Tauri native drag-drop for filesystem images

Listen for Tauri's onDragDropEvent to intercept OS-level file drops
that bypass the webview's HTML5 DnD API. When image files are dropped:
1. Copy to vault/attachments via copy_image_to_vault command
2. Insert image block into BlockNote at cursor position

Also passes vaultPath through Editor → EditorContent → SingleEditorView
so the hook can invoke the Tauri command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove nonexistent drag-drop permission from capabilities

The onDragDropEvent API works through core:event:default (included
in core:default), not a separate webview permission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: correct DragDropEvent type handling for 'over' events

Tauri's DragDropEvent discriminated union only provides `paths` on 'drop'
events, not 'over'. Show drag overlay unconditionally on 'over' since we
can't filter by image paths at that stage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* design: drag-drop-images wireframes (idle + drag-over overlay)

* style: rustfmt mcp.rs and image.rs

---------

Co-authored-by: Test <test@test.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-28 21:31:47 +01:00

79 lines
2.0 KiB
Plaintext

{
"children": [
{
"type": "frame",
"id": "drag_drop_idle",
"name": "Drag & Drop Images — Idle (no drag)",
"x": 0,
"y": 0,
"width": 900,
"height": 600,
"fill": "$--background",
"layout": "vertical",
"theme": { "Mode": "Light" },
"children": [
{
"type": "rectangle",
"id": "drag_idle_editor",
"width": "fill_container",
"height": "fill_container",
"fill": "$--background",
"cornerRadius": 0
}
]
},
{
"type": "frame",
"id": "drag_drop_active",
"name": "Drag & Drop Images — Drag Over (overlay shown)",
"x": 940,
"y": 0,
"width": 900,
"height": 600,
"fill": "$--background",
"layout": "vertical",
"theme": { "Mode": "Light" },
"children": [
{
"type": "frame",
"id": "drag_active_container",
"name": "Editor with Drag Overlay",
"layout": "vertical",
"width": "fill_container",
"height": "fill_container",
"children": [
{
"type": "rectangle",
"id": "drag_active_editor_bg",
"width": "fill_container",
"height": "fill_container",
"fill": "$--background"
},
{
"type": "frame",
"id": "drag_overlay",
"name": "Drop Overlay",
"width": "fill_container",
"height": "fill_container",
"layout": "vertical",
"fill": "rgba(0,0,0,0.4)",
"cornerRadius": 8,
"children": [
{
"type": "text",
"id": "drag_overlay_label",
"content": "Drop image to insert",
"fontSize": 18,
"fontWeight": "600",
"fill": "#ffffff",
"textAlign": "center"
}
]
}
]
}
]
}
]
}