wangeditor自定义图片视频上传

wangeditor自定义图片视频上传

完整代码

<template>
    <div style="border: 1px solid #ccc;height: 100%;">
        <Toolbar
            :editor="editorRef"
            :default-config="toolbarConfig"
            :mode="mode"
            style="border-bottom: 1px solid #ccc;"
        />
        <Editor
            v-model="valueHtml"
            :default-config="editorConfig"
            :mode="mode"
            class="editor_custom"
            style="height: 455px; overflow-y: hidden;"
            @on-created="handleCreated"
            @on-change="handleChange"
            @on-destroyed="handleDestroyed"
            @on-focus="handleFocus"
            @on-blur="handleBlur"
            @custom-alert="customAlert"
            @custom-paste="customPaste"
        />
    </div>
</template>

<script setup>
import {
    useUserOutsideStore } from '@/store/modules/user'
import {
    ustokenStore } from '@/store/modules/token'
import '@wangeditor/editor/dist/css/style.css'
import {
    usUploadStore } from '@/store/modules/upload'
import {
    onBeforeUnmount, ref, shallowRef, onMounted } from 'vue'
import {
    Editor, Toolbar  } from '@wangeditor/editor-for-vue'
const {
    proxy } = getCurrentInstance()
const userOutsideStore = useUserOutsideStore()
const tokenStore = ustokenStore()
const props = defineProps({
   
    modelValue: {
   
        type: String,
        default: ''
    },
    disabled: {
   
        type: Boolean,
        default: false
    }
})
const emit = defineEmits(['update:modelValue'])

// 编辑器实例,必须用 shallowRef,重要!
const editorRef = shallowRef()

// const menu = editor.getAllMenuKeys()
// const bar = toolbar.getConfig().toolbarKeys
// 内容 HTML
const valueHtml = ref(props.modelValue)
watch(() => valueHtml.value, newValue => {
   
    emit('update:modelValue', newValue)
})

watch(() => props.modelValue, newValue => {
   
    valueHtml.value = newValue
})
const disabled = ref(false)
watch(() => props.disabled, newValue => {
   
    disabled.value = newValue
})
// 模拟 ajax 异步获取内容
onMounted(() => {
   
    AuthorizationHeader()
    // setTimeout(() => {
   
    //     valueHtml.value = '<p>模拟 Ajax 异步设置内容</p>'
    // }, 1500)
})
const headerObj = ref({
   })
const AuthorizationHeader = () => {
   
    if (tokenStore.token != '') {
   
        if (tokenStore.token != '0') {
   
            headerObj.value.Authorization =  tokenStore.token
        } else {
   
            headerObj.value.Authorization = userOutsideStore.tokenHead + userOutsideStore.token
        }
    }
}
const toolbarConfig = {
   
    excludeKeys: ['fullScreen', 'code', 'insertTable', 'group-video'<
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值