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

tinymce扩展功能:1、行高、段落间距、格式刷;2、视频上传进度条;3、对复制的图片设置尺寸

tinymce扩展功能:1、行高、段落间距、格式刷;2、视频上传进度条;3、对复制的图片设置尺寸

  • 一、需求描述
  • 二、行高、段落间距、格式刷插件
  • 三、实现视频上传的进度条、对复制的图片设置尺寸

一、需求描述

使用技术:

vue2 + tinymce5.4.1

实现效果图:
一、扩展插件:
在这里插入图片描述
二、视频上传进度条
在这里插入图片描述

二、行高、段落间距、格式刷插件

下载引入相关扩展插件,可以放在components目录下
在这里插入图片描述

import '@/components/tinymcePlugins/importword'// 导入Word
import '@/components/tinymcePlugins/paragraphspacing' //段落间距
import '@/components/tinymcePlugins/formatpainter' //格式刷
import '@/components/tinymcePlugins/lineheight' //行高

pluginstoolbar中引入

plugins: 'importword formatpainter paragraphspacing lineheight'
toolbar: 'importword formatpainter paragraphspacing lineheight'

三、实现视频上传的进度条、对复制的图片设置尺寸

1、DOM:

<editor v-if="!reloading" v-model="myValue" :init="init" :disabled="disabled" @onClick="onClick"> </editor>
<a-modal v-model="progressShow" title="上传进度" :zIndex="1500" :closable="false" :footer="null" :mask="false"><a-progress :percent="uploadProgress" status="active"></a-progress>
</a-modal>

2、data:

progressShow: false,
uploadProgress: 0,

3、computed:

  computed: {init() {let that = thisreturn {// ......// 省略了其他的基础配置file_picker_types: 'file image media',  //分别对应三个类型文件的上传:link插件,image和axupimgs插件,media插件。file_picker_callback: function (callback, value, meta) {that.uploadProgress = 0let filetype;// 上传视频if (meta.filetype === "media") {filetype='.mp4, ‌.avi‌, .mpg, .mpeg‌, .wmv, ‌.mov‌, ‌.flv‌, .swf‌, ‌.rm‌, ‌.ram, ‌.mkv‌';  //限制文件的上传类型}// 上传图片else if (meta.filetype === "image") {filetype='.jpg, .jpeg, .png, .svg, .webp, .tif, .tiff, .gif, .raw';}// 上传文件else if (meta.filetype === "file") {filetype='.pdf, .txt, .zip, .rar, .doc, .docx, .xls, .xlsx, .ppt, .pptx';  //限制文件的上传类型}let input = document.createElement("input");input.setAttribute("type", "file");input.setAttribute('accept', filetype);input.onchange = function () {let file = this.files[0];let fd = new FormData();fd.append("file", file);fd.append('biz', "jeditor");fd.append("jeditor","1");// 视频、文件上传,显示进度条if (meta.filetype === "media" || meta.filetype === "file") {axios.post("/minio/upload", fd, {// 主要是这里,获取实时的上传进度onUploadProgress: progressEvent => {that.progressShow = true;that.uploadProgress = parseInt(Math.round((progressEvent.loaded * 100) / progressEvent.total));},}).then(res => {that.progressShow = false;if (meta.filetype === "file") {callback(res.url, {text: file.name});} else {callback(res.url);}}).catch(err => {that.progressShow = false;})}// 图片上传else {uploadAction("/minio/upload", fd).then((res) => {callback(res.url, {alt: file.name});});}};input.click();},setup: function (editor) {// 给复制粘贴而来的图片设置尺寸editor.on('paste', function (e) {setTimeout(() => {// 遍历所有粘贴的图片元素const imageDoms = editor.getBody().getElementsByTagName('img')for (let i = 0; i < imageDoms.length; i++) {imageDoms[i].width = imageDoms[i].naturalWidthimageDoms[i].height = imageDoms[i].naturalHeight}}, 100)});}}},},
http://www.lryc.cn/news/479322.html

相关文章:

  • 计算机毕业设计Python+图神经网络手机推荐系统 手机价格预测 手机可视化 手机数据分析 手机爬虫 Django Flask Spark 知识图谱
  • WPF的<ContentControl>控件
  • Python并发编程——multiprocessing
  • 智能家居的未来:AI让生活更智能还是更复杂?
  • 【物联网技术】ESP8266 WIFI模块在AP模式下作为TCP服务器与多个电脑/手机网络助手(TCP客户端)通信——TCP数据透传
  • 十五:java web(7)-- Spring Boot
  • 洛谷每日一题——P1036 [NOIP2002 普及组] 选数、P1045 [NOIP2003 普及组] 麦森数(高精度快速幂)
  • OpenHarmony开源鸿蒙
  • 2024.11.4 STM32点灯和简单的数据收发
  • Android Studio jcenter 停止服务,改用mavenCentral
  • EasyPOI使用详解
  • 【云原生开发】K8S多集群资源管理平台架构设计
  • 基于SpringBoot的城镇住房保障系统开发
  • 一文解秘Rust如何与Java互操作
  • 手机发展史介绍
  • 【ArcGISPro】单次将自己建立的工具箱添加至Arcpy中
  • docker镜像仓库常用命令
  • springboot 传统应用程序,适配云原生改造
  • D61【python 接口自动化学习】- python基础之数据库
  • 数据库期末考试简答题
  • Java[面试题]-真实面试
  • HTML5新增多媒体支持
  • K8S群集调度二
  • 43.第二阶段x86游戏实战2-提取游戏里面的lua
  • debian系统安装qt的时候 显示xcb相关文件缺失
  • 得物多模态大模型在重复商品识别上的应用和架构演进
  • 基于 SSM(Spring + Spring MVC + MyBatis)框架构建电器网上订购系统
  • 应用插件化及其进程关系梳理
  • Odoo:免费开源的医药流通行业信息化解决方案
  • 系统架构设计师论文:大数据Lambda架构