vue3中使用tinymce

1.引入必要组件:

npm install --save tinymce "@tinymce/tinymce-vue"
npm install --save "@types/tinymce"

2.页面中引入:

import tinymce from "tinymce/tinymce";
import Editor from "@tinymce/tinymce-vue"; // 引入组件
import "tinymce/models/dom"; // 特别注意 tinymce 6.0.0 版本之后必须引入,否则不显示
import "tinymce/themes/silver/theme";
import "tinymce/icons/default";
import "tinymce/plugins/image";
import "tinymce/plugins/link";
import "tinymce/plugins/code";
import "tinymce/plugins/table";
import "tinymce/plugins/lists";
import "tinymce/plugins/wordcount";
import "tinymce/plugins/fullscreen";
import "tinymce/plugins/quickbars";
import "tinymce/plugins/preview";

// 引入富文本编辑器主题的js和css
import "tinymce/themes/silver/theme.min.js";

3.页面

<Editor  v-model="tinymceHtml" :init="initData" />

4. init

const initData = {
  //初始化数据
  selector: "textarea",
  skin_url: "/public/tinymce/skins/ui/oxide",
  content_css:"/public/tinymce/skins/content/default/content.css",
  // images_upload_url: uploadUrl,
  images_upload_base_path:"",
  height: 350, // 限制高度
  min_height: 200,
  statusbar: false,
  object_resizing: false,
  image_description: false,
  image_dimensions: false, // 禁止操作图片
  plugins: "link lists image code table wordcount fullscreen preview", // 富文本插件
  font_size_formats: "8px 10px 12px 14px 16px 18px 24px 36px 48px 128px",
  font_family_formats:
    "微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;宋体=simsun,serif",
  toolbar:
    "code undo redo fontfamily fontsize fontname bold italic underline strikethrough removeformat | fontsizeselect | forecolor | alignleft aligncenter alignright | fullscreen | image | link | preview |",
  branding: false, // //是否禁用“Powered by TinyMCE”
  menubar: false, //顶部菜单栏显示
  // menubar: "file edit view format table",
  paste_data_images: false, // 禁止粘贴图片
  promotion: false
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值