1.0.20 • Published 6 years ago

hq-react-lz-editor v1.0.20

Weekly downloads
6
License
ISC
Repository
github
Last release
6 years ago

中文

react-lz-editor

An open source react rich-text editor ( mordern react editor 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. It's supports multiple languages well(just English and Chinese for now) and welcome you add your language supports.

Live demo

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

Disabled media insert feature on demo page, because of there was no online API support for the time being, here is The server side API demo in java you may want.

Install

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

Version note: React 15.4.2+ and react-dom 15.4.2+ is required. Antd version at last 2.8.3 in your project is recommended.

Git

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

Usage & Examples

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);
  }
  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'));

screenshot

API

propstypedefaultdescription
activeboolfalseIs reloading content after changing
importContentstring""Editor content value, default to ""
langstring""Editor using language, default to your browser language settings
cbReceiverfunctionnullCallback function, the changed value will be sent to its parameter.
undoRedobooltrueEnabled undo and redo feature, default to true
removeStylebooltrueEnabled remove style feature, default to true
pasteNoStylebooltrueEnabled paste plan text feature, default to true
blockStylebooltrueEnabled block style (H1,ol,pre etc.) feature, default to true
alignmentbooltrueEnabled text alignment feature, default to true
inlineStylebooltrueEnabled inline style (bold, italic, underline etc.) feature, default to true
colorbooltrueEnabled color text feature, default to true
imagebooltrueEnabled insert image feature, default to true
videobooltrueEnabled insert video feature, default to true
urlsbooltrueEnabled add hyper link feature, default to true
autoSavebooltrueEnabled auto save to draft-box feature, default to true
fullScreenbooltrueEnabled full screen feature, default to true
convertFormatstring"html"Set support format (html, markdown, raw), default to "html"
uploadPropsobjectnullCustomize uploading settings. API: Antd.Upload
1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago