@json-editor/json-editor 2.14.1 → 2.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/.eslintrc +4 -1
  2. package/.github/workflows/build.yml +5 -4
  3. package/CHANGELOG.md +25 -0
  4. package/README.md +32 -1
  5. package/config/codeceptjs_helpers.js +11 -0
  6. package/config/webpack.common.js +2 -6
  7. package/dist/jsoneditor.js +1 -1
  8. package/dist/jsoneditor.js.LICENSE.txt +1 -1
  9. package/dist/nonmin/jsoneditor.js +4124 -3939
  10. package/dist/nonmin/jsoneditor.js.map +1 -1
  11. package/docs/meta-schema.html +793 -0
  12. package/package.json +13 -13
  13. package/src/core.js +5 -1
  14. package/src/defaults.js +9 -2
  15. package/src/editor.js +33 -14
  16. package/src/editors/array.js +3 -6
  17. package/src/editors/base64.js +3 -0
  18. package/src/editors/describedby.js +2 -2
  19. package/src/editors/enum.js +9 -1
  20. package/src/editors/info.js +8 -0
  21. package/src/editors/multiple.js +9 -2
  22. package/src/editors/object.js +26 -7
  23. package/src/editors/radio.js +5 -2
  24. package/src/editors/select.js +23 -8
  25. package/src/editors/select2.js +1 -1
  26. package/src/editors/starrating.js +5 -4
  27. package/src/editors/string.js +16 -2
  28. package/src/editors/table.js +2 -2
  29. package/src/iconlib.js +0 -1
  30. package/src/schemaloader.js +2 -2
  31. package/src/style.css +4 -0
  32. package/src/style.css.js +1 -1
  33. package/src/templates/default.js +2 -2
  34. package/src/theme.js +13 -3
  35. package/src/themes/index.js +0 -1
  36. package/src/validator.js +4 -4
  37. package/tests/Dockerfile +1 -1
  38. package/tests/codeceptjs/core_test.js +8 -2
  39. package/tests/codeceptjs/editors/array_test.js +11 -6
  40. package/tests/codeceptjs/editors/autocomplete_test.js +0 -1
  41. package/tests/codeceptjs/editors/integer_test.js +3 -5
  42. package/tests/codeceptjs/editors/object_test.js +8 -0
  43. package/tests/codeceptjs/editors/rating_test.js +1 -1
  44. package/tests/codeceptjs/editors/select_test.js +30 -0
  45. package/tests/codeceptjs/editors/starrating_test.js +15 -0
  46. package/tests/codeceptjs/editors/string_test.js +7 -0
  47. package/tests/codeceptjs/issues/issue-gh-1158_test.js +1 -1
  48. package/tests/codeceptjs/issues/issue-gh-1164_test.js +0 -1
  49. package/tests/codeceptjs/issues/issue-gh-1383_test.js +1 -1
  50. package/tests/codeceptjs/issues/issue-gh-1452_test.js +10 -0
  51. package/tests/codeceptjs/issues/issue-gh-1525_test.js +9 -0
  52. package/tests/codeceptjs/issues/issue-gh-1536_test.js +12 -0
  53. package/tests/codeceptjs/issues/issue-gh-1538_test.js +10 -0
  54. package/tests/codeceptjs/issues/issue-gh-1541_test.js +8 -0
  55. package/tests/docker-compose.yml +0 -1
  56. package/tests/pages/array-events-table.html +39 -31
  57. package/tests/pages/array-events.html +39 -31
  58. package/tests/pages/assets/autocomplete.css +1 -0
  59. package/tests/pages/assets/autocomplete.min.js +1 -0
  60. package/tests/pages/autocomplete.html +4 -4
  61. package/tests/pages/enforce-const.html +176 -0
  62. package/tests/pages/integer.html +9 -10
  63. package/tests/pages/issues/issue-gh-1452.html +98 -0
  64. package/tests/pages/issues/issue-gh-1525.html +62 -0
  65. package/tests/pages/issues/issue-gh-1536.html +55 -0
  66. package/tests/pages/issues/issue-gh-1538.html +56 -0
  67. package/tests/pages/issues/issue-gh-1541.html +51 -0
  68. package/tests/pages/issues/issue-gh-1541.json +9 -0
  69. package/tests/pages/placeholder-options.html +57 -0
  70. package/tests/pages/prompt-paste-max-length-reached.html +51 -0
  71. package/tests/pages/remove-false-properties.html +85 -0
  72. package/tests/pages/select-values.html +91 -0
  73. package/tests/pages/starrating.html +86 -0
  74. package/tests/unit/editor.spec.js +1 -1
@@ -0,0 +1,176 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>enforce_const</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <label for="value">value</label>
14
+ <textarea id="value" class="form-control" rows="10"></textarea>
15
+ <div id='editor-container'></div>
16
+ </div>
17
+
18
+ <script>
19
+ const editorContainer = document.querySelector('#editor-container')
20
+ const value = document.querySelector('#value');
21
+ const schema = {
22
+ "type": "object",
23
+ "properties": {
24
+ "string": {
25
+ "title": "string (StringEditor)",
26
+ "type": "string",
27
+ "const": "Alice",
28
+ // "options": { "enforce_const": false }
29
+ },
30
+ "integer": {
31
+ "title": "integer (IntegerEditor)",
32
+ "type": "integer",
33
+ "const": 5,
34
+ // "options": { "enforce_const": false }
35
+ },
36
+ "number": {
37
+ "title": "number (NumberEditor)",
38
+ "type": "number",
39
+ "const": 5.5,
40
+ // "options": { "enforce_const": false }
41
+ },
42
+ "string-enum": {
43
+ "title": "string-enum (SelectEditor)",
44
+ "type": "string",
45
+ "const": "Bob",
46
+ "enum": [
47
+ "Alice",
48
+ "Bob",
49
+ "Carl"
50
+ ],
51
+ // "options": { "enforce_const": false }
52
+ },
53
+ "boolean": {
54
+ "title": "boolean (SelectEditor)",
55
+ "type": "boolean",
56
+ "const": true,
57
+ // "options": { "enforce_const": false }
58
+ },
59
+ "boolean-checkbox": {
60
+ "title": "boolean-checkbox (CheckboxEditor)",
61
+ "type": "boolean",
62
+ "format": "checkbox",
63
+ "const": true,
64
+ // "options": { "enforce_const": false }
65
+ },
66
+ "boolean-choices": {
67
+ "title": "boolean-choices (ChoicesEditor)",
68
+ "type": "boolean",
69
+ "format": "choices",
70
+ "const": true,
71
+ // "options": { "enforce_const": false }
72
+ },
73
+ "object": {
74
+ "title": "object (ObjectEditor)",
75
+ "type": "object",
76
+ "const": {"name": "Alice"},
77
+ // "options": { "enforce_const": false },
78
+ "properties": {
79
+ "name": {
80
+ "type": "string"
81
+ }
82
+ }
83
+ },
84
+ "array": {
85
+ "title": "array (TableEditor)",
86
+ "type": "array",
87
+ "const": [{"name": "Alice"}, {"name": "Bob"}],
88
+ // "options": { "enforce_const": false },
89
+ "items": {
90
+ "title": "object",
91
+ "type": "object",
92
+ "properties": {
93
+ "name": {
94
+ "type": "string"
95
+ }
96
+ }
97
+ }
98
+ },
99
+ "array-table": {
100
+ "title": "array (TableEditor)",
101
+ "type": "array",
102
+ "format": "table",
103
+ "const": [{"name": "Alice"}, {"name": "Bob"}],
104
+ "items": {
105
+ "title": "object",
106
+ "type": "object",
107
+ "const": {"name": "Alice"},
108
+ "properties": {
109
+ "name": {
110
+ "type": "string"
111
+ }
112
+ }
113
+ },
114
+ // "options": { "enforce_const": false }
115
+ },
116
+ "array-tabs": {
117
+ "title": "array (TableEditor)",
118
+ "type": "array",
119
+ "format": "tabs",
120
+ "const": [{"name": "Alice"}, {"name": "Bob"}],
121
+ "items": {
122
+ "title": "object",
123
+ "type": "object",
124
+ "const": {"name": "Alice"},
125
+ "properties": {
126
+ "name": {
127
+ "type": "string"
128
+ }
129
+ }
130
+ },
131
+ // "options": { "enforce_const": false }
132
+ },
133
+ "array-of-strings": {
134
+ "title": "array (MultiselectEditor)",
135
+ "type": "array",
136
+ "uniqueItems": true,
137
+ "items": {
138
+ "title": "string",
139
+ "type": "string",
140
+ "enum": ["Alice", "Bob"]
141
+ },
142
+ "const": ["Alice", "Bob"],
143
+ // "options": { "enforce_const": false }
144
+ },
145
+ "array-enum": {
146
+ "title": "array (EnumEditor)",
147
+ "type": "array",
148
+ "enum": [["Alice", "Bob"], ["Carl", "Dennis"]],
149
+ "const": ["Carl", "Dennis"],
150
+ // "options": { "enforce_const": false }
151
+ },
152
+ "object-enum": {
153
+ "title": "object (EnumEditor)",
154
+ "type": "object",
155
+ "enum": [{"name": "Alice"}, {"name": "Bob"}],
156
+ "const": {"name": "Bob"},
157
+ // "options": { "enforce_const": false }
158
+ }
159
+ }
160
+ }
161
+
162
+ const editor = new JSONEditor(editorContainer, {
163
+ schema: schema,
164
+ theme: 'bootstrap4',
165
+ iconlib: 'fontawesome',
166
+ disable_collapse: true,
167
+ enforce_const: true
168
+ })
169
+
170
+ editor.on('change', function () {
171
+ value.value = JSON.stringify(editor.getValue())
172
+ })
173
+ </script>
174
+
175
+ </body>
176
+ </html>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8"/>
5
5
  <title>Integer</title>
6
- <script src="../../dist/jsoneditor.js"></script>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
7
  </head>
8
8
  <body>
9
9
 
@@ -15,10 +15,10 @@
15
15
  <div class='container'></div>
16
16
 
17
17
  <script>
18
- var container = document.querySelector('.container');
19
- var value = document.querySelector('.value');
18
+ const container = document.querySelector('.container');
19
+ const value = document.querySelector('.value');
20
20
 
21
- var schema = {
21
+ const schema = {
22
22
  "type": "object",
23
23
  "title": "range",
24
24
  "properties": {
@@ -50,19 +50,18 @@
50
50
  }
51
51
  };
52
52
 
53
- var editor = new JSONEditor(container, {
53
+ const editor = new JSONEditor(container, {
54
54
  schema: schema
55
- });
55
+ })
56
56
 
57
57
  document.querySelector('.get-value').addEventListener('click', function () {
58
58
  value.value = JSON.stringify(editor.getValue());
59
- console.log(editor.getValue());
60
- });
59
+ })
61
60
 
62
61
 
63
62
  document.querySelector('.set-value').addEventListener('click', function () {
64
- editor.setValue({integer_range: 2})
65
- });
63
+ editor.setValue({"integer": 5, "integer_number": 5, "integer_range": 2})
64
+ })
66
65
 
67
66
  </script>
68
67
 
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1452</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
7
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
9
+ <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1452">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ <button id="set-value">Set Value</button>
18
+ </div>
19
+
20
+ <script>
21
+ const value = document.querySelector('#value')
22
+ const defaultSchema = {
23
+ "title": "Dependencies",
24
+ "type": "object",
25
+ "properties": {
26
+ "category": {
27
+ "title": "Category",
28
+ "type": "string",
29
+ "enum": [
30
+ "Chocolates",
31
+ "Vegetables",
32
+ "Icecreams"
33
+ ]
34
+ },
35
+ "subcategory1": {
36
+ "title": "Subcategory",
37
+ "type": "string",
38
+ "enum": [
39
+ "Dark chocolate",
40
+ "Milk chocolate",
41
+ "White chocolate",
42
+ "Gianduja chocolate"
43
+ ],
44
+ "options": {
45
+ "dependencies": {
46
+ "category": "Chocolates"
47
+ }
48
+ }
49
+ },
50
+ "subcategory2": {
51
+ "title": "Subcategory",
52
+ "type": "string",
53
+ "enum": [
54
+ "Broccoli",
55
+ "Cabbage",
56
+ "Carrot",
57
+ "Tomato"
58
+ ],
59
+ "options": {
60
+ "dependencies": {
61
+ "category": "Vegetables"
62
+ }
63
+ }
64
+ },
65
+ "subcategory3": {
66
+ "title": "Subcategory",
67
+ "type": "string",
68
+ "enum": [
69
+ "Frozen yogurt",
70
+ "Booza",
71
+ "Ice milk"
72
+ ],
73
+ "options": {
74
+ "dependencies": {
75
+ "category": "Icecreams"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
83
+ iconlib: 'fontawesome5',
84
+ schema: defaultSchema,
85
+ theme: 'bootstrap3'
86
+ })
87
+
88
+ const setValue = document.querySelector('#set-value')
89
+
90
+ setValue.addEventListener('click', () => {
91
+ editor.setValue({
92
+ "category": "Chocolates",
93
+ "subcategory1": "Dark chocolate"
94
+ })
95
+ })
96
+ </script>
97
+ </body>
98
+ </html>
@@ -0,0 +1,62 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>GitHub Issue 1525</title>
6
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/select2@latest/dist/js/select2.min.js "></script>
10
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@latest/dist/css/select2.min.css">
11
+ <script src="../../../dist/jsoneditor.js"></script>
12
+ </head>
13
+ <body>
14
+ <div class="container">
15
+ <h1>Test</h1>
16
+ <a href="https://github.com/json-editor/json-editor/issues/1525">Link to issue</a>
17
+
18
+ <div class="form-group">
19
+ <label for="value">Value</label>
20
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
21
+ </div>
22
+
23
+ <div id='editor_holder'></div>
24
+ </div>
25
+
26
+ <script>
27
+ window.addEventListener('load', () => {
28
+ const textareaValue = document.querySelector('#value')
29
+ const defaultSchema = {
30
+ "type": "object",
31
+ "properties": {
32
+ "example": {
33
+ "type": "string",
34
+ "format": "select2",
35
+ "enum": ["aa", "bb", "cc"],
36
+ "options": {
37
+ "select2": {
38
+ "tags": true
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
46
+ iconlib: 'fontawesome5',
47
+ schema: defaultSchema,
48
+ theme: 'bootstrap4',
49
+ show_errors: 'always'
50
+ })
51
+
52
+ editor.on('change', function () {
53
+ textareaValue.value = JSON.stringify(editor.getValue())
54
+ })
55
+
56
+ editor.on('ready', function () {
57
+ editor.getEditor('root.example').setValue('dd')
58
+ })
59
+ })
60
+ </script>
61
+ </body>
62
+ </html>
@@ -0,0 +1,55 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1536</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
7
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <script src="../../../dist/jsoneditor.js"></script>
9
+ </head>
10
+ <body>
11
+ <div class="container">
12
+ <h1>Test</h1>
13
+ <a href="https://github.com/json-editor/json-editor/issues/1536">Link to issue</a>
14
+ <div id='editor_holder'></div>
15
+ </div>
16
+
17
+ <script>
18
+ const value = document.querySelector('#value')
19
+ const defaultSchema = {
20
+ 'title': 'Dependency chain support',
21
+ 'type': 'object',
22
+ 'properties': {
23
+ 'dependent_field_two': {
24
+ 'type': 'number',
25
+ 'options': {
26
+ 'dependencies': {
27
+ 'dependent_field_one': true
28
+ }
29
+ }
30
+ },
31
+ 'dependent_field_one': {
32
+ 'type': 'boolean',
33
+ 'format': 'checkbox',
34
+ 'options': {
35
+ 'dependencies': {
36
+ 'dependency_chain_head': true
37
+ }
38
+ }
39
+ },
40
+ 'dependency_chain_head': {
41
+ 'type': 'boolean',
42
+ 'default': false,
43
+ 'format': 'checkbox'
44
+ }
45
+ }
46
+ }
47
+
48
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
49
+ iconlib: 'fontawesome5',
50
+ schema: defaultSchema,
51
+ theme: 'bootstrap3'
52
+ })
53
+ </script>
54
+ </body>
55
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1538</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
7
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
9
+ <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
10
+ <script src="../../../dist/jsoneditor.js"></script>
11
+ </head>
12
+ <body>
13
+ <div class="container">
14
+ <h1>Test</h1>
15
+ <a href="https://github.com/json-editor/json-editor/issues/1538">Link to issue</a>
16
+ <div id='editor_holder'></div>
17
+ </div>
18
+
19
+ <script>
20
+ const value = document.querySelector('#value')
21
+ const defaultSchema = {
22
+ 'title': 'Dependency chain support',
23
+ 'type': 'object',
24
+ 'properties': {
25
+ 'watched_field': {
26
+ 'type': 'boolean',
27
+ 'format': 'checkbox',
28
+ 'default': false
29
+ },
30
+ 'field_that_watch': {
31
+ 'type': 'string',
32
+ 'template': '{{content}}',
33
+ 'watch': {
34
+ 'content': 'root.watched_field',
35
+ }
36
+ },
37
+ 'dependent_field': {
38
+ 'type': 'boolean',
39
+ 'format': 'checkbox',
40
+ 'options': {
41
+ 'dependencies': {
42
+ 'field_that_watch': 'true'
43
+ }
44
+ }
45
+ },
46
+ }
47
+ }
48
+
49
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
50
+ iconlib: 'fontawesome5',
51
+ schema: defaultSchema,
52
+ theme: 'bootstrap3'
53
+ })
54
+ </script>
55
+ </body>
56
+ </html>
@@ -0,0 +1,51 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>dependentRequired</title>
6
+ <script src="../../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <h1>Test</h1>
14
+ <div id='editor-container'></div>
15
+
16
+ <div class="form-group">
17
+ <label for="textarea-value">Value</label>
18
+ <textarea class="form-control" id="textarea-value" cols="30" rows="10"></textarea>
19
+ </div>
20
+ </div>
21
+
22
+ <script>
23
+ var editorContainer = document.querySelector('#editor-container')
24
+ var textareaValue = document.querySelector('#textarea-value')
25
+ var schema = {
26
+ 'title': 'Dependency chain support',
27
+ 'type': 'object',
28
+ 'properties': {
29
+ "reference": {
30
+ "title": "Reference",
31
+ "$ref": "issue-gh-1541.json"
32
+ }
33
+ }
34
+ }
35
+
36
+ var editor = new JSONEditor(editorContainer, {
37
+ schema: schema,
38
+ theme: 'bootstrap4',
39
+ iconlib: 'fontawesome',
40
+ show_errors: 'always',
41
+ show_opt_in: false,
42
+ ajax: true,
43
+ })
44
+
45
+ editor.on('change', function () {
46
+ textareaValue.value = JSON.stringify(editor.getValue())
47
+ })
48
+ </script>
49
+
50
+ </body>
51
+ </html>`
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "external-schema",
3
+ "properties": {
4
+ "value": {
5
+ "type": ["string", "null"],
6
+ "default": null
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html lang="de">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>placeholder-options</title>
6
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
8
+ <script src="../../dist/jsoneditor.js"></script>
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <h1>Test</h1>
14
+ <label for="value">Value</label>
15
+ <textarea class="form-control" id="value"></textarea>
16
+ <button id='set-value'>Set Value that is not in enum ("c")</button>
17
+ <div class='json-editor-container'></div>
18
+ </div>
19
+
20
+ <script>
21
+ const jsonEditorContainer = document.querySelector('.json-editor-container')
22
+ const value = document.querySelector('#value')
23
+ const setValue = document.querySelector('#set-value')
24
+ const schema = {
25
+ 'title': 'test',
26
+ 'type': 'string',
27
+ 'enum': [
28
+ 'a',
29
+ 'b'
30
+ ],
31
+ 'options': {
32
+ 'has_placeholder_option': true,
33
+ 'placeholder_option_text': '-select-',
34
+ 'enum_titles': [
35
+ 'A',
36
+ 'B'
37
+ ]
38
+ }
39
+ }
40
+
41
+ const editor = new JSONEditor(jsonEditorContainer, {
42
+ schema: schema,
43
+ theme: 'bootstrap4',
44
+ iconlib: 'fontawesome5'
45
+ })
46
+
47
+ editor.on('change', function () {
48
+ value.value = JSON.stringify(editor.getValue())
49
+ })
50
+
51
+ setValue.addEventListener('click', function () {
52
+ editor.setValue('other')
53
+ })
54
+ </script>
55
+
56
+ </body>
57
+ </html>
@@ -0,0 +1,51 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>prompt_paste_max_length_reached</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
8
+ <link rel="stylesheet" id="iconlib-link" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
9
+ </head>
10
+ <body>
11
+
12
+ <div class="container">
13
+ <h1>Test</h1>
14
+ <div id='editor-container'></div>
15
+ <button id="paste">Paste</button>
16
+ </div>
17
+
18
+ <script>
19
+ const editorContainer = document.querySelector('#editor-container')
20
+ const pasteBtn = document.querySelector('#paste')
21
+ const schema = {
22
+ "type": "string",
23
+ "maxLength": 5
24
+ }
25
+
26
+ const editor = new JSONEditor(editorContainer, {
27
+ schema: schema,
28
+ theme: 'bootstrap4',
29
+ iconlib: 'fontawesome',
30
+ show_errors: 'always',
31
+ prompt_paste_max_length_reached: true
32
+ })
33
+
34
+
35
+ pasteBtn.addEventListener('click', () => {
36
+ const inputElement = document.getElementById('root')
37
+ const pasteEvent = document.createEvent('Event')
38
+ pasteEvent.initEvent('paste', true, true)
39
+
40
+ pasteEvent.clipboardData = {
41
+ getData: format => {
42
+ return 'Hello world'
43
+ }
44
+ }
45
+
46
+ inputElement.dispatchEvent(pasteEvent)
47
+ })
48
+ </script>
49
+
50
+ </body>
51
+ </html>