Gathering detailed insights and metrics for @easyv/md-editor-rt
Gathering detailed insights and metrics for @easyv/md-editor-rt
Gathering detailed insights and metrics for @easyv/md-editor-rt
Gathering detailed insights and metrics for @easyv/md-editor-rt
Markdown editor for react, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
npm install @easyv/md-editor-rt
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (91.65%)
Less (6.15%)
CSS (1.09%)
JavaScript (0.91%)
HTML (0.2%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
395 Stars
994 Commits
53 Forks
6 Watchers
14 Branches
2 Contributors
Updated on Jul 15, 2025
Latest Version
2.3.0
Package Id
@easyv/md-editor-rt@2.3.0
Unpacked Size
307.59 kB
Size
72.68 kB
File Count
13
NPM Version
8.15.0
Node Version
16.17.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
35
English | 中文
Markdown editor for react
, developed in jsx
and typescript
.
Documentation and demo:Go
Use it online:Go
The same series editor for vue3:md-editor-v3
prettier
(only for markdown content, not the code and other text).defalut
, vuepress
, github
, cyanosis
, mk-cute
, smart-blue
styles(not identical). It can be customized also(Refer to example page).mermaid
(>=1.3.0), katex
mathematical formula(>=1.4.0).1yarn add md-editor-rt
1import React, { useState } from 'react'; 2import MdEditor from 'md-editor-rt'; 3import 'md-editor-rt/lib/style.css'; 4 5export default () => { 6 const [text, setText] = useState('# Hello Editor'); 7 8 return <MdEditor modelValue={text} onChange={setText} />; 9};
Default theme | Dark theme | Preview only |
---|---|---|
![]() | ![]() | ![]() |
mark and emoji extensions
name | type | default | description |
---|---|---|---|
modelValue | string | '' | Markdown content |
theme | 'light' | 'dark' | 'light' | Editor theme |
class | string | '' | |
historyLength | number | 10 | The max length of history(if it is too big, editor will use more RAM ) |
pageFullScreen | boolean | false | Screenfull in web page |
preview | boolean | true | Preview content in editor |
htmlPreview | boolean | false | Preview html in editor |
previewOnly | boolean | false | Only render article content, no toolbar, no edit area |
language | string | 'zh-CN' | Build-in language('zh-CN','en-US') |
toolbars | Array<ToolbarNames | number> | [toolbars] | Show contents of toolbar, all keyssee toolbars below |
toolbarsExclude | Array<ToolbarNames | number> | [] | Don't show contents of toolbar, all keystoolbars |
noPrettier | boolean | false | Use prettier to beautify content or not |
editorId | string | 'md-editor-rt' | Editor id, it is used when there are more than two editors in the same page |
tabWidth | number | 2 | One tab eq some spaces |
showCodeRowNumber | boolean | false | Show row number for code block or not |
previewTheme | 'default' | 'github' | 'vuepress' | 'mk-cute' | 'smart-blue' | 'cyanosis' | 'default' | Preview theme, can be customized |
style | CSSProperties | {} | Editor inline style |
tableShape | [number, number] | [6, 4] | Preset the size of the table, [columns, rows] |
noMermaid | boolean | false | Use mermaid or not |
placeholder | string | '' | |
noKatex | boolean | false | Use katex or not |
defToolbars | Array<DropdownToolbar | NormalToolbar | ModalToolbar> | [] | Custom toolbar in DropdownToolbar , NormalToolbar or ModalToolbar |
codeTheme | 'atom' | 'a11y' | 'github' | 'gradient' | 'kimbie' | 'paraiso' | 'qtcreator' | 'stackoverflow' | 'atom' | Highlight code style, can be customized also |
markedHeadingId | (text: string, level: number, index: number) => string | (text) => text | H1-H6 ID generator |
sanitize | (html: string) => string | (html) => html | Sanitize the html, prevent XSS |
footers | Array<'markdownTotal' | '=' | 'scrollSwitch' | number> | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by '=' . Set it to [] to hidden footer |
scrollAuto | boolean | true | Scroll default setting |
defFooters | Array<string | ReactElement> | [] | Custom footer |
noIconfont | boolean | false | Not append iconfont script, download and import it by yourself |
formatCopiedText | (text: string) => string | (text: string) => text | Format copied code |
1[ 2 'bold', 3 'underline', 4 'italic', 5 '-', 6 'strikeThrough', 7 'title', 8 'sub', 9 'sup', 10 'quote', 11 'unorderedList', 12 'orderedList', 13 '-', 14 'codeRow', 15 'code', 16 'link', 17 'image', 18 'table', 19 'mermaid', 20 'katex', 21 '-', 22 'revoke', 23 'next', 24 'save', 25 '=', 26 'pageFullscreen', 27 'fullscreen', 28 'preview', 29 'htmlPreview', 30 'catalog', 31 'github' 32];
You can sort the toolbar as you like, split tools by
'-'
, the left and right toolbars are divided by'='
!
Expand language, you need to replace all the content here:
1export interface ToolbarTips { 2 bold?: string; 3 underline?: string; 4 italic?: string; 5 strikeThrough?: string; 6 title?: string; 7 sub?: string; 8 sup?: string; 9 quote?: string; 10 unorderedList?: string; 11 orderedList?: string; 12 codeRow?: string; 13 code?: string; 14 link?: string; 15 image?: string; 16 table?: string; 17 mermaid?: string; 18 katex?: string; 19 revoke?: string; 20 next?: string; 21 save?: string; 22 prettier?: string; 23 pageFullscreen?: string; 24 fullscreen?: string; 25 catalog?: string; 26 preview?: string; 27 htmlPreview?: string; 28 github?: string; 29 '-'?: string; 30 '='?: string; 31} 32 33export interface StaticTextDefaultValue { 34 // Toolbar hover tips(html title) 35 toolbarTips?: ToolbarTips; 36 // h1-h6 dropdown menu item 37 titleItem?: { 38 h1?: string; 39 h2?: string; 40 h3?: string; 41 h4?: string; 42 h5?: string; 43 h6?: string; 44 }; 45 // v1.6.0 46 imgTitleItem?: { 47 link: string; 48 upload: string; 49 clip2upload: string; 50 }; 51 // The modal tips of add link or upload picture 52 linkModalTips?: { 53 title?: string; 54 descLable?: string; 55 descLablePlaceHolder?: string; 56 urlLable?: string; 57 UrlLablePlaceHolder?: string; 58 buttonOK?: string; 59 }; 60 // The modal tips of clip the picture, v1.2.0 61 clipModalTips?: { 62 title?: string; 63 buttonUpload?: string; 64 }; 65 // Copy code tips, v1.1.4 66 copyCode?: { 67 text?: string; 68 successTips?: string; 69 failTips?: string; 70 }; 71 // 1.8.0 72 mermaid?: { 73 flow?: string; 74 sequence?: string; 75 gantt?: string; 76 class?: string; 77 state?: string; 78 pie?: string; 79 relationship?: string; 80 journey?: string; 81 }; 82 // 1.9.0 83 katex?: { 84 // formula inline 85 inline: string; 86 // formula block 87 block: string; 88 }; 89 footer?: { 90 markdownTotal: string; 91 scrollAuto: string; 92 }; 93}
name | parameter | description |
---|---|---|
onChange | value: string | Content changed event(bind to oninput of textarea ) |
onSave | value: string | Save content event, ctrl+s and click button will be triggered also |
onUploadImg | files: Array<File>, callback: (urls: Array<string>) => void | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
onHtmlChanged | html: string | Compile markdown successful event, you can use it to get the html code |
onGetCatalog | list: Array<HeadList> | Get catalog of article |
onError | error: { name: string; message: string } | Catch run-time error, Cropper , fullScreen and prettier are used when they are not loaded |
Use MdEditor.config(option: ConfigOption)
to reconfigure renderer
.
markedRenderer: (renderer: RewriteRenderer) => RewriteRenderer
Open target page in a new browser window:
1MdEditor.config({ 2 markedRenderer(renderer) { 3 renderer.link = (href, title, text) => { 4 return `<a href="${href}" title="${title}" target="_blank">${text}</a>`; 5 }; 6 7 return renderer; 8 } 9});
Reference: https://marked.js.org/using_pro#renderer, RewriteRenderer extends Renderer and rewrites heading, now provides index as the fifth parameter.
markedExtensions: Array<marked.TokenizerExtension & marked.RendererExtension>
1import MdEditor from 'md-editor-rt'; 2 3MdEditor.config({ 4 markedExtensions: [your extension] 5});
Reference: https://marked.js.org/using_pro#extensions
markedOptions: marked.MarkedOptions
Do not render <br>
on a single line break:
1import MdEditor from 'md-editor-rt'; 2 3MdEditor.config({ 4 markedOptions: { breaks: false } 5});
Reference: https://marked.js.org/using_advanced#options
editorConfig: Add more languages, reset mermaid
template or delay rendering time:
1import MdEditor from 'md-editor-rt'; 2 3MdEditor.config({ 4 editorConfig: { 5 languageUserDefined: { lang: StaticTextDefaultValue }, 6 mermaidTemplate: { 7 flow: `flow tempalte`, 8 ...more 9 }, 10 // Default 500ms. It is set to 0ms when preview only and not set. 11 renderDelay: 500 12 } 13});
editorExtensions: Config some dependency libraries, like highlight..
1import MdEditor from 'md-editor-rt'; 2 3MdEditor.config({ 4 editorExtensions: { iconfont: 'https://xxx.cc' } 5});
1import MdEditor from 'md-editor-rt'; 2 3interface EditorExtensions { 4 highlight?: { 5 instance?: any; 6 js?: string; 7 css?: { 8 [key: string]: { 9 light: string; 10 dark: string; 11 }; 12 }; 13 }; 14 prettier?: { 15 standaloneJs?: string; 16 parserMarkdownJs?: string; 17 }; 18 cropper?: { 19 instance?: any; 20 js?: string; 21 css?: string; 22 }; 23 iconfont?: string; 24 screenfull?: { 25 instance?: any; 26 js?: string; 27 }; 28 mermaid?: { 29 instance?: any; 30 js?: string; 31 }; 32 katex?: { 33 instance?: any; 34 js?: string; 35 css?: string; 36 }; 37}
key | function | description |
---|---|---|
TAB | insert space | Insert space, the length eq tabWidth , default: 2, support multiline |
SHIFT + TAB | delete space, setting is the same as Tab | |
CTRL + C | copy | When selected, copy the selected content. When not selected, copy the content of the current line |
CTRL + X | shear | When selected, cut the selected content. When not selected, cut the current line |
CTRL + D | delete | When selected, delete the selected content. When not selected, delete the current line |
CTRL + S | save | Trigger onSave event |
CTRL + B | bold text | **bold** |
CTRL + U | underline | <u>underline</u> |
CTRL + I | italic | *italic* |
CTRL + 1-6 | h1-h6 | # title |
CTRL + ↑ | superscript | <sup>superscript</sup> |
CTRL + ↓ | subscript | <sub>subscript</sub> |
CTRL + Q | quote | > quote |
CTRL + O | ordered list | 1. ordered list |
CTRL + L | link | [link](https://github.com/imzbf/md-editor-rt) |
CTRL + Z | withdraw | Withdraw history in editor, not the function of system |
CTRL + SHIFT + S | line-through | ~line-through~ |
CTRL + SHIFT + U | unordered list | - unordered list |
CTRL + SHIFT + C | code block | |
CTRL + SHIFT + I | picture |  |
CTRL + SHIFT + Z | forward | Forward history in editor, not the function of system |
CTRL + SHIFT + F | Beautify | |
CTRL + ALT + C | code row | |
CTRL + SHIFT + ALT + T | table | |table| |
They are used as attributes of the editor component, eg: Editor.DropdownToolbar
. For more examples, refer to document.
Editor.NormalToolbar
props
title
: string
, not necessary, title of toolbar.events
onClick
: (e: MouseEvent) => void
, necessary.slots
trigger
: string | JSX.Element
, necessary, it is usually an icon, which is displayed on the toolbar.Editor.DropdownToolbar
props
title
: string
, not necessary, title of toolbar.visible
: boolean
, necessary.events
onChange
: (visible: boolean) => void
, necessary.slots
trigger
: string | JSX.Element
, necessary, it is usually an icon, which is displayed on the toolbar.overlay
: string | JSX.Element
, necessary, content of dropdown box.Editor.ModalToolbar
props
title
: string
, not necessary, title of toolbar.modalTitle
: string
, not necessary, title of the Modal.visible
: boolean
, necessary, visibility of Modal.width
: string
, not necessary, width of Modal, default auto
.height
: string
, same as width
.showAdjust
: boolean
, not necessary, visibility of fullscreen button.isFullscreen
: boolean
, necessary when showAdjust = true
, status of fullscreen.events
onClick
: () => void
, necessary.onClose
: () => void
, necessary, close event.onAdjust
: (val: boolean) => void
, fullscreen button click event.slots
trigger
: string | JSX.Element
, necessary, it is usually an icon, which is displayed on the toolbar.overlay
: string | JSX.Element
, necessary, content of Modal.Editor.MdCatalog
props
editorId
: string
, necessary, same as editor's editorId
, used to register listening events.class
: string
, not necessary.markedHeadingId
: MarkedHeadingId
, not necessary, same as editor.scrollElement
: string | HTMLElement
, not necessary, it is an element selector when its type is string. When previewOnly
eq true
, it is usually set to document.documentElement
.theme
: 'light' | 'dark'
, not necessary, provide it when you want to change theme online, it is the same as Editor theme
.offsetTop
: number
, not necessary, highlight current item of catalogs when title is offsetTop
pixels from the top, defalut 20.events
onClick
: (e: MouseEvent, t: TocItem) => void
, not necessary.Tips: When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
1import React, { useState } from 'react'; 2import MdEditor from 'md-editor-rt'; 3import 'md-editor-rt/lib/style.css'; 4 5export default () => { 6 const [text, setText] = useState('# Hello Editor'); 7 8 const onUploadImg = async (files, callback) => { 9 const res = await Promise.all( 10 files.map((file) => { 11 return new Promise((rev, rej) => { 12 const form = new FormData(); 13 form.append('file', file); 14 15 axios 16 .post('/api/img/upload', form, { 17 headers: { 18 'Content-Type': 'multipart/form-data' 19 } 20 }) 21 .then((res) => rev(res)) 22 .catch((error) => rej(error)); 23 }); 24 }) 25 ); 26 27 callback(res.map((item) => item.data.url)); 28 }; 29 30 return <MdEditor modelValue={text} onChange={setText} onUploadImg={onUploadImg} />; 31};
1.css-vars(@isDark) { 2 --md-color: if(@isDark, #999, #222); 3 --md-hover-color: if(@isDark, #bbb, #000); 4 --md-bk-color: if(@isDark, #000, #fff); 5 --md-bk-color-outstand: if(@isDark, #111, #f6f6f6); 6 --md-bk-hover-color: if(@isDark, #1b1a1a, #f5f7fa); 7 --md-border-color: if(@isDark, #2d2d2d, #e6e6e6); 8 --md-border-hover-color: if(@isDark, #636262, #b9b9b9); 9 --md-border-active-color: if(@isDark, #777, #999); 10 --md-modal-mask: #00000073; 11 --md-scrollbar-bg-color: if(@isDark, #0f0f0f, #e2e2e2); 12 --md-scrollbar-thumb-color: if(@isDark, #2d2d2d, #0000004d); 13 --md-scrollbar-thumb-hover-color: if(@isDark, #3a3a3a, #00000059); 14 --md-scrollbar-thumb-avtive-color: if(@isDark, #3a3a3a, #00000061); 15} 16 17.md { 18 .css-vars(false); 19} 20 21.md-dark { 22 .css-vars(true); 23}
Change background color in dark mode:
1.md-dark { 2 --md-bk-color: #333 !important; 3}
No vulnerabilities found.
No security vulnerabilities found.