basic.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>vue html5 editor demo</title>
  6. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
  7. <script src="../dist/vue-html5-editor.js"></script>
  8. <script src="https://cdn.bootcss.com/vue/2.2.6/vue.js"></script>
  9. <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  10. <style>
  11. #app {
  12. margin: 50px auto;
  13. width: 800px;
  14. max-width: 100%;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div id="app">
  20. <p>
  21. <button type="button" @click="focus">focus</button>
  22. <button type="button" @click="fullScreen">full screen</button>
  23. <button type="button" @click="showModuleName=!showModuleName">toggle module name</button>
  24. <button type="button" @click="reset">change content</button>
  25. <span style="white-space: nowrap">content length : {{content.length}}</span>
  26. </p>
  27. <vue-html5-editor :content="content" :height="300" :show-module-name="showModuleName"
  28. @change="updateData" ref="editor"></vue-html5-editor>
  29. </div>
  30. <script>
  31. Vue.use(VueHtml5Editor, {
  32. showModuleName: true,
  33. image: {
  34. sizeLimit: 512 * 1024,
  35. compress: true,
  36. width: 500,
  37. height: 500,
  38. quality: 80
  39. }
  40. })
  41. new Vue({
  42. el: "#app",
  43. data: {
  44. content: "<h3>vue html5 editor</h3>",
  45. showModuleName: false,
  46. },
  47. methods: {
  48. updateData: function (data) {
  49. // sync content to component
  50. this.content = data
  51. },
  52. fullScreen: function () {
  53. this.$refs.editor.enableFullScreen()
  54. },
  55. focus: function () {
  56. this.$refs.editor.focus()
  57. },
  58. reset:function () {
  59. var newContent = prompt('please input some html code: ')
  60. if(newContent){
  61. this.content = newContent
  62. }
  63. }
  64. }
  65. })
  66. </script>
  67. </body>
  68. </html>