react-rte-filepicker v0.3.1
React Rich Text Editor
The package provides a simple rich text editor based on Draft JS. It has image support thanks to filepicker-js package.
It will export the content as Draft Raw
Breaking changes
starting from version 0.3.0-beta.1
, the editor no longer exports nor accepts markdown as content. Instead Raw Draft content (JSON object) will be used as export and import
Usage
- Install react-rte
npm install react-rte-filepicker
- Get a Filepicker API Key
- Import the component and use it, here is a simple example:
import React from 'react';
import RichTextEditor from 'react-rte-filepicker';
class Posts extends React.Component {
constructor(props) {
super(props);
}
handleSubmit(event) {
event.preventDefault();
const { editorRef } = this.refs;
const content = editorRef.convertToRaw();
// Do something smart with the content
console.log(content);
}
render() {
return (
<div>
<h1>Posts</h1>
<form onSubmit={this.handleSubmit.bind(this)}>
<div className="field">
<RichTextEditor
ref="editorRef"
filePickerKey="FILEPICKER_API_KEY"
/>
</div>
<button className="expanded button" type="submit">Submit</button>
</form>
</div>
);
}
}
export default Posts;
If you want to import some content (when editing a document), you may pass a Draft Raw string through the content
prop
<RichTextEditor
ref="editorRef"
filePickerKey="FILEPICKER_API_KEY"
content={convertFromRaw(contentInDraftRaw)}
/>
Roadmap
- Accept filepicker configuration options
- Enable table insertion
License
Copyright (c) 2016 Aldo Funes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago