@json-editor/json-editor 2.13.1 → 2.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/jsoneditor.js +1 -1
- package/dist/jsoneditor.js.LICENSE.txt +1 -1
- package/dist/nonmin/jsoneditor.js +50 -26
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/package.json +1 -1
- package/src/defaults.js +2 -1
- package/src/editor.js +1 -0
- package/src/editors/array.js +7 -2
- package/src/editors/button.js +1 -0
- package/src/editors/checkbox.js +17 -1
- package/src/editors/object.js +4 -11
- package/src/editors/select.js +16 -4
- package/src/validator.js +2 -1
- package/tests/codeceptjs/core_test.js +39 -0
- package/tests/codeceptjs/editors/button_test.js +6 -0
- package/tests/codeceptjs/issues/issue-gh-1453_test.js +18 -0
- package/tests/codeceptjs/issues/issue-gh-1461_test.js +14 -0
- package/tests/codeceptjs/issues/issue-gh-1463_test.js +9 -0
- package/tests/pages/disable-button-in-object-editors.html +56 -0
- package/tests/pages/issues/issue-gh-1453.html +45 -0
- package/tests/pages/issues/issue-gh-1461.html +55 -0
- package/tests/pages/issues/issue-gh-1463.html +41 -0
- package/tests/pages/show-validation-errors.html +73 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* * @name JSON Editor
|
|
4
4
|
* * @description JSON Schema Based Editor
|
|
5
5
|
* * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800)
|
|
6
|
-
* * @version "2.13.
|
|
6
|
+
* * @version "2.13.2"
|
|
7
7
|
* * @author Jeremy Dorn
|
|
8
8
|
* * @see https://github.com/jdorn/json-editor/
|
|
9
9
|
* * @see https://github.com/json-editor/json-editor
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* * @name JSON Editor
|
|
4
4
|
* * @description JSON Schema Based Editor
|
|
5
5
|
* * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800)
|
|
6
|
-
* * @version "2.13.
|
|
6
|
+
* * @version "2.13.2"
|
|
7
7
|
* * @author Jeremy Dorn
|
|
8
8
|
* * @see https://github.com/jdorn/json-editor/
|
|
9
9
|
* * @see https://github.com/json-editor/json-editor
|
|
@@ -504,7 +504,8 @@ var options = {
|
|
|
504
504
|
use_default_values: true,
|
|
505
505
|
max_depth: 0,
|
|
506
506
|
button_state_mode: 1,
|
|
507
|
-
case_sensitive_property_search: true
|
|
507
|
+
case_sensitive_property_search: true,
|
|
508
|
+
show_errors: 'interaction'
|
|
508
509
|
};
|
|
509
510
|
|
|
510
511
|
/* This assignment was previously in index.js but makes more sense here */
|
|
@@ -666,6 +667,7 @@ var AbstractEditor = /*#__PURE__*/function () {
|
|
|
666
667
|
this.original_schema = options.schema;
|
|
667
668
|
this.schema = this.jsoneditor.expandSchema(this.original_schema);
|
|
668
669
|
this.active = true;
|
|
670
|
+
this.isUiOnly = false;
|
|
669
671
|
this.options = (0,_utilities_js__WEBPACK_IMPORTED_MODULE_32__.extend)({}, this.options || {}, this.schema.options || {}, options.schema.options || {}, options);
|
|
670
672
|
this.formname = this.jsoneditor.options.form_name_root || 'root';
|
|
671
673
|
if (!options.path && !this.schema.id) this.schema.id = this.formname;
|
|
@@ -2081,7 +2083,12 @@ var ArrayEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
2081
2083
|
/* Make sure value has between minItems and maxItems items in it */
|
|
2082
2084
|
value = this.ensureArraySize(value);
|
|
2083
2085
|
var serialized = JSON.stringify(value);
|
|
2084
|
-
if (serialized === this.serialized)
|
|
2086
|
+
if (serialized === this.serialized) {
|
|
2087
|
+
if (initial) {
|
|
2088
|
+
this.refreshValue(initial);
|
|
2089
|
+
}
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2085
2092
|
value.forEach(function (val, i) {
|
|
2086
2093
|
if (_this5.rows[i]) {
|
|
2087
2094
|
/* TODO: don't set the row's value if it hasn't changed */
|
|
@@ -2191,7 +2198,7 @@ var ArrayEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
2191
2198
|
/* Get the value for this editor */
|
|
2192
2199
|
_this6.value[i] = editor.getValue();
|
|
2193
2200
|
});
|
|
2194
|
-
if (
|
|
2201
|
+
if (this.setupButtons(minItems) && !this.collapsed) {
|
|
2195
2202
|
this.controls.style.display = 'inline-block';
|
|
2196
2203
|
} else {
|
|
2197
2204
|
this.controls.style.display = 'none';
|
|
@@ -3707,6 +3714,7 @@ var ButtonEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
3707
3714
|
_classCallCheck(this, ButtonEditor);
|
|
3708
3715
|
_this = _super.call(this, options, defaults);
|
|
3709
3716
|
_this.active = false;
|
|
3717
|
+
_this.isUiOnly = true;
|
|
3710
3718
|
|
|
3711
3719
|
/* Set field to required in schema otherwise it will not be displayed */
|
|
3712
3720
|
if (_this.parent && _this.parent.schema) {
|
|
@@ -3910,6 +3918,9 @@ var CheckboxEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
3910
3918
|
var changed = this.getValue() !== value;
|
|
3911
3919
|
this.value = value;
|
|
3912
3920
|
this.input.checked = this.value;
|
|
3921
|
+
if (!initial) {
|
|
3922
|
+
this.is_dirty = true;
|
|
3923
|
+
}
|
|
3913
3924
|
this.onChange(changed);
|
|
3914
3925
|
}
|
|
3915
3926
|
}, {
|
|
@@ -3955,6 +3966,7 @@ var CheckboxEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
3955
3966
|
e.preventDefault();
|
|
3956
3967
|
e.stopPropagation();
|
|
3957
3968
|
_this.value = e.currentTarget.checked;
|
|
3969
|
+
_this.is_dirty = true;
|
|
3958
3970
|
_this.onChange(true);
|
|
3959
3971
|
});
|
|
3960
3972
|
this.container.appendChild(this.control);
|
|
@@ -3986,7 +3998,15 @@ var CheckboxEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
3986
3998
|
key: "showValidationErrors",
|
|
3987
3999
|
value: function showValidationErrors(errors) {
|
|
3988
4000
|
var _this2 = this;
|
|
3989
|
-
|
|
4001
|
+
var showErrors = this.jsoneditor.options.show_errors;
|
|
4002
|
+
var changeOrInteraction = showErrors === 'change' || showErrors === 'interaction';
|
|
4003
|
+
var never = showErrors === 'never';
|
|
4004
|
+
if (never) {
|
|
4005
|
+
return;
|
|
4006
|
+
}
|
|
4007
|
+
if (changeOrInteraction && !this.is_dirty) {
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
3990
4010
|
var addMessage = function addMessage(messages, error) {
|
|
3991
4011
|
if (error.path === _this2.path) {
|
|
3992
4012
|
messages.push(error.message);
|
|
@@ -7477,7 +7497,7 @@ var ObjectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
7477
7497
|
_get(_getPrototypeOf(ObjectEditor.prototype), "enable", this).call(this);
|
|
7478
7498
|
if (this.editors) {
|
|
7479
7499
|
Object.values(this.editors).forEach(function (e) {
|
|
7480
|
-
if (e.isActive()) {
|
|
7500
|
+
if (e.isActive() || e.isUiOnly) {
|
|
7481
7501
|
e.enable();
|
|
7482
7502
|
}
|
|
7483
7503
|
e.optInCheckbox.disabled = false;
|
|
@@ -7495,7 +7515,7 @@ var ObjectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
7495
7515
|
_get(_getPrototypeOf(ObjectEditor.prototype), "disable", this).call(this);
|
|
7496
7516
|
if (this.editors) {
|
|
7497
7517
|
Object.values(this.editors).forEach(function (e) {
|
|
7498
|
-
if (e.isActive()) {
|
|
7518
|
+
if (e.isActive() || e.isUiOnly) {
|
|
7499
7519
|
e.disable(alwaysDisabled);
|
|
7500
7520
|
}
|
|
7501
7521
|
e.optInCheckbox.disabled = true;
|
|
@@ -8265,15 +8285,9 @@ var ObjectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
8265
8285
|
key: "copyJSON",
|
|
8266
8286
|
value: function copyJSON() {
|
|
8267
8287
|
if (!this.editjson_holder) return;
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
ta.style.position = 'absolute';
|
|
8272
|
-
ta.style.left = '-9999px';
|
|
8273
|
-
document.body.appendChild(ta);
|
|
8274
|
-
ta.select();
|
|
8275
|
-
document.execCommand('copy');
|
|
8276
|
-
document.body.removeChild(ta);
|
|
8288
|
+
navigator.clipboard.writeText(this.editjson_textarea.value)["catch"](function (e) {
|
|
8289
|
+
return window.alert(e);
|
|
8290
|
+
});
|
|
8277
8291
|
}
|
|
8278
8292
|
}, {
|
|
8279
8293
|
key: "saveJSON",
|
|
@@ -9283,9 +9297,11 @@ var SelectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
9283
9297
|
sanitized = this.enum_values[0];
|
|
9284
9298
|
}
|
|
9285
9299
|
if (this.value === sanitized) return;
|
|
9286
|
-
if (initial) this.is_dirty = false;else if (this.jsoneditor.options.show_errors === 'change') this.is_dirty = true;
|
|
9287
9300
|
this.input.value = this.enum_options[this.enum_values.indexOf(sanitized)];
|
|
9288
9301
|
this.value = sanitized;
|
|
9302
|
+
if (!initial) {
|
|
9303
|
+
this.is_dirty = true;
|
|
9304
|
+
}
|
|
9289
9305
|
this.onChange();
|
|
9290
9306
|
this.change();
|
|
9291
9307
|
}
|
|
@@ -9612,7 +9628,15 @@ var SelectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
9612
9628
|
key: "showValidationErrors",
|
|
9613
9629
|
value: function showValidationErrors(errors) {
|
|
9614
9630
|
var _this3 = this;
|
|
9615
|
-
|
|
9631
|
+
var showErrors = this.jsoneditor.options.show_errors;
|
|
9632
|
+
var changeOrInteraction = showErrors === 'change' || showErrors === 'interaction';
|
|
9633
|
+
var never = showErrors === 'never';
|
|
9634
|
+
if (never) {
|
|
9635
|
+
return;
|
|
9636
|
+
}
|
|
9637
|
+
if (changeOrInteraction && !this.is_dirty) {
|
|
9638
|
+
return;
|
|
9639
|
+
}
|
|
9616
9640
|
var addMessage = function addMessage(messages, error) {
|
|
9617
9641
|
if (error.path === _this3.path) {
|
|
9618
9642
|
messages.push(error.message);
|
|
@@ -20123,12 +20147,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
20123
20147
|
/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
20124
20148
|
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.array.concat.js */ "./node_modules/core-js/modules/es.array.concat.js");
|
|
20125
20149
|
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_6__);
|
|
20126
|
-
/* harmony import */ var
|
|
20127
|
-
/* harmony import */ var
|
|
20128
|
-
/* harmony import */ var
|
|
20129
|
-
/* harmony import */ var
|
|
20130
|
-
/* harmony import */ var
|
|
20131
|
-
/* harmony import */ var
|
|
20150
|
+
/* harmony import */ var core_js_modules_es_array_some_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.array.some.js */ "./node_modules/core-js/modules/es.array.some.js");
|
|
20151
|
+
/* harmony import */ var core_js_modules_es_array_some_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_some_js__WEBPACK_IMPORTED_MODULE_7__);
|
|
20152
|
+
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.array.reduce.js */ "./node_modules/core-js/modules/es.array.reduce.js");
|
|
20153
|
+
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_8__);
|
|
20154
|
+
/* harmony import */ var core_js_modules_es_array_is_array_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.array.is-array.js */ "./node_modules/core-js/modules/es.array.is-array.js");
|
|
20155
|
+
/* harmony import */ var core_js_modules_es_array_is_array_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_is_array_js__WEBPACK_IMPORTED_MODULE_9__);
|
|
20132
20156
|
/* harmony import */ var core_js_modules_es_array_includes_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.array.includes.js */ "./node_modules/core-js/modules/es.array.includes.js");
|
|
20133
20157
|
/* harmony import */ var core_js_modules_es_array_includes_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_includes_js__WEBPACK_IMPORTED_MODULE_10__);
|
|
20134
20158
|
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");
|
|
@@ -20187,11 +20211,11 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
20187
20211
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20188
20212
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20189
20213
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20214
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20190
20215
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20191
20216
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20192
20217
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20193
20218
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20194
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20195
20219
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
20196
20220
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20197
20221
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -20351,7 +20375,7 @@ var Validator = /*#__PURE__*/function () {
|
|
|
20351
20375
|
return [];
|
|
20352
20376
|
},
|
|
20353
20377
|
"const": function _const(schema, value, path) {
|
|
20354
|
-
var valid = JSON.stringify(schema["const"]) === JSON.stringify(value)
|
|
20378
|
+
var valid = JSON.stringify(schema["const"]) === JSON.stringify(value);
|
|
20355
20379
|
if (!valid) {
|
|
20356
20380
|
return [{
|
|
20357
20381
|
path: path,
|