# NodeTypes
Class
## About
`NodeTypes` holds the node types an editor can import, insert, and restore from JSON. Each type is registered from a template instance, called a prototype, which supplies the type's JSON name, HTML tags, import priority, toolbar item, and insertion behavior. Each `Editor` creates one with the built-in text and heading types; read it from the editor's read-only `NodeTypes` property.
```xojo
Editor.NodeTypes.Add(New GraffitiProEditor.ImageNode)
Editor.NodeTypes.AddAt(0, New GraffitiProEditor.TableNode)
Var imageType As GraffitiProEditor.Node = Editor.NodeTypes.Item("image")
Editor.NodeTypes.Remove("image")
```
A type is identified by its toolbar item's identifier, such as `"node:image"`; `Item` and `Remove` accept it with or without the `node:` prefix. Adding a type also adds its button to the toolbar's Nodes section, at the same position for `AddAt`, and accepts the file and data types it imports by dropping. `Add` replaces a type with the same identifier. Removing a type removes its button and stops it being inserted or restored; nodes of that type already in the document stay.
Registering a prototype does not add it to the document. Use `Editor.AddNode` with a separately constructed instance to add content.
## Delegates
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddItemHandler | item As GraffitiProEditor . Node <br> index As Integer) | (None) | (None) |
| RemoveItemHandler | identifier As String) | (None) | (None) |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Add | item As GraffitiProEditor.Node | (None) | Registers a node type from a prototype instance and adds its button to the end of the toolbar's Nodes section. A type with the same identifier is replaced. |
| AddAt | index As Integer <br> item As GraffitiProEditor.Node | (None) | Registers a node type from a prototype instance at a zero-based position, which also places its button in the toolbar's Nodes section. A type with the same identifier is replaced. |
| IndexOf | item As GraffitiProEditor.Node | Integer | Returns the position of the supplied node type, or -1 when it is not in the list. |
| Item | identifier As String | GraffitiProEditor.Node | Returns the prototype of the node type with the supplied identifier, such as "image" or "node:image", or Nil. |
| ItemAt | index As Integer | GraffitiProEditor.Node | Returns the node type at a zero-based position, or Nil when the position is out of range. |
| Items | (None) | GraffitiProEditor.Node | Returns a copy of the list of node types, in order. |
| LastIndex | (None) | Integer | Returns the position of the last node type, or -1 when the list is empty. |
| Remove | item As GraffitiProEditor.Node | (None) | Unregisters the node type of the supplied prototype, if it is in the list, and removes its toolbar button. |
| Remove | identifier As String | (None) | Unregisters the node type with the supplied identifier, such as "image" or "node:image", and removes its toolbar button. Nodes of that type already in the document stay. |
| RemoveAll | (None) | (None) | Unregisters every node type, including the built-in text and heading types. |
| RemoveAt | index As Integer | (None) | Unregisters the node type at a zero-based position. A position out of range does nothing. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Owner | GraffitiProEditor.Editor | (None) | Returns the editor this list belongs to. |