Loading document parsing libraries...
# DetailsNode
Class Inherits TextNode
## About
`DetailsNode` is a collapsible section: a summary line that can be edited like a paragraph, and child nodes below it that are shown while it is expanded and hidden while it is collapsed, like the HTML `details` element and the toggles of other block editors.
Pressing the triangle at the summary's leading edge, its popover toolbar's Expand or Collapse button, or the inspector's Expanded switch changes `Open`. Selecting a node inside a collapsed section, by searching for example, expands it.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AcceptsChild | node As Node | Boolean | Returns whether the supplied node can be placed inside this collapsible section. |
| ActionItem | index As Integer | ToolbarItem | Returns the contextual toolbar item at the specified index: Expand or Collapse. |
| AddChildAtPoint | node As Node <br> x As Double <br> y As Double | Boolean | Places a node inside this section at the position nearest the supplied document coordinates and returns whether it was accepted. |
| CanAcceptChildAtPoint | node As Node <br> x As Double <br> y As Double | Boolean | Returns whether the supplied node can be dropped into this section at the specified document coordinates: below the summary while the section is expanded. |
| ChildAt | index As Integer | Node | Returns the child node at the specified index, whether or not the section is expanded. |
| Constructor | summary As String = "" <br> open As Boolean = True | (None) | Creates a collapsible section with the supplied summary text, expanded unless open is False. |
| ContainsNode | node As Node | Boolean | Returns whether this section is the supplied node or contains it, directly or recursively. |
| Duplicate | (None) | Node | Returns an independent copy of this section, its summary, and its child nodes. |
| ExportStyles | stylesheet As GraffitiProEditor.Stylesheet | (None) | Adds the stylesheet rules this node type's HTML output uses. |
| FindChildPlacement | node As Node <br> ByRef parent As Node <br> ByRef slot As Integer <br> ByRef index As Integer | Boolean | Finds a nested node and returns its parent, slot, and index. The section has one slot, 0. |
| FromHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Imports a details element: its summary as the summary text and its open attribute as Open. |
| FromJSON | data As JSONItem | Boolean | Restores the summary and expanded state from JSON. Child nodes are restored by RestoreJSONChildren. |
| HandlePress | x As Double <br> y As Double | Boolean | Expands or collapses the section when its triangle is pressed, and returns whether the press was handled. |
| HitTest | x As Double <br> y As Double | Node | Returns the deepest selectable node at the specified document coordinates: an expanded child, or this section. |
| HTMLTags | (None) | String | Returns the HTML tag names supported by this node type. |
| InsertChild | slot As Integer <br> index As Integer <br> node As Node | (None) | Places a child node at the specified index. The section has one slot, so slot is ignored. |
| InsertHTMLNode | node As Node | Boolean | Places an imported node at the end of this section and returns whether it was accepted. |
| InsertionIndicatorAtPoint | node As Node <br> x As Double <br> y As Double | Rect | Returns the document bounds of the line shown where a dragged node would be dropped. |
| InspectorSections | (None) | InspectorSection | Returns the inspector sections for the summary text and the expanded state. |
| LastActionIndex | (None) | Integer | Returns the index of the last contextual toolbar item. |
| LastChildIndex | (None) | Integer | Returns the last zero-based child index, or -1 when the section is empty. |
| LocalizeToolbarItem | strings As GraffitiProEditor.Editor | (None) | Sets this node type's toolbar item text from the supplied editor's localization properties. |
| PerformAction | index As Integer <br> selectedItem As DesktopMenuItem | (None) | Performs the contextual toolbar action at the specified index: expanding or collapsing the section. |
| PerformToolbarAction | editor As Editor <br> selectedItem As DesktopMenuItem | (None) | Adds a new collapsible section to the editor. |
| PlainText | (None) | String | Returns the summary text followed by the plain text of each child node, one per line. |
| PreferredHeight | g As Graphics <br> availableWidth As Double | Double | Returns the height of the summary, plus the child nodes while the section is expanded. |
| RemoveChild | node As Node | Boolean | Removes the supplied nested node and returns whether it was found. |
| Render | g As Graphics <br> bounds As Rect <br> selected As Boolean | (None) | Draws the summary with its triangle, and the child nodes while the section is expanded. |
| RestoreHTMLChildren | element As GraffitiProEditor.HTMLSupport.HTMLElement | (None) | Restores the child nodes of an imported details element, after FromHTML completes. |
| RestoreJSONChildren | data As JSONItem | (None) | Restores the child nodes from JSON, after FromJSON completes. |
| ToHTML | (None) | String | Returns the section as a details element with a summary element and the child nodes' HTML. |
| ToJSON | (None) | JSONItem | Returns the summary, the expanded state as open, and the child nodes as nodes. |
| ToMarkdown | (None) | String | Returns the section as an HTML details element with the children's Markdown inside it. |
| TypeName | (None) | String | Returns the display name for this node type. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Open | Boolean | (None) | Gets or sets whether the section is expanded, showing its child nodes. Collapsing it hides them without removing them. |
## Notes
### Children
A section has one slot, 0, holding any number of child nodes, including other sections. Drag a node onto an expanded section, below its summary, to move it in; `InsertChild`, `RemoveChild`, `ChildAt`, and `LastChildIndex` work as for other containers.
Collapsed, a section measures and draws only its summary, so long hidden content costs nothing to lay out or draw, and its children cannot be pointed at or dropped onto. The children are still part of the document: they are saved, exported, counted by `Statistics`, and found by `Search`. Native controls of a child, such as a media player, are not hidden when the section collapses, so media nodes are best kept outside collapsed sections.
### JSON HTML and Markdown
JSON adds `open`, a Boolean, and `nodes`, an array of the children's JSON, to the summary's text JSON.
HTML is a `details` element, with the `open` attribute while expanded, holding a `summary` element with the summary text and then each child's HTML. Importing reads the same structure; a `details` element without a `summary` gets an empty one.
Markdown has no collapsible section, so it is written as the same HTML, with each child's Markdown between blank lines inside it, which GitHub and most renderers display. HTML and JSON round-trip every child; Markdown import reads the section from its HTML.
## Examples
```xojo
Editor.NodeTypes.Add(New GraffitiProEditor.DetailsNode)
Var faq As New GraffitiProEditor.DetailsNode("How do I reset my password?", False)
faq.InsertChild(0, 0, New GraffitiProEditor.TextNode("Open Settings and choose Reset Password."))
Editor.AddNode(faq)
```