# `Kotoba.Nodes`
[🔗](https://github.com/hattoriai/kotoba/blob/v0.5.0/lib/kotoba/nodes.ex#L1)

The node registry.

The registry maps each Lexical node type to the module that reads it. It
has the built-in nodes, the nodes in the `:nodes` key of the `:kotoba`
application config, and the nodes that the caller gives. An app node
cannot have the type of a built-in node or of an editor node
(`"kotoba-unknown"` or `"kotoba-upload"`, see `reserved_types/0`): the
registry raises `ArgumentError`, as the editor refuses such a node. A caller node replaces a configured node with the
same type:

    config :kotoba, nodes: [MyApp.Nodes.Pointer]

`Kotoba.Document.parse/2`, `Kotoba.Content.rerender/2` and
`Kotoba.Components.kotoba_content/1` take the caller's nodes as a
`nodes` option. `Kotoba.Content.cast/1` uses the built-in and the
configured nodes only, so put a node that stored content uses in the
config. `mix kotoba.gen.node` writes a new node module and its editor
half.

# `registry`

```elixir
@type registry() :: %{required(String.t()) =&gt; module()}
```

A map from a node type to its module.

# `built_in`

```elixir
@spec built_in() :: [module()]
```

Returns the built-in node modules.

# `registry`

```elixir
@spec registry([module()]) :: registry()
```

Returns the registry for a list of extra node modules.

Raises `ArgumentError` when a module does not use `Kotoba.Node`, or when
the type of a configured node or of a node in `nodes` is a reserved type
(see `reserved_types/0`).

# `reserved_types`

```elixir
@spec reserved_types() :: [String.t()]
```

Returns the node types that an app node cannot have: the types of the
built-in nodes, and the editor's own node types, `"kotoba-unknown"` (the
node for a type it does not know) and `"kotoba-upload"` (the marker of
an upload in progress).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
