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,
      // }
    };
  },[])
相关推荐
万少16 分钟前
给 DeepSeek Harness 装个"应用商店":一条命令,595 个插件随你逛
前端·javascript·后端
波波00733 分钟前
C# 15 重磅新特性: 带标签 break 与 continue:重新定义嵌套循环控制流
服务器·前端·c#
Brown.alexis1 小时前
es6知识点1-自备使用
前端·ecmascript·es6
小爬的老粉丝2 小时前
JavaScript 纯前端预览 WPS:先识别容器,再路由解析器
前端·javascript·wps
计算机魔术师3 小时前
新兴多智能体系统的模式与问题
前端
用户059540174463 小时前
AI Agent 上下文污染踩坑实录:用 pytest + Redis 揪出 3 类记忆串号 bug,排查 6 小时
前端·css
满栀5854 小时前
状态管理:Redux、Vuex、Pinia 核心区别
前端·javascript·typescript
一拳不是超人4 小时前
DeepSeek Harness 为什么敢说"一切皆插件"?拆透 Cordis 引擎的五大核心机制
前端·人工智能·agent
IT_陈寒4 小时前
Python的GIL让我多写了500行代码
前端·人工智能·后端
风骏时光牛马4 小时前
AI智能体能力调度微服务
前端