2017-01-04 03:23:03 +08:00
<!DOCTYPE HTML>
2020-09-23 16:23:38 +08:00
< html lang = "en" >
2017-01-04 03:23:03 +08:00
< head >
2020-09-23 16:23:38 +08:00
< meta charset = "utf-8" >
2017-01-04 03:23:03 +08:00
< title > JSONEditor | Custom Ace< / title >
<!-- load a custom version of Ace editor -->
< script src = "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js" > < / script >
<!-- load the minimalist version of JSONEditor, which doesn't have Ace embedded -->
< link href = "../dist/jsoneditor.css" rel = "stylesheet" type = "text/css" >
< script src = "../dist/jsoneditor-minimalist.js" > < / script >
< style type = "text/css" >
#jsoneditor {
width: 500px;
height: 500px;
}
body, html {
font-family: "DejaVu Sans", sans-serif;
}
p, li {
width: 500px;
font-size: 10.5pt;
}
code {
background: #f5f5f5;
}
< / style >
< / head >
< body >
< h1 > Custom Ace editor< / h1 >
< p >
This example demonstrates how to load a custom version of Ace editor into JSONEditor.
< / p >
< p >
By default, JSONEditor < code > code< / code > mode loads the following Ace plugins:
< / p >
< ul >
< li > ace/mode/json< / li >
< li > ace/ext/searchbox< / li >
< li > ace/theme/jsoneditor< / li >
< / ul >
< p >
The jsoneditor theme comes embedded with JSONEditor. The other two plugins (json and searchbox) must be available in the folder of the custom Ace editor, or already be loaded via a script tag.
< / p >
< div id = "jsoneditor" > < / div >
< script >
// create the editor
2019-08-29 21:45:32 +08:00
const container = document.getElementById('jsoneditor')
const options = {
2017-01-04 03:23:03 +08:00
modes: ['text', 'code', 'tree', 'form', 'view'],
mode: 'code',
ace: ace
2019-08-29 21:45:32 +08:00
}
const json = {
2017-01-04 03:23:03 +08:00
'array': [1, 2, 3],
'boolean': true,
'null': null,
'number': 123,
'object': {'a': 'b', 'c': 'd'},
'string': 'Hello World'
2019-08-29 21:45:32 +08:00
}
const editor = new JSONEditor(container, options, json)
2017-01-04 03:23:03 +08:00
< / script >
< / body >
< / html >