Publish v6.4.0

This commit is contained in:
jos 2019-08-28 11:12:44 +02:00
parent c404c1bc1f
commit 6d5d9965c3
9 changed files with 16880 additions and 16927 deletions

View File

@ -2,7 +2,7 @@
https://github.com/josdejong/jsoneditor 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. - Replaces CSS with SASS internally, improvements in styling. Thanks @ppetkow.
- Fixed #761: JSON schema errors not rendered in the gutter for mode `code` - Fixed #761: JSON schema errors not rendered in the gutter for mode `code`

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 6.3.0 * @version 6.4.0
* @date 2019-08-15 * @date 2019-08-28
*/ */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
@ -1270,7 +1270,7 @@ exports.getPositionForPath = function(text, paths) {
paths.forEach(function (path) { paths.forEach(function (path) {
var pathArr = me.parsePath(path); var pathArr = me.parsePath(path);
var pointerName = pathArr.length ? "/" + pathArr.join("/") : ""; var pointerName = exports.compileJSONPointer(pathArr);
var pointer = jsmap.pointers[pointerName]; var pointer = jsmap.pointers[pointerName];
if (pointer) { if (pointer) {
result.push({ 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 * Get the applied color given a color name or code
* Source: https://stackoverflow.com/questions/6386090/validating-css-color-names/33184805 * Source: https://stackoverflow.com/questions/6386090/validating-css-color-names/33184805
@ -4211,6 +4228,10 @@ function showSortModal (container, json, onSort, options) {
parent: container, parent: container,
content: content, content: content,
overlayClass: 'jsoneditor-modal-overlay', overlayClass: 'jsoneditor-modal-overlay',
overlayStyles: {
backgroundColor: "rgb(1,1,1)",
opacity: 0.3
},
modalClass: 'jsoneditor-modal jsoneditor-modal-sort' modalClass: 'jsoneditor-modal jsoneditor-modal-sort'
}) })
.afterCreate(function (modal) { .afterCreate(function (modal) {
@ -4376,6 +4397,10 @@ function showTransformModal (container, json, onTransform) {
parent: container, parent: container,
content: content, content: content,
overlayClass: 'jsoneditor-modal-overlay', overlayClass: 'jsoneditor-modal-overlay',
overlayStyles: {
backgroundColor: "rgb(1,1,1)",
opacity: 0.3
},
modalClass: 'jsoneditor-modal jsoneditor-modal-transform', modalClass: 'jsoneditor-modal jsoneditor-modal-transform',
focus: false focus: false
}) })
@ -8562,8 +8587,8 @@ treemode._onChange = function () {
this._debouncedValidate(); this._debouncedValidate();
if (this.treePath) { if (this.treePath) {
var selectedNode = this.selection var selectedNode = (this.node && this.selection)
? this.node.findNodeByInternalPath(this.selection.path) ? this.node.findNodeByInternalPath(this.selection.path)
: this.multiselection : this.multiselection
? this.multiselection.nodes[0] ? this.multiselection.nodes[0]
: undefined; : undefined;
@ -11267,7 +11292,7 @@ function escapeJsonPointer(str) {
* @param {Element} container HTML container element of where to * @param {Element} container HTML container element of where to
* create the search box * create the search box
*/ */
function SearchBox (editor, container) { function SearchBox(editor, container) {
var searchBox = this; var searchBox = this;
this.editor = editor; this.editor = editor;
@ -11278,91 +11303,69 @@ function SearchBox (editor, container) {
this.dom = {}; this.dom = {};
this.dom.container = container; this.dom.container = container;
var table = document.createElement('table'); var wrapper = document.createElement("div");
this.dom.table = table; this.dom.wrapper = wrapper;
table.className = 'jsoneditor-search'; wrapper.className = "jsoneditor-search";
container.appendChild(table); container.appendChild(wrapper);
var tbody = document.createElement('tbody');
this.dom.tbody = tbody;
table.appendChild(tbody);
var tr = document.createElement('tr');
tbody.appendChild(tr);
var td = document.createElement('td'); var results = document.createElement("div");
tr.appendChild(td);
var results = document.createElement('div');
this.dom.results = results; this.dom.results = results;
results.className = 'jsoneditor-results'; results.className = "jsoneditor-results";
td.appendChild(results); wrapper.appendChild(results);
td = document.createElement('td'); var divInput = document.createElement("div");
tr.appendChild(td);
var divInput = document.createElement('div');
this.dom.input = divInput; this.dom.input = divInput;
divInput.className = 'jsoneditor-frame'; divInput.className = "jsoneditor-frame";
divInput.title = 'Search fields and values'; divInput.title = "Search fields and values";
td.appendChild(divInput); wrapper.appendChild(divInput);
// table to contain the text input and search button var refreshSearch = document.createElement("button");
var tableInput = document.createElement('table'); refreshSearch.type = "button";
divInput.appendChild(tableInput); refreshSearch.className = "jsoneditor-refresh";
var tbodySearch = document.createElement('tbody'); divInput.appendChild(refreshSearch);
tableInput.appendChild(tbodySearch);
tr = document.createElement('tr');
tbodySearch.appendChild(tr);
var refreshSearch = document.createElement('button'); var search = document.createElement("input");
refreshSearch.type = 'button'; search.type = "text";
refreshSearch.className = 'jsoneditor-refresh';
td = document.createElement('td');
td.appendChild(refreshSearch);
tr.appendChild(td);
var search = document.createElement('input');
// search.type = 'button';
this.dom.search = search; this.dom.search = search;
search.oninput = function (event) { search.oninput = function(event) {
searchBox._onDelayedSearch(event); searchBox._onDelayedSearch(event);
}; };
search.onchange = function (event) { // For IE 9 search.onchange = function(event) {
// For IE 9
searchBox._onSearch(); searchBox._onSearch();
}; };
search.onkeydown = function (event) { search.onkeydown = function(event) {
searchBox._onKeyDown(event); searchBox._onKeyDown(event);
}; };
search.onkeyup = function (event) { search.onkeyup = function(event) {
searchBox._onKeyUp(event); searchBox._onKeyUp(event);
}; };
refreshSearch.onclick = function (event) { refreshSearch.onclick = function(event) {
search.select(); search.select();
}; };
// TODO: ESC in FF restores the last input, is a FF bug, https://bugzilla.mozilla.org/show_bug.cgi?id=598819 // 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'); divInput.appendChild(search);
td.appendChild(search);
tr.appendChild(td);
var searchNext = document.createElement('button'); var searchNext = document.createElement("button");
searchNext.type = 'button'; searchNext.type = "button";
searchNext.title = 'Next result (Enter)'; searchNext.title = "Next result (Enter)";
searchNext.className = 'jsoneditor-next'; searchNext.className = "jsoneditor-next";
searchNext.onclick = function () { searchNext.onclick = function() {
searchBox.next(); searchBox.next();
}; };
td = document.createElement('td');
td.appendChild(searchNext);
tr.appendChild(td);
var searchPrevious = document.createElement('button'); divInput.appendChild(searchNext);
searchPrevious.type = 'button';
searchPrevious.title = 'Previous result (Shift+Enter)'; var searchPrevious = document.createElement("button");
searchPrevious.className = 'jsoneditor-previous'; searchPrevious.type = "button";
searchPrevious.onclick = function () { searchPrevious.title = "Previous result (Shift+Enter)";
searchPrevious.className = "jsoneditor-previous";
searchPrevious.onclick = function() {
searchBox.previous(); searchBox.previous();
}; };
td = document.createElement('td');
td.appendChild(searchPrevious); divInput.appendChild(searchPrevious);
tr.appendChild(td);
} }
/** /**
@ -11372,7 +11375,7 @@ function SearchBox (editor, container) {
*/ */
SearchBox.prototype.next = function(focus) { SearchBox.prototype.next = function(focus) {
if (this.results != undefined) { 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) { if (index > this.results.length - 1) {
index = 0; index = 0;
} }
@ -11388,7 +11391,7 @@ SearchBox.prototype.next = function(focus) {
SearchBox.prototype.previous = function(focus) { SearchBox.prototype.previous = function(focus) {
if (this.results != undefined) { if (this.results != undefined) {
var max = this.results.length - 1; 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) { if (index < 0) {
index = max; index = max;
} }
@ -11408,10 +11411,9 @@ SearchBox.prototype._setActiveResult = function(index, focus) {
if (this.activeResult) { if (this.activeResult) {
var prevNode = this.activeResult.node; var prevNode = this.activeResult.node;
var prevElem = this.activeResult.elem; var prevElem = this.activeResult.elem;
if (prevElem == 'field') { if (prevElem == "field") {
delete prevNode.searchFieldActive; delete prevNode.searchFieldActive;
} } else {
else {
delete prevNode.searchValueActive; delete prevNode.searchValueActive;
} }
prevNode.updateDom(); prevNode.updateDom();
@ -11429,17 +11431,16 @@ SearchBox.prototype._setActiveResult = function(index, focus) {
// set new node active // set new node active
var node = this.results[this.resultIndex].node; var node = this.results[this.resultIndex].node;
var elem = this.results[this.resultIndex].elem; var elem = this.results[this.resultIndex].elem;
if (elem == 'field') { if (elem == "field") {
node.searchFieldActive = true; node.searchFieldActive = true;
} } else {
else {
node.searchValueActive = true; node.searchValueActive = true;
} }
this.activeResult = this.results[this.resultIndex]; this.activeResult = this.results[this.resultIndex];
node.updateDom(); node.updateDom();
// TODO: not so nice that the focus is only set after the animation is finished // TODO: not so nice that the focus is only set after the animation is finished
node.scrollTo(function () { node.scrollTo(function() {
if (focus) { if (focus) {
node.focus(elem); node.focus(elem);
} }
@ -11463,15 +11464,14 @@ SearchBox.prototype._clearDelay = function() {
* @param {Event} event * @param {Event} event
* @private * @private
*/ */
SearchBox.prototype._onDelayedSearch = function (event) { SearchBox.prototype._onDelayedSearch = function(event) {
// execute the search after a short delay (reduces the number of // execute the search after a short delay (reduces the number of
// search actions while typing in the search text box) // search actions while typing in the search text box)
this._clearDelay(); this._clearDelay();
var searchBox = this; var searchBox = this;
this.timeout = setTimeout(function (event) { this.timeout = setTimeout(function(event) {
searchBox._onSearch(); searchBox._onSearch();
}, }, this.delay);
this.delay);
}; };
/** /**
@ -11481,18 +11481,18 @@ SearchBox.prototype._onDelayedSearch = function (event) {
* Default is false. * Default is false.
* @private * @private
*/ */
SearchBox.prototype._onSearch = function (forceSearch) { SearchBox.prototype._onSearch = function(forceSearch) {
this._clearDelay(); this._clearDelay();
var value = this.dom.search.value; 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) { if (text !== this.lastText || forceSearch) {
// only search again when changed // only search again when changed
this.lastText = text; this.lastText = text;
this.results = this.editor.search(text); this.results = this.editor.search(text);
var MAX_SEARCH_RESULTS = this.results[0] var MAX_SEARCH_RESULTS = this.results[0]
? this.results[0].node.MAX_SEARCH_RESULTS ? this.results[0].node.MAX_SEARCH_RESULTS
: Infinity; : Infinity;
// try to maintain the current active result if this is still part of the new search results // try to maintain the current active result if this is still part of the new search results
var activeResultIndex = 0; var activeResultIndex = 0;
@ -11511,20 +11511,16 @@ SearchBox.prototype._onSearch = function (forceSearch) {
if (text !== undefined) { if (text !== undefined) {
var resultCount = this.results.length; var resultCount = this.results.length;
if (resultCount === 0) { if (resultCount === 0) {
this.dom.results.innerHTML = 'no&nbsp;results'; this.dom.results.innerHTML = "no&nbsp;results";
} else if (resultCount === 1) {
this.dom.results.innerHTML = "1&nbsp;result";
} else if (resultCount > MAX_SEARCH_RESULTS) {
this.dom.results.innerHTML = MAX_SEARCH_RESULTS + "+&nbsp;results";
} else {
this.dom.results.innerHTML = resultCount + "&nbsp;results";
} }
else if (resultCount === 1) { } else {
this.dom.results.innerHTML = '1&nbsp;result'; this.dom.results.innerHTML = "";
}
else if (resultCount > MAX_SEARCH_RESULTS) {
this.dom.results.innerHTML = MAX_SEARCH_RESULTS + '+&nbsp;results';
}
else {
this.dom.results.innerHTML = resultCount + '&nbsp;results';
}
}
else {
this.dom.results.innerHTML = '';
} }
} }
}; };
@ -11534,24 +11530,23 @@ SearchBox.prototype._onSearch = function (forceSearch) {
* @param {Event} event * @param {Event} event
* @private * @private
*/ */
SearchBox.prototype._onKeyDown = function (event) { SearchBox.prototype._onKeyDown = function(event) {
var keynum = event.which; var keynum = event.which;
if (keynum == 27) { // ESC if (keynum == 27) {
this.dom.search.value = ''; // clear search // ESC
this.dom.search.value = ""; // clear search
this._onSearch(); this._onSearch();
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} } else if (keynum == 13) {
else if (keynum == 13) { // Enter // Enter
if (event.ctrlKey) { if (event.ctrlKey) {
// force to search again // force to search again
this._onSearch(true); this._onSearch(true);
} } else if (event.shiftKey) {
else if (event.shiftKey) {
// move to the previous search result // move to the previous search result
this.previous(); this.previous();
} } else {
else {
// move to the next search result // move to the next search result
this.next(); this.next();
} }
@ -11565,25 +11560,26 @@ SearchBox.prototype._onKeyDown = function (event) {
* @param {Event} event * @param {Event} event
* @private * @private
*/ */
SearchBox.prototype._onKeyUp = function (event) { SearchBox.prototype._onKeyUp = function(event) {
var keynum = event.keyCode; var keynum = event.keyCode;
if (keynum != 27 && keynum != 13) { // !show and !Enter if (keynum != 27 && keynum != 13) {
this._onDelayedSearch(event); // For IE 9 // !show and !Enter
this._onDelayedSearch(event); // For IE 9
} }
}; };
/** /**
* Clear the search results * Clear the search results
*/ */
SearchBox.prototype.clear = function () { SearchBox.prototype.clear = function() {
this.dom.search.value = ''; this.dom.search.value = "";
this._onSearch(); this._onSearch();
}; };
/** /**
* Refresh searchResults if there is a search value * Refresh searchResults if there is a search value
*/ */
SearchBox.prototype.forceSearch = function () { SearchBox.prototype.forceSearch = function() {
this._onSearch(true); this._onSearch(true);
}; };
@ -11591,23 +11587,22 @@ SearchBox.prototype.forceSearch = function () {
* Test whether the search box value is empty * Test whether the search box value is empty
* @returns {boolean} Returns true when empty. * @returns {boolean} Returns true when empty.
*/ */
SearchBox.prototype.isEmpty = function () { SearchBox.prototype.isEmpty = function() {
return this.dom.search.value === ''; return this.dom.search.value === "";
}; };
/** /**
* Destroy the search box * Destroy the search box
*/ */
SearchBox.prototype.destroy = function () { SearchBox.prototype.destroy = function() {
this.editor = null; this.editor = null;
this.dom.container.removeChild(this.dom.table); this.dom.container.removeChild(this.dom.wrapper);
this.dom = null; this.dom = null;
this.results = null; this.results = null;
this.activeResult = null; this.activeResult = null;
this._clearDelay(); this._clearDelay();
}; };
module.exports = SearchBox; 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

33536
dist/jsoneditor.js vendored

File diff suppressed because it is too large Load Diff

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

2
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "jsoneditor", "name": "jsoneditor",
"version": "6.3.0", "version": "6.4.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": [