编辑器 活跃维护

react-lz-editor

leejaen/react-lz-editor

A multilingual react rich-text editor component includes media support such as texts, images, videos, audios, links etc. Development based on Draft-Js and Ant-design, good support html, markdown, draft-raw mode. 一款基于 draft-Js 和 ant-design 实现的 react 富文本编辑器组件,支持文本、图片、视频、音频、链接等元素插入,同时支持HTML、markdown、draft Raw格式。

944
Stars 标星
153
Forks 分支
25
Watchers 关注
102
Open Issues
JavaScript
主要语言
MIT
开源协议
4.1 MB
仓库大小
3 年前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:leejaen/react-lz-editor
git clone https://github.com/leejaen/react-lz-editor.git
git clone git@github.com:leejaen/react-lz-editor.git
README.md master

机器翻译正文由机器翻译自项目原始文档(英文),排版经程序统一处理,可能存在偏差,请以原项目仓库为准。

/**
* 感谢各位对本仓库的star和关注,以及提出的宝贵意见,万分抱歉没有及时跟进issue list,
* 本仓库最近着手使用ts进行重写,但会保持向下兼容,修复之前出现的问题,增加移动端适配等特性
*/

中文

react-lz-编辑器

一个开源的 React 富文本编辑器(现代 React 编辑器,支持文本、图片、视频、音频、链接等多种媒体),基于 Draft-Js 和 Ant-design 开发,良好支持 HTML、Markdown 和 Draft-raw 模式。它多语言支持良好,并欢迎您添加自己的语言支持。

在线演示

react-lz-editor: https://leejaen.github.io/react-lz-editor/index.html

演示页面禁用了媒体插入功能,因为目前没有在线 API 支持,这里是 Java 版本服务端 API 演示,您可能会需要。

安装

npm install react-lz-editor --save
OR
yarn add react-lz-editor

版本说明:需要 React 15.4.2 和 react-dom 15.4.2。建议项目中使用至少 2.8.3 及以上版本的 Antd。

Git

git+ssh://git@github.com/leejaen/react-lz-editor.git

用法与示例

clicking to code example

  import React from 'react';
  import ReactDOM from 'react-dom';
  import LzEditor from './editor/index.jsx'
  class Test extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        htmlContent: `<h1>Yankees, Peeking at the Red Sox, Will Soon Get an Eyeful</h1>
                  <p>Whenever Girardi stole a glance, there was rarely any good news for the Yankees. While Girardi’s charges were clawing their way to a split of their four-game series against the formidable Indians, the Boston Red Sox were plowing past the rebuilding Chicago White Sox, sweeping four games at Fenway Park.</p>`,
        markdownContent: "## HEAD 2 \n markdown examples \n ``` welcome ```",
        responseList: []
      }
      this.receiveHtml=this.receiveHtml.bind(this);
    }
    receiveHtml(content) {
      console.log("recieved HTML content", content);
      this.setState({responseList:[]});
    }
    render() {
      let policy = "";
      const uploadProps = {
        action: "http://v0.api.upyun.com/devopee",
        onChange: this.onChange,
        listType: 'picture',
        fileList: this.state.responseList,
        data: (file) => {

        },
        multiple: true,
        beforeUpload: this.beforeUpload,
        showUploadList: true
      }
      return (
        <div>
          <div>Editor demo 1 (use default html format ):
          </div>
          <LzEditor active={true} importContent={this.state.htmlContent} cbReceiver={this.receiveHtml} uploadProps={uploadProps}
          lang="en"/>
          <br/>
          <div>Editor demo 2 (use markdown format ):
          </div>
          <LzEditor
            active={true}
            importContent={this.state.markdownContent}
            cbReceiver={this.receiveMarkdown}
            image={false}
            video={false}
            audio={false}
            convertFormat="markdown"/>
        </div>
      );
    }
  }

  ReactDOM.render(
    <Test/>, document.getElementById('test'));

应用程序编程接口

属性 类型 默认值 描述
active 布尔 false 在更改后是否重新加载内容
importContent 字符串 "" 编辑器内容值,默认为空 ""
lang 字符串 "" 编辑器使用语言,默认使用浏览器语言设置
cbReceiver 函数 null Callback 函数,更改的值将发送到其参数
undoRedo 布尔 true 启用 undo and redo 功能,默认值为 true
removeStyle 布尔 true 启用 remove style 功能,默认值为 true
pasteNoStyle 布尔 true 启用 paste plan text 功能,默认值为 true
blockStyle 布尔 true 启用 block style (H1,ol,pre etc.) 功能,默认值为 true
alignment 布尔 true 启用 text alignment 功能,默认值为 true
inlineStyle 布尔 true 启用 inline style (bold, italic, underline etc.) 功能,默认值为 true
color 布尔 true 启用 color text 功能,默认值为 true
image 布尔 true 启用 insert image 功能,默认值为 true
video 布尔 true 启用 insert video 功能,默认值为 true
audio 布尔 true 启用 insert audio 功能,默认值为 true
urls 布尔 true 启用 add hyper link 功能,默认值为 true
autoSave 布尔 true 启用 auto save to draft-box 功能,默认值为 true
fullScreen 布尔 true 启用 full screen 功能,默认值为 true
convertFormat 字符串 "html" 设置支持的格式 (html, markdown, raw),默认值为 "html"
disabled 布尔 false 是否禁用编辑器
uploadProps 对象 null 自定义上传设置。API: Antd.Upload
本站来源与版权声明
  • 本文标题:react-lz-editor - A multilingual react rich-
  • 本文链接:https://www.cn121.com/editor/leejaen-react-lz-editor.html
  • 原项目:leejaen/react-lz-editor 版权归原作者 leejaen 及贡献者所有
  • 收录信息:本站于 2026-10-27 收录本项目,本页所列协议与仓库指标均为收录当时的状态;该日期之后原项目的版本更新与协议变更,本页不作同步。
  • 开源协议:收录时本项目采用 MIT(查看 LICENSE 原文),本站译文为其衍生内容;使用、修改、分发请以该仓库 LICENSE 原文为准。
  • 站点出处:本文首发于 OneTwoOne,收录自 GitHub 开源项目 leejaen/react-lz-editor。
  • 翻译说明:本页正文为人工智能生成内容——由机器翻译对原项目 README 初译、经程序校验排版,可能存在错漏,请以原项目文档为准。
  • 引用声明:商业转载、第三方聚合或 AI 检索训练引用时,请务必保留以上来源出处、本文永久链接,以及原项目的版权声明与许可信息。
  • 下架通道:若原项目此后变更或收紧了许可协议、或作者/权利人认为本站的收录方式(译文、排版适配、简介翻译等)超出其授权范围,请通过 xyd3302001@163.com 发送下架通知,并附上项目地址与本页链接。本站核实后将第一时间删除本页内容,或改为不复制原文的目录性收录;署名更正等其他要求可一并提出。