Compare commits
1 Commits
develop
...
dependabot
Author | SHA1 | Date |
---|---|---|
dependabot-preview[bot] | 58b6179756 |
|
@ -9246,23 +9246,23 @@
|
|||
"dev": true
|
||||
},
|
||||
"source-map-loader": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-1.1.0.tgz",
|
||||
"integrity": "sha512-Kj7rXntLhAsEjZlqGz85Mbnu8N4gcxj5qZI1XyLQjqAI/p92ckRXwErb3jVYL5JxlFJnD4VgwybpB1h6NlETRg==",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-1.1.1.tgz",
|
||||
"integrity": "sha512-m2HjSWP2R1yR9P31e4+ciGHFOPvW6GmqHgZkneOkrME2VvWysXTGi4o0yS28iKWWP3vAUmAoa+3x5ZRI2BIX6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"abab": "^2.0.4",
|
||||
"abab": "^2.0.5",
|
||||
"iconv-lite": "^0.6.2",
|
||||
"loader-utils": "^2.0.0",
|
||||
"schema-utils": "^2.7.0",
|
||||
"schema-utils": "^3.0.0",
|
||||
"source-map": "^0.6.1",
|
||||
"whatwg-mimetype": "^2.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"abab": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.4.tgz",
|
||||
"integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
|
||||
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"ajv-keywords": {
|
||||
|
@ -9292,13 +9292,13 @@
|
|||
}
|
||||
},
|
||||
"schema-utils": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz",
|
||||
"integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz",
|
||||
"integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.5",
|
||||
"ajv": "^6.12.4",
|
||||
"@types/json-schema": "^7.0.6",
|
||||
"ajv": "^6.12.5",
|
||||
"ajv-keywords": "^3.5.2"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
"json-loader": "0.5.7",
|
||||
"mkdirp": "1.0.4",
|
||||
"mocha": "8.1.3",
|
||||
"source-map-loader": "1.1.0",
|
||||
"source-map-loader": "1.1.1",
|
||||
"standard": "14.3.4",
|
||||
"uglify-js": "3.11.1",
|
||||
"webpack": "4.44.2"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue