Publish v5.25.0

This commit is contained in:
jos 2018-10-29 20:31:10 +01:00
parent d0b49fbf12
commit 4e24601823
8 changed files with 201 additions and 127 deletions

View File

@ -3,7 +3,7 @@
https://github.com/josdejong/jsoneditor
## not yet released, version 5.25.0
## 2018-10-29, version 5.25.0
- Implemented options `enableSort` and `enableTransform` so you can turn off
these features. Thanks @tanmayrajani.

View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.24.7
* @date 2018-10-08
* @version 5.25.0
* @date 2018-10-29
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
@ -252,7 +252,7 @@ return /******/ (function(modules) { // webpackBootstrap
'colorPicker', 'onColorPicker',
'timestampTag',
'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation',
'sortObjectKeys', 'navigationBar', 'statusBar', 'languages', 'language'
'sortObjectKeys', 'navigationBar', 'statusBar', 'languages', 'language', 'enableSort', 'enableTransform'
];
/**
@ -1614,7 +1614,9 @@ return /******/ (function(modules) { // webpackBootstrap
}
},
timestampTag: true,
onEvent: null
onEvent: null,
enableSort: true,
enableTransform: true
};
// copy all options
@ -1949,9 +1951,27 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
// selection can be changed after undo/redo
this.selection = this.getDomSelection();
// validate JSON schema (if configured)
this._debouncedValidate();
if (this.treePath) {
var selectedNode = this.selection
? this.node.findNodeByInternalPath(this.selection.path)
: this.multiselection
? this.multiselection.nodes[0]
: undefined;
if (selectedNode) {
this._updateTreePath(selectedNode.getNodePath())
}
else {
this.treePath.reset()
}
}
// trigger the onChange callback
if (this.options.onChange) {
try {
@ -2437,6 +2457,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.menu.appendChild(collapseAll);
// create sort button
if (this.options.enableSort) {
var sort = document.createElement('button');
sort.type = 'button';
sort.className = 'jsoneditor-sort';
@ -2446,8 +2467,10 @@ return /******/ (function(modules) { // webpackBootstrap
showSortModal(editor.node, anchor)
};
this.menu.appendChild(sort);
}
// create transform button
if (this.options.enableTransform) {
var transform = document.createElement('button');
transform.type = 'button';
transform.title = translate('transformTitleShort');
@ -2457,6 +2480,7 @@ return /******/ (function(modules) { // webpackBootstrap
showTransformModal(editor.node, anchor)
};
this.menu.appendChild(transform);
}
// create undo/redo buttons
if (this.history) {
@ -2511,7 +2535,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.navBar.className = 'jsoneditor-navigation-bar nav-bar-empty';
this.frame.appendChild(this.navBar);
this.treePath = new TreePath(this.navBar);
this.treePath = new TreePath(this.navBar, this.frame);
this.treePath.onSectionSelected(this._onTreePathSectionSelected.bind(this));
this.treePath.onContextMenuItemSelected(this._onTreePathMenuItemSelected.bind(this));
}
@ -2752,6 +2776,7 @@ return /******/ (function(modules) { // webpackBootstrap
});
}
event.preventDefault();
};
/**
@ -3081,7 +3106,7 @@ return /******/ (function(modules) { // webpackBootstrap
*/
treemode.showContextMenu = function (anchor, onClose) {
var items = [];
var editor = this;
var selectedNodes = this.multiselection.nodes.slice();
// create duplicate button
items.push({
@ -3089,7 +3114,7 @@ return /******/ (function(modules) { // webpackBootstrap
title: translate('duplicateTitle'),
className: 'jsoneditor-duplicate',
click: function () {
Node.onDuplicate(editor.multiselection.nodes);
Node.onDuplicate(selectedNodes );
}
});
@ -3099,12 +3124,12 @@ return /******/ (function(modules) { // webpackBootstrap
title: translate('removeTitle'),
className: 'jsoneditor-remove',
click: function () {
Node.onRemove(editor.multiselection.nodes);
Node.onRemove(selectedNodes);
}
});
var menu = new ContextMenu(items, {close: onClose});
menu.show(anchor, editor.frame);
menu.show(anchor, this.frame);
};
/**
@ -6714,10 +6739,12 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* Creates a component that visualize path selection in tree based editors
* @param {HTMLElement} container
* @param {HTMLElement} root
* @constructor
*/
function TreePath(container) {
function TreePath(container, root) {
if (container) {
this.root = root;
this.path = document.createElement('div');
this.path.className = 'jsoneditor-treepath';
container.appendChild(this.path);
@ -6767,10 +6794,10 @@ return /******/ (function(modules) { // webpackBootstrap
});
});
var menu = new ContextMenu(items);
menu.show(sepEl);
menu.show(sepEl, me.root);
};
me.path.appendChild(sepEl, me.container);
me.path.appendChild(sepEl);
}
if(idx === pathObjs.length - 1) {
@ -10991,6 +11018,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
if (this._hasChilds()) {
if (this.editor.options.enableSort) {
items.push({
text: translate('sort'),
title: translate('sortTitle', {type: this.type}),
@ -11000,7 +11028,9 @@ return /******/ (function(modules) { // webpackBootstrap
showSortModal(node, anchor)
}
});
}
if (this.editor.options.enableTransform) {
items.push({
text: translate('transform'),
title: translate('transformTitle', {type: this.type}),
@ -11011,6 +11041,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
});
}
}
if (this.parent && this.parent._hasChilds()) {
if (items.length) {
@ -17897,19 +17928,25 @@ return /******/ (function(modules) { // webpackBootstrap
var json;
try {
json = this.get(); // this can fail when there is no valid json
if (this.parseErrorIndication) {
this.parseErrorIndication.style.display = 'none';
}
doValidate = true;
}
catch (err) {
if (this.getText()) {
if (this.parseErrorIndication) {
this.parseErrorIndication.style.display = 'block';
}
// try to extract the line number from the jsonlint error message
var match = /\w*line\s*(\d+)\w*/g.exec(err.message);
var line;
if (match) {
line = +match[1];
}
if (this.parseErrorIndication) {
this.parseErrorIndication.title = !isNaN(line) ? ('parse error on line ' + line) : 'parse error - check that the json is valid';
}
parseErrors.push({
type: 'error',
message: err.message.replace(/\n/g, '<br>'),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

61
dist/jsoneditor.js vendored
View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.24.7
* @date 2018-10-08
* @version 5.25.0
* @date 2018-10-29
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
@ -252,7 +252,7 @@ return /******/ (function(modules) { // webpackBootstrap
'colorPicker', 'onColorPicker',
'timestampTag',
'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation',
'sortObjectKeys', 'navigationBar', 'statusBar', 'languages', 'language'
'sortObjectKeys', 'navigationBar', 'statusBar', 'languages', 'language', 'enableSort', 'enableTransform'
];
/**
@ -30256,7 +30256,9 @@ return /******/ (function(modules) { // webpackBootstrap
}
},
timestampTag: true,
onEvent: null
onEvent: null,
enableSort: true,
enableTransform: true
};
// copy all options
@ -30591,9 +30593,27 @@ return /******/ (function(modules) { // webpackBootstrap
return;
}
// selection can be changed after undo/redo
this.selection = this.getDomSelection();
// validate JSON schema (if configured)
this._debouncedValidate();
if (this.treePath) {
var selectedNode = this.selection
? this.node.findNodeByInternalPath(this.selection.path)
: this.multiselection
? this.multiselection.nodes[0]
: undefined;
if (selectedNode) {
this._updateTreePath(selectedNode.getNodePath())
}
else {
this.treePath.reset()
}
}
// trigger the onChange callback
if (this.options.onChange) {
try {
@ -31079,6 +31099,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.menu.appendChild(collapseAll);
// create sort button
if (this.options.enableSort) {
var sort = document.createElement('button');
sort.type = 'button';
sort.className = 'jsoneditor-sort';
@ -31088,8 +31109,10 @@ return /******/ (function(modules) { // webpackBootstrap
showSortModal(editor.node, anchor)
};
this.menu.appendChild(sort);
}
// create transform button
if (this.options.enableTransform) {
var transform = document.createElement('button');
transform.type = 'button';
transform.title = translate('transformTitleShort');
@ -31099,6 +31122,7 @@ return /******/ (function(modules) { // webpackBootstrap
showTransformModal(editor.node, anchor)
};
this.menu.appendChild(transform);
}
// create undo/redo buttons
if (this.history) {
@ -31153,7 +31177,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.navBar.className = 'jsoneditor-navigation-bar nav-bar-empty';
this.frame.appendChild(this.navBar);
this.treePath = new TreePath(this.navBar);
this.treePath = new TreePath(this.navBar, this.frame);
this.treePath.onSectionSelected(this._onTreePathSectionSelected.bind(this));
this.treePath.onContextMenuItemSelected(this._onTreePathMenuItemSelected.bind(this));
}
@ -31394,6 +31418,7 @@ return /******/ (function(modules) { // webpackBootstrap
});
}
event.preventDefault();
};
/**
@ -31723,7 +31748,7 @@ return /******/ (function(modules) { // webpackBootstrap
*/
treemode.showContextMenu = function (anchor, onClose) {
var items = [];
var editor = this;
var selectedNodes = this.multiselection.nodes.slice();
// create duplicate button
items.push({
@ -31731,7 +31756,7 @@ return /******/ (function(modules) { // webpackBootstrap
title: translate('duplicateTitle'),
className: 'jsoneditor-duplicate',
click: function () {
Node.onDuplicate(editor.multiselection.nodes);
Node.onDuplicate(selectedNodes );
}
});
@ -31741,12 +31766,12 @@ return /******/ (function(modules) { // webpackBootstrap
title: translate('removeTitle'),
className: 'jsoneditor-remove',
click: function () {
Node.onRemove(editor.multiselection.nodes);
Node.onRemove(selectedNodes);
}
});
var menu = new ContextMenu(items, {close: onClose});
menu.show(anchor, editor.frame);
menu.show(anchor, this.frame);
};
/**
@ -35356,10 +35381,12 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* Creates a component that visualize path selection in tree based editors
* @param {HTMLElement} container
* @param {HTMLElement} root
* @constructor
*/
function TreePath(container) {
function TreePath(container, root) {
if (container) {
this.root = root;
this.path = document.createElement('div');
this.path.className = 'jsoneditor-treepath';
container.appendChild(this.path);
@ -35409,10 +35436,10 @@ return /******/ (function(modules) { // webpackBootstrap
});
});
var menu = new ContextMenu(items);
menu.show(sepEl);
menu.show(sepEl, me.root);
};
me.path.appendChild(sepEl, me.container);
me.path.appendChild(sepEl);
}
if(idx === pathObjs.length - 1) {
@ -39633,6 +39660,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
if (this._hasChilds()) {
if (this.editor.options.enableSort) {
items.push({
text: translate('sort'),
title: translate('sortTitle', {type: this.type}),
@ -39642,7 +39670,9 @@ return /******/ (function(modules) { // webpackBootstrap
showSortModal(node, anchor)
}
});
}
if (this.editor.options.enableTransform) {
items.push({
text: translate('transform'),
title: translate('transformTitle', {type: this.type}),
@ -39653,6 +39683,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
});
}
}
if (this.parent && this.parent._hasChilds()) {
if (items.length) {
@ -46539,19 +46570,25 @@ return /******/ (function(modules) { // webpackBootstrap
var json;
try {
json = this.get(); // this can fail when there is no valid json
if (this.parseErrorIndication) {
this.parseErrorIndication.style.display = 'none';
}
doValidate = true;
}
catch (err) {
if (this.getText()) {
if (this.parseErrorIndication) {
this.parseErrorIndication.style.display = 'block';
}
// try to extract the line number from the jsonlint error message
var match = /\w*line\s*(\d+)\w*/g.exec(err.message);
var line;
if (match) {
line = +match[1];
}
if (this.parseErrorIndication) {
this.parseErrorIndication.title = !isNaN(line) ? ('parse error on line ' + line) : 'parse error - check that the json is valid';
}
parseErrors.push({
type: 'error',
message: err.message.replace(/\n/g, '<br>'),

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

View File

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