pta-editor
v0.5.4
Published
React Markdown editor component for PTA.
Downloads
15
Readme
pta-editor
$ npm install pta-editor --save
Usage
Check out /example folder for basic usage.
Style Dependencies
- Font Awesome
/lib/style.css
/node_modules/simplemde/dist/simplemde.min.css
/node_modules/katex/dist/katex.css
/node_modules/katex/dist/fonts
PropTypes
Editor.propTypes = {
guide: React.PropTypes.string,
lng: React.PropTypes.string,
name: React.PropTypes.string,
onChange: React.PropTypes.func,
toolbar: React.PropTypes.array,
uploader: React.PropTypes.func,
value: React.PropTypes.string,
}
The uploader
function should receive an file object and return its online URL by Promise.
e.g.
function uploader(file) {
const data = new FormData('file', file)
return fetch('/upload', {
method: 'POST',
body: data,
})
.then(res => res.json())
.then(res => ({ url: res.url }))
}
Properties
editor.value
: set or get the value of editor.editor.simplemde
: simplemde instance.editor.simplemde.codemirror
: codemirror instance.
Methods
Editor.render(content, answers, options)
: render function.editor.text([text])
: set or get plain text of editor.editor.html()
: get preview HTML.editor.on(event, listener)
: add event listener.editor.off(event, listener)
: remove event listener.