Publish v5.27.0

This commit is contained in:
jos 2019-01-05 15:21:54 +01:00
parent b59da1a5c9
commit e9f6a299f7
14 changed files with 1137 additions and 1325 deletions

View File

@ -3,12 +3,12 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet published, version 5.27.0 ## 2019-01-05, version 5.27.0
- Implemented customizing object and array names via a new option - Implemented customizing object and array names via a new option
`onNodeName`. Thanks @bnanchen. `onNodeName`. Thanks @bnanchen.
- Visibility of schema validation errors at the bottom of mode code and text - Visibility of schema validation errors at the bottom of mode code and text
are now toggelable. Thanks @meirotstein. are now toggleable. Thanks @meirotstein.
- Fixed text of the mode switcher not being translated. Thanks @antfu. - Fixed text of the mode switcher not being translated. Thanks @antfu.

2
NOTICE
View File

@ -1,7 +1,7 @@
JSON Editor JSON Editor
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
Copyright (C) 2011-2018 Jos de Jong Copyright (C) 2011-2019 Jos de Jong
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -2,7 +2,7 @@
[![Version](https://img.shields.io/npm/v/jsoneditor.svg)](https://www.npmjs.com/package/jsoneditor) [![Version](https://img.shields.io/npm/v/jsoneditor.svg)](https://www.npmjs.com/package/jsoneditor)
[![Downloads](https://img.shields.io/npm/dm/jsoneditor.svg)](https://www.npmjs.com/package/jsoneditor) [![Downloads](https://img.shields.io/npm/dm/jsoneditor.svg)](https://www.npmjs.com/package/jsoneditor)
![Maintenance](https://img.shields.io/maintenance/yes/2018.svg) ![Maintenance](https://img.shields.io/maintenance/yes/2019.svg)
[![License](https://img.shields.io/github/license/josdejong/jsoneditor.svg)](https://github.com/josdejong/jsoneditor/blob/master/LICENSE) [![License](https://img.shields.io/github/license/josdejong/jsoneditor.svg)](https://github.com/josdejong/jsoneditor/blob/master/LICENSE)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjosdejong%2Fjsoneditor.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjosdejong%2Fjsoneditor?ref=badge_shield) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fjosdejong%2Fjsoneditor.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fjosdejong%2Fjsoneditor?ref=badge_shield)

View File

@ -21,11 +21,11 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
* *
* Copyright (c) 2011-2018 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.26.3 * @version 5.27.0
* @date 2018-12-06 * @date 2019-01-05
*/ */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
@ -247,7 +247,7 @@ return /******/ (function(modules) { // webpackBootstrap
'ajv', 'schema', 'schemaRefs','templates', 'ajv', 'schema', 'schemaRefs','templates',
'ace', 'theme', 'autocomplete', 'ace', 'theme', 'autocomplete',
'onChange', 'onChangeJSON', 'onChangeText', 'onChange', 'onChangeJSON', 'onChangeText',
'onEditable', 'onError', 'onEvent', 'onModeChange', 'onValidate', 'onEditable', 'onError', 'onEvent', 'onModeChange', 'onNodeName', 'onValidate',
'onSelectionChange', 'onTextSelectionChange', 'onSelectionChange', 'onTextSelectionChange',
'colorPicker', 'onColorPicker', 'colorPicker', 'onColorPicker',
'timestampTag', 'timestampTag',
@ -2000,6 +2000,15 @@ return /******/ (function(modules) { // webpackBootstrap
console.error('Error in onChangeText callback: ', err); console.error('Error in onChangeText callback: ', err);
} }
} }
// trigger the onNodeName callback
if (this.options.onNodeName && this.node.childs) {
try {
this.node.recursivelyUpdateNodeName();
} catch (err) {
console.error("Error in onNodeName callback: ", err);
}
}
}; };
/** /**
@ -6540,178 +6549,188 @@ return /******/ (function(modules) { // webpackBootstrap
var _locales = ['en', 'pt-BR']; var _locales = ['en', 'pt-BR'];
var _defs = { var _defs = {
en: { en: {
'array': 'Array', array: 'Array',
'auto': 'Auto', auto: 'Auto',
'appendText': 'Append', appendText: 'Append',
'appendTitle': 'Append a new field with type \'auto\' after this field (Ctrl+Shift+Ins)', appendTitle: 'Append a new field with type \'auto\' after this field (Ctrl+Shift+Ins)',
'appendSubmenuTitle': 'Select the type of the field to be appended', appendSubmenuTitle: 'Select the type of the field to be appended',
'appendTitleAuto': 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)', appendTitleAuto: 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)',
'ascending': 'Ascending', ascending: 'Ascending',
'ascendingTitle': 'Sort the childs of this ${type} in ascending order', ascendingTitle: 'Sort the childs of this ${type} in ascending order',
'actionsMenu': 'Click to open the actions menu (Ctrl+M)', actionsMenu: 'Click to open the actions menu (Ctrl+M)',
'collapseAll': 'Collapse all fields', collapseAll: 'Collapse all fields',
'descending': 'Descending', descending: 'Descending',
'descendingTitle': 'Sort the childs of this ${type} in descending order', descendingTitle: 'Sort the childs of this ${type} in descending order',
'drag': 'Drag to move this field (Alt+Shift+Arrows)', drag: 'Drag to move this field (Alt+Shift+Arrows)',
'duplicateKey': 'duplicate key', duplicateKey: 'duplicate key',
'duplicateText': 'Duplicate', duplicateText: 'Duplicate',
'duplicateTitle': 'Duplicate selected fields (Ctrl+D)', duplicateTitle: 'Duplicate selected fields (Ctrl+D)',
'duplicateField': 'Duplicate this field (Ctrl+D)', duplicateField: 'Duplicate this field (Ctrl+D)',
'empty': 'empty', empty: 'empty',
'expandAll': 'Expand all fields', expandAll: 'Expand all fields',
'expandTitle': 'Click to expand/collapse this field (Ctrl+E). \n' + expandTitle: 'Click to expand/collapse this field (Ctrl+E). \n' +
'Ctrl+Click to expand/collapse including all childs.', 'Ctrl+Click to expand/collapse including all childs.',
'insert': 'Insert', insert: 'Insert',
'insertTitle': 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)', insertTitle: 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)',
'insertSub': 'Select the type of the field to be inserted', insertSub: 'Select the type of the field to be inserted',
'object': 'Object', object: 'Object',
'ok': 'Ok', ok: 'Ok',
'redo': 'Redo (Ctrl+Shift+Z)', redo: 'Redo (Ctrl+Shift+Z)',
'removeText': 'Remove', removeText: 'Remove',
'removeTitle': 'Remove selected fields (Ctrl+Del)', removeTitle: 'Remove selected fields (Ctrl+Del)',
'removeField': 'Remove this field (Ctrl+Del)', removeField: 'Remove this field (Ctrl+Del)',
'selectNode': 'Select a node...', selectNode: 'Select a node...',
'showAll': 'show all', showAll: 'show all',
'showMore': 'show more', showMore: 'show more',
'showMoreStatus': 'displaying ${visibleChilds} of ${totalChilds} items.', showMoreStatus: 'displaying ${visibleChilds} of ${totalChilds} items.',
'sort': 'Sort', sort: 'Sort',
'sortTitle': 'Sort the childs of this ${type}', sortTitle: 'Sort the childs of this ${type}',
'sortTitleShort': 'Sort contents', sortTitleShort: 'Sort contents',
'sortFieldLabel': 'Field:', sortFieldLabel: 'Field:',
'sortDirectionLabel': 'Direction:', sortDirectionLabel: 'Direction:',
'sortFieldTitle': 'Select the nested field by which to sort the array or object', sortFieldTitle: 'Select the nested field by which to sort the array or object',
'sortAscending': 'Ascending', sortAscending: 'Ascending',
'sortAscendingTitle': 'Sort the selected field in ascending order', sortAscendingTitle: 'Sort the selected field in ascending order',
'sortDescending': 'Descending', sortDescending: 'Descending',
'sortDescendingTitle': 'Sort the selected field in descending order', sortDescendingTitle: 'Sort the selected field in descending order',
'string': 'String', string: 'String',
'transform': 'Transform', transform: 'Transform',
'transformTitle': 'Filter, sort, or transform the childs of this ${type}', transformTitle: 'Filter, sort, or transform the childs of this ${type}',
'transformTitleShort': 'Filter, sort, or transform contents', transformTitleShort: 'Filter, sort, or transform contents',
'transformQueryTitle': 'Enter a JMESPath query', transformQueryTitle: 'Enter a JMESPath query',
'transformWizardLabel': 'Wizard', transformWizardLabel: 'Wizard',
'transformWizardFilter': 'Filter', transformWizardFilter: 'Filter',
'transformWizardSortBy': 'Sort by', transformWizardSortBy: 'Sort by',
'transformWizardSelectFields': 'Select fields', transformWizardSelectFields: 'Select fields',
'transformQueryLabel': 'Query', transformQueryLabel: 'Query',
'transformPreviewLabel': 'Preview', transformPreviewLabel: 'Preview',
'type': 'Type', type: 'Type',
'typeTitle': 'Change the type of this field', typeTitle: 'Change the type of this field',
'openUrl': 'Ctrl+Click or Ctrl+Enter to open url in new window', openUrl: 'Ctrl+Click or Ctrl+Enter to open url in new window',
'undo': 'Undo last action (Ctrl+Z)', undo: 'Undo last action (Ctrl+Z)',
'validationCannotMove': 'Cannot move a field into a child of itself', validationCannotMove: 'Cannot move a field into a child of itself',
'autoType': 'Field type "auto". ' + autoType: 'Field type "auto". ' +
'The field type is automatically determined from the value ' + 'The field type is automatically determined from the value ' +
'and can be a string, number, boolean, or null.', 'and can be a string, number, boolean, or null.',
'objectType': 'Field type "object". ' + objectType: 'Field type "object". ' +
'An object contains an unordered set of key/value pairs.', 'An object contains an unordered set of key/value pairs.',
'arrayType': 'Field type "array". ' + arrayType: 'Field type "array". ' +
'An array contains an ordered collection of values.', 'An array contains an ordered collection of values.',
'stringType': 'Field type "string". ' + stringType: 'Field type "string". ' +
'Field type is not determined from the value, ' + 'Field type is not determined from the value, ' +
'but always returned as string.' 'but always returned as string.',
modeCodeText: 'Code',
modeCodeTitle: 'Switch to code highlighter',
modeFormText: 'Form',
modeFormTitle: 'Switch to form editor',
modeTextText: 'Text',
modeTextTitle: 'Switch to plain text editor',
modeTreeText: 'Tree',
modeTreeTitle: 'Switch to tree editor',
modeViewText: 'View',
modeViewTitle: 'Switch to tree view',
}, },
'pt-BR': { 'pt-BR': {
'array': 'Lista', array: 'Lista',
'auto': 'Automatico', auto: 'Automatico',
'appendText': 'Adicionar', appendText: 'Adicionar',
'appendTitle': 'Adicionar novo campo com tipo \'auto\' depois deste campo (Ctrl+Shift+Ins)', appendTitle: 'Adicionar novo campo com tipo \'auto\' depois deste campo (Ctrl+Shift+Ins)',
'appendSubmenuTitle': 'Selecione o tipo do campo a ser adicionado', appendSubmenuTitle: 'Selecione o tipo do campo a ser adicionado',
'appendTitleAuto': 'Adicionar novo campo com tipo \'auto\' (Ctrl+Shift+Ins)', appendTitleAuto: 'Adicionar novo campo com tipo \'auto\' (Ctrl+Shift+Ins)',
'ascending': 'Ascendente', ascending: 'Ascendente',
'ascendingTitle': 'Organizar filhor do tipo ${type} em crescente', ascendingTitle: 'Organizar filhor do tipo ${type} em crescente',
'actionsMenu': 'Clique para abrir o menu de ações (Ctrl+M)', actionsMenu: 'Clique para abrir o menu de ações (Ctrl+M)',
'collapseAll': 'Fechar todos campos', collapseAll: 'Fechar todos campos',
'descending': 'Descendente', descending: 'Descendente',
'descendingTitle': 'Organizar o filhos do tipo ${type} em decrescente', descendingTitle: 'Organizar o filhos do tipo ${type} em decrescente',
'duplicateKey': 'chave duplicada', duplicateKey: 'chave duplicada',
'drag': 'Arraste para mover este campo (Alt+Shift+Arrows)', drag: 'Arraste para mover este campo (Alt+Shift+Arrows)',
'duplicateText': 'Duplicar', duplicateText: 'Duplicar',
'duplicateTitle': 'Duplicar campos selecionados (Ctrl+D)', duplicateTitle: 'Duplicar campos selecionados (Ctrl+D)',
'duplicateField': 'Duplicar este campo (Ctrl+D)', duplicateField: 'Duplicar este campo (Ctrl+D)',
'empty': 'vazio', empty: 'vazio',
'expandAll': 'Expandir todos campos', expandAll: 'Expandir todos campos',
'expandTitle': 'Clique para expandir/encolher este campo (Ctrl+E). \n' + expandTitle: 'Clique para expandir/encolher este campo (Ctrl+E). \n' +
'Ctrl+Click para expandir/encolher incluindo todos os filhos.', 'Ctrl+Click para expandir/encolher incluindo todos os filhos.',
'insert': 'Inserir', insert: 'Inserir',
'insertTitle': 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)', insertTitle: 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)',
'insertSub': 'Selecionar o tipo de campo a ser inserido', insertSub: 'Selecionar o tipo de campo a ser inserido',
'object': 'Objeto', object: 'Objeto',
'ok': 'Ok', ok: 'Ok',
'redo': 'Refazer (Ctrl+Shift+Z)', redo: 'Refazer (Ctrl+Shift+Z)',
'removeText': 'Remover', removeText: 'Remover',
'removeTitle': 'Remover campos selecionados (Ctrl+Del)', removeTitle: 'Remover campos selecionados (Ctrl+Del)',
'removeField': 'Remover este campo (Ctrl+Del)', removeField: 'Remover este campo (Ctrl+Del)',
// TODO: correctly translate // TODO: correctly translate
'selectNode': 'Select a node...', selectNode: 'Select a node...',
// TODO: correctly translate // TODO: correctly translate
'showAll': 'mostre tudo', showAll: 'mostre tudo',
// TODO: correctly translate // TODO: correctly translate
'showMore': 'mostre mais', showMore: 'mostre mais',
// TODO: correctly translate // TODO: correctly translate
'showMoreStatus': 'exibindo ${visibleChilds} de ${totalChilds} itens.', showMoreStatus: 'exibindo ${visibleChilds} de ${totalChilds} itens.',
'sort': 'Organizar', sort: 'Organizar',
'sortTitle': 'Organizar os filhos deste ${type}', sortTitle: 'Organizar os filhos deste ${type}',
// TODO: correctly translate // TODO: correctly translate
'sortTitleShort': 'Organizar os filhos', sortTitleShort: 'Organizar os filhos',
// TODO: correctly translate // TODO: correctly translate
'sortFieldLabel': 'Field:', sortFieldLabel: 'Field:',
// TODO: correctly translate // TODO: correctly translate
'sortDirectionLabel': 'Direction:', sortDirectionLabel: 'Direction:',
// TODO: correctly translate // TODO: correctly translate
'sortFieldTitle': 'Select the nested field by which to sort the array or object', sortFieldTitle: 'Select the nested field by which to sort the array or object',
// TODO: correctly translate // TODO: correctly translate
'sortAscending': 'Ascending', sortAscending: 'Ascending',
// TODO: correctly translate // TODO: correctly translate
'sortAscendingTitle': 'Sort the selected field in ascending order', sortAscendingTitle: 'Sort the selected field in ascending order',
// TODO: correctly translate // TODO: correctly translate
'sortDescending': 'Descending', sortDescending: 'Descending',
// TODO: correctly translate // TODO: correctly translate
'sortDescendingTitle': 'Sort the selected field in descending order', sortDescendingTitle: 'Sort the selected field in descending order',
'string': 'Texto', string: 'Texto',
// TODO: correctly translate // TODO: correctly translate
'transform': 'Transform', transform: 'Transform',
// TODO: correctly translate // TODO: correctly translate
'transformTitle': 'Filter, sort, or transform the childs of this ${type}', transformTitle: 'Filter, sort, or transform the childs of this ${type}',
// TODO: correctly translate // TODO: correctly translate
'transformTitleShort': 'Filter, sort, or transform contents', transformTitleShort: 'Filter, sort, or transform contents',
// TODO: correctly translate // TODO: correctly translate
'transformQueryTitle': 'Enter a JMESPath query', transformQueryTitle: 'Enter a JMESPath query',
// TODO: correctly translate // TODO: correctly translate
'transformWizardLabel': 'Wizard', transformWizardLabel: 'Wizard',
// TODO: correctly translate // TODO: correctly translate
'transformWizardFilter': 'Filter', transformWizardFilter: 'Filter',
// TODO: correctly translate // TODO: correctly translate
'transformWizardSortBy': 'Sort by', transformWizardSortBy: 'Sort by',
// TODO: correctly translate // TODO: correctly translate
'transformWizardSelectFields': 'Select fields', transformWizardSelectFields: 'Select fields',
// TODO: correctly translate // TODO: correctly translate
'transformQueryLabel': 'Query', transformQueryLabel: 'Query',
// TODO: correctly translate // TODO: correctly translate
'transformPreviewLabel': 'Preview', transformPreviewLabel: 'Preview',
'type': 'Tipo', type: 'Tipo',
'typeTitle': 'Mudar o tipo deste campo', typeTitle: 'Mudar o tipo deste campo',
'openUrl': 'Ctrl+Click ou Ctrl+Enter para abrir link em nova janela', openUrl: 'Ctrl+Click ou Ctrl+Enter para abrir link em nova janela',
'undo': 'Desfazer último ação (Ctrl+Z)', undo: 'Desfazer último ação (Ctrl+Z)',
'validationCannotMove': 'Não pode mover um campo como filho dele mesmo', validationCannotMove: 'Não pode mover um campo como filho dele mesmo',
'autoType': 'Campo do tipo "auto". ' + autoType: 'Campo do tipo "auto". ' +
'O tipo do campo é determinao automaticamente a partir do seu valor ' + 'O tipo do campo é determinao automaticamente a partir do seu valor ' +
'e pode ser texto, número, verdade/falso ou nulo.', 'e pode ser texto, número, verdade/falso ou nulo.',
'objectType': 'Campo do tipo "objeto". ' + objectType: 'Campo do tipo "objeto". ' +
'Um objeto contém uma lista de pares com chave e valor.', 'Um objeto contém uma lista de pares com chave e valor.',
'arrayType': 'Campo do tipo "lista". ' + arrayType: 'Campo do tipo "lista". ' +
'Uma lista contem uma coleção de valores ordenados.', 'Uma lista contem uma coleção de valores ordenados.',
'stringType': 'Campo do tipo "string". ' + stringType: 'Campo do tipo "string". ' +
'Campo do tipo nao é determinado através do seu valor, ' + 'Campo do tipo nao é determinado através do seu valor, ' +
'mas sempre retornara um texto.' 'mas sempre retornara um texto.'
} }
}; };
var _defaultLang = 'en'; var _defaultLang = 'en';
var _lang; var _lang;
var userLang = typeof navigator !== 'undefined' var userLang = typeof navigator !== 'undefined' ?
? navigator.language || navigator.userLanguage navigator.language || navigator.userLanguage :
: undefined; undefined;
_lang = _locales.find(function (l) { _lang = _locales.find(function (l) {
return l === userLang; return l === userLang;
}); });
@ -9346,13 +9365,12 @@ return /******/ (function(modules) { // webpackBootstrap
// apply value to DOM // apply value to DOM
var domValue = this.dom.value; var domValue = this.dom.value;
if (domValue) { if (domValue) {
var count = this.childs ? this.childs.length : 0;
if (this.type == 'array') { if (this.type == 'array') {
domValue.innerHTML = '[' + count + ']'; this.updateNodeName();
util.addClassName(this.dom.tr, 'jsoneditor-expandable'); util.addClassName(this.dom.tr, 'jsoneditor-expandable');
} }
else if (this.type == 'object') { else if (this.type == 'object') {
domValue.innerHTML = '{' + count + '}'; this.updateNodeName();
util.addClassName(this.dom.tr, 'jsoneditor-expandable'); util.addClassName(this.dom.tr, 'jsoneditor-expandable');
} }
else { else {
@ -11352,6 +11370,49 @@ return /******/ (function(modules) { // webpackBootstrap
return escaped; return escaped;
}; };
/**
* update the object name according to the callback onNodeName
* @private
*/
Node.prototype.updateNodeName = function () {
var count = this.childs ? this.childs.length : 0;
var nodeName;
if (this.type === 'object' || this.type === 'array') {
if (this.editor.options.onNodeName) {
try {
nodeName = this.editor.options.onNodeName({
path: this.getPath(),
size: count,
type: this.type
});
}
catch (err) {
console.error('Error in onNodeName callback: ', err);
}
}
this.dom.value.innerHTML = (this.type === 'object')
? ('{' + (nodeName || count) + '}')
: ('[' + (nodeName || count) + ']');
}
}
/**
* update recursively the object's and its children's name.
* @private
*/
Node.prototype.recursivelyUpdateNodeName = function () {
if (this.expanded) {
this.updateNodeName();
if (this.childs !== 'undefined') {
var i;
for (i in this.childs) {
this.childs[i].recursivelyUpdateNodeName();
}
}
}
}
// helper function to get the internal path of a node // helper function to get the internal path of a node
function getInternalPath (node) { function getInternalPath (node) {
return node.getInternalPath(); return node.getInternalPath();
@ -16734,6 +16795,7 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict'; 'use strict';
var ContextMenu = __webpack_require__(10); var ContextMenu = __webpack_require__(10);
var translate = __webpack_require__(15).translate;
/** /**
* Create a select box to be used in the editor menu's, which allows to switch mode * Create a select box to be used in the editor menu's, which allows to switch mode
@ -16747,36 +16809,36 @@ return /******/ (function(modules) { // webpackBootstrap
// available modes // available modes
var availableModes = { var availableModes = {
code: { code: {
'text': 'Code', 'text': translate('modeCodeText'),
'title': 'Switch to code highlighter', 'title': translate('modeCodeTitle'),
'click': function () { 'click': function () {
onSwitch('code') onSwitch('code')
} }
}, },
form: { form: {
'text': 'Form', 'text': translate('modeFormText'),
'title': 'Switch to form editor', 'title': translate('modeFormTitle'),
'click': function () { 'click': function () {
onSwitch('form'); onSwitch('form');
} }
}, },
text: { text: {
'text': 'Text', 'text': translate('modeTextText'),
'title': 'Switch to plain text editor', 'title': translate('modeTextTitle'),
'click': function () { 'click': function () {
onSwitch('text'); onSwitch('text');
} }
}, },
tree: { tree: {
'text': 'Tree', 'text': translate('modeTreeText'),
'title': 'Switch to tree editor', 'title': translate('modeTreeTitle'),
'click': function () { 'click': function () {
onSwitch('tree'); onSwitch('tree');
} }
}, },
view: { view: {
'text': 'View', 'text': translate('modeViewText'),
'title': 'Switch to tree view', 'title': translate('modeViewTitle'),
'click': function () { 'click': function () {
onSwitch('view'); onSwitch('view');
} }
@ -16847,7 +16909,6 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = ModeSwitcher; module.exports = ModeSwitcher;
/***/ }, /***/ },
/* 27 */ /* 27 */
/***/ function(module, exports) { /***/ function(module, exports) {
@ -17336,6 +17397,11 @@ return /******/ (function(modules) { // webpackBootstrap
this.validateSchema = null; this.validateSchema = null;
this.validationSequence = 0; this.validationSequence = 0;
this.annotations = []; this.annotations = [];
/**
* Visibility of validation error table
* @type {Boolean|undefined} undefined means default behavior for mode
*/
this.errorTableVisible = undefined;
// create a debounced validate function // create a debounced validate function
this._debouncedValidate = util.debounce(this.validate.bind(this), this.DEBOUNCE_INTERVAL); this._debouncedValidate = util.debounce(this.validate.bind(this), this.DEBOUNCE_INTERVAL);
@ -18035,7 +18101,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
else { else {
this._renderErrors(parseErrors || []); this._renderErrors(parseErrors || [], true);
} }
}; };
@ -18088,11 +18154,13 @@ return /******/ (function(modules) { // webpackBootstrap
return Promise.resolve(null); return Promise.resolve(null);
}; };
textmode._renderErrors = function(errors) { textmode._renderErrors = function(errors, noValidation) {
// clear all current errors // clear all current errors
var me = this; var me = this;
var validationErrorsCount = 0; var validationErrorsCount = 0;
this.errorTableVisible = (typeof this.errorTableVisible === 'undefined') ? !this.aceEditor : this.errorTableVisible;
if (this.dom.validationErrors) { if (this.dom.validationErrors) {
this.dom.validationErrors.parentNode.removeChild(this.dom.validationErrors); this.dom.validationErrors.parentNode.removeChild(this.dom.validationErrors);
this.dom.validationErrors = null; this.dom.validationErrors = null;
@ -18132,8 +18200,11 @@ return /******/ (function(modules) { // webpackBootstrap
}); });
this._refreshAnnotations(); this._refreshAnnotations();
} else { }
var validationErrors = document.createElement('div');
// keep default behavior for parse errors
if (noValidation ? !this.aceEditor : this.errorTableVisible) {
var validationErrors = document.createElement('div');
validationErrors.innerHTML = '<table class="jsoneditor-text-errors"><tbody></tbody></table>'; validationErrors.innerHTML = '<table class="jsoneditor-text-errors"><tbody></tbody></table>';
var tbody = validationErrors.getElementsByTagName('tbody')[0]; var tbody = validationErrors.getElementsByTagName('tbody')[0];
@ -18196,7 +18267,10 @@ return /******/ (function(modules) { // webpackBootstrap
var height = this.dom.validationErrorsContainer.clientHeight + (this.dom.statusBar ? this.dom.statusBar.clientHeight : 0); var height = this.dom.validationErrorsContainer.clientHeight + (this.dom.statusBar ? this.dom.statusBar.clientHeight : 0);
this.content.style.marginBottom = (-height) + 'px'; this.content.style.marginBottom = (-height) + 'px';
this.content.style.paddingBottom = height + 'px'; this.content.style.paddingBottom = height + 'px';
} else {
validationErrorsCount = errors.reduce(function (acc, curr) {return (curr.type === 'validation' ? ++acc: acc)}, 0);
} }
} else { } else {
if (this.aceEditor) { if (this.aceEditor) {
this.annotations = []; this.annotations = [];
@ -18212,6 +18286,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (showIndication) { if (showIndication) {
this.validationErrorIndication.validationErrorCount.innerText = validationErrorsCount; this.validationErrorIndication.validationErrorCount.innerText = validationErrorsCount;
this.validationErrorIndication.validationErrorIcon.title = validationErrorsCount + ' schema validation error(s) found'; this.validationErrorIndication.validationErrorIcon.title = validationErrorsCount + ' schema validation error(s) found';
this.validationErrorIndication.validationErrorCount.onclick = this.validationErrorIndication.validationErrorIcon.onclick = this._toggleErrorTableVisibility.bind(this);
} }
} }
@ -18222,6 +18297,11 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
textmode._toggleErrorTableVisibility = function () {
this.errorTableVisible = !this.errorTableVisible;
this.validate();
};
/** /**
* Get the selection details * Get the selection details
* @returns {{start:{row:Number, column:Number},end:{row:Number, column:Number},text:String}} * @returns {{start:{row:Number, column:Number},end:{row:Number, column:Number},text:String}}
@ -18326,6 +18406,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
this.aceEditor.selection.setRange(range); this.aceEditor.selection.setRange(range);
this.aceEditor.scrollToLine(startPos.row - 1, true);
} }
}; };

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

@ -1429,11 +1429,13 @@ div.jsoneditor-statusbar > .jsoneditor-validation-error-icon {
padding: 0; padding: 0;
margin-top: 1px; margin-top: 1px;
background: url("img/jsoneditor-icons.svg") -168px -48px; background: url("img/jsoneditor-icons.svg") -168px -48px;
cursor: pointer;
} }
div.jsoneditor-statusbar > .jsoneditor-validation-error-count { div.jsoneditor-statusbar > .jsoneditor-validation-error-count {
float: right; float: right;
margin: 0 4px 0 0; margin: 0 4px 0 0;
cursor: pointer;
} }
div.jsoneditor-statusbar > .jsoneditor-parse-error-icon { div.jsoneditor-statusbar > .jsoneditor-parse-error-icon {

411
dist/jsoneditor.js vendored
View File

@ -21,11 +21,11 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
* *
* Copyright (c) 2011-2018 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.26.3 * @version 5.27.0
* @date 2018-12-06 * @date 2019-01-05
*/ */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
@ -247,7 +247,7 @@ return /******/ (function(modules) { // webpackBootstrap
'ajv', 'schema', 'schemaRefs','templates', 'ajv', 'schema', 'schemaRefs','templates',
'ace', 'theme', 'autocomplete', 'ace', 'theme', 'autocomplete',
'onChange', 'onChangeJSON', 'onChangeText', 'onChange', 'onChangeJSON', 'onChangeText',
'onEditable', 'onError', 'onEvent', 'onModeChange', 'onValidate', 'onEditable', 'onError', 'onEvent', 'onModeChange', 'onNodeName', 'onValidate',
'onSelectionChange', 'onTextSelectionChange', 'onSelectionChange', 'onTextSelectionChange',
'colorPicker', 'onColorPicker', 'colorPicker', 'onColorPicker',
'timestampTag', 'timestampTag',
@ -30642,6 +30642,15 @@ return /******/ (function(modules) { // webpackBootstrap
console.error('Error in onChangeText callback: ', err); console.error('Error in onChangeText callback: ', err);
} }
} }
// trigger the onNodeName callback
if (this.options.onNodeName && this.node.childs) {
try {
this.node.recursivelyUpdateNodeName();
} catch (err) {
console.error("Error in onNodeName callback: ", err);
}
}
}; };
/** /**
@ -35182,178 +35191,188 @@ return /******/ (function(modules) { // webpackBootstrap
var _locales = ['en', 'pt-BR']; var _locales = ['en', 'pt-BR'];
var _defs = { var _defs = {
en: { en: {
'array': 'Array', array: 'Array',
'auto': 'Auto', auto: 'Auto',
'appendText': 'Append', appendText: 'Append',
'appendTitle': 'Append a new field with type \'auto\' after this field (Ctrl+Shift+Ins)', appendTitle: 'Append a new field with type \'auto\' after this field (Ctrl+Shift+Ins)',
'appendSubmenuTitle': 'Select the type of the field to be appended', appendSubmenuTitle: 'Select the type of the field to be appended',
'appendTitleAuto': 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)', appendTitleAuto: 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)',
'ascending': 'Ascending', ascending: 'Ascending',
'ascendingTitle': 'Sort the childs of this ${type} in ascending order', ascendingTitle: 'Sort the childs of this ${type} in ascending order',
'actionsMenu': 'Click to open the actions menu (Ctrl+M)', actionsMenu: 'Click to open the actions menu (Ctrl+M)',
'collapseAll': 'Collapse all fields', collapseAll: 'Collapse all fields',
'descending': 'Descending', descending: 'Descending',
'descendingTitle': 'Sort the childs of this ${type} in descending order', descendingTitle: 'Sort the childs of this ${type} in descending order',
'drag': 'Drag to move this field (Alt+Shift+Arrows)', drag: 'Drag to move this field (Alt+Shift+Arrows)',
'duplicateKey': 'duplicate key', duplicateKey: 'duplicate key',
'duplicateText': 'Duplicate', duplicateText: 'Duplicate',
'duplicateTitle': 'Duplicate selected fields (Ctrl+D)', duplicateTitle: 'Duplicate selected fields (Ctrl+D)',
'duplicateField': 'Duplicate this field (Ctrl+D)', duplicateField: 'Duplicate this field (Ctrl+D)',
'empty': 'empty', empty: 'empty',
'expandAll': 'Expand all fields', expandAll: 'Expand all fields',
'expandTitle': 'Click to expand/collapse this field (Ctrl+E). \n' + expandTitle: 'Click to expand/collapse this field (Ctrl+E). \n' +
'Ctrl+Click to expand/collapse including all childs.', 'Ctrl+Click to expand/collapse including all childs.',
'insert': 'Insert', insert: 'Insert',
'insertTitle': 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)', insertTitle: 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)',
'insertSub': 'Select the type of the field to be inserted', insertSub: 'Select the type of the field to be inserted',
'object': 'Object', object: 'Object',
'ok': 'Ok', ok: 'Ok',
'redo': 'Redo (Ctrl+Shift+Z)', redo: 'Redo (Ctrl+Shift+Z)',
'removeText': 'Remove', removeText: 'Remove',
'removeTitle': 'Remove selected fields (Ctrl+Del)', removeTitle: 'Remove selected fields (Ctrl+Del)',
'removeField': 'Remove this field (Ctrl+Del)', removeField: 'Remove this field (Ctrl+Del)',
'selectNode': 'Select a node...', selectNode: 'Select a node...',
'showAll': 'show all', showAll: 'show all',
'showMore': 'show more', showMore: 'show more',
'showMoreStatus': 'displaying ${visibleChilds} of ${totalChilds} items.', showMoreStatus: 'displaying ${visibleChilds} of ${totalChilds} items.',
'sort': 'Sort', sort: 'Sort',
'sortTitle': 'Sort the childs of this ${type}', sortTitle: 'Sort the childs of this ${type}',
'sortTitleShort': 'Sort contents', sortTitleShort: 'Sort contents',
'sortFieldLabel': 'Field:', sortFieldLabel: 'Field:',
'sortDirectionLabel': 'Direction:', sortDirectionLabel: 'Direction:',
'sortFieldTitle': 'Select the nested field by which to sort the array or object', sortFieldTitle: 'Select the nested field by which to sort the array or object',
'sortAscending': 'Ascending', sortAscending: 'Ascending',
'sortAscendingTitle': 'Sort the selected field in ascending order', sortAscendingTitle: 'Sort the selected field in ascending order',
'sortDescending': 'Descending', sortDescending: 'Descending',
'sortDescendingTitle': 'Sort the selected field in descending order', sortDescendingTitle: 'Sort the selected field in descending order',
'string': 'String', string: 'String',
'transform': 'Transform', transform: 'Transform',
'transformTitle': 'Filter, sort, or transform the childs of this ${type}', transformTitle: 'Filter, sort, or transform the childs of this ${type}',
'transformTitleShort': 'Filter, sort, or transform contents', transformTitleShort: 'Filter, sort, or transform contents',
'transformQueryTitle': 'Enter a JMESPath query', transformQueryTitle: 'Enter a JMESPath query',
'transformWizardLabel': 'Wizard', transformWizardLabel: 'Wizard',
'transformWizardFilter': 'Filter', transformWizardFilter: 'Filter',
'transformWizardSortBy': 'Sort by', transformWizardSortBy: 'Sort by',
'transformWizardSelectFields': 'Select fields', transformWizardSelectFields: 'Select fields',
'transformQueryLabel': 'Query', transformQueryLabel: 'Query',
'transformPreviewLabel': 'Preview', transformPreviewLabel: 'Preview',
'type': 'Type', type: 'Type',
'typeTitle': 'Change the type of this field', typeTitle: 'Change the type of this field',
'openUrl': 'Ctrl+Click or Ctrl+Enter to open url in new window', openUrl: 'Ctrl+Click or Ctrl+Enter to open url in new window',
'undo': 'Undo last action (Ctrl+Z)', undo: 'Undo last action (Ctrl+Z)',
'validationCannotMove': 'Cannot move a field into a child of itself', validationCannotMove: 'Cannot move a field into a child of itself',
'autoType': 'Field type "auto". ' + autoType: 'Field type "auto". ' +
'The field type is automatically determined from the value ' + 'The field type is automatically determined from the value ' +
'and can be a string, number, boolean, or null.', 'and can be a string, number, boolean, or null.',
'objectType': 'Field type "object". ' + objectType: 'Field type "object". ' +
'An object contains an unordered set of key/value pairs.', 'An object contains an unordered set of key/value pairs.',
'arrayType': 'Field type "array". ' + arrayType: 'Field type "array". ' +
'An array contains an ordered collection of values.', 'An array contains an ordered collection of values.',
'stringType': 'Field type "string". ' + stringType: 'Field type "string". ' +
'Field type is not determined from the value, ' + 'Field type is not determined from the value, ' +
'but always returned as string.' 'but always returned as string.',
modeCodeText: 'Code',
modeCodeTitle: 'Switch to code highlighter',
modeFormText: 'Form',
modeFormTitle: 'Switch to form editor',
modeTextText: 'Text',
modeTextTitle: 'Switch to plain text editor',
modeTreeText: 'Tree',
modeTreeTitle: 'Switch to tree editor',
modeViewText: 'View',
modeViewTitle: 'Switch to tree view',
}, },
'pt-BR': { 'pt-BR': {
'array': 'Lista', array: 'Lista',
'auto': 'Automatico', auto: 'Automatico',
'appendText': 'Adicionar', appendText: 'Adicionar',
'appendTitle': 'Adicionar novo campo com tipo \'auto\' depois deste campo (Ctrl+Shift+Ins)', appendTitle: 'Adicionar novo campo com tipo \'auto\' depois deste campo (Ctrl+Shift+Ins)',
'appendSubmenuTitle': 'Selecione o tipo do campo a ser adicionado', appendSubmenuTitle: 'Selecione o tipo do campo a ser adicionado',
'appendTitleAuto': 'Adicionar novo campo com tipo \'auto\' (Ctrl+Shift+Ins)', appendTitleAuto: 'Adicionar novo campo com tipo \'auto\' (Ctrl+Shift+Ins)',
'ascending': 'Ascendente', ascending: 'Ascendente',
'ascendingTitle': 'Organizar filhor do tipo ${type} em crescente', ascendingTitle: 'Organizar filhor do tipo ${type} em crescente',
'actionsMenu': 'Clique para abrir o menu de ações (Ctrl+M)', actionsMenu: 'Clique para abrir o menu de ações (Ctrl+M)',
'collapseAll': 'Fechar todos campos', collapseAll: 'Fechar todos campos',
'descending': 'Descendente', descending: 'Descendente',
'descendingTitle': 'Organizar o filhos do tipo ${type} em decrescente', descendingTitle: 'Organizar o filhos do tipo ${type} em decrescente',
'duplicateKey': 'chave duplicada', duplicateKey: 'chave duplicada',
'drag': 'Arraste para mover este campo (Alt+Shift+Arrows)', drag: 'Arraste para mover este campo (Alt+Shift+Arrows)',
'duplicateText': 'Duplicar', duplicateText: 'Duplicar',
'duplicateTitle': 'Duplicar campos selecionados (Ctrl+D)', duplicateTitle: 'Duplicar campos selecionados (Ctrl+D)',
'duplicateField': 'Duplicar este campo (Ctrl+D)', duplicateField: 'Duplicar este campo (Ctrl+D)',
'empty': 'vazio', empty: 'vazio',
'expandAll': 'Expandir todos campos', expandAll: 'Expandir todos campos',
'expandTitle': 'Clique para expandir/encolher este campo (Ctrl+E). \n' + expandTitle: 'Clique para expandir/encolher este campo (Ctrl+E). \n' +
'Ctrl+Click para expandir/encolher incluindo todos os filhos.', 'Ctrl+Click para expandir/encolher incluindo todos os filhos.',
'insert': 'Inserir', insert: 'Inserir',
'insertTitle': 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)', insertTitle: 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)',
'insertSub': 'Selecionar o tipo de campo a ser inserido', insertSub: 'Selecionar o tipo de campo a ser inserido',
'object': 'Objeto', object: 'Objeto',
'ok': 'Ok', ok: 'Ok',
'redo': 'Refazer (Ctrl+Shift+Z)', redo: 'Refazer (Ctrl+Shift+Z)',
'removeText': 'Remover', removeText: 'Remover',
'removeTitle': 'Remover campos selecionados (Ctrl+Del)', removeTitle: 'Remover campos selecionados (Ctrl+Del)',
'removeField': 'Remover este campo (Ctrl+Del)', removeField: 'Remover este campo (Ctrl+Del)',
// TODO: correctly translate // TODO: correctly translate
'selectNode': 'Select a node...', selectNode: 'Select a node...',
// TODO: correctly translate // TODO: correctly translate
'showAll': 'mostre tudo', showAll: 'mostre tudo',
// TODO: correctly translate // TODO: correctly translate
'showMore': 'mostre mais', showMore: 'mostre mais',
// TODO: correctly translate // TODO: correctly translate
'showMoreStatus': 'exibindo ${visibleChilds} de ${totalChilds} itens.', showMoreStatus: 'exibindo ${visibleChilds} de ${totalChilds} itens.',
'sort': 'Organizar', sort: 'Organizar',
'sortTitle': 'Organizar os filhos deste ${type}', sortTitle: 'Organizar os filhos deste ${type}',
// TODO: correctly translate // TODO: correctly translate
'sortTitleShort': 'Organizar os filhos', sortTitleShort: 'Organizar os filhos',
// TODO: correctly translate // TODO: correctly translate
'sortFieldLabel': 'Field:', sortFieldLabel: 'Field:',
// TODO: correctly translate // TODO: correctly translate
'sortDirectionLabel': 'Direction:', sortDirectionLabel: 'Direction:',
// TODO: correctly translate // TODO: correctly translate
'sortFieldTitle': 'Select the nested field by which to sort the array or object', sortFieldTitle: 'Select the nested field by which to sort the array or object',
// TODO: correctly translate // TODO: correctly translate
'sortAscending': 'Ascending', sortAscending: 'Ascending',
// TODO: correctly translate // TODO: correctly translate
'sortAscendingTitle': 'Sort the selected field in ascending order', sortAscendingTitle: 'Sort the selected field in ascending order',
// TODO: correctly translate // TODO: correctly translate
'sortDescending': 'Descending', sortDescending: 'Descending',
// TODO: correctly translate // TODO: correctly translate
'sortDescendingTitle': 'Sort the selected field in descending order', sortDescendingTitle: 'Sort the selected field in descending order',
'string': 'Texto', string: 'Texto',
// TODO: correctly translate // TODO: correctly translate
'transform': 'Transform', transform: 'Transform',
// TODO: correctly translate // TODO: correctly translate
'transformTitle': 'Filter, sort, or transform the childs of this ${type}', transformTitle: 'Filter, sort, or transform the childs of this ${type}',
// TODO: correctly translate // TODO: correctly translate
'transformTitleShort': 'Filter, sort, or transform contents', transformTitleShort: 'Filter, sort, or transform contents',
// TODO: correctly translate // TODO: correctly translate
'transformQueryTitle': 'Enter a JMESPath query', transformQueryTitle: 'Enter a JMESPath query',
// TODO: correctly translate // TODO: correctly translate
'transformWizardLabel': 'Wizard', transformWizardLabel: 'Wizard',
// TODO: correctly translate // TODO: correctly translate
'transformWizardFilter': 'Filter', transformWizardFilter: 'Filter',
// TODO: correctly translate // TODO: correctly translate
'transformWizardSortBy': 'Sort by', transformWizardSortBy: 'Sort by',
// TODO: correctly translate // TODO: correctly translate
'transformWizardSelectFields': 'Select fields', transformWizardSelectFields: 'Select fields',
// TODO: correctly translate // TODO: correctly translate
'transformQueryLabel': 'Query', transformQueryLabel: 'Query',
// TODO: correctly translate // TODO: correctly translate
'transformPreviewLabel': 'Preview', transformPreviewLabel: 'Preview',
'type': 'Tipo', type: 'Tipo',
'typeTitle': 'Mudar o tipo deste campo', typeTitle: 'Mudar o tipo deste campo',
'openUrl': 'Ctrl+Click ou Ctrl+Enter para abrir link em nova janela', openUrl: 'Ctrl+Click ou Ctrl+Enter para abrir link em nova janela',
'undo': 'Desfazer último ação (Ctrl+Z)', undo: 'Desfazer último ação (Ctrl+Z)',
'validationCannotMove': 'Não pode mover um campo como filho dele mesmo', validationCannotMove: 'Não pode mover um campo como filho dele mesmo',
'autoType': 'Campo do tipo "auto". ' + autoType: 'Campo do tipo "auto". ' +
'O tipo do campo é determinao automaticamente a partir do seu valor ' + 'O tipo do campo é determinao automaticamente a partir do seu valor ' +
'e pode ser texto, número, verdade/falso ou nulo.', 'e pode ser texto, número, verdade/falso ou nulo.',
'objectType': 'Campo do tipo "objeto". ' + objectType: 'Campo do tipo "objeto". ' +
'Um objeto contém uma lista de pares com chave e valor.', 'Um objeto contém uma lista de pares com chave e valor.',
'arrayType': 'Campo do tipo "lista". ' + arrayType: 'Campo do tipo "lista". ' +
'Uma lista contem uma coleção de valores ordenados.', 'Uma lista contem uma coleção de valores ordenados.',
'stringType': 'Campo do tipo "string". ' + stringType: 'Campo do tipo "string". ' +
'Campo do tipo nao é determinado através do seu valor, ' + 'Campo do tipo nao é determinado através do seu valor, ' +
'mas sempre retornara um texto.' 'mas sempre retornara um texto.'
} }
}; };
var _defaultLang = 'en'; var _defaultLang = 'en';
var _lang; var _lang;
var userLang = typeof navigator !== 'undefined' var userLang = typeof navigator !== 'undefined' ?
? navigator.language || navigator.userLanguage navigator.language || navigator.userLanguage :
: undefined; undefined;
_lang = _locales.find(function (l) { _lang = _locales.find(function (l) {
return l === userLang; return l === userLang;
}); });
@ -37988,13 +38007,12 @@ return /******/ (function(modules) { // webpackBootstrap
// apply value to DOM // apply value to DOM
var domValue = this.dom.value; var domValue = this.dom.value;
if (domValue) { if (domValue) {
var count = this.childs ? this.childs.length : 0;
if (this.type == 'array') { if (this.type == 'array') {
domValue.innerHTML = '[' + count + ']'; this.updateNodeName();
util.addClassName(this.dom.tr, 'jsoneditor-expandable'); util.addClassName(this.dom.tr, 'jsoneditor-expandable');
} }
else if (this.type == 'object') { else if (this.type == 'object') {
domValue.innerHTML = '{' + count + '}'; this.updateNodeName();
util.addClassName(this.dom.tr, 'jsoneditor-expandable'); util.addClassName(this.dom.tr, 'jsoneditor-expandable');
} }
else { else {
@ -39994,6 +40012,49 @@ return /******/ (function(modules) { // webpackBootstrap
return escaped; return escaped;
}; };
/**
* update the object name according to the callback onNodeName
* @private
*/
Node.prototype.updateNodeName = function () {
var count = this.childs ? this.childs.length : 0;
var nodeName;
if (this.type === 'object' || this.type === 'array') {
if (this.editor.options.onNodeName) {
try {
nodeName = this.editor.options.onNodeName({
path: this.getPath(),
size: count,
type: this.type
});
}
catch (err) {
console.error('Error in onNodeName callback: ', err);
}
}
this.dom.value.innerHTML = (this.type === 'object')
? ('{' + (nodeName || count) + '}')
: ('[' + (nodeName || count) + ']');
}
}
/**
* update recursively the object's and its children's name.
* @private
*/
Node.prototype.recursivelyUpdateNodeName = function () {
if (this.expanded) {
this.updateNodeName();
if (this.childs !== 'undefined') {
var i;
for (i in this.childs) {
this.childs[i].recursivelyUpdateNodeName();
}
}
}
}
// helper function to get the internal path of a node // helper function to get the internal path of a node
function getInternalPath (node) { function getInternalPath (node) {
return node.getInternalPath(); return node.getInternalPath();
@ -45376,6 +45437,7 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict'; 'use strict';
var ContextMenu = __webpack_require__(63); var ContextMenu = __webpack_require__(63);
var translate = __webpack_require__(68).translate;
/** /**
* Create a select box to be used in the editor menu's, which allows to switch mode * Create a select box to be used in the editor menu's, which allows to switch mode
@ -45389,36 +45451,36 @@ return /******/ (function(modules) { // webpackBootstrap
// available modes // available modes
var availableModes = { var availableModes = {
code: { code: {
'text': 'Code', 'text': translate('modeCodeText'),
'title': 'Switch to code highlighter', 'title': translate('modeCodeTitle'),
'click': function () { 'click': function () {
onSwitch('code') onSwitch('code')
} }
}, },
form: { form: {
'text': 'Form', 'text': translate('modeFormText'),
'title': 'Switch to form editor', 'title': translate('modeFormTitle'),
'click': function () { 'click': function () {
onSwitch('form'); onSwitch('form');
} }
}, },
text: { text: {
'text': 'Text', 'text': translate('modeTextText'),
'title': 'Switch to plain text editor', 'title': translate('modeTextTitle'),
'click': function () { 'click': function () {
onSwitch('text'); onSwitch('text');
} }
}, },
tree: { tree: {
'text': 'Tree', 'text': translate('modeTreeText'),
'title': 'Switch to tree editor', 'title': translate('modeTreeTitle'),
'click': function () { 'click': function () {
onSwitch('tree'); onSwitch('tree');
} }
}, },
view: { view: {
'text': 'View', 'text': translate('modeViewText'),
'title': 'Switch to tree view', 'title': translate('modeViewTitle'),
'click': function () { 'click': function () {
onSwitch('view'); onSwitch('view');
} }
@ -45489,7 +45551,6 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = ModeSwitcher; module.exports = ModeSwitcher;
/***/ }, /***/ },
/* 80 */ /* 80 */
/***/ function(module, exports) { /***/ function(module, exports) {
@ -45978,6 +46039,11 @@ return /******/ (function(modules) { // webpackBootstrap
this.validateSchema = null; this.validateSchema = null;
this.validationSequence = 0; this.validationSequence = 0;
this.annotations = []; this.annotations = [];
/**
* Visibility of validation error table
* @type {Boolean|undefined} undefined means default behavior for mode
*/
this.errorTableVisible = undefined;
// create a debounced validate function // create a debounced validate function
this._debouncedValidate = util.debounce(this.validate.bind(this), this.DEBOUNCE_INTERVAL); this._debouncedValidate = util.debounce(this.validate.bind(this), this.DEBOUNCE_INTERVAL);
@ -46677,7 +46743,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
} }
else { else {
this._renderErrors(parseErrors || []); this._renderErrors(parseErrors || [], true);
} }
}; };
@ -46730,11 +46796,13 @@ return /******/ (function(modules) { // webpackBootstrap
return Promise.resolve(null); return Promise.resolve(null);
}; };
textmode._renderErrors = function(errors) { textmode._renderErrors = function(errors, noValidation) {
// clear all current errors // clear all current errors
var me = this; var me = this;
var validationErrorsCount = 0; var validationErrorsCount = 0;
this.errorTableVisible = (typeof this.errorTableVisible === 'undefined') ? !this.aceEditor : this.errorTableVisible;
if (this.dom.validationErrors) { if (this.dom.validationErrors) {
this.dom.validationErrors.parentNode.removeChild(this.dom.validationErrors); this.dom.validationErrors.parentNode.removeChild(this.dom.validationErrors);
this.dom.validationErrors = null; this.dom.validationErrors = null;
@ -46774,8 +46842,11 @@ return /******/ (function(modules) { // webpackBootstrap
}); });
this._refreshAnnotations(); this._refreshAnnotations();
} else { }
var validationErrors = document.createElement('div');
// keep default behavior for parse errors
if (noValidation ? !this.aceEditor : this.errorTableVisible) {
var validationErrors = document.createElement('div');
validationErrors.innerHTML = '<table class="jsoneditor-text-errors"><tbody></tbody></table>'; validationErrors.innerHTML = '<table class="jsoneditor-text-errors"><tbody></tbody></table>';
var tbody = validationErrors.getElementsByTagName('tbody')[0]; var tbody = validationErrors.getElementsByTagName('tbody')[0];
@ -46838,7 +46909,10 @@ return /******/ (function(modules) { // webpackBootstrap
var height = this.dom.validationErrorsContainer.clientHeight + (this.dom.statusBar ? this.dom.statusBar.clientHeight : 0); var height = this.dom.validationErrorsContainer.clientHeight + (this.dom.statusBar ? this.dom.statusBar.clientHeight : 0);
this.content.style.marginBottom = (-height) + 'px'; this.content.style.marginBottom = (-height) + 'px';
this.content.style.paddingBottom = height + 'px'; this.content.style.paddingBottom = height + 'px';
} else {
validationErrorsCount = errors.reduce(function (acc, curr) {return (curr.type === 'validation' ? ++acc: acc)}, 0);
} }
} else { } else {
if (this.aceEditor) { if (this.aceEditor) {
this.annotations = []; this.annotations = [];
@ -46854,6 +46928,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (showIndication) { if (showIndication) {
this.validationErrorIndication.validationErrorCount.innerText = validationErrorsCount; this.validationErrorIndication.validationErrorCount.innerText = validationErrorsCount;
this.validationErrorIndication.validationErrorIcon.title = validationErrorsCount + ' schema validation error(s) found'; this.validationErrorIndication.validationErrorIcon.title = validationErrorsCount + ' schema validation error(s) found';
this.validationErrorIndication.validationErrorCount.onclick = this.validationErrorIndication.validationErrorIcon.onclick = this._toggleErrorTableVisibility.bind(this);
} }
} }
@ -46864,6 +46939,11 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
textmode._toggleErrorTableVisibility = function () {
this.errorTableVisible = !this.errorTableVisible;
this.validate();
};
/** /**
* Get the selection details * Get the selection details
* @returns {{start:{row:Number, column:Number},end:{row:Number, column:Number},text:String}} * @returns {{start:{row:Number, column:Number},end:{row:Number, column:Number},text:String}}
@ -46968,6 +47048,7 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}; };
this.aceEditor.selection.setRange(range); this.aceEditor.selection.setRange(range);
this.aceEditor.scrollToLine(startPos.row - 1, true);
} }
}; };

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

1548
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -21,7 +21,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
* *
* Copyright (c) 2011-2018 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 @@version * @version @@version