edit.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>文本编辑器示例</title>
  6. <!-- 引入Quill样式 -->
  7. <link rel="stylesheet" href="//cdn.quilljs.com/1.3.6/quill.snow.css">
  8. <style>
  9. #editor {
  10. height: calc(100vh - 70px); /* 假设其他元素的高度是100px */
  11. }
  12. /*.ql-editor ul, ol {*/
  13. /* padding-left: 0.25rem;*/
  14. /*}*/
  15. /*.ql-indent-1, .ql-indent-2, .ql-indent-3, .ql-indent-4, .ql-indent-5, .ql-indent-6, .ql-indent-7 {*/
  16. /* padding-left: 2.5rem;*/
  17. /*}*/
  18. /* Continue replicating until ql-indent-9*/
  19. </style>
  20. </head>
  21. <body>
  22. <!-- 创建一个用于编辑的容器 -->
  23. <div id="editor"></div>
  24. <!-- 引入Quill库 -->
  25. <script src="//cdn.quilljs.com/1.3.6/quill.js"></script>
  26. <script>
  27. const quill = new Quill('#editor', {
  28. theme: 'snow', // 指定使用的主题
  29. modules: {
  30. toolbar: [
  31. [{'header': [1, 2, false]}, 'bold', 'italic', 'blockquote', 'code-block', 'link'],
  32. [{'list': 'ordered'}, {'list': 'bullet'}, {'indent': '-1'}, {'indent': '+1'}, 'image', 'video'],
  33. ]
  34. }
  35. });
  36. // 获取编辑器内容
  37. function getContent() {
  38. const content = quill.root.innerHTML;
  39. console.log(content);
  40. }
  41. </script>
  42. </body>
  43. </html>