live_code_preview.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0" />
  6. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
  7. <link rel="stylesheet" href="../../css/froala_editor.css">
  8. <link rel="stylesheet" href="../../css/froala_style.css">
  9. <link rel="stylesheet" href="../../css/plugins/code_view.css">
  10. <link rel="stylesheet" href="../../css/plugins/image_manager.css">
  11. <link rel="stylesheet" href="../../css/plugins/image.css">
  12. <link rel="stylesheet" href="../../css/plugins/table.css">
  13. <link rel="stylesheet" href="../../css/plugins/video.css">
  14. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.css">
  15. <style>
  16. body {
  17. text-align: center;
  18. }
  19. div#editor {
  20. width: 81%;
  21. margin: auto;
  22. text-align: left;
  23. }
  24. pre#preview {
  25. padding: 10px;
  26. background: #efefef;
  27. white-space: pre-line;
  28. line-height: 1.5;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="editor">
  34. <div id='edit' style="margin-top: 30px;">
  35. <img class="fr-fir fr-dii" src="../../img/photo1.jpg" alt="Old Clock" width="200" />
  36. <h1>Live Code Preview</h1>
  37. <p>This example allows you to see when the <a
  38. href="https://www.froala.com/wysiwyg-editor/v2.0/docs/events#contentChanged" title="contentChanged event"
  39. target="_blank">contentChanged</a> event is triggered and how the rich text editor's content appears outside
  40. the editable area.</p>
  41. <p>Start typing and you can preview the code of the WYSIWYG HTML editor as you type below the editing box.</p>
  42. </div>
  43. <pre id="preview"></pre>
  44. </div>
  45. <script type="text/javascript"
  46. src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.js"></script>
  47. <script type="text/javascript"
  48. src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/mode/xml/xml.min.js"></script>
  49. <script type="text/javascript" src="../../js/froala_editor.min.js"></script>
  50. <script type="text/javascript" src="../../js/plugins/align.min.js"></script>
  51. <script type="text/javascript" src="../../js/plugins/code_beautifier.min.js"></script>
  52. <script type="text/javascript" src="../../js/plugins/code_view.min.js"></script>
  53. <script type="text/javascript" src="../../js/plugins/draggable.min.js"></script>
  54. <script type="text/javascript" src="../../js/plugins/image.min.js"></script>
  55. <script type="text/javascript" src="../../js/plugins/image_manager.min.js"></script>
  56. <script type="text/javascript" src="../../js/plugins/link.min.js"></script>
  57. <script type="text/javascript" src="../../js/plugins/lists.min.js"></script>
  58. <script type="text/javascript" src="../../js/plugins/paragraph_format.min.js"></script>
  59. <script type="text/javascript" src="../../js/plugins/paragraph_style.min.js"></script>
  60. <script type="text/javascript" src="../../js/plugins/table.min.js"></script>
  61. <script type="text/javascript" src="../../js/plugins/video.min.js"></script>
  62. <script type="text/javascript" src="../../js/plugins/url.min.js"></script>
  63. <script type="text/javascript" src="../../js/plugins/entities.min.js"></script>
  64. <script>
  65. (function () {
  66. const editorInstance = new FroalaEditor('#edit', {
  67. events: {
  68. initialized: function () {
  69. const editor = this
  70. document.getElementById('preview').innerText = editor.codeBeautifier.run(editor.html.get())
  71. },
  72. contentChanged: function () {
  73. const editor = this
  74. document.getElementById('preview').innerText = editor.codeBeautifier.run(editor.html.get())
  75. }
  76. }
  77. })
  78. })()
  79. </script>
  80. </body>
  81. </html>