
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
for-editor-herb
Advanced tools
Markdown editor for React, support Tex rendering!
x.x.x ---> Incompatible Update . New Features(include Fixing Known Bugs) . Fix Bugs
A branch of for-editor! Beacuse of long time without refreshing, without PR handler. Hug to Open Source! If you like this, please give a star to for-editor
Base on
0.3.5
Tex Block and Inline Tex sentencesemoji by emoji shortname ( v2.2.0~ ), visit joypixels for more information==Mark== to highlight (mark) the inline text ( v2.3.0~ )# npm
npm install for-editor-herb -S
# yarn
yarn add for-editor-herb
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Editor from 'for-editor-herb'
// require `highlight.js` package
const Hljs = require('highlight.js')
class App extends Component {
constructor() {
super()
this.state = {
value: ''
}
}
componentDidMount() {
// register languages in componentDidMount lifecycle
Hljs.registerLanguage('css', require('highlight.js/lib/languages/css'))
Hljs.registerLanguage('json', require('highlight.js/lib/languages/json'))
Hljs.registerLanguage('less', require('highlight.js/lib/languages/less'))
Hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss'))
Hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'))
Hljs.registerLanguage('typescript', require('highlight.js/lib/languages/typescript'))
Hljs.registerLanguage('go', require('highlight.js/lib/languages/go'))
}
handleChange(value) {
this.setState({
value
})
}
render() {
const { value } = this.state
// Support default language('en', 'zh-CN', 'zh-TW', 'jp') and localization
const customLang: any = {
placeholder: "Begin editing...",
undo: "Undo",
redo: "Redo",
h1: "Header 1",
h2: "Header 2",
h3: "Header 3",
h4: "Header 4",
h5: "Header 5",
h6: "Header 6",
img: "Image Link",
para: "Paragraphy",
italic: "Italic",
bold: "Bold",
bolditalic: "Bold Italic",
delline: "Delete Line",
underline: "Underline",
keytext: "Keyboard Text",
superscript: "Superscript",
subscript: "Subscript",
marktag: "Mark Tag",
table: "Table",
quote: "Quote",
link: "Link",
list: "List",
orderlist: "Order List",
disorderlist: "Disorder List",
checklist: "Check List",
inlinecode: "Inline Code",
code: "Code",
collapse: "Collapse",
katex: "KaTeX",
save: "Save",
preview: "Preview",
singleColumn: "Single Column",
doubleColumn: "Double Columns",
fullscreenOn: "FullScreen ON",
fullscreenOff: "FullScreen OFF",
addImgLink: "Add Image Link",
addImg: "Upload Image",
toc: "Generate TOC"
}
}
// Transfer function `Hljs.highlightAuto` to the Editor
return (
<Editor
value={value}
onChange={() => this.handleChange()}
highlight={Hljs.highlightAuto}
/>
)
}
}
ReactDOM.render(<App />, document.getElementById('root'))
| name | type | default | description |
|---|---|---|---|
| value | String | - | value |
| language | String / IWords | en | Default Language(zh-CN: Simplified Chinese, en: English, zh-TW: Traditional Chinese, jp: Japanese), support localization by following the interface IWords |
| placeholder | String | Begin editing... | The default prompt text when the textarea is empty |
| lineNum | Boolean | true | Show lineNum |
| style | Object | - | editor styles |
| height | String | 600px | editor height |
| preview | Boolean | false | preview switch |
| expand | Boolean | false | fullscreen switch |
| subfield | Boolean | false | true: Double columns - Edit preview same screen(notice: preview: true), Single Columns - otherwise not |
| toolbar | Object | As in the following example | toolbars |
| outline | Boolean | true | Display outline list for markdown |
| highlight | Function | Hljs.highlightAuto | Hljs (highlight.js)'s function --- highlightAuto |
| anchor | Boolean | true | Control if the anchor is displayed at the preview |
/*
The default toolbar properties are all true,
You can customize the object to cover them.
eg: {
h1: true,
code: true,
preview: true,
}
At this point, the toolbar only displays the three function keys.
notice: Toolbar will be hidden when empty object.
*/
toolbar: {
h1: true,
h2: true,
h3: true,
h4: true,
h5: true,
h6: true,
img: true,
list: true,
para: {
paragraph: true, // control the whole part if you don't want to display
italic: true,
bold: true,
bolditalic: true,
delline: true,
underline: true,
keytext: true,
superscript: true,
subscript: true,
marktag: true
},
table: true,
quote: true,
link: true,
inlinecode: true,
code: true,
collapse: true,
katex: true,
preview: true,
expand: true,
undo: true,
redo: true,
save: true,
subfield: true,
toc: true // generate TOC
IWords
interface IWords {
placeholder: string
h1: string
h2: string
h3: string
h4: string
h5: string
h6: string
undo: string
redo: string
list: string
orderlist: string
disorderlist: string
checklist: string
para: string
italic: string
bold: string
bolditalic: string
delline: string
underline: string
keytext: string
superscript: string
subscript: string
marktag: string
quote: string
table: string
img: string
link: string
inlinecode: string
code: string
collapse: string
katex: string
save: string
preview: string
singleColumn: string
doubleColumn: string
fullscreenOn: string
fullscreenOff: string
addImgLink: string
addImg: string
toc: string
}
| name | params | default | description |
|---|---|---|---|
| onChange | String: value | - | Edit area change callback event |
| onSave | String: value | - | Ctrl+s and click save button callback event |
| addImg | File: file | - | upload image callback event |
class App extends Component {
constructor() {
super()
this.state = {
value: ''
}
this.$vm = React.createRef()
}
handleChange(value) {
this.setState({
value
})
}
addImg($file) {
this.$vm.current.$img2Url($file.name, 'file_url')
console.log($file)
}
render() {
const { value } = this.state
return (
<Editor
ref={this.$vm}
value={value}
addImg={($file) => this.addImg($file)}
onChange={(value) => this.handleChange(value)}
/>
)
}
}
| name | description |
|---|---|
| tab | two space |
| ctrl+s | save |
| ctrl+z | undo |
| ctrl+y | redo |
for-editor is MIT Licence.
FAQs
react markdown editor
The npm package for-editor-herb receives a total of 20 weekly downloads. As such, for-editor-herb popularity was classified as not popular.
We found that for-editor-herb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.