UNPKG

vue-html5-editor

Version:

A WYSIWYG text editor base on html5 and vue

71 lines (68 loc) 2.19 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue html5 editor demo</title> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/> <script src="../dist/vue-html5-editor.js"></script> <script src="https://cdn.bootcss.com/vue/2.2.6/vue.js"></script> <link href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"> <style> #app { margin: 50px auto; width: 800px; max-width: 100%; } </style> </head> <body> <div id="app"> <p> <button type="button" @click="focus">focus</button> <button type="button" @click="fullScreen">full screen</button> <button type="button" @click="showModuleName=!showModuleName">toggle module name</button> <button type="button" @click="reset">change content</button> <span style="white-space: nowrap">content length : {{content.length}}</span> </p> <vue-html5-editor :content="content" :height="300" :show-module-name="showModuleName" @change="updateData" ref="editor"></vue-html5-editor> </div> <script> Vue.use(VueHtml5Editor, { showModuleName: true, image: { sizeLimit: 512 * 1024, compress: true, width: 500, height: 500, quality: 80 } }) new Vue({ el: "#app", data: { content: "<h3>vue html5 editor</h3>", showModuleName: false, }, methods: { updateData: function (data) { // sync content to component this.content = data }, fullScreen: function () { this.$refs.editor.enableFullScreen() }, focus: function () { this.$refs.editor.focus() }, reset:function () { var newContent = prompt('please input some html code: ') if(newContent){ this.content = newContent } } } }) </script> </body> </html>