File: string-ace-editor.html

package info (click to toggle)
json-editor.js 1.3.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,700 kB
  • sloc: javascript: 10,168; perl: 39; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <title>string-ace-editor</title>

  <!-- json editor -->
  <script src="../../dist/jsoneditor.js"></script>

  <!-- ace-editor -->
  <script src="./../../node_modules/ace-builds/src-noconflict/ace.js"></script>
</head>
<body>

<textarea class="debug" cols="30" rows="10"></textarea>
<button class='get-value'>Get Value</button>
<div class='container'></div>

<script>
  var container = document.querySelector('.container');
  var debug = document.querySelector('.debug');

  var schema = {
    "type": "array",
    "title": "string-ace-editor",
    "items": {
      "type": "object",
      "properties": {
        "editor": {
          "type": "string",
          "format": "yaml"
        }
      }
    }
  };

  JSONEditor.plugins.ace.theme = 'twilight';

  var editor = new JSONEditor(container, {
    schema: schema
  });

  document.querySelector('.get-value').addEventListener('click', function () {
    debug.value = JSON.stringify(editor.getValue());
  });

</script>

</body>
</html>