Skip to content

feat: register_drop hook for external data (URLs, images, text) #200

@careck

Description

@careck

Summary

Add a register_drop Rhai hook that lets schemas handle external data dropped or pasted onto tree nodes. When a URL is dragged from a browser, an image is pasted from a screenshot, or text is pasted while a tree node has focus, the system classifies the data, finds matching schemas, enforces parent/child constraints, pre-fetches metadata, and invokes the schema's handler to create and populate a child note.

Design Spec

Full spec committed at docs/superpowers/specs/2026-05-13-register-drop-design.md

Key Features

  • register_drop(schema, [data_types], handler) — child schema declares which data types it can be created from
  • Data types: url, image, text, html, file — each with pre-processing (URL metadata fetch, temp file storage for images/files)
  • Unified trigger: drag-and-drop and paste-on-tree-node share the same flow
  • Constraint enforcement: standard allowed_children_schemas / allowed_parent_schemas checks, no bypasses — mismatch shows a toast error
  • Multi-match picker: when multiple schemas handle the same data type, a dialog lets the user choose
  • Pre-fetch model: metadata is fetched by the Rust/Tauri layer before invoking the Rhai handler — sandbox stays network-free
  • attach() Rhai built-in: wraps existing ChaCha20-Poly1305 attachment pipeline for image/file drops

System Scripts

Ships with two script pairs:

  • BookmarkFolder + Bookmark — URL capture with status tracking (to-read/reading/read/archived), folder views by date/site/unread
  • ScreenshotFolder + Screenshot — image paste capture with thumbnail grid view, caption field

Scope

  • Core engine: register_drop hook registration, handler dispatch, attach() Rhai function, new display helpers (thumbnail, thumbnail_grid, domain)
  • Desktop crate: reqwest + scraper for URL metadata fetching, temp file management, two new Tauri commands (handle_drop, execute_drop_handler)
  • Frontend: external drop/paste detection on tree nodes, loading state, picker dialog, error toasts, i18n keys
  • System scripts: 4 new .rhai files (02–05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions