123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>JSON Editor Selectize Integration Example</title>
- <script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor/dist/jsoneditor.min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/js/standalone/selectize.js"></script>
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/css/selectize.bootstrap3.css">
- </head>
- <body>
- <h1>JSON Editor Selectize Integration Example</h1>
- <p style='margin-bottom:20px;'>This example demonstrates JSONEditor's integration with Selectize</p>
- <div id='editor_holder'></div>
- <button id='submit'>Submit (console.log)</button>
- <script>
- // Global selectize options
- JSONEditor.plugins.selectize.enable = true;
- // Initialize the editor with a JSON schema
- var editor = new JSONEditor(document.getElementById('editor_holder'),{
- schema: {
- type: "object",
- title: "Text",
- required: ["fontSize","color","font","weight","possibleFonts"],
- properties: {
- fontSize: {
- type: "integer",
- enum: [10,11,12,14,16,18,20,22,24,36,48,60,72,100],
- default: 24,
- options: {
- // Override defaullt options
- selectize_options: {
- create: true
- }
- }
- },
- color: {
- type: "string",
- enum: ["black","red","green","blue","yellow","orange","purple","brown","white","cyan","magenta"],
- options: {
- // Override defaullt options
- selectize_options: {
- create: false,
- sortField: 'text'
- }
- }
- },
- font: {
- type: "string",
- enumSource: "possible_fonts",
- watch: {
- "possible_fonts": "root.possibleFonts"
- },
- options: {
- // Override defaullt options
- selectize_options: {
- create: false,
- sortField: 'text'
- }
- }
- },
- weight: {
- type: "string",
- enum: ["normal","bold","bolder","lighter"],
- options: {
- enum_titles: ["Normal (400)","Bold (700)","Bolder (900)","Lighter (200)"]
- }
- },
- possibleFonts: {
- type: "array",
- uniqueItems: true,
- items: {
- type: "string"
- },
- default: ["Arial","Times","Helvetica","Comic Sans"]
- }
- }
- },
- startval: {
- color: "red"
- }
- });
- // Hook up the submit button to log to the console
- document.getElementById('submit').addEventListener('click',function() {
- // Get the value from the editor
- console.log(editor.getValue());
- });
- </script>
- </body>
- </html>
|