Coelho.Schema.NodeSpec (coelho v0.2.0)

Copy Markdown View Source

Specification of a single node type.

Fields:

  • :name — the node name, an atom
  • :content — parsed content expression, nil for a leaf node
  • :content_source — the original expression, kept for JSON export
  • :group — group names this node belongs to
  • :marks:all, or the list of mark names allowed on its children
  • :attrs — map of attribute name to Coelho.Schema.Attr
  • :inline — whether the node is inline rather than block
  • :text — set only on the built-in text node
  • :void — rendered as a self-closing tag, without children
  • :class — a CSS class merged into the rendered element and exported to the browser, so the editor shows the class the public page will use
  • :editor_attrs — extra DOM attributes for the editor only, exported with the schema and never emitted server side
  • :render — how the node is turned into HTML, see Coelho.Render
  • :to_text — what the node contributes to the plain text extraction, when that is not simply its children
  • :parse — HTML this node is imported from, see Coelho.HTML

Summary

Types

render()

@type render() ::
  nil
  | {String.t(),
     [{String.t(), String.t()}] | (map() -> [{String.t(), String.t()}])}
  | (map(), iodata() -> iodata())

t()

@type t() :: %Coelho.Schema.NodeSpec{
  attrs: %{optional(atom()) => Coelho.Schema.Attr.t()},
  class: String.t() | nil,
  content: Coelho.Schema.ContentExpression.ast() | nil,
  content_source: String.t() | nil,
  editor_attrs: %{optional(String.t()) => String.t()},
  group: [atom()],
  inline: boolean(),
  marks: :all | [atom()],
  name: atom(),
  parse: [Coelho.HTML.rule()],
  render: render(),
  text: boolean(),
  to_text: String.t() | (map() -> iodata()) | nil,
  void: boolean()
}