View Source Philtre.Block behaviour (philtre v0.12.1)

Defines what the structure of a block should be

Link to this section Summary

Callbacks

Returns a list of base cells contained within the block

Takes the struct for the specific block type and returns its data serialized as a json-encodeable map with string keys.

Takes the struct for the specific block type and returns its id

Takes in the block id and the serialized data and returns the struct for the block.

Used to simplify and cleanup the block, remove blank fields, etc.

Renderer for the live, interactive version of the block, when editing

Renderer for the static, read-only version of the block, when rendering as plain html

Used to set a selection (focus cursor) on the block

Used to transform the contenteditable block into the current block

Takes the struct for the specific block type and returns its string type

Link to this section Callbacks

@callback cells(struct()) :: [Philtre.Block.ContentEditable.Cell.t()]

Returns a list of base cells contained within the block

@callback data(struct()) :: %{required(String.t()) => any()}

Takes the struct for the specific block type and returns its data serialized as a json-encodeable map with string keys.

@callback id(struct()) :: String.t()

Takes the struct for the specific block type and returns its id

@callback normalize(String.t(), any()) :: struct()

Takes in the block id and the serialized data and returns the struct for the block.

@callback reduce(struct()) :: struct()

Used to simplify and cleanup the block, remove blank fields, etc.

@callback render_live(%{block: struct()}) :: Phoenix.LiveView.Rendered.t()

Renderer for the live, interactive version of the block, when editing

@callback render_static(%{block: struct()}) :: Phoenix.LiveView.Rendered.t()

Renderer for the static, read-only version of the block, when rendering as plain html

Link to this callback

set_selection( struct, t )

View Source
@callback set_selection(
  struct(),
  Philtre.Block.ContentEditable.Selection.t()
) :: struct()

Used to set a selection (focus cursor) on the block

@callback transform(Philtre.Block.ContentEditable.t()) :: struct()

Used to transform the contenteditable block into the current block

@callback type(struct()) :: String.t()

Takes the struct for the specific block type and returns its string type