项目作者: Weeken

项目描述 :
A vue plugin base on wangeditor
高级语言: JavaScript
项目地址: git://github.com/Weeken/vue-wangeditor-simple.git
创建时间: 2017-06-27T08:55:38Z
项目社区:https://github.com/Weeken/vue-wangeditor-simple

开源协议:

下载


vue-wangeditor-simple

这个是基于wangeditor v3.0+ 版本写成的vue插件

wangEditor —— 轻量级 web 富文本编辑器,配置方便,使用简单。支持IE10+浏览器。

安装及使用

  1. npm install vue-wangeditor-simple --save
  2. // main.js
  3. import VueWangeditor from 'vue-wangeditor-simple'
  4. Vue.use(VueWangeditor)
  5. // app.vue
  6. <div class="editor_wrap">
  7. <vue-wangeditor id="editor" :options="options" v-model="content" :init-content="initContent" :disabled="true"></vue-wangeditor>
  8. <vue-wangeditor id="editor1" :options="options1" v-model="content1" @get-text="getText"></vue-wangeditor>
  9. </div>
  10. data () {
  11. return {
  12. initContent: '<p>要初始化的内容</p>'
  13. content1: '', // 包含html标签
  14. text1: '', // 不含html标签,纯文本
  15. options1: {
  16. width: '900px',
  17. height: '500px',
  18. },
  19. content: '<p>edit here</p>',
  20. text: '',
  21. options: {
  22. width: '90%', // 自定义单位,字符串
  23. height: '800px', // 自定义单位,字符串
  24. // 更多配置项请看官网或者官网文档
  25. menus: [
  26. width: '900px',
  27. height: '500px',
  28. menus: [
  29. 'head', // 标题
  30. 'bold', // 粗体
  31. 'italic', // 斜体
  32. 'underline', // 下划线
  33. ...
  34. 'redo', // 重复
  35. /* ---- 新增 ---- */
  36. 'clearStyle', //清除文字的样式
  37. 'clearFormat', //清除文字的格式
  38. 'clearAll', //一键清空编辑器
  39. 'insertCode', //插入带类名的代码
  40. // <pre class="className"><code class="className">hellow world</code></pre>
  41. 'fullscreen' // 全屏
  42. ],
  43. ],
  44. pasteFilterStyle: true, // 打开/关闭粘贴样式的过滤
  45. ...
  46. }
  47. }
  48. }

优化

  • props 新增init-content,传入要初始化的内容
  • 由于之前版本都是检测v-model的变化,会影响输入,故将两者分开。
  • 2018-11-11 update:
  • props 新增disabled,控制编辑器的可编辑状态
  • 2019-3-28 update:
  • 移除:text.sync="text",新增@get-text="getText",使用事件代替.sync
    1. getText (text) {
    2. console.log(text)
    3. }

新增

1、clearStyle: 清除编辑器内所有文字的样式(无法撤销)

  • 等同于粘贴样式的过滤的作用,去除标签内的style,class属性以及\