- Published on
react版本markdown编辑器md-editor-rt,支持ssr
- Authors
- Name
- duluwa.com
Intro
Install
yarn add md-editor-rt
Usage
import React, { useState } from 'react'
import { MdEditor } from 'md-editor-rt'
import 'md-editor-rt/lib/style.css'
export default () => {
const [text, setText] = useState('hello md-editor-rt!')
return <MdEditor modelValue={text} onChange={setText} />
}
Preview Only
import React, { useState } from 'react'
import { MdPreview, MdCatalog } from 'md-editor-rt'
import 'md-editor-rt/lib/preview.css'
export default () => {
const [id] = useState('preview-only')
const [scrollElement] = useState(document.documentElement)
const [text] = useState('hello md-editor-rt!')
return (
<>
<MdPreview editorId={id} modelValue={text} />
<MdCatalog editorId={id} scrollElement={scrollElement} />
</>
)
}