Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

6 changed files with 80 additions and 118 deletions

View File

@ -3,12 +3,6 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet published, version 9.1.2
- Log a clear error in the console when the returned value of `onEditable` is
invalid. See #1112.
## 2020-09-23, version 9.1.1 ## 2020-09-23, version 9.1.1
- Fix #1111: Enum dropdown not showing when using patternProperties for schema. - Fix #1111: Enum dropdown not showing when using patternProperties for schema.

53
package-lock.json generated
View File

@ -1682,15 +1682,14 @@
} }
}, },
"asn1.js": { "asn1.js": {
"version": "5.4.1", "version": "4.10.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
"integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
"dev": true, "dev": true,
"requires": { "requires": {
"bn.js": "^4.0.0", "bn.js": "^4.0.0",
"inherits": "^2.0.1", "inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0", "minimalistic-assert": "^1.0.0"
"safer-buffer": "^2.1.0"
}, },
"dependencies": { "dependencies": {
"bn.js": { "bn.js": {
@ -1979,9 +1978,9 @@
"dev": true "dev": true
}, },
"bn.js": { "bn.js": {
"version": "5.1.3", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.2.tgz",
"integrity": "sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==", "integrity": "sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA==",
"dev": true "dev": true
}, },
"brace-expansion": { "brace-expansion": {
@ -7773,13 +7772,14 @@
} }
}, },
"parse-asn1": { "parse-asn1": {
"version": "5.1.6", "version": "5.1.5",
"resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz",
"integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"asn1.js": "^5.2.0", "asn1.js": "^4.0.0",
"browserify-aes": "^1.0.0", "browserify-aes": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.0", "evp_bytestokey": "^1.0.0",
"pbkdf2": "^3.0.3", "pbkdf2": "^3.0.3",
"safe-buffer": "^5.1.1" "safe-buffer": "^5.1.1"
@ -9753,16 +9753,16 @@
} }
}, },
"terser-webpack-plugin": { "terser-webpack-plugin": {
"version": "1.4.5", "version": "1.4.4",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.4.tgz",
"integrity": "sha512-04Rfe496lN8EYruwi6oPQkG0vo8C+HT49X687FZnpPF0qMAIHONI6HEXYPKDOE8e5HjXTyKfqRd/agHtH0kOtw==", "integrity": "sha512-U4mACBHIegmfoEe5fdongHESNJWqsGU+W0S/9+BmYGVQDw1+c2Ow05TpMhxjPK1sRb7cuYq1BPl1e5YHJMTCqA==",
"dev": true, "dev": true,
"requires": { "requires": {
"cacache": "^12.0.2", "cacache": "^12.0.2",
"find-cache-dir": "^2.1.0", "find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0", "is-wsl": "^1.1.0",
"schema-utils": "^1.0.0", "schema-utils": "^1.0.0",
"serialize-javascript": "^4.0.0", "serialize-javascript": "^3.1.0",
"source-map": "^0.6.1", "source-map": "^0.6.1",
"terser": "^4.1.2", "terser": "^4.1.2",
"webpack-sources": "^1.4.0", "webpack-sources": "^1.4.0",
@ -9780,6 +9780,15 @@
"ajv-keywords": "^3.1.0" "ajv-keywords": "^3.1.0"
} }
}, },
"serialize-javascript": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz",
"integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==",
"dev": true,
"requires": {
"randombytes": "^2.1.0"
}
},
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@ -10006,9 +10015,9 @@
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.11.1", "version": "3.10.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.1.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.10.4.tgz",
"integrity": "sha512-OApPSuJcxcnewwjSGGfWOjx3oix5XpmrK9Z2j0fTRlHGoZ49IU6kExfZTM0++fCArOOCet+vIfWwFHbvWqwp6g==", "integrity": "sha512-kBFT3U4Dcj4/pJ52vfjCSfyLyvG9VYYuGYPmrPvAxRw/i7xHiT4VvCev+uiEMcEEiu6UNB6KgWmGtSUYIWScbw==",
"dev": true "dev": true
}, },
"unc-path-regex": { "unc-path-regex": {
@ -10520,9 +10529,9 @@
"dev": true "dev": true
}, },
"webpack": { "webpack": {
"version": "4.44.2", "version": "4.44.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.44.2.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.44.1.tgz",
"integrity": "sha512-6KJVGlCxYdISyurpQ0IPTklv+DULv05rs2hseIXer6D7KrUicRDLFb4IUM1S6LUAKypPM/nSiVSuv8jHu1m3/Q==", "integrity": "sha512-4UOGAohv/VGUNQJstzEywwNxqX417FnjZgZJpJQegddzPmTvph37eBIRbRTfdySXzVtJXLJfbMN3mMYhM6GdmQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@webassemblyjs/ast": "1.9.0", "@webassemblyjs/ast": "1.9.0",

View File

@ -53,8 +53,8 @@
"mocha": "8.1.3", "mocha": "8.1.3",
"source-map-loader": "1.1.0", "source-map-loader": "1.1.0",
"standard": "14.3.4", "standard": "14.3.4",
"uglify-js": "3.11.1", "uglify-js": "3.10.4",
"webpack": "4.44.2" "webpack": "4.44.1"
}, },
"files": [ "files": [
"dist", "dist",

View File

@ -104,17 +104,9 @@ export class Node {
if (typeof editable === 'boolean') { if (typeof editable === 'boolean') {
this.editable.field = editable this.editable.field = editable
this.editable.value = editable this.editable.value = editable
} else if (typeof editable === 'object' && editable !== null) { } else {
if (typeof editable.field === 'boolean') this.editable.field = editable.field if (typeof editable.field === 'boolean') this.editable.field = editable.field
if (typeof editable.value === 'boolean') this.editable.value = editable.value if (typeof editable.value === 'boolean') this.editable.value = editable.value
} else {
console.error(
'Invalid return value for function onEditable.',
'Actual value:', editable, '.',
'Either a boolean or object { field: boolean, value: boolean } expected.')
this.editable.field = false
this.editable.value = false
} }
} }
} }

View File

@ -9,7 +9,6 @@ if (window.ace) {
// load required Ace plugins // load required Ace plugins
require('ace-builds/src-noconflict/mode-json') require('ace-builds/src-noconflict/mode-json')
require('ace-builds/src-noconflict/mode-text')
require('ace-builds/src-noconflict/ext-searchbox') require('ace-builds/src-noconflict/ext-searchbox')
// embed Ace json worker // embed Ace json worker

View File

@ -68,7 +68,7 @@ textmode.create = function (container, options = {}) {
// TODO: make the option options.ace deprecated, it's not needed anymore (see #309) // TODO: make the option options.ace deprecated, it's not needed anymore (see #309)
// determine mode // determine mode
this.mode = (options.mode === 'code') ? 'code' : ((options.mode === 'text') ? 'text' : 'text-plain') this.mode = (options.mode === 'code') ? 'code' : 'text'
if (this.mode === 'code') { if (this.mode === 'code') {
// verify whether Ace editor is available and supported // verify whether Ace editor is available and supported
if (typeof _ace === 'undefined') { if (typeof _ace === 'undefined') {
@ -132,41 +132,37 @@ textmode.create = function (container, options = {}) {
this.frame.appendChild(this.menu) this.frame.appendChild(this.menu)
// create format button // create format button
if(this.mode !== 'text-plain') { const buttonFormat = document.createElement('button')
const buttonFormat = document.createElement('button') buttonFormat.type = 'button'
buttonFormat.type = 'button' buttonFormat.className = 'jsoneditor-format'
buttonFormat.className = 'jsoneditor-format' buttonFormat.title = translate('formatTitle')
buttonFormat.title = translate('formatTitle') this.menu.appendChild(buttonFormat)
this.menu.appendChild(buttonFormat) buttonFormat.onclick = () => {
buttonFormat.onclick = () => { try {
try { me.format()
me.format() me._onChange()
me._onChange() } catch (err) {
} catch (err) { me._onError(err)
me._onError(err)
}
} }
} }
// create compact button // create compact button
if(this.mode !== 'text-plain') { const buttonCompact = document.createElement('button')
const buttonCompact = document.createElement('button') buttonCompact.type = 'button'
buttonCompact.type = 'button' buttonCompact.className = 'jsoneditor-compact'
buttonCompact.className = 'jsoneditor-compact' buttonCompact.title = translate('compactTitle')
buttonCompact.title = translate('compactTitle') this.menu.appendChild(buttonCompact)
this.menu.appendChild(buttonCompact) buttonCompact.onclick = () => {
buttonCompact.onclick = () => { try {
try { me.compact()
me.compact() me._onChange()
me._onChange() } catch (err) {
} catch (err) { me._onError(err)
me._onError(err)
}
} }
} }
// create sort button // create sort button
if (this.options.enableSort && this.mode !== 'text-plain') { if (this.options.enableSort) {
const sort = document.createElement('button') const sort = document.createElement('button')
sort.type = 'button' sort.type = 'button'
sort.className = 'jsoneditor-sort' sort.className = 'jsoneditor-sort'
@ -178,7 +174,7 @@ textmode.create = function (container, options = {}) {
} }
// create transform button // create transform button
if (this.options.enableTransform && this.mode !== 'text-plain') { if (this.options.enableTransform) {
const transform = document.createElement('button') const transform = document.createElement('button')
transform.type = 'button' transform.type = 'button'
transform.title = translate('transformTitleShort') transform.title = translate('transformTitleShort')
@ -190,24 +186,22 @@ textmode.create = function (container, options = {}) {
} }
// create repair button // create repair button
if(this.mode !== 'text-plain') { const buttonRepair = document.createElement('button')
const buttonRepair = document.createElement('button') buttonRepair.type = 'button'
buttonRepair.type = 'button' buttonRepair.className = 'jsoneditor-repair'
buttonRepair.className = 'jsoneditor-repair' buttonRepair.title = translate('repairTitle')
buttonRepair.title = translate('repairTitle') this.menu.appendChild(buttonRepair)
this.menu.appendChild(buttonRepair) buttonRepair.onclick = () => {
buttonRepair.onclick = () => { try {
try { me.repair()
me.repair() me._onChange()
me._onChange() } catch (err) {
} catch (err) { me._onError(err)
me._onError(err)
}
} }
} }
// create undo/redo buttons // create undo/redo buttons
if (this.mode === 'code' || this.mode === 'text-plain') { if (this.mode === 'code') {
// create undo button // create undo button
const undo = document.createElement('button') const undo = document.createElement('button')
undo.type = 'button' undo.type = 'button'
@ -240,7 +234,7 @@ textmode.create = function (container, options = {}) {
}) })
} }
if (this.mode === 'code' || this.mode === 'text-plain') { if (this.mode === 'code') {
const poweredBy = document.createElement('a') const poweredBy = document.createElement('a')
poweredBy.appendChild(document.createTextNode('powered by ace')) poweredBy.appendChild(document.createTextNode('powered by ace'))
poweredBy.href = 'https://ace.c9.io/' poweredBy.href = 'https://ace.c9.io/'
@ -264,7 +258,7 @@ textmode.create = function (container, options = {}) {
this.frame.appendChild(this.content) this.frame.appendChild(this.content)
this.container.appendChild(this.frame) this.container.appendChild(this.frame)
if (this.mode === 'code' || this.mode === 'text-plain') { if (this.mode === 'code') {
this.editorDom = document.createElement('div') this.editorDom = document.createElement('div')
this.editorDom.style.height = '100%' // TODO: move to css this.editorDom.style.height = '100%' // TODO: move to css
this.editorDom.style.width = '100%' // TODO: move to css this.editorDom.style.width = '100%' // TODO: move to css
@ -277,12 +271,7 @@ textmode.create = function (container, options = {}) {
aceEditor.setOptions({ readOnly: isReadOnly }) aceEditor.setOptions({ readOnly: isReadOnly })
aceEditor.setShowPrintMargin(false) aceEditor.setShowPrintMargin(false)
aceEditor.setFontSize('13px') aceEditor.setFontSize('13px')
if(this.mode === 'text-plain') { aceSession.setMode('ace/mode/json')
aceSession.setMode('ace/mode/text')
}
else{
aceSession.setMode('ace/mode/json')
}
aceSession.setTabSize(this.indentation) aceSession.setTabSize(this.indentation)
aceSession.setUseSoftTabs(true) aceSession.setUseSoftTabs(true)
aceSession.setUseWrapMode(true) aceSession.setUseWrapMode(true)
@ -702,24 +691,17 @@ textmode.compact = function () {
*/ */
textmode.format = function () { textmode.format = function () {
const json = this.get() const json = this.get()
if(this.mode !== 'text-plain') { const text = JSON.stringify(json, null, this.indentation)
const text = JSON.stringify(json, null, this.indentation) this.updateText(text)
this.updateText(text)
}
else {
this.updateText(json)
}
} }
/** /**
* Repair the code in the text editor * Repair the code in the text editor
*/ */
textmode.repair = function () { textmode.repair = function () {
if(this.mode !== 'text-plain') { const text = this.getText()
const text = this.getText() const repairedText = repair(text)
const repairedText = repair(text) this.updateText(repairedText)
this.updateText(repairedText)
}
} }
/** /**
@ -749,12 +731,7 @@ textmode.resize = function () {
* @param {*} json * @param {*} json
*/ */
textmode.set = function (json) { textmode.set = function (json) {
if(this.mode !== 'text-plain') { this.setText(JSON.stringify(json, null, this.indentation))
this.setText(JSON.stringify(json, null, this.indentation))
}
else{
this.setText(json)
}
} }
/** /**
@ -852,9 +829,6 @@ textmode.updateText = function (jsonText) {
* Throws an exception when no JSON schema is configured * Throws an exception when no JSON schema is configured
*/ */
textmode.validate = function () { textmode.validate = function () {
if(this.mode === 'text-plain') {
return
}
let schemaErrors = [] let schemaErrors = []
let parseErrors = [] let parseErrors = []
let json let json
@ -1089,11 +1063,5 @@ export const textModeMixins = [
mixin: textmode, mixin: textmode,
data: 'text', data: 'text',
load: load load: load
},
{
mode: 'text-plain',
mixin: textmode,
data: 'text',
load: load
} }
] ]