@uiw/react-md-editor 3.19.0 → 3.19.2

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.
Files changed (139) hide show
  1. package/dist/mdeditor.css +2 -0
  2. package/dist/mdeditor.js +834 -834
  3. package/dist/mdeditor.min.css +1 -1
  4. package/dist/mdeditor.min.js +1 -1
  5. package/esm/Context.js.map +1 -1
  6. package/esm/Editor.js +43 -67
  7. package/esm/Editor.js.map +1 -1
  8. package/esm/commands/bold.js +4 -4
  9. package/esm/commands/bold.js.map +1 -1
  10. package/esm/commands/code.js +4 -6
  11. package/esm/commands/code.js.map +1 -1
  12. package/esm/commands/comment.js +4 -4
  13. package/esm/commands/comment.js.map +1 -1
  14. package/esm/commands/divider.js.map +1 -1
  15. package/esm/commands/fullscreen.js +3 -4
  16. package/esm/commands/fullscreen.js.map +2 -2
  17. package/esm/commands/group.js +2 -4
  18. package/esm/commands/group.js.map +1 -1
  19. package/esm/commands/hr.js.map +1 -1
  20. package/esm/commands/image.js +4 -4
  21. package/esm/commands/image.js.map +1 -1
  22. package/esm/commands/index.d.ts +2 -2
  23. package/esm/commands/index.js +6 -17
  24. package/esm/commands/index.js.map +3 -2
  25. package/esm/commands/italic.js +4 -4
  26. package/esm/commands/italic.js.map +1 -1
  27. package/esm/commands/link.js +4 -4
  28. package/esm/commands/link.js.map +1 -1
  29. package/esm/commands/list.js +4 -4
  30. package/esm/commands/list.js.map +1 -1
  31. package/esm/commands/preview.js +21 -3
  32. package/esm/commands/preview.js.map +7 -2
  33. package/esm/commands/quote.js +2 -1
  34. package/esm/commands/quote.js.map +1 -1
  35. package/esm/commands/strikeThrough.js +4 -4
  36. package/esm/commands/strikeThrough.js.map +1 -1
  37. package/esm/commands/title.js.map +1 -1
  38. package/esm/commands/title1.js.map +1 -1
  39. package/esm/commands/title2.js.map +1 -1
  40. package/esm/commands/title3.js.map +1 -1
  41. package/esm/commands/title4.js.map +1 -1
  42. package/esm/commands/title5.js.map +1 -1
  43. package/esm/commands/title6.js.map +1 -1
  44. package/esm/components/DragBar/index.js +2 -9
  45. package/esm/components/DragBar/index.js.map +1 -1
  46. package/esm/components/TextArea/Markdown.js +2 -7
  47. package/esm/components/TextArea/Markdown.js.map +1 -1
  48. package/esm/components/TextArea/Textarea.js +8 -11
  49. package/esm/components/TextArea/Textarea.js.map +1 -1
  50. package/esm/components/TextArea/handleKeyDown.js +2 -16
  51. package/esm/components/TextArea/handleKeyDown.js.map +1 -1
  52. package/esm/components/TextArea/index.js +11 -15
  53. package/esm/components/TextArea/index.js.map +1 -1
  54. package/esm/components/TextArea/shortcuts.js +1 -17
  55. package/esm/components/TextArea/shortcuts.js.map +2 -2
  56. package/esm/components/Toolbar/Child.js +2 -1
  57. package/esm/components/Toolbar/Child.js.map +1 -1
  58. package/esm/components/Toolbar/index.js +2 -12
  59. package/esm/components/Toolbar/index.js.map +1 -1
  60. package/esm/index.js.map +1 -1
  61. package/esm/utils/InsertTextAtPosition.js +28 -34
  62. package/esm/utils/InsertTextAtPosition.js.map +1 -1
  63. package/esm/utils/markdownUtils.js +14 -23
  64. package/esm/utils/markdownUtils.js.map +1 -1
  65. package/lib/Context.js +0 -6
  66. package/lib/Context.js.map +1 -1
  67. package/lib/Editor.js +74 -114
  68. package/lib/Editor.js.map +1 -1
  69. package/lib/commands/bold.js +4 -9
  70. package/lib/commands/bold.js.map +1 -1
  71. package/lib/commands/code.js +4 -11
  72. package/lib/commands/code.js.map +1 -1
  73. package/lib/commands/comment.js +4 -7
  74. package/lib/commands/comment.js.map +1 -1
  75. package/lib/commands/divider.js.map +1 -1
  76. package/lib/commands/fullscreen.js +3 -8
  77. package/lib/commands/fullscreen.js.map +2 -2
  78. package/lib/commands/group.js +2 -10
  79. package/lib/commands/group.js.map +1 -1
  80. package/lib/commands/hr.js +0 -4
  81. package/lib/commands/hr.js.map +1 -1
  82. package/lib/commands/image.js +4 -9
  83. package/lib/commands/image.js.map +1 -1
  84. package/lib/commands/index.d.ts +2 -2
  85. package/lib/commands/index.js +4 -41
  86. package/lib/commands/index.js.map +3 -2
  87. package/lib/commands/italic.js +4 -9
  88. package/lib/commands/italic.js.map +1 -1
  89. package/lib/commands/link.js +4 -9
  90. package/lib/commands/link.js.map +1 -1
  91. package/lib/commands/list.js +4 -10
  92. package/lib/commands/list.js.map +1 -1
  93. package/lib/commands/preview.js +21 -7
  94. package/lib/commands/preview.js.map +7 -2
  95. package/lib/commands/quote.js +2 -6
  96. package/lib/commands/quote.js.map +1 -1
  97. package/lib/commands/strikeThrough.js +4 -9
  98. package/lib/commands/strikeThrough.js.map +1 -1
  99. package/lib/commands/title.js +0 -6
  100. package/lib/commands/title.js.map +1 -1
  101. package/lib/commands/title1.js +0 -5
  102. package/lib/commands/title1.js.map +1 -1
  103. package/lib/commands/title2.js +0 -5
  104. package/lib/commands/title2.js.map +1 -1
  105. package/lib/commands/title3.js +0 -5
  106. package/lib/commands/title3.js.map +1 -1
  107. package/lib/commands/title4.js +0 -5
  108. package/lib/commands/title4.js.map +1 -1
  109. package/lib/commands/title5.js +0 -5
  110. package/lib/commands/title5.js.map +1 -1
  111. package/lib/commands/title6.js +0 -5
  112. package/lib/commands/title6.js.map +1 -1
  113. package/lib/components/DragBar/index.js +4 -15
  114. package/lib/components/DragBar/index.js.map +1 -1
  115. package/lib/components/TextArea/Markdown.js +6 -22
  116. package/lib/components/TextArea/Markdown.js.map +1 -1
  117. package/lib/components/TextArea/Textarea.js +15 -36
  118. package/lib/components/TextArea/Textarea.js.map +1 -1
  119. package/lib/components/TextArea/handleKeyDown.js +1 -18
  120. package/lib/components/TextArea/handleKeyDown.js.map +1 -1
  121. package/lib/components/TextArea/index.js +15 -37
  122. package/lib/components/TextArea/index.js.map +1 -1
  123. package/lib/components/TextArea/shortcuts.js +1 -17
  124. package/lib/components/TextArea/shortcuts.js.map +2 -2
  125. package/lib/components/Toolbar/Child.js +8 -18
  126. package/lib/components/Toolbar/Child.js.map +1 -1
  127. package/lib/components/Toolbar/index.js +14 -36
  128. package/lib/components/Toolbar/index.js.map +1 -1
  129. package/lib/index.js +0 -9
  130. package/lib/index.js.map +1 -1
  131. package/lib/utils/InsertTextAtPosition.js +28 -37
  132. package/lib/utils/InsertTextAtPosition.js.map +1 -1
  133. package/lib/utils/markdownUtils.js +17 -28
  134. package/lib/utils/markdownUtils.js.map +1 -1
  135. package/package.json +2 -2
  136. package/src/commands/fullscreen.tsx +3 -2
  137. package/src/commands/index.ts +3 -1
  138. package/src/commands/preview.tsx +35 -4
  139. package/src/components/TextArea/shortcuts.ts +2 -2
@@ -7,118 +7,107 @@ exports.getBreaksNeededForEmptyLineAfter = getBreaksNeededForEmptyLineAfter;
7
7
  exports.getBreaksNeededForEmptyLineBefore = getBreaksNeededForEmptyLineBefore;
8
8
  exports.getSurroundingWord = getSurroundingWord;
9
9
  exports.selectWord = selectWord;
10
-
11
10
  function selectWord(_ref) {
12
11
  var text = _ref.text,
13
- selection = _ref.selection;
14
-
12
+ selection = _ref.selection;
15
13
  if (text && text.length && selection.start === selection.end) {
16
14
  // the user is pointing to a word
17
15
  return getSurroundingWord(text, selection.start);
18
16
  }
19
-
20
17
  return selection;
21
18
  }
19
+
22
20
  /**
23
21
  * Gets the number of line-breaks that would have to be inserted before the given 'startPosition'
24
22
  * to make sure there's an empty line between 'startPosition' and the previous text
25
23
  */
26
-
27
-
28
24
  function getBreaksNeededForEmptyLineBefore() {
29
25
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
30
26
  var startPosition = arguments.length > 1 ? arguments[1] : undefined;
31
- if (startPosition === 0) return 0; // rules:
27
+ if (startPosition === 0) return 0;
28
+
29
+ // rules:
32
30
  // - If we're in the first line, no breaks are needed
33
31
  // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
34
32
  // may need to insert 0, 1 or 2 breaks
35
33
 
36
34
  var neededBreaks = 2;
37
35
  var isInFirstLine = true;
38
-
39
36
  for (var i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {
40
37
  switch (text.charCodeAt(i)) {
41
38
  case 32:
42
39
  // blank space
43
40
  continue;
44
-
45
41
  case 10:
46
42
  // line break
47
43
  neededBreaks--;
48
44
  isInFirstLine = false;
49
45
  break;
50
-
51
46
  default:
52
47
  return neededBreaks;
53
48
  }
54
49
  }
55
-
56
50
  return isInFirstLine ? 0 : neededBreaks;
57
51
  }
52
+
58
53
  /**
59
54
  * Gets the number of line-breaks that would have to be inserted after the given 'startPosition'
60
55
  * to make sure there's an empty line between 'startPosition' and the next text
61
56
  */
62
-
63
-
64
57
  function getBreaksNeededForEmptyLineAfter() {
65
58
  var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
66
59
  var startPosition = arguments.length > 1 ? arguments[1] : undefined;
67
- if (startPosition === text.length - 1) return 0; // rules:
60
+ if (startPosition === text.length - 1) return 0;
61
+
62
+ // rules:
68
63
  // - If we're in the first line, no breaks are needed
69
64
  // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
70
65
  // may need to insert 0, 1 or 2 breaks
71
66
 
72
67
  var neededBreaks = 2;
73
68
  var isInLastLine = true;
74
-
75
69
  for (var i = startPosition; i < text.length && neededBreaks >= 0; i++) {
76
70
  switch (text.charCodeAt(i)) {
77
71
  case 32:
78
72
  continue;
79
-
80
73
  case 10:
81
74
  {
82
75
  neededBreaks--;
83
76
  isInLastLine = false;
84
77
  break;
85
78
  }
86
-
87
79
  default:
88
80
  return neededBreaks;
89
81
  }
90
82
  }
91
-
92
83
  return isInLastLine ? 0 : neededBreaks;
93
84
  }
94
-
95
85
  function getSurroundingWord(text, position) {
96
86
  if (!text) throw Error("Argument 'text' should be truthy");
97
-
98
87
  var isWordDelimiter = function isWordDelimiter(c) {
99
88
  return c === ' ' || c.charCodeAt(0) === 10;
100
- }; // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration
101
-
102
-
103
- var start = 0; // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation
89
+ };
104
90
 
105
- var end = text.length; // iterate to the left
91
+ // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration
92
+ var start = 0;
93
+ // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation
94
+ var end = text.length;
106
95
 
96
+ // iterate to the left
107
97
  for (var i = position; i - 1 > -1; i--) {
108
98
  if (isWordDelimiter(text[i - 1])) {
109
99
  start = i;
110
100
  break;
111
101
  }
112
- } // iterate to the right
113
-
102
+ }
114
103
 
104
+ // iterate to the right
115
105
  for (var _i = position; _i < text.length; _i++) {
116
106
  if (isWordDelimiter(text[_i])) {
117
107
  end = _i;
118
108
  break;
119
109
  }
120
110
  }
121
-
122
111
  return {
123
112
  start: start,
124
113
  end: end
@@ -27,5 +27,5 @@
27
27
  "sourcesContent": [
28
28
  "import { TextRange } from '../commands';\n\nexport interface TextSection {\n text: string;\n selection: TextRange;\n}\n\nexport function selectWord({ text, selection }: TextSection): TextRange {\n if (text && text.length && selection.start === selection.end) {\n // the user is pointing to a word\n return getSurroundingWord(text, selection.start);\n }\n return selection;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted before the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the previous text\n */\nexport function getBreaksNeededForEmptyLineBefore(text = '', startPosition: number): number {\n if (startPosition === 0) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInFirstLine = true;\n for (let i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {\n switch (text.charCodeAt(i)) {\n case 32: // blank space\n continue;\n case 10: // line break\n neededBreaks--;\n isInFirstLine = false;\n break;\n default:\n return neededBreaks;\n }\n }\n return isInFirstLine ? 0 : neededBreaks;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted after the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the next text\n */\nexport function getBreaksNeededForEmptyLineAfter(text = '', startPosition: number): number {\n if (startPosition === text.length - 1) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInLastLine = true;\n for (let i = startPosition; i < text.length && neededBreaks >= 0; i++) {\n switch (text.charCodeAt(i)) {\n case 32:\n continue;\n case 10: {\n neededBreaks--;\n isInLastLine = false;\n break;\n }\n default:\n return neededBreaks;\n }\n }\n return isInLastLine ? 0 : neededBreaks;\n}\n\nexport function getSurroundingWord(text: string, position: number): TextRange {\n if (!text) throw Error(\"Argument 'text' should be truthy\");\n\n const isWordDelimiter = (c: string) => c === ' ' || c.charCodeAt(0) === 10;\n\n // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration\n let start = 0;\n // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation\n let end = text.length;\n\n // iterate to the left\n for (let i = position; i - 1 > -1; i--) {\n if (isWordDelimiter(text[i - 1])) {\n start = i;\n break;\n }\n }\n\n // iterate to the right\n for (let i = position; i < text.length; i++) {\n if (isWordDelimiter(text[i])) {\n end = i;\n break;\n }\n }\n\n return { start, end };\n}\n"
29
29
  ],
30
- "mappings": ";;;;;;;;;;AAOO,SAASA,UAAT,OAAiE;EAAA,IAA3CC,IAA2C,QAA3CA,IAA2C;EAAA,IAArCC,SAAqC,QAArCA,SAAqC;;EACtE,IAAID,IAAI,IAAIA,IAAI,CAACE,MAAb,IAAuBD,SAAS,CAACE,KAAV,KAAoBF,SAAS,CAACG,GAAzD,EAA8D;IAC5D;IACA,OAAOC,kBAAkB,CAACL,IAAD,EAAOC,SAAS,CAACE,KAAjB,CAAzB;EACD;;EACD,OAAOF,SAAP;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASK,iCAAT,GAAqF;EAAA,IAA1CN,IAA0C,uEAAnC,EAAmC;EAAA,IAA/BO,aAA+B;EAC1F,IAAIA,aAAa,KAAK,CAAtB,EAAy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CAAkC,CAAC;EAE1D,IAAMC,eAAe,GAAG,SAAlBA,eAAe,CAAIC,CAAS;IAAA,OAAKA,CAAC,KAAK,GAAG,IAAIA,CAAC,CAACN,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE;EAAA;;EAE1E;EACA,IAAIR,KAAK,GAAG,CAAC;EACb;EACA,IAAIC,GAAG,GAAGJ,IAAI,CAACE,MAAM;;EAErB;EACA,KAAK,IAAIQ,CAAC,GAAGI,QAAQ,EAAEJ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAEA,CAAC,EAAE,EAAE;IACtC,IAAIM,eAAe,CAAChB,IAAI,CAACU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;MAChCP,KAAK,GAAGO,CAAC;MACT;IACF;EACF;;EAEA;EACA,KAAK,IAAIA,EAAC,GAAGI,QAAQ,EAAEJ,EAAC,GAAGV,IAAI,CAACE,MAAM,EAAEQ,EAAC,EAAE,EAAE;IAC3C,IAAIM,eAAe,CAAChB,IAAI,CAACU,EAAC,CAAC,CAAC,EAAE;MAC5BN,GAAG,GAAGM,EAAC;MACP;IACF;EACF;EAEA,OAAO;IAAEP,KAAK,EAALA,KAAK;IAAEC,GAAG,EAAHA;EAAI,CAAC;AACvB"
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.19.0",
3
+ "version": "3.19.2",
4
4
  "description": "A markdown editor with preview, implemented with React.js and TypeScript.",
5
5
  "homepage": "https://uiwjs.github.io/react-md-editor/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.14.6",
39
- "@uiw/react-markdown-preview": "^4.0.24",
39
+ "@uiw/react-markdown-preview": "^4.1.4",
40
40
  "rehype": "~12.0.1"
41
41
  },
42
42
  "keywords": [
@@ -21,10 +21,11 @@ export const fullscreen: ICommand = {
21
21
  api: TextAreaTextApi,
22
22
  dispatch?: React.Dispatch<ContextStore>,
23
23
  executeCommandState?: ExecuteCommandState,
24
+ shortcuts?: string[],
24
25
  ) => {
25
26
  api.textArea.focus();
26
- if (dispatch && executeCommandState && executeCommandState.fullscreen) {
27
- dispatch({ fullscreen: false });
27
+ if (shortcuts && dispatch && executeCommandState) {
28
+ dispatch({ fullscreen: !executeCommandState.fullscreen });
28
29
  }
29
30
  },
30
31
  };
@@ -62,6 +62,7 @@ export interface ICommandBase<T> {
62
62
  api: TextAreaTextApi,
63
63
  dispatch?: React.Dispatch<ContextStore>,
64
64
  executeCommandState?: ExecuteCommandState,
65
+ shortcuts?: string[],
65
66
  ) => void;
66
67
  }
67
68
 
@@ -161,8 +162,9 @@ class TextAreaCommandOrchestrator implements CommandOrchestrator {
161
162
  command: ICommand<string>,
162
163
  dispatch?: React.Dispatch<ContextStore>,
163
164
  state?: ExecuteCommandState,
165
+ shortcuts?: string[],
164
166
  ): void {
165
- command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state);
167
+ command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state, shortcuts);
166
168
  }
167
169
  }
168
170
 
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { ICommand } from './';
2
+ import { ICommand, TextState, TextAreaTextApi } from './';
3
+ import { ContextStore, ExecuteCommandState } from '../Context';
3
4
 
4
5
  export const codePreview: ICommand = {
5
6
  name: 'preview',
@@ -19,7 +20,17 @@ export const codePreview: ICommand = {
19
20
  />
20
21
  </svg>
21
22
  ),
22
- execute: () => {},
23
+ execute: (
24
+ state: TextState,
25
+ api: TextAreaTextApi,
26
+ dispatch?: React.Dispatch<ContextStore>,
27
+ executeCommandState?: ExecuteCommandState,
28
+ shortcuts?: string[],
29
+ ) => {
30
+ if (shortcuts && dispatch && executeCommandState) {
31
+ dispatch({ preview: 'preview' });
32
+ }
33
+ },
23
34
  };
24
35
 
25
36
  export const codeEdit: ICommand = {
@@ -37,7 +48,17 @@ export const codeEdit: ICommand = {
37
48
  />
38
49
  </svg>
39
50
  ),
40
- execute: () => {},
51
+ execute: (
52
+ state: TextState,
53
+ api: TextAreaTextApi,
54
+ dispatch?: React.Dispatch<ContextStore>,
55
+ executeCommandState?: ExecuteCommandState,
56
+ shortcuts?: string[],
57
+ ) => {
58
+ if (shortcuts && dispatch && executeCommandState) {
59
+ dispatch({ preview: 'edit' });
60
+ }
61
+ },
41
62
  };
42
63
 
43
64
  export const codeLive: ICommand = {
@@ -55,5 +76,15 @@ export const codeLive: ICommand = {
55
76
  />
56
77
  </svg>
57
78
  ),
58
- execute: () => {},
79
+ execute: (
80
+ state: TextState,
81
+ api: TextAreaTextApi,
82
+ dispatch?: React.Dispatch<ContextStore>,
83
+ executeCommandState?: ExecuteCommandState,
84
+ shortcuts?: string[],
85
+ ) => {
86
+ if (shortcuts && dispatch && executeCommandState) {
87
+ dispatch({ preview: 'live' });
88
+ }
89
+ },
59
90
  };
@@ -20,7 +20,7 @@ export default function shortcutsHandle(
20
20
  state?: ExecuteCommandState,
21
21
  ) {
22
22
  const data = getCommands(commands || []);
23
- const shortcuts: (string | number)[] = [];
23
+ const shortcuts: string[] = [];
24
24
  if (e.altKey) {
25
25
  shortcuts.push('alt');
26
26
  }
@@ -60,7 +60,7 @@ export default function shortcutsHandle(
60
60
  if (command && commandOrchestrator) {
61
61
  e.stopPropagation();
62
62
  e.preventDefault();
63
- commandOrchestrator.executeCommand(command, dispatch, state);
63
+ commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);
64
64
  return;
65
65
  }
66
66
  }