Publish v5.34.0

This commit is contained in:
jos 2019-06-08 12:13:53 +02:00
parent 85e0710097
commit 7bf25b3129
11 changed files with 198 additions and 122 deletions

View File

@ -3,7 +3,15 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet published, version 5.33.0 ## 2019-06-08, version 5.34.0
- Extended the autocomplete feature with new options `filter` and `trigger`.
Thanks @Gcaufy.
- Removed :hover style on disabled buttons. Thanks @Gcaufy.
- Upgraded dependency `mobius1-selectr@2.4.12`.
## 2019-05-29, version 5.33.0
- Fixed #697: JSON Schema enum dropdown not working inside an array. - Fixed #697: JSON Schema enum dropdown not working inside an array.
- Fixed #698: When using `onCreateMenu`, `node.path` is null when clicking - Fixed #698: When using `onCreateMenu`, `node.path` is null when clicking

View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2019 Jos de Jong, http://jsoneditoronline.org * Copyright (c) 2011-2019 Jos de Jong, http://jsoneditoronline.org
* *
* @author Jos de Jong, <wjosdejong@gmail.com> * @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.33.0 * @version 5.34.0
* @date 2019-05-29 * @date 2019-06-08
*/ */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
@ -2603,12 +2603,17 @@ return /******/ (function(modules) { // webpackBootstrap
return; return;
} }
var node = Node.getNodeFromTarget(event.target);
if (event.type === 'keydown') { if (event.type === 'keydown') {
this._onKeyDown(event); this._onKeyDown(event);
} }
if (event.type === 'focus') { if (event.type === 'focus') {
this.focusTarget = event.target; this.focusTarget = event.target;
if (this.options.autocomplete && this.options.autocomplete.trigger === 'focus') {
this._showAutoComplete(event.target);
}
} }
if (event.type === 'mousedown') { if (event.type === 'mousedown') {
@ -2618,7 +2623,6 @@ return /******/ (function(modules) { // webpackBootstrap
this._updateDragDistance(event); this._updateDragDistance(event);
} }
var node = Node.getNodeFromTarget(event.target);
if (node && this.options && this.options.navigationBar && node && (event.type === 'keydown' || event.type === 'mousedown')) { if (node && this.options && this.options.navigationBar && node && (event.type === 'keydown' || event.type === 'mousedown')) {
// apply on next tick, right after the new key press is applied // apply on next tick, right after the new key press is applied
@ -2968,6 +2972,51 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
/**
* Show autocomplete menu
* @param {Node} node
* @param {HTMLElement} element
* @private
*/
treemode._showAutoComplete = function (element) {
var node = Node.getNodeFromTarget(element);
var jsonElementType = "";
if (event.target.className.indexOf("jsoneditor-value") >= 0) jsonElementType = "value";
if (event.target.className.indexOf("jsoneditor-field") >= 0) jsonElementType = "field";
var self = this;
setTimeout(function () {
if (self.options.autocomplete.trigger === 'focus' || element.innerText.length > 0) {
var result = self.options.autocomplete.getOptions(element.innerText, node.getPath(), jsonElementType, node.editor);
if (result === null) {
self.autocomplete.hideDropDown();
} else if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (obj) {
if (obj === null) {
self.autocomplete.hideDropDown();
} else if (obj.options) {
self.autocomplete.show(element, obj.startFrom, obj.options);
} else {
self.autocomplete.show(element, 0, obj);
}
}.bind(self)));
} else {
// definitely not a promise
if (result.options)
self.autocomplete.show(element, result.startFrom, result.options);
else
self.autocomplete.show(element, 0, result);
}
}
else
self.autocomplete.hideDropDown();
}, 50);
}
/** /**
* Event handler for keydown. Handles shortcut keys * Event handler for keydown. Handles shortcut keys
* @param {Event} event * @param {Event} event
@ -3026,40 +3075,10 @@ return /******/ (function(modules) { // webpackBootstrap
if ((this.options.autocomplete) && (!handled)) { if ((this.options.autocomplete) && (!handled)) {
if (!ctrlKey && !altKey && !metaKey && (event.key.length == 1 || keynum == 8 || keynum == 46)) { if (!ctrlKey && !altKey && !metaKey && (event.key.length == 1 || keynum == 8 || keynum == 46)) {
handled = false; handled = false;
var jsonElementType = "";
if (event.target.className.indexOf("jsoneditor-value") >= 0) jsonElementType = "value";
if (event.target.className.indexOf("jsoneditor-field") >= 0) jsonElementType = "field";
var node = Node.getNodeFromTarget(event.target); var node = Node.getNodeFromTarget(event.target);
// Activate autocomplete
setTimeout(function (hnode, element) {
if (element.innerText.length > 0) {
var result = this.options.autocomplete.getOptions(element.innerText, hnode.getPath(), jsonElementType, hnode.editor);
if (result === null) {
this.autocomplete.hideDropDown();
} else if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (obj) {
if (obj === null) {
this.autocomplete.hideDropDown();
} else if (obj.options) {
this.autocomplete.show(element, obj.startFrom, obj.options);
} else {
this.autocomplete.show(element, 0, obj);
}
}.bind(this)));
} else {
// definitely not a promise
if (result.options)
this.autocomplete.show(element, result.startFrom, result.options);
else
this.autocomplete.show(element, 0, result);
}
}
else
this.autocomplete.hideDropDown();
}.bind(this, node, event.target), 50); // Activate autocomplete
this._showAutoComplete(event.target);
} }
} }
@ -17438,8 +17457,19 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict'; 'use strict';
var defaultFilterFunction = {
start: function (token, match, config) {
return match.indexOf(token) === 0;
},
contain: function (token, match, config) {
return match.indexOf(token) > -1;
}
};
function completely(config) { function completely(config) {
config = config || {}; config = config || {};
config.filter = config.filter || 'start';
config.trigger = config.trigger || 'keydown';
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive
@ -17485,22 +17515,25 @@ return /******/ (function(modules) { // webpackBootstrap
var distanceToBottom = vph - rect.bottom - 6; // distance from the browser border. var distanceToBottom = vph - rect.bottom - 6; // distance from the browser border.
rows = []; rows = [];
for (var i = 0; i < array.length; i++) { var filterFn = typeof config.filter === 'function' ? config.filter : defaultFilterFunction[config.filter];
if ( (config.caseSensitive && array[i].indexOf(token) !== 0) var filtered = !filterFn ? [] : array.filter(function (match) {
||(!config.caseSensitive && array[i].toLowerCase().indexOf(token.toLowerCase()) !== 0)) { continue; } return filterFn(config.caseSensitive ? token : token.toLowerCase(), config.caseSensitive ? match : match.toLowerCase(), config);
});
rows = filtered.map(function (row) {
var divRow = document.createElement('div'); var divRow = document.createElement('div');
divRow.className = 'item'; divRow.className = 'item';
//divRow.style.color = config.color; //divRow.style.color = config.color;
divRow.onmouseover = onMouseOver; divRow.onmouseover = onMouseOver;
divRow.onmouseout = onMouseOut; divRow.onmouseout = onMouseOut;
divRow.onmousedown = onMouseDown; divRow.onmousedown = onMouseDown;
divRow.__hint = array[i]; divRow.__hint = row;
divRow.innerHTML = array[i].substring(0, token.length) + '<b>' + array[i].substring(token.length) + '</b>'; divRow.innerHTML = row.substring(0, token.length) + '<b>' + row.substring(token.length) + '</b>';
rows.push(divRow);
elem.appendChild(divRow); elem.appendChild(divRow);
} return divRow;
});
if (rows.length === 0) { if (rows.length === 0) {
return; // nothing to show. return; // nothing to show.
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/jsoneditor.css vendored
View File

@ -1198,6 +1198,8 @@ div.jsoneditor-menu > div.jsoneditor-modes > button:active {
div.jsoneditor-menu > button:disabled, div.jsoneditor-menu > button:disabled,
div.jsoneditor-menu > div.jsoneditor-modes > button:disabled { div.jsoneditor-menu > div.jsoneditor-modes > button:disabled {
opacity: 0.5; opacity: 0.5;
background-color: transparent;
border: none;
} }
div.jsoneditor-menu > button.jsoneditor-collapse-all { div.jsoneditor-menu > button.jsoneditor-collapse-all {

117
dist/jsoneditor.js vendored
View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2019 Jos de Jong, http://jsoneditoronline.org * Copyright (c) 2011-2019 Jos de Jong, http://jsoneditoronline.org
* *
* @author Jos de Jong, <wjosdejong@gmail.com> * @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.33.0 * @version 5.34.0
* @date 2019-05-29 * @date 2019-06-08
*/ */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
@ -31361,12 +31361,17 @@ return /******/ (function(modules) { // webpackBootstrap
return; return;
} }
var node = Node.getNodeFromTarget(event.target);
if (event.type === 'keydown') { if (event.type === 'keydown') {
this._onKeyDown(event); this._onKeyDown(event);
} }
if (event.type === 'focus') { if (event.type === 'focus') {
this.focusTarget = event.target; this.focusTarget = event.target;
if (this.options.autocomplete && this.options.autocomplete.trigger === 'focus') {
this._showAutoComplete(event.target);
}
} }
if (event.type === 'mousedown') { if (event.type === 'mousedown') {
@ -31376,7 +31381,6 @@ return /******/ (function(modules) { // webpackBootstrap
this._updateDragDistance(event); this._updateDragDistance(event);
} }
var node = Node.getNodeFromTarget(event.target);
if (node && this.options && this.options.navigationBar && node && (event.type === 'keydown' || event.type === 'mousedown')) { if (node && this.options && this.options.navigationBar && node && (event.type === 'keydown' || event.type === 'mousedown')) {
// apply on next tick, right after the new key press is applied // apply on next tick, right after the new key press is applied
@ -31726,6 +31730,51 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
/**
* Show autocomplete menu
* @param {Node} node
* @param {HTMLElement} element
* @private
*/
treemode._showAutoComplete = function (element) {
var node = Node.getNodeFromTarget(element);
var jsonElementType = "";
if (event.target.className.indexOf("jsoneditor-value") >= 0) jsonElementType = "value";
if (event.target.className.indexOf("jsoneditor-field") >= 0) jsonElementType = "field";
var self = this;
setTimeout(function () {
if (self.options.autocomplete.trigger === 'focus' || element.innerText.length > 0) {
var result = self.options.autocomplete.getOptions(element.innerText, node.getPath(), jsonElementType, node.editor);
if (result === null) {
self.autocomplete.hideDropDown();
} else if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (obj) {
if (obj === null) {
self.autocomplete.hideDropDown();
} else if (obj.options) {
self.autocomplete.show(element, obj.startFrom, obj.options);
} else {
self.autocomplete.show(element, 0, obj);
}
}.bind(self)));
} else {
// definitely not a promise
if (result.options)
self.autocomplete.show(element, result.startFrom, result.options);
else
self.autocomplete.show(element, 0, result);
}
}
else
self.autocomplete.hideDropDown();
}, 50);
}
/** /**
* Event handler for keydown. Handles shortcut keys * Event handler for keydown. Handles shortcut keys
* @param {Event} event * @param {Event} event
@ -31784,40 +31833,10 @@ return /******/ (function(modules) { // webpackBootstrap
if ((this.options.autocomplete) && (!handled)) { if ((this.options.autocomplete) && (!handled)) {
if (!ctrlKey && !altKey && !metaKey && (event.key.length == 1 || keynum == 8 || keynum == 46)) { if (!ctrlKey && !altKey && !metaKey && (event.key.length == 1 || keynum == 8 || keynum == 46)) {
handled = false; handled = false;
var jsonElementType = "";
if (event.target.className.indexOf("jsoneditor-value") >= 0) jsonElementType = "value";
if (event.target.className.indexOf("jsoneditor-field") >= 0) jsonElementType = "field";
var node = Node.getNodeFromTarget(event.target); var node = Node.getNodeFromTarget(event.target);
// Activate autocomplete
setTimeout(function (hnode, element) {
if (element.innerText.length > 0) {
var result = this.options.autocomplete.getOptions(element.innerText, hnode.getPath(), jsonElementType, hnode.editor);
if (result === null) {
this.autocomplete.hideDropDown();
} else if (typeof result.then === 'function') {
// probably a promise
if (result.then(function (obj) {
if (obj === null) {
this.autocomplete.hideDropDown();
} else if (obj.options) {
this.autocomplete.show(element, obj.startFrom, obj.options);
} else {
this.autocomplete.show(element, 0, obj);
}
}.bind(this)));
} else {
// definitely not a promise
if (result.options)
this.autocomplete.show(element, result.startFrom, result.options);
else
this.autocomplete.show(element, 0, result);
}
}
else
this.autocomplete.hideDropDown();
}.bind(this, node, event.target), 50); // Activate autocomplete
this._showAutoComplete(event.target);
} }
} }
@ -46196,8 +46215,19 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict'; 'use strict';
var defaultFilterFunction = {
start: function (token, match, config) {
return match.indexOf(token) === 0;
},
contain: function (token, match, config) {
return match.indexOf(token) > -1;
}
};
function completely(config) { function completely(config) {
config = config || {}; config = config || {};
config.filter = config.filter || 'start';
config.trigger = config.trigger || 'keydown';
config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab config.confirmKeys = config.confirmKeys || [39, 35, 9] // right, end, tab
config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive config.caseSensitive = config.caseSensitive || false // autocomplete case sensitive
@ -46243,22 +46273,25 @@ return /******/ (function(modules) { // webpackBootstrap
var distanceToBottom = vph - rect.bottom - 6; // distance from the browser border. var distanceToBottom = vph - rect.bottom - 6; // distance from the browser border.
rows = []; rows = [];
for (var i = 0; i < array.length; i++) { var filterFn = typeof config.filter === 'function' ? config.filter : defaultFilterFunction[config.filter];
if ( (config.caseSensitive && array[i].indexOf(token) !== 0) var filtered = !filterFn ? [] : array.filter(function (match) {
||(!config.caseSensitive && array[i].toLowerCase().indexOf(token.toLowerCase()) !== 0)) { continue; } return filterFn(config.caseSensitive ? token : token.toLowerCase(), config.caseSensitive ? match : match.toLowerCase(), config);
});
rows = filtered.map(function (row) {
var divRow = document.createElement('div'); var divRow = document.createElement('div');
divRow.className = 'item'; divRow.className = 'item';
//divRow.style.color = config.color; //divRow.style.color = config.color;
divRow.onmouseover = onMouseOver; divRow.onmouseover = onMouseOver;
divRow.onmouseout = onMouseOut; divRow.onmouseout = onMouseOut;
divRow.onmousedown = onMouseDown; divRow.onmousedown = onMouseDown;
divRow.__hint = array[i]; divRow.__hint = row;
divRow.innerHTML = array[i].substring(0, token.length) + '<b>' + array[i].substring(token.length) + '</b>'; divRow.innerHTML = row.substring(0, token.length) + '<b>' + row.substring(token.length) + '</b>';
rows.push(divRow);
elem.appendChild(divRow); elem.appendChild(divRow);
} return divRow;
});
if (rows.length === 0) { if (rows.length === 0) {
return; // nothing to show. return; // nothing to show.
} }

2
dist/jsoneditor.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "jsoneditor", "name": "jsoneditor",
"version": "5.33.0", "version": "5.34.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "jsoneditor", "name": "jsoneditor",
"version": "5.33.0", "version": "5.34.0",
"main": "./index", "main": "./index",
"description": "A web-based tool to view, edit, format, and validate JSON", "description": "A web-based tool to view, edit, format, and validate JSON",
"tags": [ "tags": [