A React markdown editor and previewer.
npm install react-markplusA React markdown editor and previewer.
- Demo for Markdown authors
- Demo for React developers
- source code
```
yarn add react-markplus
`tsx
import MarkPlus from "react-markplus";
`
You will need to import the following CSS:
- "katex/dist/katex.css";
- "@fortawesome/fontawesome-free/css/all.css";
- "react-markplus/src/css/index.scss";
Initial markdown text to load into the editor.
`tsx`
Default value is ''.
A callback function to be invoked automatically when markdown text changes.
`tsx`
console.log("markdown text changed to:", markdown);
}}
/>;
Default value is () => {}.
A callback function to be invoked automatidally when preview html changes.
This has been removed from the library. Because you are supposed to generate
preview using
markplus-engine.
Show, hide or remove toolbar.
`tsx`
3 possible values:
- show: show toolbar, show a gutter below toolbar. Click the gutter to hidehide
toolbar.
- : hide toolbar, show a gutter on top. Click the gutter to show toolbar.none
- : no toolbar, no gutter.
Default value: show.
Display editor, preview or both.
`tsx`
3 possible values:
- both: show both editor and previeweditor
- there is a vertical gutter between editor and preview, you may drag the
gutter to adjust sizes of them.
- : show editor onlypreview
- : show preview only
- Use this mode if you don't need any editing feature.
- in this mode this library is a markdown renderer.
Default value: both.
Overall theme: light, dark or auto:
`tsx`
3 possible values:
- light: light themedark
- : dark themeauto
- : same as system theme
Default value: auto.
You may configure the toolbar freely.
`tsx`
A toolbar item could be either a string or a ReactElement. For toolbar itemsReactElement
included with library, you may just specify a string. For your own custom
toolbar items, please specify a .
- 'about''|'
- show a modal about MarkPlus
- 'bold'
- a vertical separator
- 'italic'
- make text bold
- 'strikethrough'
- make text italic
- 'underline'
- make text strokethrough
- 'mark'
- make text underlined
- 'emoji'
- make text marked
- 'fontawesome'
- show a modal to insert emojis
- 'quote'
- show a modal to insert fontawesome icons
- 'unordered-list'
- quote text
- 'ordered-list'
- create unordered list item
- 'unchecked-list'
- create ordered list item
- 'checked-list'
- create unchecked task list item
- 'link'
- create checked task list item
- 'image'
- insert a link
- 'code'
- insert a image
- 'table'
- insert a code snippet
- 'math'
- insert a table
- flowchart
- insert some math formulas
-
- insert some flowcharts
`tsx`
import { defaultToolbarItems } from "react-markplus";
Its value is:
`tsx`
[
"about",
"|",
"bold",
"italic",
"strikethrough",
"underline",
"mark",
"|",
"emoji",
"fontawesome",
"|",
"quote",
"unordered-list",
"ordered-list",
"unchecked-list",
"checked-list",
"|",
"link",
"image",
"code",
"table",
"|",
"math",
"flowchart",
];
You may add or remote items from it to customize your own toolbar.
Here is a sample to create and insert a custom toolbar item:
`tsx``
"about",
"|",
key="preferences"
title="Preferences"
className="fa fa-cog"
onClick={() => {
console.log("Todo: display a preferences modal");
}}
>
,
]}
/>;
Custom toolbar item will freeze in React 19 dev mode.
It works in production mode though. It also works with React 18.