关于wangEditor的覆盖问题 以及修改默认高度

用富文本编辑器的的时候,发现弹框被富文本编辑器覆盖了
在这里插入图片描述

经过查看控制台发现

wangEditor设置的z-index很大,为1000,所以会覆盖掉和他重合的区域,加入下面代码就行

<style lang="less">
//修改默认高度
.w-e-text-container {
  height: 420px !important;
}
//修改层级
.w-e-menu {
  z-index: 2 !important;
}
.w-e-toolbar {
  z-index: 1 !important;
}
.w-e-text-container {
  z-index: 1 !important;
}
</style>

效果
在这里插入图片描述

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
wangeditor 中上传图片时,可以通过配置 editor.customConfig.uploadImgShowBase64 属性来预览图片,并设置图片的默认宽度。 1. 首先需要在组件中创建一个 ref 对象,用于获取 wangEditor 实例: ```javascript import React, { Component } from 'react'; import wangEditor from 'wangeditor'; class Editor extends Component { constructor(props) { super(props); this.editorRef = React.createRef(); } componentDidMount() { const editor = new wangEditor(this.editorRef.current); editor.customConfig.onchange = (html) => { this.props.onChange(html); }; editor.customConfig.uploadImgShowBase64 = true; editor.customConfig.uploadImgParams = {...}; editor.customConfig.uploadImgServer = '...'; editor.customConfig.uploadImgHooks = {...}; editor.create(); this.editor = editor; } render() { return ( <div ref={this.editorRef} /> ); } } ``` 2. 在 uploadImgHooks 中的 success 回调函数中,可以获取到上传图片成功后返回的图片地址和图片宽度,并将图片宽度设置为默认宽度: ```javascript const editor = this.editor; editor.customConfig.uploadImgHooks = { success: function (xhr, editor, result) { if (result && result.data && result.data.length > 0) { const imgWidth = result.data[0].width || ''; editor.cmd.do('insertHtml', `<img src="${result.data[0].url}" style="max-width:100%;width:${imgWidth}" />`); } else { window.alert('上传失败'); } }, ... }; ``` 在上面的代码中,imgWidth 代表图片的宽度,可以通过上传图片成功后返回的 result 对象中的 width 属性获取到。将图片的宽度设置为 style 属性的 width 值,并设置 max-width 属性为 100%,可以使图片自适应编辑器的宽度。 需要注意的是,如果上传的图片本身就有宽度属性,那么可以直接使用图片本身的宽度,不需要再设置默认宽度。如果图片没有宽度属性,那么可以设置一个固定的默认宽度,例如: ```javascript editor.cmd.do('insertHtml', `<img src="${result.data[0].url}" style="max-width:100%;width:600px" />`); ``` 在这个例子中,将图片的默认宽度设置为 600px。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值