3.1.1 • Published 2 months ago

react-m-editor v3.1.1

Weekly downloads
1
License
-
Repository
-
Last release
2 months ago

react-m-editor

A markdown editor with React.js

GitHub package.json version GitHub JavaScript Style Guide

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(&#39;hello world&#39;)</code></p>

Preview

address

Api

props

nametypedefaultdescription
valuestring-value
placeholderstring-placehoder
modelive | edit | previewliveedit mode
fullScreenbooleanfalsefull screen
showLineNumbooleantrueshow side line number
themestringlightlight or dark
autoScrollbooleantrueauto sroll or not
debounceRenderbooleanfalsedebounce render html when edit
debounceRenderWaitnumber200debounce wait time
onChangefunction ({ content, htmlContent })-callback when editor changes
onModeChangefunction (mode, oldMode)-callback when editor's mode changes
onFullScreenChangefunction (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