Skip to content

Commit 678ce56

Browse files
authored
Merge pull request #17 from Webbrother/develop
2.0.1 => main
2 parents 5d0e9f4 + d80dbbd commit 678ce56

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Introduction
22

33
A simple yet powerful and extensible **React Markdown Editor** that aims to have feature parity with the Github Markdown editor.
4-
React-mde-headless has no 3rd party dependencies.
4+
React-mde-headless has **no 3rd party dependencies**.
55

66
## [Demo](https://codesandbox.io/s/competent-jepsen-qyz51q?file=/src/index.tsx)
77

demo/index.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import ReactDOM from 'react-dom';
33
import { Box, ChakraProvider, HStack, Textarea } from '@chakra-ui/react';
44
import { faBold, faItalic, faCode, faHeading, faImage, faLink } from '@fortawesome/free-solid-svg-icons';
55
import {
6+
// hook
7+
useTextAreaMarkdownEditor,
8+
// commands
69
boldCommand,
710
codeCommand,
811
codeBlockCommand,
912
headingLevel1Command,
1013
italicCommand,
1114
strikethroughCommand,
12-
useTextAreaMarkdownEditor,
1315
quoteCommand,
1416
checkedListCommand,
1517
orderedListCommand,
@@ -19,6 +21,7 @@ import {
1921
} from '../src';
2022
import { ToolbarButton } from './toolbar-button';
2123
import ReactMarkdown from 'react-markdown';
24+
import ChakraUIRenderer from 'chakra-ui-markdown-renderer';
2225

2326
export const Demo = () => {
2427
const { ref, commandController } = useTextAreaMarkdownEditor({
@@ -69,6 +72,12 @@ export const Demo = () => {
6972
}}
7073
icon={faCode}
7174
/>
75+
<ToolbarButton
76+
onClick={() => {
77+
commandController.executeCommand('codeBlock');
78+
}}
79+
icon={faCode}
80+
/>
7281

7382
<ToolbarButton
7483
onClick={() => {
@@ -97,13 +106,6 @@ export const Demo = () => {
97106
{'>'}
98107
</ToolbarButton>
99108

100-
<ToolbarButton
101-
onClick={() => {
102-
commandController.executeCommand('codeBlock');
103-
}}
104-
icon={faCode}
105-
/>
106-
107109
<ToolbarButton
108110
onClick={() => {
109111
commandController.executeCommand('orderedList');
@@ -138,7 +140,7 @@ export const Demo = () => {
138140
</HStack>
139141

140142
{isPreview ? (
141-
<ReactMarkdown>{ref.current?.value ?? ''}</ReactMarkdown>
143+
<ReactMarkdown components={ChakraUIRenderer()}>{ref.current?.value ?? ''}</ReactMarkdown>
142144
) : (
143145
<Textarea
144146
ref={ref}

package-lock.json

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-headless-mde",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "React Headless Markdown Editor",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",
@@ -48,6 +48,7 @@
4848
"@typescript-eslint/eslint-plugin": "5.54.1",
4949
"@vitejs/plugin-react": "^1.3.0",
5050
"add": "^2.0.6",
51+
"chakra-ui-markdown-renderer": "^4.1.0",
5152
"cross-env": "^6.0.3",
5253
"eslint": "8.35.0",
5354
"eslint-config-prettier": "8.7.0",

0 commit comments

Comments
 (0)