# TextSnapshot
Class
## About
`TextSnapshot` stores everything needed to save and restore editable text. Text nodes, captions, table cells, form options, and undo operations use it to keep text together with character styles, list levels, embedded nodes, alignment, and cell appearance.
Custom-node authors normally use snapshots while implementing `EditableContent` save and restore methods. A receiving node owns the snapshot it receives and may change it. Copy styles and child collections when two nodes must not share changes.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Constructor | (None) | (None) | Creates an empty text snapshot. |
| FromJSON | data As JSONItem | (None) | Restores state from JSON data. |
| HTMLText | start As Integer = 0 <br> length As Integer = -1 | String | Returns the specified text range as an HTML fragment. |
| MarkdownText | start As Integer = 0 <br> length As Integer = -1 | String | Returns the specified text range with supported Markdown formatting. |
| ToJSON | (None) | JSONItem | Returns a JSON representation of this object's persistent state. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| AlertType | Integer | (None) | Gets or sets the alert type. |
| BackgroundImage | GraffitiProEditor.BackgroundImage | (None) | Gets or sets the background image configuration. |
| CellBackgroundColor | Color | (None) | Gets or sets the cell background color. |
| CellBorderBottomColor | Color | (None) | Gets or sets the bottom cell border color. |
| CellBorderBottomSize | Double | 1 | Gets or sets the bottom cell border width. |
| CellBorderBottomVisible | Boolean | (None) | Gets or sets whether the bottom cell border is drawn. |
| CellBorderLeftColor | Color | (None) | Gets or sets the left cell border color. |
| CellBorderLeftSize | Double | 1 | Gets or sets the left cell border width. |
| CellBorderLeftVisible | Boolean | (None) | Gets or sets whether the left cell border is drawn. |
| CellBorderRightColor | Color | (None) | Gets or sets the right cell border color. |
| CellBorderRightSize | Double | 1 | Gets or sets the right cell border width. |
| CellBorderRightVisible | Boolean | (None) | Gets or sets whether the right cell border is drawn. |
| CellBorderTopColor | Color | (None) | Gets or sets the top cell border color. |
| CellBorderTopSize | Double | 1 | Gets or sets the top cell border width. |
| CellBorderTopVisible | Boolean | (None) | Gets or sets whether the top cell border is drawn. |
| ColumnSpan | Integer | 1 | Gets or sets how many columns a table cell covers. Cells covered by a merged cell keep a span of 1. |
| EmbeddedNodes() | Node | (None) | Gets or sets the nodes embedded in this snapshot. |
| HasCellBackgroundColor | Boolean | (None) | Gets or sets whether cell background color is enabled. |
| HeadingLevel | Integer | (None) | Gets or sets the heading level. |
| ListChecked() | Boolean | (None) | The checked state for each item of a checklist list. |
| ListLevels() | Integer | (None) | Gets or sets the list levels collection. |
| ListType | Integer | (None) | Gets or sets the list type. |
| RowSpan | Integer | 1 | Gets or sets how many rows a table cell covers. Cells covered by a merged cell keep a span of 1. |
| Styles() | TextStyle | (None) | Gets or sets the styles collection. |
| Text | String | (None) | Gets or sets the editable plain text. |
| TextAlignment | GraffitiProEditor.Alignments | GraffitiProEditor.Alignments.Automatic | Gets or sets the alignment of a table or column cell's text. Automatic uses the table's or columns node's text alignment. |
| VerticalAlignment | Integer | (None) | Gets or sets the vertical alignment. |
## Notes
Text snapshots are internal value objects returned by editable nodes and container cells. Their JSON representation is embedded within the owning node rather than stored as a root document node.
### JSON Format
The JSON object stores `text`, a `styleTable` array of the distinct `TextStyle` objects (each containing only attributes that differ from the defaults), a `styleRuns` array of alternating run lengths and `styleTable` indexes covering the text in order, an integer `listLevels` array, and a `nodes` array containing embedded node objects. `backgroundImage` is optional. Documents saved before format version 3 store a positional `styles` array with one `TextStyle` object per character instead of `styleTable` and `styleRuns`; both forms are read. `hasCellBackgroundColor` determines whether `cellBackgroundColor` is applied. Table and column cells store independent `cellBorderTop*`, `cellBorderRight*`, `cellBorderBottom*`, and `cellBorderLeft*` visibility, size, and color values.
Container-specific integer fields use these conversions:
- `alertType`: `0` Info, `1` Success, `2` Warning, `3` Danger.
- `headingLevel`: `1` through `6` correspond to Heading1 through Heading6.
- `listType`: `0` Unordered and `1` Ordered when used by `ListNode`. `RadioGroupNode` uses this field internally for its active option index.
- `textAlignment`: `0` Automatic, `1` Leading (Start), `2` Middle (Center), `3` Trailing (End) for table and column cells, the values of `GraffitiProEditor.Alignments`. Automatic uses the table's or columns node's text alignment. Leading and Trailing follow the cell text's direction. Documents saved earlier store `horizontalAlignment` instead, `0` Start, `1` Center, `2` End; it is read when `textAlignment` is missing, with `0` read as Automatic.
- `verticalAlignment`: `0` Top, `1` Middle, `2` Bottom for table and column cells.
Colors are objects containing integer `red`, `green`, `blue`, and `alpha` components as returned by Xojo `Color`, each in the range 0 through 255.
Values at their defaults are omitted, and missing names restore those defaults: empty `text`; `alertType`, `headingLevel`, `listType`, `textAlignment`, and `verticalAlignment` of `0`; no cell background; each cell border hidden, `1` point, and black with alpha `0`; empty `listLevels` and `nodes`. `styleTable` and `styleRuns` are omitted when every character has the default style, and missing styles are restored as default styles.