• wangEditor富文本编辑器使用


    官网链接 https://www.kancloud.cn/wangfupeng/wangeditor3/332599

    由于使用公司封装的富文本编辑器不太好使(小声bb),摸索了一个好用的富文本编辑器

    npm install wangeditor --save

    在componentDidMount中声明使用

        const elemMenu = document.getElementById('editorElemMenu');
        const elemBody = document.getElementById('editorElemBody');
        const editor = new Editor(elemMenu, elemBody);
        (editor as any).config.zIndex = 0;
        // 使用 onchange 函数监听内容的变化,并实时更新到 state 中
        editor.config.onchange = () => {
          const kmContent = editor.txt.html();
          const kmContentText = editor.txt.text();
        };
        editor.config.menus = [
          'head', // 标题
          'bold', // 粗体
          'fontSize', // 字号
          'fontName', // 字体
          'italic', // 斜体
          'underline', // 下划线
          'strikeThrough', // 删除线
          'foreColor', // 文字颜色
          'backColor', // 背景颜色
          'link', // 插入链接
          'list', // 列表
          'justify', // 对齐方式
          'quote', // 引用
          'emoticon', // 表情
          'image', // 插入图片
          'table', // 表格
          'video', // 插入视频
          'code', // 插入代码
          'undo', // 撤销
          'redo', // 重复
        ];
        editor.config.uploadImgShowBase64 = true;
        editor.create();

    在组件中使用

                    <div
                      id="editorElemMenu"
                      style={{ backgroundColor: '#f1f1f1', border: '1px solid #ccc' }}
                      className="editorElemMenu"
                    />
                    <div
                      style={{
                        height: 270,
                        border: '1px solid #ccc',
                        borderTop: 'none',
                      }}
                      id="editorElemBody"
                      className="editorElem-body"
                    />
  • 相关阅读:
    [转]<UNIX编程艺术>之精华文字
    2012年学习小结
    重试逻辑代码
    《构建高性能web站点》读书点滴
    mysql体系结构
    设计memcache的部署结构
    一般性hash算法c#版
    Flex带进度条的多文件上传(基于Servlet)
    C++11中值得关注的几大变化
    优化网站响应时间tomcat添加gzip
  • 原文地址:https://www.cnblogs.com/fdd-111/p/14754354.html
Copyright © 2020-2023  润新知