You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

editor-react-quill

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

editor-react-quill

react quill

1.2.25
latest
npmnpm
Version published
Weekly downloads
50
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

editor-react-quill

一个基于quill 的 react组件 Editor

  • 使用 npm i editor-react-quillyarn add editor-react-quill

  • // 在React 项目中快速使用
    import { Editor } from 'editor-react-quill'
    const show = (content: string, textLen: number, imgsLen: number) => {
        console.log(content, textLen, imgsLen)
    }
    function Demo() {
        // onChange为必传参数
        return <div>
            <Editor onChange={show}/> 
        </div>
    }
    
  • API

    NameDescriptionTypeDefault
    onChange实时获取编辑器的内容content,以及内容的文字长度textLen,图片数量imgsLen(content: string, textLen: number, imgsLen: number) => void-
    onError用于接收图片格式错误msg的提示(msg: string) => void-
    placeholder编辑器的placeholderstring'请在这里输入内容'
    clearable是否开启清空按钮booleanfalse
    theme主题theme'snow'丨'bubble''snow'
    clipboard是否过滤剪切板的内容为纯文字booleantrue
    toolBar是否开启toolBar, 默认关闭false, 也可自定义any[][]丨booleanfalse
    upload在打开toolbar 的 image 的基础上,是否自定义上传图片的函数(file: File) => Promise<string丨{status: number, target: string}>-
    maxLength文字最大长度number1000
    maxImages图片最大数量number6
  • toolBar 常用配置

    更多配置

    toolBar={[
        ['bold', 'italic', 'underline', 'strike'], // 加粗,斜体,下划线,删除线
        ['blockquote', 'code-block'], // 引用,代码块
        [{ header: 1 }, { header: 2 }], // 标题,键值对的形式;1、2表示字体大小
        [{ list: 'ordered' }, { list: 'bullet' }], // 列表
        [{ script: 'sub' }, { script: 'super' }], // 上下标
        [{ indent: '-1' }, { indent: '+1' }], // 缩进
        [{ direction: 'rtl' }], // 文本方向
        [{ size: ['small', false, 'large', 'huge'] }], // 字体大小
        [{ header: [1, 2, 3, 4, 5, 6, false] }], // 几级标题
        [{ color: [] }, { background: [] }], // 字体颜色,字体背景颜色
        [{ font: [] }], // 字体
        [{ align: [] }], // 对齐方式
        ['clean'], // 清除字体样式
        ['image'] // 上传图片
    ]}
    
  • 注意

    // 如果想自定义上传图片的方法请同时传入toolBar和upload
    <Editor 
        onChange={show} 
        upload={yourFunc} 
        toolBar={[['image']]} 
    />
    

Keywords

quill

FAQs

Package last updated on 24 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts