Normalization for LivePanels cross-space drag/drop declarations and payloads.
Drag/drop is explicit opt-in. Items declare the actions they allow and the placement spaces they may target. Browser drop requests use a single payload shape:
%{
action: :move | :copy | :add,
target_space: :world | :viewport,
x: integer,
y: integer,
w: pos_integer,
h: pos_integer,
anchor: LivePanels.Canvas.Placement.anchor(),
source_item_id: String.t(), # required for :move and :copy
source_type: atom() | String.t(), # required for :add
opts: map()
}
Summary
Functions
Returns the supported drag/drop actions.
Serializes allowed drag/drop actions for HTML data attributes.
Returns true when a drag/drop capability allows an action into a target space.
Returns an empty drag/drop capability declaration.
Normalizes an item drag/drop capability declaration.
Returns the placement spaces that can receive drops.
Serializes allowed drag/drop target spaces for HTML data attributes.
Types
Functions
@spec actions() :: [action()]
Returns the supported drag/drop actions.
@spec actions_attr(capability() | nil | term()) :: String.t()
Serializes allowed drag/drop actions for HTML data attributes.
@spec allowed?(capability() | nil | term(), action(), target()) :: boolean()
Returns true when a drag/drop capability allows an action into a target space.
@spec empty() :: capability()
Returns an empty drag/drop capability declaration.
@spec normalize_capability(term()) :: {:ok, capability() | nil} | {:error, atom()}
Normalizes an item drag/drop capability declaration.
@spec targets() :: [target()]
Returns the placement spaces that can receive drops.
@spec targets_attr(capability() | nil | term()) :: String.t()
Serializes allowed drag/drop target spaces for HTML data attributes.