UEditor组件封装,重写上传文件功能,重写全屏样式(Vue版本)

前言:
  1. 使用百度编辑器,重写上传功能,将编辑器的上传图片,上传音视频功能禁用,在工具栏中多加一个上传文件的功能(这是一个文件柜,支持上传图片/音频/视频/压缩文件/文本文档)

  2. 将ueditor封装成组件,编辑器的id要随机生成的,这里编辑器的id我拿的是时间戳
    this.editorId = String(new Date().getTime())

  3. 修改编辑器的ueditor.config.js配置文件
    (1)编辑器的默认层级过高,修改编辑器的默认层级
    在这里插入图片描述

    (2)插入图片时,需要为图片增加style样式![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/5e053520d788ad4ee2450b49b41abed7.png![在这里插入图片描述](https://img-blog.csdnimg.cn/202012171002446.png

UEditor组件封装
<template>
    <div>
        <div :style="{ overflow: 'hidden'}">
            <div :style="ueditorStyle">
                <script :id="editorId" type="text/plain" :style="ueditorStyle"></script>
            </div>
        </div>

        <!-- 上传文件弹层 -->
        <FileGroupModal  v-if="showObj.visible"
                         @cancel="showObj.visible = false"
                         :sysType="sysType"
                         @changeImgUrl="(files) => { changeFileCabinets(files)}" />
    </div>
</template>
<script>
    import FileGroupModal from "@/components/FileGroupModal";
    let showObj ={
   
   
        visible: false
    }
    export default {
   
   
        name: 'UE',
        components: {
   
   
            FileGroupModal
        },
        data () {
   
   
            return {
   
   
                editorId: '',
                modalStatus: true,
                editor: null,
                showObj: showObj,
                insertImgList: []
            }
        },
        props: {
   
   
            defaultValue: {
   
   
                type: String
            },
            config: {
   
   
                type: Object
            },
            ueditorStyle: {
   
   
                type: Object,
                default: ()=>{
   
   
                    return {
   
   
                        width: '600px',
                        minHeight: '600px'
                    }
                }
            },
            sysType: {
   
    // 模块类型,mall(商城)、sitecms(网站)、common(公共)、develop(开发)【不传查询所有】
                type: String,
                default: 'common'
            },
        },
        watch: {
   
   
            'defaultValue': function (newVal, oldValue) {
   
   
                if (this.editor) {
   
   
                    this.editor.setContent
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值