@json-editor/json-editor 2.15.0 → 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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@json-editor/json-editor",
3
3
  "title": "JSONEditor",
4
4
  "description": "JSON Schema based editor",
5
- "version": "2.15.0",
5
+ "version": "2.15.1",
6
6
  "main": "dist/jsoneditor.js",
7
7
  "author": {
8
8
  "name": "Jeremy Dorn",
@@ -15,10 +15,14 @@ export class SelectEditor extends AbstractEditor {
15
15
 
16
16
  if (this.value === sanitized) return
17
17
 
18
- if (inEnum && this.hasPlaceholderOption) {
19
- this.input.value = this.enum_options[this.enum_values.indexOf(sanitized)]
20
- } else {
18
+ const selectedIndex = this.enum_values.indexOf(sanitized)
19
+
20
+ if (inEnum && selectedIndex !== -1) {
21
+ this.input.value = this.enum_options[selectedIndex]
22
+ } else if (this.hasPlaceholderOption) {
21
23
  this.input.value = '_placeholder_'
24
+ } else {
25
+ this.input.value = sanitized
22
26
  }
23
27
 
24
28
  this.value = sanitized
@@ -69,10 +69,12 @@ Scenario('should be readonly if specified and not disabled @readOnly', async ({
69
69
  I.seeReadOnlyAttribute('[name="root[integer]"]')
70
70
  })
71
71
 
72
- Scenario('should update output when (method) setValue is called', async ({ I }) => {
72
+ Scenario('should update output when (method) setValue is called @integer_range', async ({ I }) => {
73
73
  I.amOnPage('integer.html')
74
+ I.waitForElement('.je-ready')
74
75
  I.waitForText('5', DEFAULT_WAIT_TIME, '[data-schemapath="root.integer_range"] output')
75
76
  I.click('.set-value')
77
+ I.wait(1)
76
78
  I.waitForText('2', DEFAULT_WAIT_TIME, '[data-schemapath="root.integer_range"] output')
77
79
  })
78
80
 
@@ -2,6 +2,18 @@
2
2
 
3
3
  Feature('select')
4
4
 
5
+ Scenario('Should start with correct value @select-value', async ({ I }) => {
6
+ I.amOnPage('select-values.html')
7
+ I.waitForElement('.je-ready')
8
+ I.waitForValue('#value', '{"data":[]}')
9
+ I.click('#set-value')
10
+ I.waitForValue('#value', '{"data":[{"baumart":"other_hardwood"},{"baumart":"beech"},{"baumart":"oak"},{"baumart":"spruce"}]}')
11
+ I.getSelectedValueAndAssert('select[name="root[data][0][baumart]"]', 'other_hardwood');
12
+ I.getSelectedValueAndAssert('select[name="root[data][1][baumart]"]', 'beech');
13
+ I.getSelectedValueAndAssert('select[name="root[data][2][baumart]"]', 'oak');
14
+ I.getSelectedValueAndAssert('select[name="root[data][3][baumart]"]', 'spruce');
15
+ })
16
+
5
17
  Scenario('Should render a non selectable placeholder options for not in enum values @placeholderOption', async ({ I }) => {
6
18
  I.amOnPage('placeholder-options.html')
7
19
  I.waitForElement('.je-ready')
@@ -1,3 +1,4 @@
1
+ version: '3'
1
2
  services:
2
3
  chrome:
3
- image: seleniarm/standalone-chromium:114.0
4
+ image: seleniarm/standalone-chromium:114.0
@@ -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,91 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>string-simple-mde-editor</title>
6
+ <script src="../../dist/jsoneditor.js"></script>
7
+ <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Test</h1>
12
+ <div class="form-group">
13
+ <label for="value">Value</label>
14
+ <textarea class="form-control" id="value" cols="30" rows="10"></textarea>
15
+ </div>
16
+
17
+ <button id="set-value">Set value</button>
18
+ <div id="editor-container"></div>
19
+ </div>
20
+
21
+ <script>
22
+ const container = document.querySelector("#editor-container")
23
+ const debug = document.querySelector("#value")
24
+ const setValueBtn = document.querySelector("#set-value")
25
+ const schema = {
26
+ "type": "object",
27
+ "properties": {
28
+ "data": {
29
+ "type": "array",
30
+ "uniqueItems": true,
31
+ "format": "table",
32
+ "minLength": 1,
33
+ "items": {
34
+ "type": "object",
35
+ "required": [
36
+ "baumart"
37
+ ],
38
+ "properties": {
39
+ "baumart": {
40
+ "type": "string",
41
+ "enum": [
42
+ "not_set",
43
+ "other_hardwood",
44
+ "beech",
45
+ "oak",
46
+ "spruce"
47
+ ]
48
+ },
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ const value = {
56
+ "data": [
57
+ {
58
+ "baumart": "other_hardwood",
59
+ },
60
+ {
61
+ "baumart": "beech",
62
+ },
63
+ {
64
+ "baumart": "oak",
65
+ },
66
+ {
67
+ "baumart": "spruce",
68
+ }
69
+ ]
70
+ }
71
+
72
+ const editor = new JSONEditor(container, {
73
+ disable_collapse: true,
74
+ schema: schema,
75
+ theme: 'bootstrap3'
76
+ })
77
+
78
+ editor.on('ready', () => {
79
+ debug.value = JSON.stringify(editor.getValue())
80
+ })
81
+
82
+ editor.on('change', () => {
83
+ debug.value = JSON.stringify(editor.getValue())
84
+ })
85
+
86
+ setValueBtn.addEventListener('click', () => {
87
+ editor.setValue(value)
88
+ })
89
+ </script>
90
+ </body>
91
+ </html>