Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
md-editor-rt
Advanced tools
Markdown editor for react, developed by jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
English | 中文
Markdown editor for react
, developed by 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
styles(not identical).More features are developing, if you have some ideas or find issues, please tell it to me~
Default theme | Dark theme | Preview only |
---|---|---|
name | type | default | description |
---|---|---|---|
modelValue | String | '' | Markdown content |
theme | 'light' | 'dark' | 'light' | Change editor theme |
editorClass | String | '' | |
hljs | Object | null | Highlight instance, editor will not insert script of it, but you need to import highlight code style by yourself |
highlightJs | String | highlight.js@11.2.0 | HighlightJs url |
highlightCss | String | atom-one-dark@11.2.0 | Highlight code style |
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') |
languageUserDefined | Object | {key: StaticTextDefaultValue} | Expand language,update language api to your key |
toolbars | Array | [toolbars] | Show some item of toolbars,all keyssee toolbars below |
toolbarsExclude | Array | [] | Don't show some item of toolbars,all keystoolbars |
prettier | Boolean | true | Use prettier to beautify content or not |
prettierCDN | String | standalone@2.4.0 | |
prettierMDCDN | String | parser-markdown@2.4.0 | |
cropperCss | String | cropper.min.css@1.5.12 | Cropper css url |
cropperJs | String | cropper.min.js@1.5.12 | Cropper js url |
iconfontJs | String | iconfont | Icon url |
editorId | String | md-editor-rt | Editor id, also the html id, it is used when there are more than two editors |
tabWidth | Number | 2 | One tab eq some space |
showCodeRowNumber | Boolean | false | Show row number for code block or not |
screenfull | Object | null | Screenfull instance, editor will not insert script of it |
screenfullJs | String | screenfull@5.1.0 | Screenfull js url |
previewTheme | 'default' | 'github' | 'vuepress' | 'default' | Preview themes |
style | CSSProperties | {} | Editor's inline style |
[toolbars]
[
'bold',
'underline',
'italic',
'-',
'strikeThrough',
'title',
'sub',
'sup',
'quote',
'unorderedList',
'orderedList',
'-',
'codeRow',
'code',
'link',
'image',
'table',
'-',
'revoke',
'next',
'save',
'=',
'pageFullscreen',
'fullscreen',
'preview',
'htmlPreview',
'catalog',
'github'
];
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:
[StaticTextDefaultValue]
export interface StaticTextDefaultValue {
// Toolbar hover tips(html title)
toolbarTips?: ToolbarTips;
// h1-h6 dropdown menu item
titleItem?: {
h1?: string;
h2?: string;
h3?: string;
h4?: string;
h5?: string;
h6?: string;
};
imgTitleItem?: {
link: string;
upload: string;
clip2upload: string;
};
// The modal tips of add link or upload picture
linkModalTips?: {
title?: string;
descLable?: string;
descLablePlaceHolder?: string;
urlLable?: string;
UrlLablePlaceHolder?: string;
buttonOK?: string;
};
// The modal tips of clip the picture
clipModalTips?: {
title?: string;
buttonUpload?: string;
};
// Copy code tips
copyCode?: {
text?: string;
tips?: string;
};
}
name | type | description |
---|---|---|
onChange | (v: string) => void | Content changed event(bind to oninput of textarea ) |
onSave | (v: string) => void | Save Content event,ctrl+s and click button will trigger |
onUploadImg | (files: FileList, callback: function) => void | Upload picture event,when picture is uploading the modal will not close,please provide right urls to the callback function |
onHtmlChanged | (h: string) => void | Compile markdown successful event,you can use it to get the html code |
onGetCatalog | (list: HeadList[]) => void | Get catalogue of article |
markedHeading | (text: string,level: 1-6,raw: string, slugger: Slugger) => string | marked head renderer methods |
markedHeadingId | (text: string, level: number) => string | title ID generator |
If
markedHeading
is overridden, be sure to tell the editor the algorithm for generating the title ID bymarketheadingid
.
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-v3) |
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 | ![picture](https://imbf.cc) |
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| |
import { useState } from 'react';
import Editor from 'md-editor-rt';
import 'md-editor-rt/lib/style.css';
export default function App() {
const [text, setText] = useState('hello md-editor-rt!');
return (
<Editor
modelValue={text}
onChange={(modelValue) => {
setText(modelValue);
}}
/>
);
}
Tips:When you paste and upload GIF,it will upload a static picture. So you should upload it by file system!
async onUploadImg(files: FileList, callback: (urls: string[]) => void) {
const res = await Promise.all(
Array.from(files).map((file) => {
return new Promise((rev, rej) => {
const form = new FormData();
form.append('file', file);
axios
.post('/api/img/upload', form, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then((res) => rev(res))
.catch((error) => rej(error));
});
})
);
callback(res.map((item: any) => item.data.url));
}
FAQs
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...
The npm package md-editor-rt receives a total of 1,361 weekly downloads. As such, md-editor-rt popularity was classified as popular.
We found that md-editor-rt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.