@json-editor/json-editor 2.5.2 → 2.6.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/.eslintrc +5 -2
- package/.github/PULL_REQUEST_TEMPLATE.md +6 -6
- package/.github/workflows/build.yml +58 -0
- package/CHANGELOG.md +41 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +39 -4
- package/README_ADDON.md +65 -0
- package/config/codeceptjs_helpers.js +4 -0
- package/dist/jsoneditor.js +2 -2
- package/dist/nonmin/jsoneditor.js +3711 -3324
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/docs/cleave.html +1 -1
- package/docs/datetime.html +1 -1
- package/docs/describedby.html +1 -1
- package/docs/index.html +4 -2
- package/docs/materialize_css.html +1 -1
- package/docs/meta_schema.json +0 -1
- package/docs/radio.html +1 -1
- package/docs/select2.html +1 -1
- package/docs/selectize.html +1 -1
- package/docs/starrating.html +1 -1
- package/docs/wysiwyg.html +1 -1
- package/package.json +27 -26
- package/release-notes.md +9 -9
- package/src/core.js +1 -0
- package/src/defaults.js +182 -94
- package/src/editor.js +28 -9
- package/src/editors/array.js +20 -16
- package/src/editors/autocomplete.js +1 -0
- package/src/editors/base64.js +5 -4
- package/src/editors/button.js +2 -2
- package/src/editors/checkbox.js +3 -3
- package/src/editors/datetime.js +2 -2
- package/src/editors/info.js +1 -1
- package/src/editors/multiple.js +8 -2
- package/src/editors/multiselect.js +5 -3
- package/src/editors/object.js +35 -21
- package/src/editors/radio.js +9 -4
- package/src/editors/select.js +6 -6
- package/src/editors/signature.js +3 -2
- package/src/editors/starrating.js +5 -5
- package/src/editors/string.js +6 -4
- package/src/editors/table.js +24 -14
- package/src/editors/upload.js +4 -3
- package/src/editors/uuid.js +1 -1
- package/src/iconlibs/index.js +2 -0
- package/src/iconlibs/openiconic.js +28 -0
- package/src/schemaloader.js +112 -28
- package/src/theme.js +6 -3
- package/src/themes/bootstrap3.js +4 -4
- package/src/themes/bootstrap4.js +11 -3
- package/src/themes/html.js +1 -2
- package/src/themes/materialize.js +1 -1
- package/src/themes/spectre.js +11 -8
- package/src/themes/tailwind.js +1 -1
- package/src/validator.js +128 -16
- package/tests/codeceptjs/core_test.js +125 -1
- package/tests/codeceptjs/editors/array_test.js +13 -11
- package/tests/codeceptjs/editors/button_test.js +6 -1
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
- package/tests/codeceptjs/editors/number_test.js +1 -1
- package/tests/codeceptjs/editors/object_test.js +216 -100
- package/tests/codeceptjs/editors/programmatic-changes_test.js +3 -1
- package/tests/codeceptjs/editors/radio_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +10 -11
- package/tests/codeceptjs/editors/select_test.js +17 -15
- package/tests/codeceptjs/editors/stepper_test.js +13 -1
- package/tests/codeceptjs/editors/string_test.js +81 -80
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +58 -56
- package/tests/codeceptjs/editors/tabs_test.js +12 -10
- package/tests/codeceptjs/editors/validation_test.js +10 -8
- package/tests/codeceptjs/meta-schema_test.js +13 -14
- package/tests/codeceptjs/schemaloader_test.js +13 -0
- package/tests/codeceptjs/steps_file.js +4 -3
- package/tests/codeceptjs/themes_test.js +31 -0
- package/tests/docker-compose.yml +4 -3
- package/tests/fixtures/validation.json +382 -1
- package/tests/pages/_demo.html +2 -0
- package/tests/pages/anyof.html +80 -0
- package/tests/pages/issues/issue-gh-812.html +110 -0
- package/tests/pages/issues/issue-gh-848.html +81 -0
- package/tests/pages/meta_schema.json +0 -1
- package/tests/pages/object-no-additional-properties.html +27 -12
- package/tests/pages/object-required-properties.html +43 -9
- package/tests/pages/object-show-opt-in.html +110 -0
- package/tests/pages/object-with-dependencies-array.html +56 -0
- package/tests/pages/oneof.html +103 -0
- package/tests/pages/read-only.html +19 -4
- package/tests/pages/stepper-manual.html +57 -0
- package/tests/pages/themes.html +2 -0
- package/tests/pages/translate-property.html +247 -0
- package/tests/pages/urn.html +93 -0
- package/tests/unit/core.spec.js +2 -0
- package/tests/unit/defaults.spec.js +4 -2
- package/tests/unit/editor.spec.js +2 -0
- package/tests/unit/editors/array.spec.js +86 -0
- package/tests/unit/editors/table.spec.js +91 -0
- package/tests/unit/schemaloader.spec.js +362 -3
- package/tests/unit/validator.spec.js +14 -2
|
@@ -62,6 +62,18 @@
|
|
|
62
62
|
"value3"
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
|
+
"const": {
|
|
66
|
+
"schema": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"const": "value1"
|
|
69
|
+
},
|
|
70
|
+
"valid": [
|
|
71
|
+
"value1"
|
|
72
|
+
],
|
|
73
|
+
"invalid": [
|
|
74
|
+
"value2"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
65
77
|
"extends": {
|
|
66
78
|
"schema": {
|
|
67
79
|
"type": "string",
|
|
@@ -962,5 +974,374 @@
|
|
|
962
974
|
"abc 1999-01-01",
|
|
963
975
|
"1999-01-01 abc"
|
|
964
976
|
]
|
|
977
|
+
},
|
|
978
|
+
"property_names_invalid": {
|
|
979
|
+
"schema": {
|
|
980
|
+
"type": "object",
|
|
981
|
+
"properties": {
|
|
982
|
+
"abc": { "type": "string" }
|
|
983
|
+
},
|
|
984
|
+
"propertyNames": {
|
|
985
|
+
"unsupported": 10
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
"valid": [
|
|
989
|
+
],
|
|
990
|
+
"invalid": [
|
|
991
|
+
{
|
|
992
|
+
"abc": "hello"
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
},
|
|
996
|
+
"property_names_invalid_maxlength": {
|
|
997
|
+
"schema": {
|
|
998
|
+
"type": "object",
|
|
999
|
+
"properties": {
|
|
1000
|
+
"abc": { "type": "string" }
|
|
1001
|
+
},
|
|
1002
|
+
"propertyNames": {
|
|
1003
|
+
"maxLength": "10"
|
|
1004
|
+
}
|
|
1005
|
+
},
|
|
1006
|
+
"valid": [
|
|
1007
|
+
],
|
|
1008
|
+
"invalid": [
|
|
1009
|
+
{
|
|
1010
|
+
"abc": "hello"
|
|
1011
|
+
}
|
|
1012
|
+
]
|
|
1013
|
+
},
|
|
1014
|
+
"property_names_invalid_enum": {
|
|
1015
|
+
"schema": {
|
|
1016
|
+
"type": "object",
|
|
1017
|
+
"properties": {
|
|
1018
|
+
"abc": { "type": "string" }
|
|
1019
|
+
},
|
|
1020
|
+
"propertyNames": {
|
|
1021
|
+
"enum": "list"
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
"valid": [
|
|
1025
|
+
],
|
|
1026
|
+
"invalid": [
|
|
1027
|
+
{
|
|
1028
|
+
"abc": "hello"
|
|
1029
|
+
}
|
|
1030
|
+
]
|
|
1031
|
+
},
|
|
1032
|
+
"property_names_invalid_const": {
|
|
1033
|
+
"schema": {
|
|
1034
|
+
"type": "object",
|
|
1035
|
+
"properties": {
|
|
1036
|
+
"abc": { "type": "string" }
|
|
1037
|
+
},
|
|
1038
|
+
"propertyNames": {
|
|
1039
|
+
"const": "abc"
|
|
1040
|
+
},
|
|
1041
|
+
"additionalProperties": true
|
|
1042
|
+
},
|
|
1043
|
+
"valid": [
|
|
1044
|
+
{
|
|
1045
|
+
"abc": "hello"
|
|
1046
|
+
}
|
|
1047
|
+
],
|
|
1048
|
+
"invalid": [
|
|
1049
|
+
{
|
|
1050
|
+
"foo": "world"
|
|
1051
|
+
}
|
|
1052
|
+
]
|
|
1053
|
+
},
|
|
1054
|
+
"property_names_invalid_pattern": {
|
|
1055
|
+
"schema": {
|
|
1056
|
+
"type": "object",
|
|
1057
|
+
"properties": {
|
|
1058
|
+
"abc": { "type": "string" }
|
|
1059
|
+
},
|
|
1060
|
+
"propertyNames": {
|
|
1061
|
+
"pattern": [
|
|
1062
|
+
"abc"
|
|
1063
|
+
]
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
"valid": [
|
|
1067
|
+
],
|
|
1068
|
+
"invalid": [
|
|
1069
|
+
{
|
|
1070
|
+
"abc": "hello"
|
|
1071
|
+
}
|
|
1072
|
+
]
|
|
1073
|
+
},
|
|
1074
|
+
"property_names_true": {
|
|
1075
|
+
"schema": {
|
|
1076
|
+
"type": "object",
|
|
1077
|
+
"properties": {
|
|
1078
|
+
"abc": { "type": "string" }
|
|
1079
|
+
},
|
|
1080
|
+
"propertyNames": true
|
|
1081
|
+
},
|
|
1082
|
+
"valid": [
|
|
1083
|
+
{
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
"abc": "hello"
|
|
1087
|
+
}
|
|
1088
|
+
],
|
|
1089
|
+
"invalid": [
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
1092
|
+
"property_names_false": {
|
|
1093
|
+
"schema": {
|
|
1094
|
+
"type": "object",
|
|
1095
|
+
"properties": {
|
|
1096
|
+
"abc": { "type": "string" }
|
|
1097
|
+
},
|
|
1098
|
+
"propertyNames": false
|
|
1099
|
+
},
|
|
1100
|
+
"valid": [
|
|
1101
|
+
{
|
|
1102
|
+
}
|
|
1103
|
+
],
|
|
1104
|
+
"invalid": [
|
|
1105
|
+
{
|
|
1106
|
+
"abc": "hello"
|
|
1107
|
+
}
|
|
1108
|
+
]
|
|
1109
|
+
},
|
|
1110
|
+
"property_names": {
|
|
1111
|
+
"schema": {
|
|
1112
|
+
"type": "object",
|
|
1113
|
+
"propertyNames": {
|
|
1114
|
+
"maxLength": 5,
|
|
1115
|
+
"pattern": "^[a-z]+",
|
|
1116
|
+
"enum": [
|
|
1117
|
+
"alpha",
|
|
1118
|
+
"bravo",
|
|
1119
|
+
"charlie"
|
|
1120
|
+
]
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
"valid": [
|
|
1124
|
+
{
|
|
1125
|
+
"alpha": {"type": "string" }
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
"bravo": {"type": "string" }
|
|
1129
|
+
}
|
|
1130
|
+
],
|
|
1131
|
+
"invalid": [
|
|
1132
|
+
{
|
|
1133
|
+
"abc": { "type": "string" }
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
"charlie": { "type": "string" }
|
|
1137
|
+
}
|
|
1138
|
+
]
|
|
1139
|
+
},
|
|
1140
|
+
"nested_anyOf": {
|
|
1141
|
+
"schema": {
|
|
1142
|
+
"type": "object",
|
|
1143
|
+
"properties": {
|
|
1144
|
+
"prop": {
|
|
1145
|
+
"anyOf": [
|
|
1146
|
+
{
|
|
1147
|
+
"$ref": "#/definitions/A"
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
"$ref": "#/definitions/B"
|
|
1151
|
+
}
|
|
1152
|
+
]
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
"definitions": {
|
|
1156
|
+
"A": {
|
|
1157
|
+
"title": "A",
|
|
1158
|
+
"type": "object",
|
|
1159
|
+
"properties": {
|
|
1160
|
+
"fooA": {
|
|
1161
|
+
"type": "string"
|
|
1162
|
+
},
|
|
1163
|
+
"barA": {
|
|
1164
|
+
"type": "string"
|
|
1165
|
+
},
|
|
1166
|
+
"common": {
|
|
1167
|
+
"type": "string"
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
"required": [
|
|
1171
|
+
"fooA",
|
|
1172
|
+
"barA"
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
"B": {
|
|
1176
|
+
"title": "B",
|
|
1177
|
+
"anyOf": [
|
|
1178
|
+
{
|
|
1179
|
+
"$ref": "#/definitions/C"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
"$ref": "#/definitions/D"
|
|
1183
|
+
}
|
|
1184
|
+
]
|
|
1185
|
+
},
|
|
1186
|
+
"C": {
|
|
1187
|
+
"title": "C",
|
|
1188
|
+
"type": "object",
|
|
1189
|
+
"properties": {
|
|
1190
|
+
"fooC": {
|
|
1191
|
+
"type": "string"
|
|
1192
|
+
},
|
|
1193
|
+
"barC": {
|
|
1194
|
+
"type": "string"
|
|
1195
|
+
},
|
|
1196
|
+
"common": {
|
|
1197
|
+
"type": "string"
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
"required": [
|
|
1201
|
+
"fooC",
|
|
1202
|
+
"barC"
|
|
1203
|
+
]
|
|
1204
|
+
},
|
|
1205
|
+
"D": {
|
|
1206
|
+
"title": "D",
|
|
1207
|
+
"type": "object",
|
|
1208
|
+
"properties": {
|
|
1209
|
+
"fooD": {
|
|
1210
|
+
"type": "string"
|
|
1211
|
+
},
|
|
1212
|
+
"barD": {
|
|
1213
|
+
"type": "string"
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
"required": [
|
|
1217
|
+
"fooD",
|
|
1218
|
+
"barD"
|
|
1219
|
+
]
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
"valid": [
|
|
1224
|
+
{
|
|
1225
|
+
"prop": {
|
|
1226
|
+
"fooC": "foo",
|
|
1227
|
+
"barC": "bar",
|
|
1228
|
+
"common": "common"
|
|
1229
|
+
}
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
"prop": {
|
|
1233
|
+
"fooD": "foo",
|
|
1234
|
+
"barD": "bar",
|
|
1235
|
+
"common": "common"
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
"prop": {
|
|
1240
|
+
"fooA": "foo",
|
|
1241
|
+
"barA": "bar",
|
|
1242
|
+
"common": "common"
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
],
|
|
1246
|
+
"invalid": [
|
|
1247
|
+
{
|
|
1248
|
+
"prop": {
|
|
1249
|
+
"common": "common"
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
]
|
|
1253
|
+
},
|
|
1254
|
+
"anyOf_invalid_better_fit_test": {
|
|
1255
|
+
"schema": {
|
|
1256
|
+
"type": "object",
|
|
1257
|
+
"properties": {
|
|
1258
|
+
"foo": {
|
|
1259
|
+
"anyOf": [
|
|
1260
|
+
{
|
|
1261
|
+
"$ref": "#/definitions/A"
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
"$ref": "#/definitions/B"
|
|
1265
|
+
}
|
|
1266
|
+
]
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
"definitions": {
|
|
1270
|
+
"A": {
|
|
1271
|
+
"type": "object",
|
|
1272
|
+
"properties": {
|
|
1273
|
+
"type": {
|
|
1274
|
+
"enum": [
|
|
1275
|
+
"A"
|
|
1276
|
+
],
|
|
1277
|
+
"type": "string"
|
|
1278
|
+
},
|
|
1279
|
+
"referenced": {
|
|
1280
|
+
"$ref": "#/definitions/ReferencedObject"
|
|
1281
|
+
}
|
|
1282
|
+
},
|
|
1283
|
+
"required": [
|
|
1284
|
+
"type"
|
|
1285
|
+
]
|
|
1286
|
+
},
|
|
1287
|
+
"B": {
|
|
1288
|
+
"type": "object",
|
|
1289
|
+
"properties": {
|
|
1290
|
+
"type": {
|
|
1291
|
+
"enum": [
|
|
1292
|
+
"B"
|
|
1293
|
+
],
|
|
1294
|
+
"type": "string"
|
|
1295
|
+
},
|
|
1296
|
+
"referenced": {
|
|
1297
|
+
"properties": {
|
|
1298
|
+
"foo": {
|
|
1299
|
+
"type": "string"
|
|
1300
|
+
},
|
|
1301
|
+
"bar": {
|
|
1302
|
+
"type": "string"
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
"type": "object"
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
"required": [
|
|
1309
|
+
"type"
|
|
1310
|
+
]
|
|
1311
|
+
},
|
|
1312
|
+
"ReferencedObject": {
|
|
1313
|
+
"properties": {
|
|
1314
|
+
"foo": {
|
|
1315
|
+
"type": "string"
|
|
1316
|
+
},
|
|
1317
|
+
"bar": {
|
|
1318
|
+
"type": "string"
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1321
|
+
"type": "object"
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
"valid": [
|
|
1326
|
+
{
|
|
1327
|
+
"foo": {
|
|
1328
|
+
"type": "A",
|
|
1329
|
+
"referenced": {
|
|
1330
|
+
"foo": "",
|
|
1331
|
+
"bar": ""
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
"foo": {
|
|
1337
|
+
"type": "B",
|
|
1338
|
+
"referenced": {
|
|
1339
|
+
"foo": "",
|
|
1340
|
+
"bar": ""
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
],
|
|
1345
|
+
"invalid": []
|
|
965
1346
|
}
|
|
966
|
-
}
|
|
1347
|
+
}
|
package/tests/pages/_demo.html
CHANGED
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
<option value='fontawesome4'>fontawesome 4</option>
|
|
71
71
|
<option value='fontawesome5'>fontawesome 5</option>
|
|
72
72
|
<option value='jqueryui'>jQuery UI</option>
|
|
73
|
+
<option value='openiconic'>Open Iconic</option>
|
|
73
74
|
<option value='spectre'>Spectre</option>
|
|
74
75
|
</select>
|
|
75
76
|
</div>
|
|
@@ -214,6 +215,7 @@
|
|
|
214
215
|
fontawesome4: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css',
|
|
215
216
|
fontawesome5: 'https://use.fontawesome.com/releases/v5.6.1/css/all.css',
|
|
216
217
|
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
|
|
218
|
+
openiconic: 'https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic.min.css',
|
|
217
219
|
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
|
|
218
220
|
}
|
|
219
221
|
iconlibLink.href = iconLibMap[data.options.iconlib]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8"/>
|
|
5
|
+
<title>oneOf</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
|
+
<textarea class="value form-control" rows="10"></textarea>
|
|
14
|
+
<button class='get-value'>Get Value</button>
|
|
15
|
+
<button class='set-value'>Set Value</button>
|
|
16
|
+
<div class='json-editor-container'></div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
var jsonEditorContainer = document.querySelector('.json-editor-container');
|
|
22
|
+
var value = document.querySelector('.value');
|
|
23
|
+
|
|
24
|
+
var schema = {
|
|
25
|
+
"title": "Person",
|
|
26
|
+
"type": "object",
|
|
27
|
+
"required": [
|
|
28
|
+
"age"
|
|
29
|
+
],
|
|
30
|
+
"properties": {
|
|
31
|
+
"age": {
|
|
32
|
+
"anyOf": [
|
|
33
|
+
{
|
|
34
|
+
"type": "number",
|
|
35
|
+
"title": "Value, number"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "string",
|
|
39
|
+
"title": "Value, string",
|
|
40
|
+
"minLength": 1
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "null",
|
|
44
|
+
"title": "Value, null"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var editor = new JSONEditor(jsonEditorContainer, {
|
|
52
|
+
schema: schema,
|
|
53
|
+
theme: 'bootstrap4',
|
|
54
|
+
show_errors: 'always',
|
|
55
|
+
iconlib: 'fontawesome5',
|
|
56
|
+
object_layout: 'normal',
|
|
57
|
+
disable_collapse: true,
|
|
58
|
+
disable_edit_json: true,
|
|
59
|
+
disable_properties: true,
|
|
60
|
+
use_default_values: false,
|
|
61
|
+
required_by_default: true,
|
|
62
|
+
disable_array_reorder: true,
|
|
63
|
+
disable_array_delete_all_rows: true,
|
|
64
|
+
disable_array_delete_last_row: true,
|
|
65
|
+
keep_oneof_values: false
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
69
|
+
value.value = JSON.stringify(editor.getValue());
|
|
70
|
+
console.log(editor.getValue());
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
document.querySelector('.set-value').addEventListener('click', function () {
|
|
74
|
+
editor.setValue({number_range: 2})
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
</body>
|
|
80
|
+
</html>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>GitHub Issue 812</title>
|
|
6
|
+
<script src="../../../dist/jsoneditor.js"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<h1><a href="https://github.com/json-editor/json-editor/issues/812">GitHub Issue 812</a></h1>
|
|
10
|
+
|
|
11
|
+
<textarea class="debug" cols="30" rows="10"></textarea>
|
|
12
|
+
<button class='get-value'>Get Value</button>
|
|
13
|
+
|
|
14
|
+
<div id='editor_holder'></div>
|
|
15
|
+
<button id='submit'>Submit (console.log)</button>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
var debug = document.querySelector('.debug');
|
|
19
|
+
|
|
20
|
+
// Initialize the editor with a JSON schema
|
|
21
|
+
// JSONEditor.defaults.options.remove_empty_properties = true;
|
|
22
|
+
var editor = new JSONEditor(document.getElementById('editor_holder'),{
|
|
23
|
+
schema: {
|
|
24
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"students": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"format": "tabs",
|
|
30
|
+
"items": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"id": "student_arr_item",
|
|
33
|
+
"properties": {
|
|
34
|
+
"name": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"sessions": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"format": "table",
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"student_name": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"watch": {
|
|
46
|
+
"watch_student_name": "student_arr_item.name"
|
|
47
|
+
},
|
|
48
|
+
"template": "{{ watch_student_name }}"
|
|
49
|
+
},
|
|
50
|
+
"minutes": {
|
|
51
|
+
"type": "integer"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Hook up the submit button to log to the console
|
|
64
|
+
document.getElementById('submit').addEventListener('click',function() {
|
|
65
|
+
// Get the value from the editor
|
|
66
|
+
console.log(editor.getValue());
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
document.querySelector('.get-value').addEventListener('click', function () {
|
|
70
|
+
debug.value = JSON.stringify(editor.getValue());
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
editor.setValue({
|
|
74
|
+
"students": [
|
|
75
|
+
{
|
|
76
|
+
"name": "AAA",
|
|
77
|
+
"sessions": [
|
|
78
|
+
{
|
|
79
|
+
"student_name": "AAA",
|
|
80
|
+
"minutes": 15
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"student_name": "AAA",
|
|
84
|
+
"minutes": 15
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "BBB",
|
|
90
|
+
"sessions": [
|
|
91
|
+
{
|
|
92
|
+
"student_name": "BBB",
|
|
93
|
+
"minutes": 20
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "CCC",
|
|
99
|
+
"sessions": [
|
|
100
|
+
{
|
|
101
|
+
"student_name": "CCC",
|
|
102
|
+
"minutes": 10
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
</script>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>GitHub Issue 848</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
|
+
<div class="container">
|
|
12
|
+
<a href="https://github.com/json-editor/json-editor/issues/848">GitHub Issue 848</a>
|
|
13
|
+
<div id='editor_holder'></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
var defaultSchema = {
|
|
18
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
19
|
+
"name": "SettingListItem",
|
|
20
|
+
"title": "List Source Item",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"definitions": {
|
|
23
|
+
"pattern.name": {
|
|
24
|
+
"pattern": "^([a-zA-Z_][a-zA-Z0-9_]*?)$"
|
|
25
|
+
},
|
|
26
|
+
"length.id": {
|
|
27
|
+
"maxLength": 250
|
|
28
|
+
},
|
|
29
|
+
"length.propertyid": {
|
|
30
|
+
"maxLength": 100
|
|
31
|
+
},
|
|
32
|
+
"length.other": {
|
|
33
|
+
"maxLength": 2000
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"properties": {
|
|
37
|
+
"list": {
|
|
38
|
+
"allOf": [
|
|
39
|
+
{
|
|
40
|
+
"title": "List name",
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"$ref": "#/definitions/pattern.name"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"$ref": "#/definitions/length.propertyid"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"list_group": {
|
|
52
|
+
"title": "List group",
|
|
53
|
+
"anyOf": [
|
|
54
|
+
{
|
|
55
|
+
"type": "string",
|
|
56
|
+
"title": "Value, string",
|
|
57
|
+
"$ref": "#/definitions/length.other"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"type": "null",
|
|
61
|
+
"title": "Value, null"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": [
|
|
67
|
+
"list",
|
|
68
|
+
"list_group"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var editor = new JSONEditor(document.getElementById('editor_holder'),{
|
|
73
|
+
iconlib: 'fontawesome5',
|
|
74
|
+
object_layout: 'normal',
|
|
75
|
+
schema: defaultSchema,
|
|
76
|
+
show_errors: 'always',
|
|
77
|
+
theme: 'bootstrap4'
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
</body>
|
|
81
|
+
</html>
|