lerna-editor
is a rich text editor component used for React project
npm install --save lerna-editor
Before using the editor, you must add the following tags to your index.html
file
<link rel="stylesheet" href="https://cdn.quilljs.com/1.2.6/quill.snow.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js"></script>
The following code shows how to use the rich text editor:
import React, { Component } from "react";
import { Editor } from "lerna-editor";
class Example extends Component {
render() {
return <Editor />;
}
}
Name | Description | Type | Default value |
---|---|---|---|
initialContent | Initial content of the editor | string | HTML |
null |
placeholder | Placeholder of the editor | string |
null |
Name | Description | Default value |
---|---|---|
onChange(html, deltas, text) | Event firing when editor's content changes | null |
Note that:
html
is HTML generated by the editordeltas
is array of delta, which is editor content's representation in objecttext
is text inferred from HTML
When you want to render the HTML generated from editor, you use the following code:
import React, { Component } from "react";
import { EditorContent } from "lerna-editor";
class Example extends Component {
render() {
return <EditorContent content={"Editor"}/>;
}
}
Name | Description | Type | Default value |
---|---|---|---|
content | Content of the editor | string | HTML |
null |
inline | Whether editor is inline or block | bool |
false |
className | className of the editor content |
string |
null |
MIT © ntncsebku