You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api.md
+56-10Lines changed: 56 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,11 +71,21 @@ Constructs a new JSONEditor.
71
71
The callback will only be triggered on changes made by the user, not in case of programmatic changes via the functions `set`, `setText`, `update`, or `updateText`.
72
72
See also callback function `onChangeJSON(json)`.
73
73
74
-
-`{function} onEditable(node)`
74
+
-`{function} onEditable({ field, value, path })`
75
75
76
76
Set a callback function to determine whether individual nodes are editable or read-only. Only applicable when option `mode` is `tree`, `text`, or `code`.
77
77
78
-
In case of mode `tree`, the callback is invoked as `editable(node)`, where `node` is an object `{field: string, value: string, path: string[]}`. The function must either return a boolean value to set both the nodes field and value editable or read-only, or return an object `{field: boolean, value: boolean}` to set set the read-only attribute for field and value individually.
78
+
In case of mode `tree`, the callback is invoked as `editable(node)`, where the first parameter is an object:
79
+
80
+
```
81
+
{
82
+
field: string,
83
+
value: string,
84
+
path: string[]
85
+
}
86
+
```
87
+
88
+
The function must either return a boolean value to set both the nodes field and value editable or read-only, or return an object `{field: boolean, value: boolean}` to set set the read-only attribute for field and value individually.
79
89
80
90
In modes `text` and `code`, the callback is invoked as `editable(node)` where `node` is an empty object (no field, value, or path). In that case the function can return false to make the text or code editor completely read-only.
81
91
@@ -89,6 +99,24 @@ Constructs a new JSONEditor.
89
99
Set a callback function triggered right after the mode is changed by the user. Only applicable when
90
100
the mode can be changed by the user (i.e. when option `modes` is set).
91
101
102
+
-`{function} onNodeName({ path, type, size })`
103
+
104
+
Customize the name of object and array nodes. By default the names are brackets with the number of childs inside,
105
+
like `{5}` and `[32]`. The number inside can be customized. using `onNodeName`.
106
+
107
+
The first parameter is an object containing the following properties:
108
+
109
+
```
110
+
{
111
+
path: string[],
112
+
type: 'object' | 'array',
113
+
size: number
114
+
}
115
+
```
116
+
117
+
The `onNodeName` function should return a string containing the name for the node. If nothing is returned,
118
+
the size (number of childs) will be displayed.
119
+
92
120
-`{function} onValidate(json)`
93
121
94
122
Set a callback function for custom validation. Available in all modes.
@@ -246,24 +274,24 @@ Constructs a new JSONEditor.
246
274
247
275
Adds status bar to the bottom of the editor - the status bar shows the cursor position and a count of the selected characters. True by default. Only applicable when `mode` is 'code' or 'text'.
0 commit comments