Git Product home page Git Product logo

vue-wangeditor-simple's Introduction

vue-wangeditor-simple

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

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

安装及使用

npm install vue-wangeditor-simple --save

// main.js
import VueWangeditor from 'vue-wangeditor-simple'
Vue.use(VueWangeditor)

// app.vue
<div class="editor_wrap">
    <vue-wangeditor id="editor" :options="options" v-model="content" :init-content="initContent" :disabled="true"></vue-wangeditor>
    <vue-wangeditor id="editor1" :options="options1" v-model="content1" @get-text="getText"></vue-wangeditor>
</div>

data () {
    return {
      initContent: '<p>要初始化的内容</p>'
      content1: '', // 包含html标签
      text1: '', // 不含html标签,纯文本
      options1: {
        width: '900px',
        height: '500px',
      },
      content: '<p>edit here</p>',
      text: '',
      options: {
      width: '90%', // 自定义单位,字符串
      height: '800px', // 自定义单位,字符串
      // 更多配置项请看官网或者官网文档
        menus: [
        width: '900px',
      height: '500px',
      menus: [
        'head',  // 标题
        'bold',  // 粗体
        'italic',  // 斜体
        'underline',  // 下划线
          ...
        'redo',  // 重复
        /* ---- 新增 ---- */
        'clearStyle', //清除文字的样式
        'clearFormat', //清除文字的格式
        'clearAll', //一键清空编辑器
        'insertCode', //插入带类名的代码
        // <pre class="className"><code class="className">hellow world</code></pre>
        'fullscreen' // 全屏
      ],
        ],
        pasteFilterStyle: true,  // 打开/关闭粘贴样式的过滤
        ...
      }
    }
  }

优化

  • props 新增init-content,传入要初始化的内容

  • 由于之前版本都是检测v-model的变化,会影响输入,故将两者分开。

  • 2018-11-11 update:

  • props 新增disabled,控制编辑器的可编辑状态

  • 2019-3-28 update:

  • 移除:text.sync="text",新增@get-text="getText",使用事件代替.sync

getText (text) {
  console.log(text)
}

新增

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

  • 等同于粘贴样式的过滤的作用,去除标签内的style,class属性以及<style>标签
  • 文档里说 pasteFilterStyle,pasteTextHandle配置暂时对 IE 无效 ,可以在配置menus里添加 clearStyle ,复制进去后手动清除样式,可以清除word文档复制过来的样式(在IE已测试)。
  • 若有清除不了的,请报issues。

2、clearFormat: 清除格式(无法撤销)

  • 这功能会把所有的文字格式化为正文,即把所有HTML标签替换为<p>标签
  • 排版可能会有错乱(应该只是换行了而已),请自行调整

3、clearAll: 一键清空编辑器功能

  • 一键清空编辑器的所有内容

4、fullscreen: 全屏/退出全屏功能

5、insertCode: 插入带类名的代码

  <pre class="className"><code class="className">hellow world</code></pre>

为了方便在网页中使用插件(prismjs)来显示代码高亮

欢迎前来starissues

vue-wangeditor-simple's People

Contributors

weeken avatar yakii9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-wangeditor-simple's Issues

Error in mounted hook: "TypeError: Cannot read property 'includes' of undefined"

`vue.esm.js?5425:578 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'includes' of undefined"

found in

--->



at src/components/article-edit.vue

at src/App.vue

warn @ vue.esm.js?5425:578
logError @ vue.esm.js?5425:1713
globalHandleError @ vue.esm.js?5425:1708
handleError @ vue.esm.js?5425:1697
callHook @ vue.esm.js?5425:2897
insert @ vue.esm.js?5425:4090
invokeInsertHook @ vue.esm.js?5425:5864
patch @ vue.esm.js?5425:6083
Vue._update @ vue.esm.js?5425:2637
updateComponent @ vue.esm.js?5425:2765
get @ vue.esm.js?5425:3115
Watcher @ vue.esm.js?5425:3104
mountComponent @ vue.esm.js?5425:2772
Vue$3.$mount @ vue.esm.js?5425:8429
Vue$3.$mount @ vue.esm.js?5425:10790
Vue._init @ vue.esm.js?5425:4570
Vue$3 @ vue.esm.js?5425:4659
(anonymous) @ main.js?1c90:35
./src/main.js @ app.js:2003
webpack_require @ app.js:679
fn @ app.js:89
0 @ app.js:2020
webpack_require @ app.js:679
(anonymous) @ app.js:725
(anonymous) @ app.js:728
vue.esm.js?5425:1717 TypeError: Cannot read property 'includes' of undefined
at VueComponent.mounted (vue-wangeditor-simple.js?075c:1)
at callHook (vue.esm.js?5425:2895)
at Object.insert (vue.esm.js?5425:4090)
at invokeInsertHook (vue.esm.js?5425:5864)
at Vue$3.patch [as patch] (vue.esm.js?5425:6083)
at Vue$3.Vue._update (vue.esm.js?5425:2637)
at Vue$3.updateComponent (vue.esm.js?5425:2765)
at Watcher.get (vue.esm.js?5425:3115)
at new Watcher (vue.esm.js?5425:3104)
at mountComponent (vue.esm.js?5425:2772)`

清楚当前格式的工具栏

大神,现在有个清楚文本当前格式的需求,能不能加上呀,我看目前菜单栏,没有这个功能

配置后不显示上传图片选项

// 下面两个配置,使用其中一个即可显示“上传图片”的tab。但是两者不要同时使用!!!
// editor.customConfig.uploadImgShowBase64 = true   // 使用 base64 保存图片
// editor.customConfig.uploadImgServer = '/upload'  // 上传图片到服务器

配置后,不显示上传图片选项

报错

import进入之后,总是报错,显示没有找到模块

动态添加多个vue-wangeditor-smiple,删除其中一个,vue-wangeditor的v-model绑定的值不会改变

页面中可以动态添加多个vue-wangeditor-smiple ,我从list中删除一个后,v-model="item.title"值 不会改变
TIM图片20190905180758

<el-form v-for="(item, i) in form.items" :key="i" :inline="true" class="demo-form-inline"> <el-form-item :model="form"> <el-col :span="2"> <el-radio-group v-model="form.ans_right"> <el-radio :label="item.id">{{ i | letterFilter }}</el-radio> </el-radio-group> </el-col> <el-col :span="18"> <vue-wangeditor :id="'editor_'+i" :options="options" v-model="item.title" style="width:650px" /> </el-col> <el-col :span="4"> <i v-if="i>=2" class="el-icon-delete" @click="Delete(i)"></i> </el-col> </el-form-item> </el-form>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.