Publish v6.4.0
This commit is contained in:
parent
c404c1bc1f
commit
6d5d9965c3
|
@ -2,7 +2,7 @@
|
|||
|
||||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
## not yet published, version 6.4.0
|
||||
## 2019-08-28, version 6.4.0
|
||||
|
||||
- Replaces CSS with SASS internally, improvements in styling. Thanks @ppetkow.
|
||||
- Fixed #761: JSON schema errors not rendered in the gutter for mode `code`
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
* Copyright (c) 2011-2019 Jos de Jong, http://jsoneditoronline.org
|
||||
*
|
||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||
* @version 6.3.0
|
||||
* @date 2019-08-15
|
||||
* @version 6.4.0
|
||||
* @date 2019-08-28
|
||||
*/
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
if(typeof exports === 'object' && typeof module === 'object')
|
||||
|
@ -1270,7 +1270,7 @@ exports.getPositionForPath = function(text, paths) {
|
|||
|
||||
paths.forEach(function (path) {
|
||||
var pathArr = me.parsePath(path);
|
||||
var pointerName = pathArr.length ? "/" + pathArr.join("/") : "";
|
||||
var pointerName = exports.compileJSONPointer(pathArr);
|
||||
var pointer = jsmap.pointers[pointerName];
|
||||
if (pointer) {
|
||||
result.push({
|
||||
|
@ -1285,6 +1285,23 @@ exports.getPositionForPath = function(text, paths) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile a JSON Pointer
|
||||
* WARNING: this is an incomplete implementation
|
||||
* @param {Array.<string | number>} path
|
||||
* @return {string}
|
||||
*/
|
||||
exports.compileJSONPointer = function (path) {
|
||||
return path
|
||||
.map(function (p) {
|
||||
return ('/' + String(p)
|
||||
.replace(/~/g, '~0')
|
||||
.replace(/\//g, '~1')
|
||||
);
|
||||
})
|
||||
.join('');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the applied color given a color name or code
|
||||
* Source: https://stackoverflow.com/questions/6386090/validating-css-color-names/33184805
|
||||
|
@ -4211,6 +4228,10 @@ function showSortModal (container, json, onSort, options) {
|
|||
parent: container,
|
||||
content: content,
|
||||
overlayClass: 'jsoneditor-modal-overlay',
|
||||
overlayStyles: {
|
||||
backgroundColor: "rgb(1,1,1)",
|
||||
opacity: 0.3
|
||||
},
|
||||
modalClass: 'jsoneditor-modal jsoneditor-modal-sort'
|
||||
})
|
||||
.afterCreate(function (modal) {
|
||||
|
@ -4376,6 +4397,10 @@ function showTransformModal (container, json, onTransform) {
|
|||
parent: container,
|
||||
content: content,
|
||||
overlayClass: 'jsoneditor-modal-overlay',
|
||||
overlayStyles: {
|
||||
backgroundColor: "rgb(1,1,1)",
|
||||
opacity: 0.3
|
||||
},
|
||||
modalClass: 'jsoneditor-modal jsoneditor-modal-transform',
|
||||
focus: false
|
||||
})
|
||||
|
@ -8562,8 +8587,8 @@ treemode._onChange = function () {
|
|||
this._debouncedValidate();
|
||||
|
||||
if (this.treePath) {
|
||||
var selectedNode = this.selection
|
||||
? this.node.findNodeByInternalPath(this.selection.path)
|
||||
var selectedNode = (this.node && this.selection)
|
||||
? this.node.findNodeByInternalPath(this.selection.path)
|
||||
: this.multiselection
|
||||
? this.multiselection.nodes[0]
|
||||
: undefined;
|
||||
|
@ -11267,7 +11292,7 @@ function escapeJsonPointer(str) {
|
|||
* @param {Element} container HTML container element of where to
|
||||
* create the search box
|
||||
*/
|
||||
function SearchBox (editor, container) {
|
||||
function SearchBox(editor, container) {
|
||||
var searchBox = this;
|
||||
|
||||
this.editor = editor;
|
||||
|
@ -11278,91 +11303,69 @@ function SearchBox (editor, container) {
|
|||
this.dom = {};
|
||||
this.dom.container = container;
|
||||
|
||||
var table = document.createElement('table');
|
||||
this.dom.table = table;
|
||||
table.className = 'jsoneditor-search';
|
||||
container.appendChild(table);
|
||||
var tbody = document.createElement('tbody');
|
||||
this.dom.tbody = tbody;
|
||||
table.appendChild(tbody);
|
||||
var tr = document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
var wrapper = document.createElement("div");
|
||||
this.dom.wrapper = wrapper;
|
||||
wrapper.className = "jsoneditor-search";
|
||||
container.appendChild(wrapper);
|
||||
|
||||
var td = document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
var results = document.createElement('div');
|
||||
var results = document.createElement("div");
|
||||
this.dom.results = results;
|
||||
results.className = 'jsoneditor-results';
|
||||
td.appendChild(results);
|
||||
results.className = "jsoneditor-results";
|
||||
wrapper.appendChild(results);
|
||||
|
||||
td = document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
var divInput = document.createElement('div');
|
||||
var divInput = document.createElement("div");
|
||||
this.dom.input = divInput;
|
||||
divInput.className = 'jsoneditor-frame';
|
||||
divInput.title = 'Search fields and values';
|
||||
td.appendChild(divInput);
|
||||
divInput.className = "jsoneditor-frame";
|
||||
divInput.title = "Search fields and values";
|
||||
wrapper.appendChild(divInput);
|
||||
|
||||
// table to contain the text input and search button
|
||||
var tableInput = document.createElement('table');
|
||||
divInput.appendChild(tableInput);
|
||||
var tbodySearch = document.createElement('tbody');
|
||||
tableInput.appendChild(tbodySearch);
|
||||
tr = document.createElement('tr');
|
||||
tbodySearch.appendChild(tr);
|
||||
var refreshSearch = document.createElement("button");
|
||||
refreshSearch.type = "button";
|
||||
refreshSearch.className = "jsoneditor-refresh";
|
||||
divInput.appendChild(refreshSearch);
|
||||
|
||||
var refreshSearch = document.createElement('button');
|
||||
refreshSearch.type = 'button';
|
||||
refreshSearch.className = 'jsoneditor-refresh';
|
||||
td = document.createElement('td');
|
||||
td.appendChild(refreshSearch);
|
||||
tr.appendChild(td);
|
||||
|
||||
var search = document.createElement('input');
|
||||
// search.type = 'button';
|
||||
var search = document.createElement("input");
|
||||
search.type = "text";
|
||||
this.dom.search = search;
|
||||
search.oninput = function (event) {
|
||||
search.oninput = function(event) {
|
||||
searchBox._onDelayedSearch(event);
|
||||
};
|
||||
search.onchange = function (event) { // For IE 9
|
||||
search.onchange = function(event) {
|
||||
// For IE 9
|
||||
searchBox._onSearch();
|
||||
};
|
||||
search.onkeydown = function (event) {
|
||||
search.onkeydown = function(event) {
|
||||
searchBox._onKeyDown(event);
|
||||
};
|
||||
search.onkeyup = function (event) {
|
||||
search.onkeyup = function(event) {
|
||||
searchBox._onKeyUp(event);
|
||||
};
|
||||
refreshSearch.onclick = function (event) {
|
||||
refreshSearch.onclick = function(event) {
|
||||
search.select();
|
||||
};
|
||||
|
||||
// TODO: ESC in FF restores the last input, is a FF bug, https://bugzilla.mozilla.org/show_bug.cgi?id=598819
|
||||
td = document.createElement('td');
|
||||
td.appendChild(search);
|
||||
tr.appendChild(td);
|
||||
divInput.appendChild(search);
|
||||
|
||||
var searchNext = document.createElement('button');
|
||||
searchNext.type = 'button';
|
||||
searchNext.title = 'Next result (Enter)';
|
||||
searchNext.className = 'jsoneditor-next';
|
||||
searchNext.onclick = function () {
|
||||
var searchNext = document.createElement("button");
|
||||
searchNext.type = "button";
|
||||
searchNext.title = "Next result (Enter)";
|
||||
searchNext.className = "jsoneditor-next";
|
||||
searchNext.onclick = function() {
|
||||
searchBox.next();
|
||||
};
|
||||
td = document.createElement('td');
|
||||
td.appendChild(searchNext);
|
||||
tr.appendChild(td);
|
||||
|
||||
var searchPrevious = document.createElement('button');
|
||||
searchPrevious.type = 'button';
|
||||
searchPrevious.title = 'Previous result (Shift+Enter)';
|
||||
searchPrevious.className = 'jsoneditor-previous';
|
||||
searchPrevious.onclick = function () {
|
||||
divInput.appendChild(searchNext);
|
||||
|
||||
var searchPrevious = document.createElement("button");
|
||||
searchPrevious.type = "button";
|
||||
searchPrevious.title = "Previous result (Shift+Enter)";
|
||||
searchPrevious.className = "jsoneditor-previous";
|
||||
searchPrevious.onclick = function() {
|
||||
searchBox.previous();
|
||||
};
|
||||
td = document.createElement('td');
|
||||
td.appendChild(searchPrevious);
|
||||
tr.appendChild(td);
|
||||
|
||||
divInput.appendChild(searchPrevious);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11372,7 +11375,7 @@ function SearchBox (editor, container) {
|
|||
*/
|
||||
SearchBox.prototype.next = function(focus) {
|
||||
if (this.results != undefined) {
|
||||
var index = (this.resultIndex != undefined) ? this.resultIndex + 1 : 0;
|
||||
var index = this.resultIndex != undefined ? this.resultIndex + 1 : 0;
|
||||
if (index > this.results.length - 1) {
|
||||
index = 0;
|
||||
}
|
||||
|
@ -11388,7 +11391,7 @@ SearchBox.prototype.next = function(focus) {
|
|||
SearchBox.prototype.previous = function(focus) {
|
||||
if (this.results != undefined) {
|
||||
var max = this.results.length - 1;
|
||||
var index = (this.resultIndex != undefined) ? this.resultIndex - 1 : max;
|
||||
var index = this.resultIndex != undefined ? this.resultIndex - 1 : max;
|
||||
if (index < 0) {
|
||||
index = max;
|
||||
}
|
||||
|
@ -11408,10 +11411,9 @@ SearchBox.prototype._setActiveResult = function(index, focus) {
|
|||
if (this.activeResult) {
|
||||
var prevNode = this.activeResult.node;
|
||||
var prevElem = this.activeResult.elem;
|
||||
if (prevElem == 'field') {
|
||||
if (prevElem == "field") {
|
||||
delete prevNode.searchFieldActive;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
delete prevNode.searchValueActive;
|
||||
}
|
||||
prevNode.updateDom();
|
||||
|
@ -11429,17 +11431,16 @@ SearchBox.prototype._setActiveResult = function(index, focus) {
|
|||
// set new node active
|
||||
var node = this.results[this.resultIndex].node;
|
||||
var elem = this.results[this.resultIndex].elem;
|
||||
if (elem == 'field') {
|
||||
if (elem == "field") {
|
||||
node.searchFieldActive = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
node.searchValueActive = true;
|
||||
}
|
||||
this.activeResult = this.results[this.resultIndex];
|
||||
node.updateDom();
|
||||
|
||||
// TODO: not so nice that the focus is only set after the animation is finished
|
||||
node.scrollTo(function () {
|
||||
node.scrollTo(function() {
|
||||
if (focus) {
|
||||
node.focus(elem);
|
||||
}
|
||||
|
@ -11463,15 +11464,14 @@ SearchBox.prototype._clearDelay = function() {
|
|||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
SearchBox.prototype._onDelayedSearch = function (event) {
|
||||
SearchBox.prototype._onDelayedSearch = function(event) {
|
||||
// execute the search after a short delay (reduces the number of
|
||||
// search actions while typing in the search text box)
|
||||
this._clearDelay();
|
||||
var searchBox = this;
|
||||
this.timeout = setTimeout(function (event) {
|
||||
this.timeout = setTimeout(function(event) {
|
||||
searchBox._onSearch();
|
||||
},
|
||||
this.delay);
|
||||
}, this.delay);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -11481,18 +11481,18 @@ SearchBox.prototype._onDelayedSearch = function (event) {
|
|||
* Default is false.
|
||||
* @private
|
||||
*/
|
||||
SearchBox.prototype._onSearch = function (forceSearch) {
|
||||
SearchBox.prototype._onSearch = function(forceSearch) {
|
||||
this._clearDelay();
|
||||
|
||||
var value = this.dom.search.value;
|
||||
var text = (value.length > 0) ? value : undefined;
|
||||
var text = value.length > 0 ? value : undefined;
|
||||
if (text !== this.lastText || forceSearch) {
|
||||
// only search again when changed
|
||||
this.lastText = text;
|
||||
this.results = this.editor.search(text);
|
||||
var MAX_SEARCH_RESULTS = this.results[0]
|
||||
? this.results[0].node.MAX_SEARCH_RESULTS
|
||||
: Infinity;
|
||||
? this.results[0].node.MAX_SEARCH_RESULTS
|
||||
: Infinity;
|
||||
|
||||
// try to maintain the current active result if this is still part of the new search results
|
||||
var activeResultIndex = 0;
|
||||
|
@ -11511,20 +11511,16 @@ SearchBox.prototype._onSearch = function (forceSearch) {
|
|||
if (text !== undefined) {
|
||||
var resultCount = this.results.length;
|
||||
if (resultCount === 0) {
|
||||
this.dom.results.innerHTML = 'no results';
|
||||
this.dom.results.innerHTML = "no results";
|
||||
} else if (resultCount === 1) {
|
||||
this.dom.results.innerHTML = "1 result";
|
||||
} else if (resultCount > MAX_SEARCH_RESULTS) {
|
||||
this.dom.results.innerHTML = MAX_SEARCH_RESULTS + "+ results";
|
||||
} else {
|
||||
this.dom.results.innerHTML = resultCount + " results";
|
||||
}
|
||||
else if (resultCount === 1) {
|
||||
this.dom.results.innerHTML = '1 result';
|
||||
}
|
||||
else if (resultCount > MAX_SEARCH_RESULTS) {
|
||||
this.dom.results.innerHTML = MAX_SEARCH_RESULTS + '+ results';
|
||||
}
|
||||
else {
|
||||
this.dom.results.innerHTML = resultCount + ' results';
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.dom.results.innerHTML = '';
|
||||
} else {
|
||||
this.dom.results.innerHTML = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -11534,24 +11530,23 @@ SearchBox.prototype._onSearch = function (forceSearch) {
|
|||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
SearchBox.prototype._onKeyDown = function (event) {
|
||||
SearchBox.prototype._onKeyDown = function(event) {
|
||||
var keynum = event.which;
|
||||
if (keynum == 27) { // ESC
|
||||
this.dom.search.value = ''; // clear search
|
||||
if (keynum == 27) {
|
||||
// ESC
|
||||
this.dom.search.value = ""; // clear search
|
||||
this._onSearch();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
else if (keynum == 13) { // Enter
|
||||
} else if (keynum == 13) {
|
||||
// Enter
|
||||
if (event.ctrlKey) {
|
||||
// force to search again
|
||||
this._onSearch(true);
|
||||
}
|
||||
else if (event.shiftKey) {
|
||||
} else if (event.shiftKey) {
|
||||
// move to the previous search result
|
||||
this.previous();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// move to the next search result
|
||||
this.next();
|
||||
}
|
||||
|
@ -11565,25 +11560,26 @@ SearchBox.prototype._onKeyDown = function (event) {
|
|||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
SearchBox.prototype._onKeyUp = function (event) {
|
||||
SearchBox.prototype._onKeyUp = function(event) {
|
||||
var keynum = event.keyCode;
|
||||
if (keynum != 27 && keynum != 13) { // !show and !Enter
|
||||
this._onDelayedSearch(event); // For IE 9
|
||||
if (keynum != 27 && keynum != 13) {
|
||||
// !show and !Enter
|
||||
this._onDelayedSearch(event); // For IE 9
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the search results
|
||||
*/
|
||||
SearchBox.prototype.clear = function () {
|
||||
this.dom.search.value = '';
|
||||
SearchBox.prototype.clear = function() {
|
||||
this.dom.search.value = "";
|
||||
this._onSearch();
|
||||
};
|
||||
|
||||
/**
|
||||
* Refresh searchResults if there is a search value
|
||||
*/
|
||||
SearchBox.prototype.forceSearch = function () {
|
||||
SearchBox.prototype.forceSearch = function() {
|
||||
this._onSearch(true);
|
||||
};
|
||||
|
||||
|
@ -11591,23 +11587,22 @@ SearchBox.prototype.forceSearch = function () {
|
|||
* Test whether the search box value is empty
|
||||
* @returns {boolean} Returns true when empty.
|
||||
*/
|
||||
SearchBox.prototype.isEmpty = function () {
|
||||
return this.dom.search.value === '';
|
||||
SearchBox.prototype.isEmpty = function() {
|
||||
return this.dom.search.value === "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the search box
|
||||
*/
|
||||
SearchBox.prototype.destroy = function () {
|
||||
SearchBox.prototype.destroy = function() {
|
||||
this.editor = null;
|
||||
this.dom.container.removeChild(this.dom.table);
|
||||
this.dom.container.removeChild(this.dom.wrapper);
|
||||
this.dom = null;
|
||||
|
||||
this.results = null;
|
||||
this.activeResult = null;
|
||||
|
||||
this._clearDelay();
|
||||
|
||||
};
|
||||
|
||||
module.exports = SearchBox;
|
||||
|
|
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 it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "jsoneditor",
|
||||
"version": "6.3.0",
|
||||
"version": "6.4.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "jsoneditor",
|
||||
"version": "6.3.0",
|
||||
"version": "6.4.0",
|
||||
"main": "./index",
|
||||
"description": "A web-based tool to view, edit, format, and validate JSON",
|
||||
"tags": [
|
||||
|
|
Loading…
Reference in New Issue