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,
      // }
    };
  },[])
相关推荐
weixin_427771611 天前
前端调试隐藏元素
前端
threelab1 天前
Three.js 代码云效果 | 三维可视化 / AI 提示词
开发语言·javascript·人工智能
爱上好庆祝1 天前
学习js的第五天
前端·css·学习·html·css3·js
C澒1 天前
IntelliPro 产研协作平台:基于 AI Agent 的低代码智能化配置方案设计与实现
前端·低代码·ai编程
一袋米扛几楼981 天前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
网络点点滴1 天前
前端与后端的区别与联系
前端
yqcoder1 天前
JavaScript 柯里化:把“大餐”拆成“小炒”的艺术
开发语言·javascript·ecmascript
每天吃饭的羊1 天前
JSZip的使用
开发语言·javascript
EnCi Zheng1 天前
M5-markconv自定义CSS样式指南 [特殊字符]
前端·css·python
kyriewen1 天前
你的网页慢,用户不说直接走——前端性能监控教你“读心术”
前端·性能优化·监控