MingaEditor.Extension.Sidebar (Minga v0.1.0)

Copy Markdown View Source

Source-owned registry for extension sidebar contributions.

Extensions register sidebar metadata once, then publish snapshots whenever their content changes. The editor render and layout paths read the cached registry state directly instead of invoking extension callbacks per frame.

Summary

Types

Action handler invoked through the editor action pipeline.

Registered sidebar entry.

Sidebar placement.

Registration attributes.

Contribution source that owns a sidebar.

Registry table name.

Functions

Returns the first visible left sidebar, if any.

Returns all registered sidebars ordered by priority and id.

Returns the default production sidebar registry table.

Dispatches a semantic action through the registered action handler.

Makes one visible left sidebar focused and clears focus from the rest.

Returns a sidebar by id.

Publishes a cached snapshot for a sidebar.

Registers or replaces a sidebar owned by source.

Updates sidebar focus state.

Updates sidebar visibility.

Returns the sidebar registry table for a state-like value.

Unregisters a sidebar when it is owned by the caller's source.

Removes every sidebar owned by a source.

Returns visible registered sidebars ordered by priority and id.

Types

action_handler()

Action handler invoked through the editor action pipeline.

entry()

Registered sidebar entry.

placement()

Sidebar placement.

register_attrs()

@type register_attrs() :: %{
  :id => String.t(),
  :display_name => String.t(),
  optional(:description) => String.t(),
  optional(:placement) => placement(),
  optional(:priority) => integer(),
  optional(:preferred_width) => pos_integer(),
  optional(:visible?) => boolean(),
  optional(:focused?) => boolean(),
  optional(:semantic_kind) => String.t(),
  optional(:icon) => String.t(),
  optional(:input_handler) => module() | nil,
  optional(:action_handler) => action_handler(),
  optional(:badge_count) => non_neg_integer() | nil,
  optional(:snapshot) => MingaEditor.Extension.Sidebar.Snapshot.t()
}

Registration attributes.

source()

Contribution source that owns a sidebar.

table()

@type table() :: atom()

Registry table name.

Functions

active_left()

@spec active_left() :: entry() | nil

Returns the first visible left sidebar, if any.

active_left(table)

@spec active_left(table()) :: entry() | nil

all()

@spec all() :: [entry()]

Returns all registered sidebars ordered by priority and id.

all(table)

@spec all(table()) :: [entry()]

default_table()

@spec default_table() :: table()

Returns the default production sidebar registry table.

dispatch_action(state, sidebar_id, action, context \\ %{})

@spec dispatch_action(MingaEditor.State.t(), String.t(), String.t(), map()) ::
  MingaEditor.State.t()

Dispatches a semantic action through the registered action handler.

dispatch_action(table, state, sidebar_id, action, context)

@spec dispatch_action(table(), MingaEditor.State.t(), String.t(), String.t(), map()) ::
  MingaEditor.State.t()

focus_left(id)

@spec focus_left(String.t() | nil) :: :ok | {:error, term()}

Makes one visible left sidebar focused and clears focus from the rest.

focus_left(table, id)

@spec focus_left(table(), String.t() | nil) :: :ok | {:error, term()}

get(id)

@spec get(String.t()) :: entry() | nil

Returns a sidebar by id.

get(table, id)

@spec get(table(), String.t()) :: entry() | nil

publish_snapshot(source, id, snapshot)

@spec publish_snapshot(
  source(),
  String.t(),
  MingaEditor.Extension.Sidebar.Snapshot.t() | keyword() | map()
) :: :ok | {:error, term()}

Publishes a cached snapshot for a sidebar.

publish_snapshot(table, source, id, snapshot)

@spec publish_snapshot(
  table(),
  source(),
  String.t(),
  MingaEditor.Extension.Sidebar.Snapshot.t() | keyword() | map()
) :: :ok | {:error, term()}

register(source, attrs)

@spec register(source(), register_attrs() | keyword()) :: :ok | {:error, term()}

Registers or replaces a sidebar owned by source.

register(table, source, attrs)

@spec register(table(), source(), register_attrs() | keyword()) ::
  :ok | {:error, term()}

set_focused(source, id, focused?)

@spec set_focused(source(), String.t(), boolean()) :: :ok | {:error, term()}

Updates sidebar focus state.

set_focused(table, source, id, focused?)

@spec set_focused(table(), source(), String.t(), boolean()) :: :ok | {:error, term()}

set_visible(source, id, visible?)

@spec set_visible(source(), String.t(), boolean()) :: :ok | {:error, term()}

Updates sidebar visibility.

set_visible(table, source, id, visible?)

@spec set_visible(table(), source(), String.t(), boolean()) :: :ok | {:error, term()}

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

table_for(arg1)

@spec table_for(map() | nil) :: table()

Returns the sidebar registry table for a state-like value.

unregister(source, id)

@spec unregister(source(), String.t()) :: :ok | {:error, term()}

Unregisters a sidebar when it is owned by the caller's source.

unregister(table, source, id)

@spec unregister(table(), source(), String.t()) :: :ok | {:error, term()}

unregister_source(source)

@spec unregister_source(source()) :: :ok

Removes every sidebar owned by a source.

unregister_source(table, source)

@spec unregister_source(table(), source()) :: :ok

visible()

@spec visible() :: [entry()]

Returns visible registered sidebars ordered by priority and id.

visible(table)

@spec visible(table()) :: [entry()]