Update documentation

This commit is contained in:
Cristina 2018-08-10 12:29:25 +02:00
parent 5adf77a193
commit bb699e1473
2 changed files with 11 additions and 10 deletions

View File

@ -233,16 +233,15 @@ Constructs a new JSONEditor.
a JSON field or value. a JSON field or value.
In case of field event, node information will be In case of field event, node information will be
`{field: String, path: [{name: String, type: String}]}`. `{field: string, path: {string|number}[]}`.
In case of value event, node information will be In case of value event, node information will be
`{field: String, path: [{name: String, type: String}], value: String}` `{field: string, path: {string|number}[], value: string}`
signature should be: signature should be:
```js ```js
/** /**
* @param {Node} the Node where event has been triggered * @param {Node} the Node where event has been triggered
identified by {field: String, path: [{name: String, type: String}] [, identified by {field: string, path: {string|number}[] [, value: string]}`
value: String]}`
* @param {event} the event fired * @param {event} the event fired
*/ */
function onEvent(node, event) { function onEvent(node, event) {

View File

@ -90,7 +90,8 @@ Node.prototype._updateEditability = function () {
/** /**
* Get the path of this node * Get the path of this node
* @return {String[]} Array containing the path to this node * @return {{string|number}[]} Array containing the path to this node.
* Element is a number if is the index of an array, a string otherwise.
*/ */
Node.prototype.getPath = function () { Node.prototype.getPath = function () {
var node = this; var node = this;
@ -2378,6 +2379,11 @@ Node.prototype.onEvent = function (event) {
node = this, node = this,
expandable = this._hasChilds(); expandable = this._hasChilds();
if (typeof this.editor.options.onEvent === 'function') {
this._onEvent(event);
}
// check if mouse is on menu or on dragarea. // check if mouse is on menu or on dragarea.
// If so, highlight current row and its childs // If so, highlight current row and its childs
if (target == dom.drag || target == dom.menu) { if (target == dom.drag || target == dom.menu) {
@ -2550,10 +2556,6 @@ Node.prototype.onEvent = function (event) {
if (type == 'keydown') { if (type == 'keydown') {
this.onKeyDown(event); this.onKeyDown(event);
} }
if (typeof this.editor.options.onEvent === 'function') {
this._onEvent(event);
}
}; };
/** /**
@ -2561,7 +2563,7 @@ Node.prototype.onEvent = function (event) {
* value. * value.
* Information provided depends on the element, value is only included if * Information provided depends on the element, value is only included if
* event occurs in a JSON value: * event occurs in a JSON value:
* {field: String, path: [{name: String, type: String}] [, value: String]} * {field: string, path: {string|number}[] [, value: string]}
* @param {Event} event * @param {Event} event
* @private * @private
*/ */