Released v5.0.1
This commit is contained in:
parent
593c6bd528
commit
4ad31c5bf1
|
@ -3,7 +3,7 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet released, version 5.0.1
|
||||
## 2015-12-31, version 5.0.1
|
||||
|
||||
- Fixed a bug in positioning of the context menu for multiple selected nodes.
|
||||
- Fixed #130: option `onEditable` not available in mode `form`.
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Copyright (c) 2011-2015 Jos de Jong, http://jsoneditoronline.org
|
||||
*
|
||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||
* @version 5.0.0
|
||||
* @version 5.0.1
|
||||
* @date 2015-12-31
|
||||
*/
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
|
@ -402,12 +402,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var Highlighter = __webpack_require__(5);
|
||||
var History = __webpack_require__(6);
|
||||
var SearchBox = __webpack_require__(7);
|
||||
var ContextMenu = __webpack_require__(8);
|
||||
var Node = __webpack_require__(9);
|
||||
var modeswitcher = __webpack_require__(4);
|
||||
var Highlighter = __webpack_require__(4);
|
||||
var History = __webpack_require__(5);
|
||||
var SearchBox = __webpack_require__(6);
|
||||
var ContextMenu = __webpack_require__(7);
|
||||
var Node = __webpack_require__(8);
|
||||
var modeswitcher = __webpack_require__(9);
|
||||
var util = __webpack_require__(3);
|
||||
|
||||
// create a mixin with the functions for tree mode
|
||||
|
@ -1057,7 +1057,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
if (node && node.selected) {
|
||||
if (event.type == 'click') {
|
||||
if (event.target == node.dom.menu) {
|
||||
this.showContextMenu(event.target.parentNode);
|
||||
this.showContextMenu(event.target);
|
||||
|
||||
// stop propagation (else we will open the context menu of a single node)
|
||||
return;
|
||||
|
@ -1467,7 +1467,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
// failed to load ace, no problem, we will fall back to plain text
|
||||
}
|
||||
|
||||
var modeswitcher = __webpack_require__(4);
|
||||
var modeswitcher = __webpack_require__(9);
|
||||
var util = __webpack_require__(3);
|
||||
|
||||
// create a mixin with the functions for text mode
|
||||
|
@ -2457,117 +2457,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
/***/ },
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var ContextMenu = __webpack_require__(8);
|
||||
|
||||
/**
|
||||
* Create a select box to be used in the editor menu's, which allows to switch mode
|
||||
* @param {Object} editor
|
||||
* @param {String[]} modes Available modes: 'code', 'form', 'text', 'tree', 'view'
|
||||
* @param {String} current Available modes: 'code', 'form', 'text', 'tree', 'view'
|
||||
* @returns {HTMLElement} box
|
||||
*/
|
||||
function createModeSwitcher(editor, modes, current) {
|
||||
// TODO: decouple mode switcher from editor
|
||||
|
||||
/**
|
||||
* Switch the mode of the editor
|
||||
* @param {String} mode
|
||||
*/
|
||||
function switchMode(mode) {
|
||||
// switch mode
|
||||
editor.setMode(mode);
|
||||
|
||||
// restore focus on mode box
|
||||
var modeBox = editor.dom && editor.dom.modeBox;
|
||||
if (modeBox) {
|
||||
modeBox.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// available modes
|
||||
var availableModes = {
|
||||
code: {
|
||||
'text': 'Code',
|
||||
'title': 'Switch to code highlighter',
|
||||
'click': function () {
|
||||
switchMode('code')
|
||||
}
|
||||
},
|
||||
form: {
|
||||
'text': 'Form',
|
||||
'title': 'Switch to form editor',
|
||||
'click': function () {
|
||||
switchMode('form');
|
||||
}
|
||||
},
|
||||
text: {
|
||||
'text': 'Text',
|
||||
'title': 'Switch to plain text editor',
|
||||
'click': function () {
|
||||
switchMode('text');
|
||||
}
|
||||
},
|
||||
tree: {
|
||||
'text': 'Tree',
|
||||
'title': 'Switch to tree editor',
|
||||
'click': function () {
|
||||
switchMode('tree');
|
||||
}
|
||||
},
|
||||
view: {
|
||||
'text': 'View',
|
||||
'title': 'Switch to tree view',
|
||||
'click': function () {
|
||||
switchMode('view');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// list the selected modes
|
||||
var items = [];
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
var mode = modes[i];
|
||||
var item = availableModes[mode];
|
||||
if (!item) {
|
||||
throw new Error('Unknown mode "' + mode + '"');
|
||||
}
|
||||
|
||||
item.className = 'jsoneditor-type-modes' + ((current == mode) ? ' jsoneditor-selected' : '');
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
// retrieve the title of current mode
|
||||
var currentMode = availableModes[current];
|
||||
if (!currentMode) {
|
||||
throw new Error('Unknown mode "' + current + '"');
|
||||
}
|
||||
var currentTitle = currentMode.text;
|
||||
|
||||
// create the html element
|
||||
var box = document.createElement('button');
|
||||
box.className = 'jsoneditor-modes jsoneditor-separator';
|
||||
box.innerHTML = currentTitle + ' ▾';
|
||||
box.title = 'Switch editor mode';
|
||||
box.onclick = function () {
|
||||
var menu = new ContextMenu(items);
|
||||
menu.show(box);
|
||||
};
|
||||
|
||||
var div = document.createElement('div');
|
||||
div.className = 'jsoneditor-modes';
|
||||
div.style.position = 'relative';
|
||||
div.appendChild(box);
|
||||
|
||||
return div;
|
||||
}
|
||||
|
||||
exports.create = createModeSwitcher;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/**
|
||||
|
@ -2657,7 +2546,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/* 5 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var util = __webpack_require__(3);
|
||||
|
@ -2915,7 +2804,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/**
|
||||
|
@ -3216,7 +3105,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var util = __webpack_require__(3);
|
||||
|
@ -3675,10 +3564,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/* 8 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var ContextMenu = __webpack_require__(8);
|
||||
var ContextMenu = __webpack_require__(7);
|
||||
var appendNodeFactory = __webpack_require__(12);
|
||||
var util = __webpack_require__(3);
|
||||
|
||||
|
@ -3723,7 +3612,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.editable.field = this.editor.options.mode === 'tree';
|
||||
this.editable.value = this.editor.options.mode !== 'view';
|
||||
|
||||
if (this.editor.options.mode === 'tree' && (typeof this.editor.options.onEditable === 'function')) {
|
||||
if ((this.editor.options.mode === 'tree' || this.editor.options.mode === 'form') &&
|
||||
(typeof this.editor.options.onEditable === 'function')) {
|
||||
var editable = this.editor.options.onEditable({
|
||||
field: this.field,
|
||||
value: this.value,
|
||||
|
@ -6823,6 +6713,117 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
module.exports = Node;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var ContextMenu = __webpack_require__(7);
|
||||
|
||||
/**
|
||||
* Create a select box to be used in the editor menu's, which allows to switch mode
|
||||
* @param {Object} editor
|
||||
* @param {String[]} modes Available modes: 'code', 'form', 'text', 'tree', 'view'
|
||||
* @param {String} current Available modes: 'code', 'form', 'text', 'tree', 'view'
|
||||
* @returns {HTMLElement} box
|
||||
*/
|
||||
function createModeSwitcher(editor, modes, current) {
|
||||
// TODO: decouple mode switcher from editor
|
||||
|
||||
/**
|
||||
* Switch the mode of the editor
|
||||
* @param {String} mode
|
||||
*/
|
||||
function switchMode(mode) {
|
||||
// switch mode
|
||||
editor.setMode(mode);
|
||||
|
||||
// restore focus on mode box
|
||||
var modeBox = editor.dom && editor.dom.modeBox;
|
||||
if (modeBox) {
|
||||
modeBox.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// available modes
|
||||
var availableModes = {
|
||||
code: {
|
||||
'text': 'Code',
|
||||
'title': 'Switch to code highlighter',
|
||||
'click': function () {
|
||||
switchMode('code')
|
||||
}
|
||||
},
|
||||
form: {
|
||||
'text': 'Form',
|
||||
'title': 'Switch to form editor',
|
||||
'click': function () {
|
||||
switchMode('form');
|
||||
}
|
||||
},
|
||||
text: {
|
||||
'text': 'Text',
|
||||
'title': 'Switch to plain text editor',
|
||||
'click': function () {
|
||||
switchMode('text');
|
||||
}
|
||||
},
|
||||
tree: {
|
||||
'text': 'Tree',
|
||||
'title': 'Switch to tree editor',
|
||||
'click': function () {
|
||||
switchMode('tree');
|
||||
}
|
||||
},
|
||||
view: {
|
||||
'text': 'View',
|
||||
'title': 'Switch to tree view',
|
||||
'click': function () {
|
||||
switchMode('view');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// list the selected modes
|
||||
var items = [];
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
var mode = modes[i];
|
||||
var item = availableModes[mode];
|
||||
if (!item) {
|
||||
throw new Error('Unknown mode "' + mode + '"');
|
||||
}
|
||||
|
||||
item.className = 'jsoneditor-type-modes' + ((current == mode) ? ' jsoneditor-selected' : '');
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
// retrieve the title of current mode
|
||||
var currentMode = availableModes[current];
|
||||
if (!currentMode) {
|
||||
throw new Error('Unknown mode "' + current + '"');
|
||||
}
|
||||
var currentTitle = currentMode.text;
|
||||
|
||||
// create the html element
|
||||
var box = document.createElement('button');
|
||||
box.className = 'jsoneditor-modes jsoneditor-separator';
|
||||
box.innerHTML = currentTitle + ' ▾';
|
||||
box.title = 'Switch editor mode';
|
||||
box.onclick = function () {
|
||||
var menu = new ContextMenu(items);
|
||||
menu.show(box);
|
||||
};
|
||||
|
||||
var div = document.createElement('div');
|
||||
div.className = 'jsoneditor-modes';
|
||||
div.style.position = 'relative';
|
||||
div.appendChild(box);
|
||||
|
||||
return div;
|
||||
}
|
||||
|
||||
exports.create = createModeSwitcher;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 10 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
@ -7266,7 +7267,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var util = __webpack_require__(3);
|
||||
var ContextMenu = __webpack_require__(8);
|
||||
var ContextMenu = __webpack_require__(7);
|
||||
|
||||
/**
|
||||
* A factory function to create an AppendNode, which depends on a Node
|
||||
|
|
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": "5.0.0",
|
||||
"version": "5.0.1",
|
||||
"main": "./index",
|
||||
"description": "A web-based tool to view, edit and format JSON",
|
||||
"tags": [
|
||||
|
|
Loading…
Reference in New Issue