tinymce富文本编辑器

1、第一步: 安装tinymce

cnpm install @tinymce/tinymce-vue -S 注意版本
cnpm install tinymce -S 

2、 安装下载完成之后到node_modules中找到tinymce/skins文件。拷贝到静态目录下(public或者static)下。

中文语言包戳

3、可以封装成组件,多处复用,不累述了。

<template>
  <div>
    <editor id="tinymce" v-model="tinymceHtml" :init="editorInit"></editor>
  </div>  
</template>
<script>
import tinymce from "tinymce";
import Editor from "@tinymce/tinymce-vue";
import 'tinymce/themes/silver/theme'

//插件引入
import 'tinymce/plugins/image'
import 'tinymce/plugins/link'
import 'tinymce/plugins/code'
import 'tinymce/plugins/table'
import 'tinymce/plugins/lists'
import 'tinymce/plugins/advlist'
import 'tinymce/plugins/contextmenu'
import 'tinymce/plugins/wordcount'
import 'tinymce/plugins/colorpicker'
import 'tinymce/plugins/textcolor'
import 'tinymce/plugins/preview'
import 'tinymce/plugins/hr'
import 'tinymce/plugins/autosave'
import 'tinymce/plugins/save'
import 'tinymce/plugins/anchor'
import 'tinymce/plugins/pagebreak'
import 'tinymce/plugins/media'
import 'tinymce/icons/default'


export default {
  name: 'TinymceEditor',
  components: {
    Editor
  },
  data () {
    return {
      tinymceHtml:"",
      editorInit: {
        selector: "#tinymce",
        language_url: "/tinymce/zh_CN.js",
        language: "zh_CN",
        skin_url: "/tinymce/skins/ui/oxide", 
        height: 600,
        fontsize_formats: "12px 14px 16px 18px 20px 24px 26px 28px 30px 32px 36px 38px 40px 42px 44px 48px", //字体大小
        plugins: 'link lists advlist image code table colorpicker textcolor wordcount contextmenu preview hr autosave save anchor pagebreak media',
        toolbar: [
          'bold italic underline strikethrough | fontselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | ',
          'outdent indent blockquote hr removeformat | undo redo | link unlink image  pagebreak code | preview | restoredraft save'
        ],
        images_upload_url:'',
        branding: false,
        autosave_ask_before_unload:true,
        save_enablewhendirty: false,
        save_onsavecallback: function () {
           alert('已保存')
        }
      }
    }
  },
  mounted() {
    //初始化
    tinymce.init({});
  },
  created () {
  },
  methods: {
  }
}
</script>

4、最终效果

 

 5、官方中文文档

上传图片和文件 | TinyMCE中文文档中文手册icon-default.png?t=LBL2http://tinymce.ax-z.cn/general/upload-images.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值