test_wysiwyg.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>WYSIWYG Editor Test</title>
  7. <link rel="stylesheet" href="css/wysiwyg.css">
  8. <style>
  9. body {
  10. font-family: Arial, sans-serif;
  11. max-width: 800px;
  12. margin: 0 auto;
  13. padding: 20px;
  14. }
  15. .test-form {
  16. margin-top: 20px;
  17. }
  18. .btn {
  19. padding: 10px 20px;
  20. border: none;
  21. border-radius: 4px;
  22. cursor: pointer;
  23. margin: 5px;
  24. }
  25. .btn-primary {
  26. background-color: #3b82f6;
  27. color: white;
  28. }
  29. .btn-secondary {
  30. background-color: #6b7280;
  31. color: white;
  32. }
  33. .output {
  34. margin-top: 20px;
  35. padding: 15px;
  36. border: 1px solid #d1d5db;
  37. border-radius: 4px;
  38. background-color: #f9fafb;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <h1>WYSIWYG Editor Test</h1>
  44. <form class="test-form" id="testForm">
  45. <div class="form-group">
  46. <label for="title">Title:</label>
  47. <input type="text" id="title" name="title" value="Test Publication">
  48. </div>
  49. <div class="form-group">
  50. <label for="content" class="wysiwyg-label">Content:</label>
  51. <textarea id="content" name="content" rows="20" style="display: none;">
  52. <h2>Welcome to the WYSIWYG Editor</h2>
  53. <p>This is a <strong>test</strong> of the rich text editor. You can:</p>
  54. <ul>
  55. <li>Format text with <strong>bold</strong>, <em>italic</em>, and <u>underline</u></li>
  56. <li>Create headings (H1, H2, H3)</li>
  57. <li>Add links and images</li>
  58. <li>Create ordered and unordered lists</li>
  59. </ul>
  60. <p>Try editing this content to test the editor features!</p>
  61. </textarea>
  62. </div>
  63. <div class="form-actions">
  64. <button type="submit" class="btn btn-primary">Submit Form</button>
  65. <button type="button" class="btn btn-secondary" onclick="showContent()">Show Content</button>
  66. <button type="button" class="btn btn-secondary" onclick="clearContent()">Clear</button>
  67. </div>
  68. </form>
  69. <div id="output" class="output" style="display: none;">
  70. <h3>Form Output:</h3>
  71. <pre id="outputText"></pre>
  72. </div>
  73. <div id="preview" class="output" style="display: none;">
  74. <h3>Content Preview:</h3>
  75. <div id="previewContent"></div>
  76. </div>
  77. <script src="js/wysiwyg.js"></script>
  78. <script>
  79. // Override the default initialization since we're not in the admin context
  80. document.addEventListener('DOMContentLoaded', () => {
  81. const editor = new WYSIWYGEditor('content');
  82. window.wysiwygEditor = editor;
  83. // Handle form submission
  84. const form = document.getElementById('testForm');
  85. form.addEventListener('submit', (e) => {
  86. e.preventDefault();
  87. showContent();
  88. });
  89. });
  90. function showContent() {
  91. const content = document.getElementById('content').value;
  92. const title = document.getElementById('title').value;
  93. // Show raw content
  94. document.getElementById('outputText').textContent = `Title: ${title}\nContent: ${content}`;
  95. document.getElementById('output').style.display = 'block';
  96. // Show preview
  97. document.getElementById('previewContent').innerHTML = content;
  98. document.getElementById('preview').style.display = 'block';
  99. }
  100. function clearContent() {
  101. window.wysiwygEditor.setContent('');
  102. document.getElementById('output').style.display = 'none';
  103. document.getElementById('preview').style.display = 'none';
  104. }
  105. </script>
  106. </body>
  107. </html>