Athanor.Editor.State (Athanor v0.1.0-beta.1)

Copy Markdown View Source

Internal state struct owned by Athanor.Editor.Live.

Encapsulates the assigns the library manages on behalf of the consumer:

  • content: the editor's node tree, persisted at editor_content.content in the canonical Athanor shape %{"content" => [nodes...]}
  • metadata: flat map persisted at editor_content.metadata (page-level fields edited via the page_settings_component: form)
  • selected_component_id: id of the currently-selected node (right sidebar shows that node's config when set)
  • column_picker: nil | {parent_id, zone_name} — drives the zone-picker modal opened by Athanor.Components.Columns' per-zone "Add Component" button

  • preview_viewport: :desktop | :tablet | :mobile — applied as max-width class on the canvas wrapper

  • show_components_panel: boolean — toggles the left sidebar
  • ctx: Athanor.Ctx with editor-mode fields populated (edit_mode?: true, add_component_callback, select_component_callback)

Summary

Functions

Build a default state. Useful for tests and as the seed value the Editor LV macro uses before load/3 fills in real values.

Build a state with overrides. Unknown keys raise KeyError.

Types

t()

@type t() :: %Athanor.Editor.State{
  column_picker: {String.t(), String.t()} | nil,
  content: map(),
  ctx: Athanor.Ctx.t() | nil,
  metadata: map(),
  preview_viewport: viewport(),
  selected_component_id: String.t() | nil,
  show_components_panel: boolean()
}

viewport()

@type viewport() :: :desktop | :tablet | :mobile

Functions

new()

Build a default state. Useful for tests and as the seed value the Editor LV macro uses before load/3 fills in real values.

new(overrides)

Build a state with overrides. Unknown keys raise KeyError.