LivePanels.Canvas.Clipboard (livepanels v0.1.0)

Copy Markdown View Source

Actor-scoped clipboard projection returned by LivePanels.Canvas.Read.clipboard/1.

Applications may inspect this struct for read-only UI state. This module also owns socket-first and transaction-first clipboard command helpers.

Summary

Types

t()

First argument accepted by clipboard command helpers.

Functions

Copies the current actor selection and returns the command result.

Copies the current actor selection into the actor clipboard.

Returns the number of items held by a clipboard projection.

Copies and removes the current actor selection and returns the command result.

Copies the current actor selection and removes it through one canvas command.

Returns true when a clipboard projection contains no items.

Pastes the current actor clipboard and returns the command result.

Pastes the current actor clipboard into the canvas.

Types

command_opts()

@type command_opts() :: keyword()

command_result()

@type command_result() :: LivePanels.Canvas.Command.result()

offset()

@type offset() :: %{x: integer(), y: integer()}

socket()

@type socket() :: Phoenix.LiveView.Socket.t()

t()

@type t() :: %LivePanels.Canvas.Clipboard{
  items: %{optional(String.t()) => LivePanels.Item.t()}
}

target()

@type target() :: LivePanels.Canvas.command_target()

First argument accepted by clipboard command helpers.

Pass a LiveView socket for a standalone command, or a LivePanels.Canvas.Transaction context inside LivePanels.Canvas.transaction/2.

Functions

copy(target)

@spec copy(target()) :: command_result()

Copies the current actor selection and returns the command result.

copy!(target)

@spec copy!(target()) :: target()

Copies the current actor selection into the actor clipboard.

count(clipboard)

@spec count(t() | term()) :: non_neg_integer()

Returns the number of items held by a clipboard projection.

cut(target)

@spec cut(target()) :: command_result()

Copies and removes the current actor selection and returns the command result.

cut!(target)

@spec cut!(target()) :: target()

Copies the current actor selection and removes it through one canvas command.

empty?(clipboard)

@spec empty?(t() | term()) :: boolean()

Returns true when a clipboard projection contains no items.

paste(target, opts \\ [])

@spec paste(target(), command_opts()) :: command_result()

Pastes the current actor clipboard and returns the command result.

paste!(target, opts \\ [])

@spec paste!(target(), command_opts()) :: target()

Pastes the current actor clipboard into the canvas.