Describe new methods `update` and `updateText` in the docs

This commit is contained in:
jos 2018-08-06 14:39:21 +02:00
parent a7da2349e5
commit d49518a9ba
2 changed files with 37 additions and 1 deletions

View File

@ -3,6 +3,12 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet released, version 5.20.0
- Implemented new methods `update` and `updateText`, which maintain the state
of the editor (expanded nodes, search, selection).
## 2018-08-02, version 5.19.2 ## 2018-08-02, version 5.19.2
- Fixed #558: scrolling to search results and automatically scrolling up/down - Fixed #558: scrolling to search results and automatically scrolling up/down

View File

@ -50,7 +50,7 @@ Constructs a new JSONEditor.
- `{function} onChange` - `{function} onChange`
Set a callback function triggered when the contents of the JSONEditor change. Called without parameters. Will only be triggered on changes made by the user, not in case of programmatic changes via the functions `set` or `setText`. Set a callback function triggered when the contents of the JSONEditor change. Called without parameters. Will only be triggered on changes made by the user, not in case of programmatic changes via the functions `set`, `setText`, `update`, or `updateText`.
- `{function} onEditable` - `{function} onEditable`
@ -354,6 +354,8 @@ Get the current selected text with the selection range, Only applicable for mode
#### `JSONEditor.set(json)` #### `JSONEditor.set(json)`
Set JSON data. Set JSON data.
Resets the state of the editor (expanded nodes, search, selection).
See also `JSONEditor.update(json)`.
*Parameters:* *Parameters:*
@ -441,6 +443,34 @@ Set text selection for a range, Only applicable for mode 'text' and 'code'.
Position for selection end Position for selection end
#### `JSONEditor.update(json)`
Replace JSON data when the new data contains changes.
In modes `tree`, `form`, and `view`, the state of the editor will be maintained (expanded nodes, search, selection).
See also `JSONEditor.set(json)`.
*Parameters:*
- `{JSON} json`
JSON data to be displayed in the JSONEditor.
#### `JSONEditor.updateText (json)`
Replace text data when the new data contains changes.
In modes `tree`, `form`, and `view`, the state of the editor will be maintained (expanded nodes, search, selection).
See also `JSONEditor.setText(json)`.
This method throws an exception when the provided jsonString does not contain
valid JSON and the editor is in mode `tree`, `view`, or `form`.
*Parameters:*
- `{String} jsonString`
Contents of the editor as string.
### Examples ### Examples
A tree editor: A tree editor: