wysiwyg.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>JSON Editor WYSIWYG Example</title>
  6. <script src="//unpkg.com/json-editor"></script>
  7. <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  8. <script src="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.bbcode.min.js"></script>
  9. <link rel="stylesheet" href="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.default.min.css">
  10. <script src="//cdn.jsdelivr.net/sceditor/1.4.3/jquery.sceditor.xhtml.min.js"></script>
  11. <link rel="stylesheet" href="//cdn.jsdelivr.net/sceditor/1.4.3/themes/default.min.css">
  12. </head>
  13. <body>
  14. <h1>JSON Editor WYSIWYG Example</h1>
  15. <p style='margin-bottom:20px;'>This example demonstrates JSONEditor's integration with SCEditor</p>
  16. <div id='editor_holder'></div>
  17. <button id='submit'>Submit (console.log)</button>
  18. <script>
  19. // Initialize the editor with a JSON schema
  20. var editor = new JSONEditor(document.getElementById('editor_holder'),{
  21. schema: {
  22. type: "object",
  23. title: "Blog Post",
  24. properties: {
  25. title: {
  26. type: "string"
  27. },
  28. body: {
  29. type: "string",
  30. format: "html",
  31. options: {
  32. wysiwyg: true
  33. }
  34. }
  35. }
  36. }
  37. });
  38. // Hook up the submit button to log to the console
  39. document.getElementById('submit').addEventListener('click',function() {
  40. // Get the value from the editor
  41. console.log(editor.getValue());
  42. });
  43. </script>
  44. </body>
  45. </html>