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
## 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
- Fix #1111: Enum dropdown not showing when using patternProperties for schema.

53
package-lock.json generated
View File

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

View File

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

View File

@ -104,17 +104,9 @@ export class Node {
if (typeof editable === 'boolean') {
this.editable.field = 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.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
require('ace-builds/src-noconflict/mode-json')
require('ace-builds/src-noconflict/mode-text')
require('ace-builds/src-noconflict/ext-searchbox')
// 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)
// 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') {
// verify whether Ace editor is available and supported
if (typeof _ace === 'undefined') {
@ -132,41 +132,37 @@ textmode.create = function (container, options = {}) {
this.frame.appendChild(this.menu)
// create format button
if(this.mode !== 'text-plain') {
const buttonFormat = document.createElement('button')
buttonFormat.type = 'button'
buttonFormat.className = 'jsoneditor-format'
buttonFormat.title = translate('formatTitle')
this.menu.appendChild(buttonFormat)
buttonFormat.onclick = () => {
try {
me.format()
me._onChange()
} catch (err) {
me._onError(err)
}
const buttonFormat = document.createElement('button')
buttonFormat.type = 'button'
buttonFormat.className = 'jsoneditor-format'
buttonFormat.title = translate('formatTitle')
this.menu.appendChild(buttonFormat)
buttonFormat.onclick = () => {
try {
me.format()
me._onChange()
} catch (err) {
me._onError(err)
}
}
// create compact button
if(this.mode !== 'text-plain') {
const buttonCompact = document.createElement('button')
buttonCompact.type = 'button'
buttonCompact.className = 'jsoneditor-compact'
buttonCompact.title = translate('compactTitle')
this.menu.appendChild(buttonCompact)
buttonCompact.onclick = () => {
try {
me.compact()
me._onChange()
} catch (err) {
me._onError(err)
}
const buttonCompact = document.createElement('button')
buttonCompact.type = 'button'
buttonCompact.className = 'jsoneditor-compact'
buttonCompact.title = translate('compactTitle')
this.menu.appendChild(buttonCompact)
buttonCompact.onclick = () => {
try {
me.compact()
me._onChange()
} catch (err) {
me._onError(err)
}
}
// create sort button
if (this.options.enableSort && this.mode !== 'text-plain') {
if (this.options.enableSort) {
const sort = document.createElement('button')
sort.type = 'button'
sort.className = 'jsoneditor-sort'
@ -178,7 +174,7 @@ textmode.create = function (container, options = {}) {
}
// create transform button
if (this.options.enableTransform && this.mode !== 'text-plain') {
if (this.options.enableTransform) {
const transform = document.createElement('button')
transform.type = 'button'
transform.title = translate('transformTitleShort')
@ -190,24 +186,22 @@ textmode.create = function (container, options = {}) {
}
// create repair button
if(this.mode !== 'text-plain') {
const buttonRepair = document.createElement('button')
buttonRepair.type = 'button'
buttonRepair.className = 'jsoneditor-repair'
buttonRepair.title = translate('repairTitle')
this.menu.appendChild(buttonRepair)
buttonRepair.onclick = () => {
try {
me.repair()
me._onChange()
} catch (err) {
me._onError(err)
}
const buttonRepair = document.createElement('button')
buttonRepair.type = 'button'
buttonRepair.className = 'jsoneditor-repair'
buttonRepair.title = translate('repairTitle')
this.menu.appendChild(buttonRepair)
buttonRepair.onclick = () => {
try {
me.repair()
me._onChange()
} catch (err) {
me._onError(err)
}
}
// create undo/redo buttons
if (this.mode === 'code' || this.mode === 'text-plain') {
if (this.mode === 'code') {
// create undo button
const undo = document.createElement('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')
poweredBy.appendChild(document.createTextNode('powered by ace'))
poweredBy.href = 'https://ace.c9.io/'
@ -264,7 +258,7 @@ textmode.create = function (container, options = {}) {
this.frame.appendChild(this.content)
this.container.appendChild(this.frame)
if (this.mode === 'code' || this.mode === 'text-plain') {
if (this.mode === 'code') {
this.editorDom = document.createElement('div')
this.editorDom.style.height = '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.setShowPrintMargin(false)
aceEditor.setFontSize('13px')
if(this.mode === 'text-plain') {
aceSession.setMode('ace/mode/text')
}
else{
aceSession.setMode('ace/mode/json')
}
aceSession.setMode('ace/mode/json')
aceSession.setTabSize(this.indentation)
aceSession.setUseSoftTabs(true)
aceSession.setUseWrapMode(true)
@ -702,24 +691,17 @@ textmode.compact = function () {
*/
textmode.format = function () {
const json = this.get()
if(this.mode !== 'text-plain') {
const text = JSON.stringify(json, null, this.indentation)
this.updateText(text)
}
else {
this.updateText(json)
}
const text = JSON.stringify(json, null, this.indentation)
this.updateText(text)
}
/**
* Repair the code in the text editor
*/
textmode.repair = function () {
if(this.mode !== 'text-plain') {
const text = this.getText()
const repairedText = repair(text)
this.updateText(repairedText)
}
const text = this.getText()
const repairedText = repair(text)
this.updateText(repairedText)
}
/**
@ -749,12 +731,7 @@ textmode.resize = function () {
* @param {*} json
*/
textmode.set = function (json) {
if(this.mode !== 'text-plain') {
this.setText(JSON.stringify(json, null, this.indentation))
}
else{
this.setText(json)
}
this.setText(JSON.stringify(json, null, this.indentation))
}
/**
@ -852,9 +829,6 @@ textmode.updateText = function (jsonText) {
* Throws an exception when no JSON schema is configured
*/
textmode.validate = function () {
if(this.mode === 'text-plain') {
return
}
let schemaErrors = []
let parseErrors = []
let json
@ -1089,11 +1063,5 @@ export const textModeMixins = [
mixin: textmode,
data: 'text',
load: load
},
{
mode: 'text-plain',
mixin: textmode,
data: 'text',
load: load
}
]