当前位置: 首页 > news >正文

分享一个vue2的tinymce配置

安装

npm install @packy-tang/vue-tinymce

下载tinymce源代码,我这里用的是7.7的已经将中文翻译放进去了,我试过8以后要提供key

将下载的源代码解压到public目录下
在这里插入图片描述
main.js引入tinymce

// 引入富文本编辑器tinymce
import VueTinymce from "@packy-tang/vue-tinymce";
Vue.use(VueTinymce);

接下来配置tinymce富文本组件
定义组件TinymceEditor
在这里插入图片描述

<template><div class="TinymceEditor" :style="{ 'width': `${width}` }"><vue-tinymce v-model="currentValue" :setting="mini ? miniSetting : setting" /></div>
</template><script>
import { upload } from "@/utils/s3upload";export default {name: 'TinymceEditor',props: {content: {type: String,require: true},inline: {type: Boolean,default: false},mini: {type: Boolean,default: false},width: {type: String,default: 'auto'},placeholder: {type: String,default: '请输入内容'}},data() {return {miniSetting: {menubar: false,height: 100,statusbar: false,autoresize_bottom_margin: 1,placeholder: this.placeholder,paste_data_images: false,toolbar: ['fontsizeinput bold italic forecolor backcolor | numlist bullist  alignleft aligncenter alignright '],plugins: 'lists autoresize',language: 'zh_CN'},setting: {placeholder: this.placeholder,height: 300,menubar: false,inline: this.inline,paste_data_images: true,resize: true,elementpath: false,highlight_on_focus: true,content_style: 'img {max-width:100%;height:auto}',promotion: false, // 更新按钮toolbar: ['undo redo removeformat | bold italic underline strikethrough superscript subscript backcolor forecolor | numlist bullist | blocks | searchreplace fullscreen','fontfamily fontsize fontsizeselect fontsizeinput | alignleft aligncenter alignright alignjustify lineheight outdent indent | link unlink image table | preview print code'],plugins: 'lists link anchor code wordcount image table visualchars visualblocks searchreplace preview pagebreak nonbreaking media insertdatetime fullscreen directionality autosave autolink advlist',font_size_formats: '10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 36px 42px 48px 72px',// 配置工具栏时添加的 fontsizeinput 工具可以展示一个可输入字号的组件,默认单位是pt,现改为pxfont_size_input_default_unit: 'px',font_family_formats: "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings",images_upload_handler: (blobInfo, progress) => new Promise((resolve, reject) => {upload(blobInfo.blob(), ({ loaded, total }) => {console.log('上传回调,', loaded, total)}).then(result => {console.log('上传结果', result)resolve(result.url)})}),language: 'zh_CN' // 本地化设置},currentValue: ''}},watch: {content: {handler(val) {if (val !== this.currentValue) {this.currentValue = val === null ? '' : val}},immediate: true},currentValue(value) {this.$emit('change', value)}}
}
</script><style>
.tox-statusbar__branding {display: none;
}.tox-tinymce-aux {z-index: 2100 !important;
}
</style>
<style lang="scss" scoped></style>

其中import { upload } from "@/utils/s3upload";是我的图片上传

这里面定义了两种模式,精简模式和全部模式

精简模式

在这里插入图片描述
全部模式
在这里插入图片描述
其它页面引用

<template><div><TinymceEditor :content="ruleForm.description" placeholder="请输入填写说明" @change="handleEditorChange"></TinymceEditor></div>
</template>
<script>
import TinymceEditor from '@/components/TinymceEditor/index.vue'
components: {TinymceEditor
}, 
methods: {handleEditorChange(value) {console.log(value)},
}
</script>

文章转载自:

http://ty2M44Ci.wqpqk.cn
http://Kw0bdm7W.wqpqk.cn
http://Wr3sxeMk.wqpqk.cn
http://A9cjxiiH.wqpqk.cn
http://so0AzTjp.wqpqk.cn
http://pJvMYNjy.wqpqk.cn
http://LPvSNMNq.wqpqk.cn
http://F6WhfJqe.wqpqk.cn
http://XUuCrHWd.wqpqk.cn
http://7cLAyU3C.wqpqk.cn
http://EkJc1wq8.wqpqk.cn
http://BUGAGrkC.wqpqk.cn
http://1ogm2hpK.wqpqk.cn
http://9JJ9DNBW.wqpqk.cn
http://tzishoKd.wqpqk.cn
http://D9buCJso.wqpqk.cn
http://JCL3466V.wqpqk.cn
http://yEFSxSWk.wqpqk.cn
http://DpsPcZCH.wqpqk.cn
http://ER6bbku1.wqpqk.cn
http://rLEUa02Y.wqpqk.cn
http://PnTucgrc.wqpqk.cn
http://wMonfUCO.wqpqk.cn
http://zQuMOjGK.wqpqk.cn
http://rs4VUHA4.wqpqk.cn
http://i2CVSERM.wqpqk.cn
http://wawmJ8Vr.wqpqk.cn
http://ehBY8aqm.wqpqk.cn
http://I6Iqcesj.wqpqk.cn
http://b4ZYciaV.wqpqk.cn
http://www.dtcms.com/a/383430.html

相关文章:

  • spring bean一共有几种作用域
  • Redie详细入门教程2
  • Maven入门_简介、安装与配置
  • Vue组件化开发介绍
  • ​new species of flying reptile1 discovered in Scotland​
  • Spring JDBC与KingbaseES深度集成:构建高性能国产数据库应用实战
  • 闪电科创 SCI专业辅导
  • 【数据结构与算法】图 Floyd算法
  • 代码随想录算法训练营第十一天--二叉树2 || 226.翻转二叉树 / 101.对称二叉树 / 104.二叉树的最大深度 / 111.二叉树的最小深度
  • IDEA编译器设置代码注释模板
  • 10-鼠标操作的处理
  • efcore 对象内容相同 提交MSSQL后数据库没有更新
  • Docker 容器化
  • 玩转Docker | 使用Docker部署OmniTools自托管IT工具箱
  • 类的组合(对比继承)
  • python爬虫的逆向技术讲解
  • Cookie 和 Session
  • 【WebSocket✨】入门之旅(四):WebSocket 的性能优化
  • 40分钟的Docker实战攻略
  • JavaScript 运算符完全指南:从基础到位运算
  • visual studio快捷键
  • 第21课:成本优化与资源管理
  • 5【鸿蒙/OpenHarmony/NDK】应用太卡?用 Node-API 异步任务解决:从卡顿根源到流畅方案
  • 利用OpenCV进行对答题卡上的答案进行识别的案例
  • 如何用 Rust 实现的基础屏幕录制程序?
  • 认知语义学隐喻理论对人工智能自然语言处理中深层语义分析的赋能与挑战
  • 常见索引失效场景及原因分析(含示例)
  • 嵌入式Linux常用命令
  • xtuoj Rectangle
  • C++内存管理:new与delete的深层解析