3.1.1 • Published 2 months ago
react-m-editor v3.1.1
react-m-editor
A markdown editor with React.js
Install
// npm
npm install -S react-m-editor highlight.js marked prop-types
// yarn
yarn add react-m-editor highlight.js marked prop-types
// pnpm
pnpm install react-m-editor highlight.js marked prop-types
Usage with React
Use the component
import React, { useState } from 'react'
import { MEditor } from 'react-m-editor'
import 'react-m-editor/dist/index.min.css'
function Example () {
const [value, setValue] = useState('')
const handleChange = ({ content, htmlContent }) => {
setValue(content)
console.log(htmlContent)
}
return (
<MEditor
theme='dark'
showLineNum={false}
onChange={() => handleChange(contentObj)}
/>
)
}
The component also exports marked
function:
// The marked funciton will replace
// <code> or <code class="language-*"> tag
// to <code class="hljs">
import { marked } from 'react-m-editor'
let a = '```console.log('hello world')```'
console.log(marked(a)) // <p><code class="hljs">console.log('hello world')</code></p>
Preview
Api
props
name | type | default | description |
---|---|---|---|
value | string | - | value |
placeholder | string | - | placehoder |
mode | live | edit | preview | live | edit mode |
fullScreen | boolean | false | full screen |
showLineNum | boolean | true | show side line number |
theme | string | light | light or dark |
autoScroll | boolean | true | auto sroll or not |
debounceRender | boolean | false | debounce render html when edit |
debounceRenderWait | number | 200 | debounce wait time |
onChange | function ({ content, htmlContent }) | - | callback when editor changes |
onModeChange | function (mode, oldMode) | - | callback when editor's mode changes |
onFullScreenChange | function (isFullScreen) | - | callback when editor's fullscreen changes |
License
MIT © hellomrbigshot
3.1.1
2 months ago
3.1.0
2 months ago
3.0.7
3 years ago
3.0.6
3 years ago
3.0.4
3 years ago
3.0.3
3 years ago
3.0.5
3 years ago
3.0.2
3 years ago
3.0.1
3 years ago
2.0.0
3 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago