Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit ed0a4c6

Browse files
committed
Update readme
1 parent e57c238 commit ed0a4c6

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

README.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,64 @@ A [DraftJS] plugin for supporting Markdown syntax shortcuts in DraftJS. This plu
1717
npm i --save draft-js-markdown-plugin
1818
```
1919

20+
## Usage
21+
22+
```js
23+
import React, { Component } from 'react';
24+
import Editor from 'draft-js-plugins-editor';
25+
import createMarkdownPlugin from 'draft-js-markdown-plugin';
26+
import { EditorState } from 'draft-js';
27+
28+
export default class DemoEditor extends Component {
29+
30+
state = {
31+
editorState: EditorState.createEmpty(),
32+
plugins: [createMarkdownPlugin()]
33+
};
34+
35+
onChange = (editorState) => {
36+
this.setState({
37+
editorState,
38+
});
39+
};
40+
41+
render() {
42+
return (
43+
<Editor
44+
editorState={this.state.editorState}
45+
onChange={this.onChange}
46+
plugins={this.state.plugins}
47+
/>
48+
);
49+
}
50+
}
51+
```
52+
53+
### Add code block syntax highlighting
54+
55+
Using the [`draft-js-prism-plugin`](https://github.com/withspectrum/draft-js-prism-plugin) you can easily add syntax highlighting support to your code blocks!
56+
57+
```JS
58+
// Install prismjs and draft-js-prism-plugin
59+
import Prism from 'prismjs';
60+
import createPrismPlugin from 'draft-js-prism-plugin';
61+
62+
class Editor extends Component {
63+
state = {
64+
plugins: [
65+
// Add the Prism plugin to the plugins array
66+
createPrismPlugin({
67+
prism: Prism
68+
}),
69+
createMarkdownPlugin()
70+
]
71+
}
72+
}
73+
```
74+
2075
## Options
21-
The `draft-js-markdown-plugin` is configurable. Just pass a config object. Here are the available options:
2276

77+
The `draft-js-markdown-plugin` is configurable. Just pass a config object. Here are the available options:
2378

2479
### `renderLanguageSelect`
2580

@@ -152,61 +207,6 @@ const markdownPlugin = createMarkdownPlugin({ entityType });
152207
const editorPlugins = [focusPlugin, imagePlugin, markdownPlugin];
153208
```
154209

155-
## Usage
156-
157-
```js
158-
import React, { Component } from 'react';
159-
import Editor from 'draft-js-plugins-editor';
160-
import createMarkdownPlugin from 'draft-js-markdown-plugin';
161-
import { EditorState } from 'draft-js';
162-
163-
export default class DemoEditor extends Component {
164-
165-
state = {
166-
editorState: EditorState.createEmpty(),
167-
plugins: [createMarkdownPlugin()]
168-
};
169-
170-
onChange = (editorState) => {
171-
this.setState({
172-
editorState,
173-
});
174-
};
175-
176-
render() {
177-
return (
178-
<Editor
179-
editorState={this.state.editorState}
180-
onChange={this.onChange}
181-
plugins={this.state.plugins}
182-
/>
183-
);
184-
}
185-
}
186-
```
187-
188-
### Add code block syntax highlighting
189-
190-
Using the [`draft-js-prism-plugin`](https://github.com/withspectrum/draft-js-prism-plugin) you can easily add syntax highlighting support to your code blocks!
191-
192-
```JS
193-
// Install prismjs and draft-js-prism-plugin
194-
import Prism from 'prismjs';
195-
import createPrismPlugin from 'draft-js-prism-plugin';
196-
197-
class Editor extends Component {
198-
state = {
199-
plugins: [
200-
// Add the Prism plugin to the plugins array
201-
createPrismPlugin({
202-
prism: Prism
203-
}),
204-
createMarkdownPlugin()
205-
]
206-
}
207-
}
208-
```
209-
210210
## Why fork the `markdown-shortcuts-plugin`?
211211

212212
Writing is a core part of our app, and while the `markdown-shortcuts-plugin` is awesome and battle-tested there are a few opinionated things we wanted to do differently. Rather than bother [@ngs](https://github.com/ngs) with tons of PRs, we figured it'd be better to own that core part of our experience fully.

0 commit comments

Comments
 (0)