react-headless-mde 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,14 +12,26 @@ React-mde-headless has no 3rd party dependencies.
12
12
  ## Using
13
13
 
14
14
  ```jsx
15
- import { bold, italic, link, useTextAreaMarkdownEditor } from 'react-mde-headless';
15
+ import { boldCommand, italicCommand, linkCommand, useTextAreaMarkdownEditor } from 'react-mde-headless';
16
16
 
17
17
  export const MarkdownEditor = () => {
18
- const { ref } = useTextAreaMarkdownEditor();
18
+ const { ref, commandController } = useTextAreaMarkdownEditor({
19
+ commandMap: {
20
+ bold: boldCommand,
21
+ italic: italicCommand,
22
+ link: linkCommand,
23
+ },
24
+ });
19
25
 
20
26
  return (
21
27
  <div>
22
- <button onClick={bold}>B</button>
28
+ <button
29
+ onClick={() => {
30
+ commandController.executeCommand('bold');
31
+ }}
32
+ >
33
+ B
34
+ </button>
23
35
 
24
36
  <textarea ref={ref} />
25
37
  </div>
@@ -29,24 +41,23 @@ export const MarkdownEditor = () => {
29
41
 
30
42
  ## Supported commands
31
43
 
32
- - bold
33
- - italic
34
- - strikethrough
35
44
  - headingLevel1
36
45
  - headingLevel2
37
46
  - headingLevel3
38
47
  - headingLevel4
39
48
  - headingLevel5
40
49
  - headingLevel6
41
- - link
42
50
  - quote
43
- - code
44
- - codeBlock
45
51
  - checkedList
46
52
  - orderedList
47
53
  - unorderedList
54
+ - bold
55
+ - code
56
+ - codeBlock
57
+ - italic
58
+ - strikethrough
48
59
  - image
49
- - attachment
60
+ - link
50
61
 
51
62
  ## Todo
52
63
 
@@ -54,6 +65,16 @@ export const MarkdownEditor = () => {
54
65
  - undo/redo
55
66
  - Check execution on SSR (For example, Next.js) and, if necessary, regenerate eslint config, taking into account execution on node.js
56
67
  - peerDependencies React?
68
+ - undo for
69
+ - 1st priority
70
+ - all headings
71
+ - quote
72
+ - strikethrough
73
+ - 2nd priority
74
+ - orderedList
75
+ - unorderedList
76
+ - checkedList
77
+ - codeBlock
57
78
 
58
79
  PR's are welcome!
59
80
 
@@ -69,7 +90,7 @@ this has been taken from [their documentation](<https://github.com/showdownjs/sh
69
90
  > Cross-side scripting is a well known technique to gain access to private information of the users
70
91
  > of a website. The attacker injects spurious HTML content (a script) on the web page which will read
71
92
  > the user’s cookies and do something bad with it (like steal credentials). As a countermeasure,
72
- > you should filter any suspicious content coming from user input. Showdown doesn’t include an
93
+ > you should filter any suspicious content coming from user input. Showdown does not include an
73
94
  > XSS filter, so you must provide your own. But be careful in how you do it…
74
95
 
75
96
  You might want to take a look at [showdown-xss-filter](https://github.com/VisionistInc/showdown-xss-filter).