@json-editor/json-editor 2.14.0 → 2.15.0

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 (83) hide show
  1. package/.env +4 -0
  2. package/.eslintrc +4 -1
  3. package/.github/workflows/build.yml +5 -4
  4. package/CHANGELOG.md +31 -0
  5. package/README.md +32 -1
  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 +4152 -3955
  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 +34 -15
  16. package/src/editors/array.js +10 -7
  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 +16 -3
  22. package/src/editors/object.js +26 -7
  23. package/src/editors/radio.js +9 -2
  24. package/src/editors/select.js +19 -8
  25. package/src/editors/select2.js +1 -1
  26. package/src/editors/starrating.js +5 -4
  27. package/src/editors/string.js +17 -1
  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/bootstrap3.js +0 -9
  36. package/src/themes/index.js +0 -1
  37. package/src/validator.js +4 -4
  38. package/tests/Dockerfile +1 -1
  39. package/tests/codeceptjs/core_test.js +8 -2
  40. package/tests/codeceptjs/editors/array_test.js +11 -6
  41. package/tests/codeceptjs/editors/autocomplete_test.js +0 -1
  42. package/tests/codeceptjs/editors/integer_test.js +0 -4
  43. package/tests/codeceptjs/editors/object_test.js +8 -0
  44. package/tests/codeceptjs/editors/rating_test.js +1 -1
  45. package/tests/codeceptjs/editors/select_test.js +18 -0
  46. package/tests/codeceptjs/editors/starrating_test.js +15 -0
  47. package/tests/codeceptjs/editors/string_test.js +7 -0
  48. package/tests/codeceptjs/issues/issue-gh-1158_test.js +1 -1
  49. package/tests/codeceptjs/issues/issue-gh-1164_test.js +0 -1
  50. package/tests/codeceptjs/issues/issue-gh-1171_test.js +11 -0
  51. package/tests/codeceptjs/issues/issue-gh-1272_test.js +21 -0
  52. package/tests/codeceptjs/issues/issue-gh-1383_test.js +1 -1
  53. package/tests/codeceptjs/issues/issue-gh-1452_test.js +10 -0
  54. package/tests/codeceptjs/issues/issue-gh-1485_test.js +13 -0
  55. package/tests/codeceptjs/issues/issue-gh-1491_test.js +9 -0
  56. package/tests/codeceptjs/issues/issue-gh-1525_test.js +9 -0
  57. package/tests/codeceptjs/issues/issue-gh-1536_test.js +12 -0
  58. package/tests/codeceptjs/issues/issue-gh-1538_test.js +10 -0
  59. package/tests/codeceptjs/issues/issue-gh-1541_test.js +8 -0
  60. package/tests/docker-compose-local.yml +1 -2
  61. package/tests/docker-compose.yml +0 -1
  62. package/tests/pages/array-events-table.html +39 -31
  63. package/tests/pages/array-events.html +39 -31
  64. package/tests/pages/assets/autocomplete.css +1 -0
  65. package/tests/pages/assets/autocomplete.min.js +1 -0
  66. package/tests/pages/autocomplete.html +4 -4
  67. package/tests/pages/enforce-const.html +176 -0
  68. package/tests/pages/issues/issue-gh-1171.html +39 -0
  69. package/tests/pages/issues/issue-gh-1272.html +167 -0
  70. package/tests/pages/issues/issue-gh-1452.html +98 -0
  71. package/tests/pages/issues/issue-gh-1466.html +63 -0
  72. package/tests/pages/issues/issue-gh-1485.html +59 -0
  73. package/tests/pages/issues/issue-gh-1491.html +59 -0
  74. package/tests/pages/issues/issue-gh-1525.html +62 -0
  75. package/tests/pages/issues/issue-gh-1536.html +55 -0
  76. package/tests/pages/issues/issue-gh-1538.html +56 -0
  77. package/tests/pages/issues/issue-gh-1541.html +51 -0
  78. package/tests/pages/issues/issue-gh-1541.json +9 -0
  79. package/tests/pages/placeholder-options.html +57 -0
  80. package/tests/pages/prompt-paste-max-length-reached.html +51 -0
  81. package/tests/pages/remove-false-properties.html +85 -0
  82. package/tests/pages/starrating.html +86 -0
  83. package/tests/unit/editor.spec.js +1 -1
@@ -10,16 +10,22 @@
10
10
  <h1>Test</h1>
11
11
  <label for="debug">Value</label>
12
12
  <textarea id="debug" class="debug" cols="30" rows="10"></textarea>
13
- <label for="action">Value</label>
14
- <textarea id="action" class="action" cols="30" rows="5"></textarea>
15
13
  <button class='get-value'>Get Value</button>
14
+
15
+ <label for="action1">Action1</label>
16
+ <textarea id="action1" cols="30" rows="5"></textarea>
17
+
18
+ <label for="action2">Action2</label>
19
+ <textarea id="action2" cols="30" rows="5"></textarea>
20
+
16
21
  <div class='container'></div>
17
22
 
18
23
  <script>
19
- var container = document.querySelector('.container');
20
- var debug = document.querySelector('.debug');
21
- var action = document.querySelector('.action');
22
- var schema = {
24
+ const container = document.querySelector('.container');
25
+ const debug = document.querySelector('.debug');
26
+ const action1 = document.querySelector('#action1');
27
+ const action2 = document.querySelector('#action2');
28
+ const schema = {
23
29
  "type": "array",
24
30
  "title": "Strings",
25
31
  "items": {
@@ -28,40 +34,42 @@
28
34
  }
29
35
  };
30
36
 
31
- var editor = new JSONEditor(container, {
32
- schema: schema
37
+ const editor = new JSONEditor(container, {
38
+ schema: schema,
39
+ enable_array_copy: true
33
40
  });
34
41
  editor.promise.then(() => {
35
42
  document.querySelector('.get-value').addEventListener('click', function () {
36
- debug.value = JSON.stringify(editor.getValue());
37
- });
38
-
39
- editor.setValue(["A","B"]);
43
+ debug.value = JSON.stringify(editor.getValue());
44
+ });
40
45
 
41
- editor.on('moveRow', function () {
42
- action.value = 'moveRow';
43
- console.log('moveRow');
44
- });
46
+ editor.setValue(["A", "B"]);
45
47
 
46
- editor.on('addRow', function () {
47
- action.value = 'addRow'
48
- console.log('addRow')
49
- });
48
+ editor.on('copyRow', function () {
49
+ action2.value = 'copyRow'
50
+ console.log('copyRow');
51
+ });
50
52
 
51
- editor.on('deleteRow', function () {
52
- action.value = 'deleteRow'
53
- console.log('deleteRow')
54
- });
53
+ editor.on('moveRow', function () {
54
+ action1.value = 'moveRow';
55
+ console.log('moveRow');
56
+ });
55
57
 
56
- editor.on('deleteAllRows', function () {
57
- action.value = 'deleteAllRows'
58
- console.log('deleteAllRows')
59
- });
60
- })
61
-
58
+ editor.on('addRow', function () {
59
+ action1.value = 'addRow'
60
+ console.log('addRow')
61
+ });
62
62
 
63
+ editor.on('deleteRow', function () {
64
+ action1.value = 'deleteRow'
65
+ console.log('deleteRow')
66
+ });
63
67
 
68
+ editor.on('deleteAllRows', function () {
69
+ action1.value = 'deleteAllRows'
70
+ console.log('deleteAllRows')
71
+ });
72
+ })
64
73
  </script>
65
-
66
74
  </body>
67
75
  </html>
@@ -0,0 +1 @@
1
+ .autocomplete-input{background-color:#eee;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iOCIvPjxwYXRoIGQ9Im0yMSAyMS00LTQiLz48L3N2Zz4=");background-position:12px;background-repeat:no-repeat;border:1px solid #eee;border-radius:8px;box-sizing:border-box;flex:1;font-size:16px;line-height:1.5;padding:12px 12px 12px 48px;position:relative;width:100%}.autocomplete-input:focus,.autocomplete-input[aria-expanded=true]{background-color:#fff;border-color:rgba(0,0,0,.12);box-shadow:0 2px 2px rgba(0,0,0,.16);outline:none}[data-position=below] .autocomplete-input[aria-expanded=true]{border-bottom-color:transparent;border-radius:8px 8px 0 0}[data-position=above] .autocomplete-input[aria-expanded=true]{border-radius:0 0 8px 8px;border-top-color:transparent;z-index:2}.autocomplete[data-loading=true]:after{animation:rotate 1s linear infinite;border:3px solid rgba(0,0,0,.12);border-radius:100%;border-right-color:rgba(0,0,0,.48);content:"";height:20px;position:absolute;right:12px;top:50%;transform:translateY(-50%);width:20px}.autocomplete-result-list{background:#fff;border:1px solid rgba(0,0,0,.12);box-shadow:0 2px 2px rgba(0,0,0,.16);box-sizing:border-box;list-style:none;margin:0;max-height:296px;overflow-y:auto;padding:0}[data-position=below] .autocomplete-result-list{border-radius:0 0 8px 8px;border-top-color:transparent;margin-top:-1px;padding-bottom:8px}[data-position=above] .autocomplete-result-list{border-bottom-color:transparent;border-radius:8px 8px 0 0;margin-bottom:-1px;padding-top:8px}.autocomplete-result{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjY2NjIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iOCIvPjxwYXRoIGQ9Im0yMSAyMS00LTQiLz48L3N2Zz4=");background-position:12px;background-repeat:no-repeat;cursor:default;padding:12px 12px 12px 48px}.autocomplete-result:hover,.autocomplete-result[aria-selected=true]{background-color:rgba(0,0,0,.06)}@keyframes rotate{0%{transform:translateY(-50%) rotate(0deg)}to{transform:translateY(-50%) rotate(359deg)}}
@@ -0,0 +1 @@
1
+ var Autocomplete=function(){"use strict";function t(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var i=0;i<n.length;i++){var s=n[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,t(s.key),s)}}function i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(e,n,i){return(n=t(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}var o=function(t,e){return t.matches?t.matches(e):t.msMatchesSelector?t.msMatchesSelector(e):t.webkitMatchesSelector?t.webkitMatchesSelector(e):null},u=function(t,e){return t.closest?t.closest(e):function(t,e){for(var n=t;n&&1===n.nodeType;){if(o(n,e))return n;n=n.parentNode}return null}(t,e)},l=i((function t(){var n,i=this,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=o.search,r=o.autoSelect,a=void 0!==r&&r,c=o.setValue,d=void 0===c?function(){}:c,h=o.setAttribute,p=void 0===h?function(){}:h,b=o.onUpdate,f=void 0===b?function(){}:b,v=o.onSubmit,m=void 0===v?function(){}:v,L=o.onShow,y=void 0===L?function(){}:L,g=o.autocorrect,w=void 0!==g&&g,R=o.onHide,S=void 0===R?function(){}:R,x=o.onLoading,A=void 0===x?function(){}:x,E=o.onLoaded,k=void 0===E?function(){}:E,I=o.submitOnEnter,C=void 0!==I&&I;e(this,t),s(this,"value",""),s(this,"searchCounter",0),s(this,"results",[]),s(this,"selectedIndex",-1),s(this,"selectedResult",null),s(this,"destroy",(function(){i.search=null,i.setValue=null,i.setAttribute=null,i.onUpdate=null,i.onSubmit=null,i.autocorrect=null,i.onShow=null,i.onHide=null,i.onLoading=null,i.onLoaded=null})),s(this,"handleInput",(function(t){var e=t.target.value;i.updateResults(e),i.value=e})),s(this,"handleKeyDown",(function(t){var e=t.key;switch(e){case"Up":case"Down":case"ArrowUp":case"ArrowDown":var n="ArrowUp"===e||"Up"===e?i.selectedIndex-1:i.selectedIndex+1;t.preventDefault(),i.handleArrows(n);break;case"Tab":i.selectResult();break;case"Enter":var s=t.target.getAttribute("aria-activedescendant").length>0;i.selectedResult=i.results[i.selectedIndex]||i.selectedResult,i.selectResult(),i.submitOnEnter?i.selectedResult&&i.onSubmit(i.selectedResult):s?t.preventDefault():(i.selectedResult&&i.onSubmit(i.selectedResult),i.selectedResult=null);break;case"Esc":case"Escape":i.hideResults(),i.setValue();break;default:return}})),s(this,"handleFocus",(function(t){var e=t.target.value;i.updateResults(e),i.value=e})),s(this,"handleBlur",(function(){i.hideResults()})),s(this,"handleResultMouseDown",(function(t){t.preventDefault()})),s(this,"handleResultClick",(function(t){var e=t.target,n=u(e,"[data-result-index]");if(n){i.selectedIndex=parseInt(n.dataset.resultIndex,10);var s=i.results[i.selectedIndex];i.selectResult(),i.onSubmit(s)}})),s(this,"handleArrows",(function(t){var e=i.results.length;i.selectedIndex=(t%e+e)%e,i.onUpdate(i.results,i.selectedIndex)})),s(this,"selectResult",(function(){var t=i.results[i.selectedIndex];t&&i.setValue(t),i.hideResults()})),s(this,"updateResults",(function(t){var e=++i.searchCounter;i.onLoading(),i.search(t).then((function(t){e===i.searchCounter&&(i.results=t,i.onLoaded(),0!==i.results.length?(i.selectedIndex=i.autoSelect?0:-1,i.onUpdate(i.results,i.selectedIndex),i.showResults()):i.hideResults())}))})),s(this,"showResults",(function(){i.setAttribute("aria-expanded",!0),i.onShow()})),s(this,"hideResults",(function(){i.selectedIndex=-1,i.results=[],i.setAttribute("aria-expanded",!1),i.setAttribute("aria-activedescendant",""),i.onUpdate(i.results,i.selectedIndex),i.onHide()})),s(this,"checkSelectedResultVisible",(function(t){var e=t.querySelector('[data-result-index="'.concat(i.selectedIndex,'"]'));if(e){var n=t.getBoundingClientRect(),s=e.getBoundingClientRect();s.top<n.top?t.scrollTop-=n.top-s.top:s.bottom>n.bottom&&(t.scrollTop+=s.bottom-n.bottom)}})),this.search=(n=l,Boolean(n&&"function"==typeof n.then)?l:function(t){return Promise.resolve(l(t))}),this.autoSelect=a,this.setValue=d,this.setAttribute=p,this.onUpdate=f,this.onSubmit=m,this.autocorrect=w,this.onShow=y,this.onHide=S,this.onLoading=A,this.onLoaded=k,this.submitOnEnter=C})),r=0,a=function(){return i((function t(n,i,s){e(this,t),this.id="".concat(s,"-result-").concat(n),this.class="".concat(s,"-result"),this["data-result-index"]=n,this.role="option",n===i&&(this["aria-selected"]="true")}),[{key:"toString",value:function(){var t=this;return Object.keys(this).reduce((function(e,n){return"".concat(e," ").concat(n,'="').concat(t[n],'"')}),"")}}])}(),c=i((function t(n){var i=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.search,c=o.onSubmit,d=void 0===c?function(){}:c,h=o.onUpdate,p=void 0===h?function(){}:h,b=o.baseClass,f=void 0===b?"autocomplete":b,v=o.autocorrect,m=void 0!==v&&v,L=o.autoSelect,y=o.getResultValue,g=void 0===y?function(t){return t}:y,w=o.renderResult,R=o.debounceTime,S=void 0===R?0:R,x=o.resultListLabel,A=o.submitOnEnter,E=void 0!==A&&A;e(this,t),s(this,"expanded",!1),s(this,"loading",!1),s(this,"position",{}),s(this,"resetPosition",!0),s(this,"initialize",(function(){i.root.style.position="relative",i.input.setAttribute("role","combobox"),i.input.setAttribute("autocomplete","off"),i.input.setAttribute("autocapitalize","off"),i.autocorrect&&i.input.setAttribute("autocorrect","on"),i.input.setAttribute("spellcheck","false"),i.input.setAttribute("aria-autocomplete","list"),i.input.setAttribute("aria-haspopup","listbox"),i.input.setAttribute("aria-expanded","false"),i.resultList.setAttribute("role","listbox");var t=function(t){if(null!=t&&t.length){var e=t.startsWith("#");return{attribute:e?"aria-labelledby":"aria-label",content:e?t.substring(1):t}}}(i.resultListLabel);t&&i.resultList.setAttribute(t.attribute,t.content),i.resultList.style.position="absolute",i.resultList.style.zIndex="1",i.resultList.style.width="100%",i.resultList.style.boxSizing="border-box",i.resultList.id||(i.resultList.id=function(){return"".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").concat(++r)}("".concat(i.baseClass,"-result-list-"))),i.input.setAttribute("aria-owns",i.resultList.id),document.body.addEventListener("click",i.handleDocumentClick),i.input.addEventListener("input",i.core.handleInput),i.input.addEventListener("keydown",i.core.handleKeyDown),i.input.addEventListener("focus",i.core.handleFocus),i.input.addEventListener("blur",i.core.handleBlur),i.resultList.addEventListener("mousedown",i.core.handleResultMouseDown),i.resultList.addEventListener("click",i.core.handleResultClick),i.updateStyle()})),s(this,"destroy",(function(){document.body.removeEventListener("click",i.handleDocumentClick),i.input.removeEventListener("input",i.core.handleInput),i.input.removeEventListener("keydown",i.core.handleKeyDown),i.input.removeEventListener("focus",i.core.handleFocus),i.input.removeEventListener("blur",i.core.handleBlur),i.resultList.removeEventListener("mousedown",i.core.handleResultMouseDown),i.resultList.removeEventListener("click",i.core.handleResultClick),i.root=null,i.input=null,i.resultList=null,i.getResultValue=null,i.onUpdate=null,i.renderResult=null,i.core.destroy(),i.core=null})),s(this,"setAttribute",(function(t,e){i.input.setAttribute(t,e)})),s(this,"setValue",(function(t){i.input.value=t?i.getResultValue(t):""})),s(this,"renderResult",(function(t,e){return"<li ".concat(e,">").concat(i.getResultValue(t),"</li>")})),s(this,"handleUpdate",(function(t,e){var n,s,o,u;i.resultList.innerHTML="",t.forEach((function(t,n){var s=new a(n,e,i.baseClass),o=i.renderResult(t,s);"string"==typeof o?i.resultList.insertAdjacentHTML("beforeend",o):i.resultList.insertAdjacentElement("beforeend",o)})),i.input.setAttribute("aria-activedescendant",e>-1?"".concat(i.baseClass,"-result-").concat(e):""),i.resetPosition&&(i.resetPosition=!1,i.position=(n=i.input,s=i.resultList,o=n.getBoundingClientRect(),u=s.getBoundingClientRect(),o.bottom+u.height>window.innerHeight&&window.innerHeight-o.bottom<o.top&&window.pageYOffset+o.top-u.height>0?"above":"below"),i.updateStyle()),i.core.checkSelectedResultVisible(i.resultList),i.onUpdate(t,e)})),s(this,"handleShow",(function(){i.expanded=!0,i.updateStyle()})),s(this,"handleHide",(function(){i.expanded=!1,i.resetPosition=!0,i.updateStyle()})),s(this,"handleLoading",(function(){i.loading=!0,i.updateStyle()})),s(this,"handleLoaded",(function(){i.loading=!1,i.updateStyle()})),s(this,"handleDocumentClick",(function(t){i.root.contains(t.target)||i.core.hideResults()})),s(this,"updateStyle",(function(){i.root.dataset.expanded=i.expanded,i.root.dataset.loading=i.loading,i.root.dataset.position=i.position,i.resultList.style.visibility=i.expanded?"visible":"hidden",i.resultList.style.pointerEvents=i.expanded?"auto":"none","below"===i.position?(i.resultList.style.bottom=null,i.resultList.style.top="100%"):(i.resultList.style.top=null,i.resultList.style.bottom="100%")})),this.root="string"==typeof n?document.querySelector(n):n,this.input=this.root.querySelector("input"),this.resultList=this.root.querySelector("ul"),this.baseClass=f,this.autocorrect=m,this.getResultValue=g,this.onUpdate=p,"function"==typeof w&&(this.renderResult=w),this.resultListLabel=x,this.submitOnEnter=E;var k,I,C,U,V=new l({search:u,autoSelect:L,setValue:this.setValue,setAttribute:this.setAttribute,onUpdate:this.handleUpdate,autocorrect:this.autocorrect,onSubmit:d,onShow:this.handleShow,onHide:this.handleHide,onLoading:this.handleLoading,onLoaded:this.handleLoaded,submitOnEnter:this.submitOnEnter});S>0&&(V.handleInput=(k=V.handleInput,I=S,function(){var t=this,e=arguments,n=C&&!U;clearTimeout(U),U=setTimeout((function(){U=null,C||k.apply(t,e)}),I),n&&k.apply(t,e)})),this.core=V,this.initialize()}));return c}();
@@ -5,9 +5,8 @@
5
5
  <title>Autocomplete</title>
6
6
  <link rel="stylesheet" id="theme-link" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
7
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://unpkg.com/@trevoreyre/autocomplete-js/dist/style.css"/>
9
- <script src="https://unpkg.com/@trevoreyre/autocomplete-js"></script>
10
- <script src="../../dist/jsoneditor.js"></script>
8
+ <link rel="stylesheet" href="./assets/autocomplete.css"/>
9
+
11
10
  </head>
12
11
  <body>
13
12
 
@@ -18,7 +17,8 @@
18
17
  <div class='json-editor-container'></div>
19
18
  </div>
20
19
 
21
-
20
+ <script src="./assets/autocomplete.min.js"></script>
21
+ <script src="../../dist/jsoneditor.js"></script>
22
22
  <script>
23
23
  window.addEventListener('load', function () {
24
24
  var jsonEditorContainer = document.querySelector('.json-editor-container')
@@ -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>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1171</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
+ <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/1171">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
+ "type": "string",
23
+ "format": "radio",
24
+ "title": "Gender",
25
+ "enum": [
26
+ "male",
27
+ "female"
28
+ ]
29
+ }
30
+
31
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
32
+ iconlib: 'fontawesome5',
33
+ schema: defaultSchema,
34
+ theme: 'bootstrap4',
35
+ use_name_attributes: false
36
+ })
37
+ </script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,167 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>GitHub Issue 1272</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
+ <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/1272">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
+ "$schema": "http://json-schema.org/draft-04/schema#",
23
+ "title": "&nbsp;",
24
+ "description": "&nbsp;",
25
+ "type": "object",
26
+ "format": "categories",
27
+ "options": {
28
+ "keep_oneof_values": false,
29
+ "disable_collapse": true
30
+ },
31
+ "properties": {
32
+ "recorder": {
33
+ "title": "Recorder",
34
+ "type": "object",
35
+ "format": "grid-strict",
36
+ "properties": {
37
+ "albums": {
38
+ "title": "Select album:",
39
+ "type": "string",
40
+ "options": {
41
+ "grid_columns": 2
42
+ },
43
+ "enum": [
44
+ "album1",
45
+ "album2"
46
+ ]
47
+ },
48
+ "album1": {
49
+ "title": "&nbsp;",
50
+ "type": "object",
51
+ "format": "grid-strict",
52
+ "options": {
53
+ "disable_collapse": true,
54
+ "dependencies": {
55
+ "albums": "album1"
56
+ }
57
+ },
58
+ "required": [
59
+ "song1",
60
+ "song2"
61
+ ],
62
+ "properties": {
63
+ "song1": {
64
+ "options": {
65
+ "grid_columns": 4
66
+ },
67
+ "type": "string"
68
+ },
69
+ "song2": {
70
+ "options": {
71
+ "grid_columns": 4
72
+ },
73
+ "type": "string"
74
+ }
75
+ }
76
+ },
77
+ "album2": {
78
+ "title": "&nbsp;",
79
+ "options": {
80
+ "dependencies": {
81
+ "albums": "album2"
82
+ }
83
+ },
84
+ "oneOf": [
85
+ {
86
+ "title": "SideA",
87
+ "type": "object",
88
+ "format": "grid-strict",
89
+ "options": {
90
+ "disable_collapse": true
91
+ },
92
+ "required": [
93
+ "song1",
94
+ "song2"
95
+ ],
96
+ "properties": {
97
+ "song1": {
98
+ "options": {
99
+ "grid_columns": 3
100
+ },
101
+ "type": "string"
102
+ },
103
+ "song2": {
104
+ "options": {
105
+ "grid_columns": 3
106
+ },
107
+ "type": "string"
108
+ }
109
+ }
110
+ },
111
+ {
112
+ "title": "SideB",
113
+ "type": "object",
114
+ "format": "grid-strict",
115
+ "options": {
116
+ "disable_collapse": true
117
+ },
118
+ "required": [
119
+ "songs"
120
+ ],
121
+ "properties": {
122
+ "songs": {
123
+ "title": "array editor",
124
+ "type": "array",
125
+ "format": "table",
126
+ "uniqueItems": true,
127
+ "items": {
128
+ "title": "song",
129
+ "type": "object",
130
+ "options": {
131
+ "disable_collapse": true
132
+ },
133
+ "properties": {
134
+ "song": {
135
+ "type": "integer",
136
+ "enum": [
137
+ 1,
138
+ 2,
139
+ 3,
140
+ 4,
141
+ 5
142
+ ]
143
+ },
144
+ "title": {
145
+ "type": "string"
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ]
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ const editor = new JSONEditor(document.getElementById('editor_holder'), {
160
+ iconlib: 'fontawesome5',
161
+ schema: defaultSchema,
162
+ theme: 'bootstrap4',
163
+ keep_oneof_values: false
164
+ })
165
+ </script>
166
+ </body>
167
+ </html>
@@ -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>