react使用react-quill 富文本插件、加入handlers富文本不显示解决办法

可以调整图片大小

quill-image-resize-module-react

复制代码
加入插件quill-image-resize-module-react

Quill.register("modules/imageResize", ImageResize); // 注册图片缩放


富文本配置中加入如下
 const quildConfig = {
    toolbar: {
      container: [
        ["bold", "italic", "underline", "strike", "divisionLine"],
        [{ header: [1, 2, 3, 4, 5, 6, false] }],
        ["clean"],
        [{ size: ["small", false, "large", "huge"] }],
        [{ color: [] }], //y颜色
        ["image"],
        ["horizontalRule"], // 分隔线按钮
      ],
      
    },
    imageResize: {
      // 调整图片尺寸
      displayStyles: {
        border: "none",
      },
      modules: ["Resize", "DisplaySize", "Toolbar"],
    },
    
    // modules:{
    //   imageResize: true,
    // }
  };

加入handlers富文本不显示、浏览器也没有报错

复制代码
// 富文本 配置
加入这个就可以 useMemo

  const quildConfig = useMemo(()=>{
    return {
      toolbar: {
        container: [
          ["bold", "italic", "underline", "strike", "divisionLine"],
          [{ header: [1, 2, 3, 4, 5, 6, false] }],
          ["clean"],
          [{ size: ["small", false, "large", "huge"] }],
          [{ color: [] }], //y颜色
          ["image"],
          ["horizontalRule"], // 分隔线按钮
        ],
        handlers: {
          image: ()=>{
            console.log("啊哈哈哈---")
          }, // 自定义图片上传逻辑
        },
      },
      // image: {
      //   // 禁用 Base64 图片
      //   urlEnabled: false,
      // },
      imageResize: {
        // 调整图片尺寸
        displayStyles: {
          border: "none",
        },
        modules: ["Resize", "DisplaySize", "Toolbar"],
      },
      
      // modules:{
      //   imageResize: true,
      // }
    };
  },[])
相关推荐
万少9 分钟前
Trae AI 编辑器6大使用规则
前端·javascript·人工智能
好玩的Matlab(NCEPU)31 分钟前
如何编写 Chrome 插件(Chrome Extension)
前端·chrome
Yan-英杰36 分钟前
Deepseek大模型结合Chrome搜索爬取2025AI投资趋势数据
前端·chrome
Crystal3281 小时前
app里video层级最高导致全屏视频上的操作的东西显示不出来的问题
前端·vue.js
weixin_445476681 小时前
Vue+redis全局添加水印解决方案
前端·vue.js·redis
lecepin1 小时前
AI Coding 资讯 2025-10-29
前端·后端·面试
余道各努力,千里自同风1 小时前
小程序中获取元素节点
前端·小程序
PineappleCoder1 小时前
大模型也栽跟头的 Promise 题!来挑战一下?
前端·面试·promise
非凡ghost1 小时前
MousePlus(鼠标增强工具) 中文绿色版
前端·windows·计算机外设·软件需求
Moonbit2 小时前
MoonBit Pearls Vol.13:初探 MoonBit 中的 JavaScript 交互
javascript·后端