@uiw/react-md-editor 3.20.5 → 3.20.7

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 (188) hide show
  1. package/README.md +8 -2
  2. package/dist/mdeditor.css +13 -0
  3. package/dist/mdeditor.js +9517 -1252
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/esm/Context.d.ts +3 -3
  7. package/esm/Context.js +1 -2
  8. package/esm/Editor.d.ts +1 -1
  9. package/esm/Editor.js +9 -2
  10. package/esm/commands/bold.js +1 -2
  11. package/esm/commands/code.js +2 -3
  12. package/esm/commands/comment.js +2 -2
  13. package/esm/commands/divider.js +1 -2
  14. package/esm/commands/fullscreen.js +2 -3
  15. package/esm/commands/group.d.ts +1 -1
  16. package/esm/commands/group.js +1 -2
  17. package/esm/commands/hr.js +2 -3
  18. package/esm/commands/image.js +2 -3
  19. package/esm/commands/index.d.ts +2 -2
  20. package/esm/commands/index.js +1 -2
  21. package/esm/commands/italic.js +2 -3
  22. package/esm/commands/link.js +2 -3
  23. package/esm/commands/list.d.ts +1 -1
  24. package/esm/commands/list.js +2 -3
  25. package/esm/commands/preview.js +2 -3
  26. package/esm/commands/quote.js +2 -3
  27. package/esm/commands/strikeThrough.js +2 -3
  28. package/esm/commands/title.js +1 -2
  29. package/esm/commands/title1.js +1 -2
  30. package/esm/commands/title2.js +2 -3
  31. package/esm/commands/title3.js +2 -3
  32. package/esm/commands/title4.js +2 -3
  33. package/esm/commands/title5.js +2 -3
  34. package/esm/commands/title6.js +2 -3
  35. package/esm/components/DragBar/index.js +8 -3
  36. package/esm/components/TextArea/Markdown.js +1 -2
  37. package/esm/components/TextArea/Textarea.js +1 -2
  38. package/esm/components/TextArea/handleKeyDown.d.ts +1 -0
  39. package/esm/components/TextArea/handleKeyDown.js +1 -2
  40. package/esm/components/TextArea/index.d.ts +2 -2
  41. package/esm/components/TextArea/index.js +1 -2
  42. package/esm/components/TextArea/shortcuts.d.ts +1 -0
  43. package/esm/components/TextArea/shortcuts.js +1 -2
  44. package/esm/components/Toolbar/Child.d.ts +2 -1
  45. package/esm/components/Toolbar/Child.js +1 -2
  46. package/esm/components/Toolbar/index.d.ts +1 -0
  47. package/esm/components/Toolbar/index.js +1 -2
  48. package/esm/index.js +1 -2
  49. package/esm/react-app-env.d.ts +1 -0
  50. package/esm/utils/InsertTextAtPosition.js +1 -2
  51. package/esm/utils/markdownUtils.js +1 -2
  52. package/lib/Context.d.ts +3 -3
  53. package/lib/Context.js +1 -2
  54. package/lib/Editor.d.ts +1 -1
  55. package/lib/Editor.js +13 -2
  56. package/lib/commands/bold.js +1 -2
  57. package/lib/commands/code.js +3 -4
  58. package/lib/commands/comment.js +3 -2
  59. package/lib/commands/divider.js +1 -2
  60. package/lib/commands/fullscreen.js +3 -4
  61. package/lib/commands/group.d.ts +1 -1
  62. package/lib/commands/group.js +1 -2
  63. package/lib/commands/hr.js +3 -4
  64. package/lib/commands/image.js +3 -4
  65. package/lib/commands/index.d.ts +2 -2
  66. package/lib/commands/index.js +1 -2
  67. package/lib/commands/italic.js +3 -4
  68. package/lib/commands/link.js +3 -4
  69. package/lib/commands/list.d.ts +1 -1
  70. package/lib/commands/list.js +3 -4
  71. package/lib/commands/preview.js +3 -4
  72. package/lib/commands/quote.js +3 -4
  73. package/lib/commands/strikeThrough.js +3 -4
  74. package/lib/commands/title.js +1 -2
  75. package/lib/commands/title1.js +1 -2
  76. package/lib/commands/title2.js +3 -4
  77. package/lib/commands/title3.js +3 -4
  78. package/lib/commands/title4.js +3 -4
  79. package/lib/commands/title5.js +3 -4
  80. package/lib/commands/title6.js +3 -4
  81. package/lib/components/DragBar/index.js +8 -3
  82. package/lib/components/TextArea/Markdown.js +1 -2
  83. package/lib/components/TextArea/Textarea.js +1 -2
  84. package/lib/components/TextArea/handleKeyDown.d.ts +1 -0
  85. package/lib/components/TextArea/handleKeyDown.js +1 -2
  86. package/lib/components/TextArea/index.d.ts +2 -2
  87. package/lib/components/TextArea/index.js +1 -2
  88. package/lib/components/TextArea/shortcuts.d.ts +1 -0
  89. package/lib/components/TextArea/shortcuts.js +1 -2
  90. package/lib/components/Toolbar/Child.d.ts +2 -1
  91. package/lib/components/Toolbar/Child.js +1 -2
  92. package/lib/components/Toolbar/index.d.ts +1 -0
  93. package/lib/components/Toolbar/index.js +1 -2
  94. package/lib/index.js +1 -2
  95. package/lib/react-app-env.d.ts +1 -0
  96. package/lib/utils/InsertTextAtPosition.js +1 -2
  97. package/lib/utils/markdownUtils.js +1 -2
  98. package/package.json +1 -1
  99. package/src/Editor.tsx +4 -0
  100. package/src/__test__/commands.test.tsx +4 -4
  101. package/src/commands/code.tsx +1 -1
  102. package/src/commands/comment.tsx +1 -0
  103. package/src/commands/divider.tsx +1 -0
  104. package/src/commands/fullscreen.tsx +1 -1
  105. package/src/commands/hr.tsx +1 -1
  106. package/src/commands/image.tsx +1 -1
  107. package/src/commands/italic.tsx +1 -1
  108. package/src/commands/link.tsx +1 -1
  109. package/src/commands/list.tsx +1 -1
  110. package/src/commands/preview.tsx +1 -1
  111. package/src/commands/quote.tsx +1 -1
  112. package/src/commands/strikeThrough.tsx +1 -1
  113. package/src/commands/title2.tsx +1 -1
  114. package/src/commands/title3.tsx +1 -1
  115. package/src/commands/title4.tsx +1 -1
  116. package/src/commands/title5.tsx +1 -1
  117. package/src/commands/title6.tsx +1 -1
  118. package/src/components/DragBar/index.tsx +9 -1
  119. package/esm/Context.js.map +0 -19
  120. package/esm/Editor.js.map +0 -116
  121. package/esm/commands/bold.js.map +0 -38
  122. package/esm/commands/code.js.map +0 -47
  123. package/esm/commands/comment.js.map +0 -35
  124. package/esm/commands/divider.js.map +0 -14
  125. package/esm/commands/fullscreen.js.map +0 -28
  126. package/esm/commands/group.js.map +0 -26
  127. package/esm/commands/hr.js.map +0 -27
  128. package/esm/commands/image.js.map +0 -40
  129. package/esm/commands/index.js.map +0 -69
  130. package/esm/commands/italic.js.map +0 -38
  131. package/esm/commands/link.js.map +0 -38
  132. package/esm/commands/list.js.map +0 -61
  133. package/esm/commands/preview.js.map +0 -31
  134. package/esm/commands/quote.js.map +0 -44
  135. package/esm/commands/strikeThrough.js.map +0 -38
  136. package/esm/commands/title.js.map +0 -16
  137. package/esm/commands/title1.js.map +0 -33
  138. package/esm/commands/title2.js.map +0 -33
  139. package/esm/commands/title3.js.map +0 -33
  140. package/esm/commands/title4.js.map +0 -33
  141. package/esm/commands/title5.js.map +0 -33
  142. package/esm/commands/title6.js.map +0 -33
  143. package/esm/components/DragBar/index.js.map +0 -41
  144. package/esm/components/TextArea/Markdown.js.map +0 -47
  145. package/esm/components/TextArea/Textarea.js.map +0 -47
  146. package/esm/components/TextArea/handleKeyDown.js.map +0 -66
  147. package/esm/components/TextArea/index.js.map +0 -57
  148. package/esm/components/TextArea/shortcuts.js.map +0 -52
  149. package/esm/components/Toolbar/Child.js.map +0 -28
  150. package/esm/components/Toolbar/index.js.map +0 -84
  151. package/esm/index.js.map +0 -15
  152. package/esm/utils/InsertTextAtPosition.js.map +0 -67
  153. package/esm/utils/markdownUtils.js.map +0 -31
  154. package/lib/Context.js.map +0 -19
  155. package/lib/Editor.js.map +0 -112
  156. package/lib/commands/bold.js.map +0 -37
  157. package/lib/commands/code.js.map +0 -46
  158. package/lib/commands/comment.js.map +0 -35
  159. package/lib/commands/divider.js.map +0 -14
  160. package/lib/commands/fullscreen.js.map +0 -27
  161. package/lib/commands/group.js.map +0 -25
  162. package/lib/commands/hr.js.map +0 -26
  163. package/lib/commands/image.js.map +0 -39
  164. package/lib/commands/index.js.map +0 -64
  165. package/lib/commands/italic.js.map +0 -37
  166. package/lib/commands/link.js.map +0 -37
  167. package/lib/commands/list.js.map +0 -60
  168. package/lib/commands/preview.js.map +0 -30
  169. package/lib/commands/quote.js.map +0 -43
  170. package/lib/commands/strikeThrough.js.map +0 -37
  171. package/lib/commands/title.js.map +0 -15
  172. package/lib/commands/title1.js.map +0 -32
  173. package/lib/commands/title2.js.map +0 -32
  174. package/lib/commands/title3.js.map +0 -32
  175. package/lib/commands/title4.js.map +0 -32
  176. package/lib/commands/title5.js.map +0 -32
  177. package/lib/commands/title6.js.map +0 -32
  178. package/lib/components/DragBar/index.js.map +0 -40
  179. package/lib/components/TextArea/Markdown.js.map +0 -47
  180. package/lib/components/TextArea/Textarea.js.map +0 -47
  181. package/lib/components/TextArea/handleKeyDown.js.map +0 -66
  182. package/lib/components/TextArea/index.js.map +0 -54
  183. package/lib/components/TextArea/shortcuts.js.map +0 -52
  184. package/lib/components/Toolbar/Child.js.map +0 -26
  185. package/lib/components/Toolbar/index.js.map +0 -82
  186. package/lib/index.js.map +0 -13
  187. package/lib/utils/InsertTextAtPosition.js.map +0 -67
  188. package/lib/utils/markdownUtils.js.map +0 -31
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.comment = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
7
9
  var _markdownUtils = require("../utils/markdownUtils");
8
10
  var _jsxRuntime = require("react/jsx-runtime");
9
11
  var comment = {
@@ -55,5 +57,4 @@ var comment = {
55
57
  })
56
58
  })
57
59
  };
58
- exports.comment = comment;
59
- //# sourceMappingURL=comment.js.map
60
+ exports.comment = comment;
@@ -7,5 +7,4 @@ exports.divider = void 0;
7
7
  var divider = {
8
8
  keyCommand: 'divider'
9
9
  };
10
- exports.divider = divider;
11
- //# sourceMappingURL=divider.js.map
10
+ exports.divider = divider;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.fullscreen = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  var fullscreen = {
11
11
  name: 'fullscreen',
@@ -34,5 +34,4 @@ var fullscreen = {
34
34
  }
35
35
  }
36
36
  };
37
- exports.fullscreen = fullscreen;
38
- //# sourceMappingURL=fullscreen.js.map
37
+ exports.fullscreen = fullscreen;
@@ -1,5 +1,5 @@
1
1
  import { ICommand, ICommandChildCommands, ICommandChildHandle } from './';
2
- export declare type GroupOptions = Omit<ICommand<string>, 'children'> & {
2
+ export type GroupOptions = Omit<ICommand<string>, 'children'> & {
3
3
  children?: ICommandChildHandle['children'];
4
4
  };
5
5
  export declare const group: (arr: ICommandChildCommands['children'], options?: GroupOptions) => ICommand<string>;
@@ -35,5 +35,4 @@ var group = function group(arr, options) {
35
35
  }
36
36
  return data;
37
37
  };
38
- exports.group = group;
39
- //# sourceMappingURL=group.js.map
38
+ exports.group = group;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.hr = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  var hr = {
11
11
  name: 'hr',
@@ -30,5 +30,4 @@ var hr = {
30
30
  api.replaceSelection("".concat(state.selectedText, "\n\n").concat(state.command.value || '', "-\n\n"));
31
31
  }
32
32
  };
33
- exports.hr = hr;
34
- //# sourceMappingURL=hr.js.map
33
+ exports.hr = hr;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.image = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _markdownUtils = require("../utils/markdownUtils");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var image = {
@@ -48,5 +48,4 @@ var image = {
48
48
  });
49
49
  }
50
50
  };
51
- exports.image = image;
52
- //# sourceMappingURL=image.js.map
51
+ exports.image = image;
@@ -49,10 +49,10 @@ export interface ICommandBase<T> {
49
49
  render?: (command: ICommand<T>, disabled: boolean, executeCommand: (command: ICommand<T>, name?: string) => void, index: number) => void | undefined | null | React.ReactElement;
50
50
  execute?: (state: ExecuteState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState, shortcuts?: string[]) => void;
51
51
  }
52
- export declare type ExecuteState = TextState & {
52
+ export type ExecuteState = TextState & {
53
53
  command: ICommand;
54
54
  };
55
- export declare type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
55
+ export type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
56
56
  export interface TextRange {
57
57
  start: number;
58
58
  end: number;
@@ -274,5 +274,4 @@ var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
274
274
  }]);
275
275
  return TextAreaCommandOrchestrator;
276
276
  }();
277
- exports.TextAreaCommandOrchestrator = TextAreaCommandOrchestrator;
278
- //# sourceMappingURL=index.js.map
277
+ exports.TextAreaCommandOrchestrator = TextAreaCommandOrchestrator;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.italic = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _markdownUtils = require("../utils/markdownUtils");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var italic = {
@@ -47,5 +47,4 @@ var italic = {
47
47
  });
48
48
  }
49
49
  };
50
- exports.italic = italic;
51
- //# sourceMappingURL=italic.js.map
50
+ exports.italic = italic;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.link = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _markdownUtils = require("../utils/markdownUtils");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var link = {
@@ -47,5 +47,4 @@ var link = {
47
47
  });
48
48
  }
49
49
  };
50
- exports.link = link;
51
- //# sourceMappingURL=link.js.map
50
+ exports.link = link;
@@ -1,5 +1,5 @@
1
1
  import { ICommand, TextState, TextAreaTextApi } from './';
2
- export declare type AlterLineFunction = (line: string, index: number) => string;
2
+ export type AlterLineFunction = (line: string, index: number) => string;
3
3
  /**
4
4
  * Inserts insertionString before each line
5
5
  */
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.checkedListCommand = void 0;
8
8
  exports.insertBeforeEachLine = insertBeforeEachLine;
9
9
  exports.unorderedListCommand = exports.orderedListCommand = exports.makeList = void 0;
10
- var React = _interopRequireWildcard(require("react"));
10
+ var _react = _interopRequireDefault(require("react"));
11
11
  var _markdownUtils = require("../utils/markdownUtils");
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
  /**
@@ -135,5 +135,4 @@ var checkedListCommand = {
135
135
  });
136
136
  }
137
137
  };
138
- exports.checkedListCommand = checkedListCommand;
139
- //# sourceMappingURL=list.js.map
138
+ exports.checkedListCommand = checkedListCommand;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.codePreview = exports.codeLive = exports.codeEdit = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  var codePreview = {
11
11
  name: 'preview',
@@ -99,5 +99,4 @@ var codeLive = {
99
99
  }
100
100
  }
101
101
  };
102
- exports.codeLive = codeLive;
103
- //# sourceMappingURL=preview.js.map
102
+ exports.codeLive = codeLive;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.quote = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _markdownUtils = require("../utils/markdownUtils");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var quote = {
@@ -47,5 +47,4 @@ var quote = {
47
47
  });
48
48
  }
49
49
  };
50
- exports.quote = quote;
51
- //# sourceMappingURL=quote.js.map
50
+ exports.quote = quote;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.strikethrough = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _markdownUtils = require("../utils/markdownUtils");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var strikethrough = {
@@ -47,5 +47,4 @@ var strikethrough = {
47
47
  });
48
48
  }
49
49
  };
50
- exports.strikethrough = strikethrough;
51
- //# sourceMappingURL=strikeThrough.js.map
50
+ exports.strikethrough = strikethrough;
@@ -20,5 +20,4 @@ var title = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _t
20
20
  })
21
21
  })
22
22
  });
23
- exports.title = title;
24
- //# sourceMappingURL=title.js.map
23
+ exports.title = title;
@@ -32,5 +32,4 @@ var title1 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title1 = title1;
36
- //# sourceMappingURL=title1.js.map
35
+ exports.title1 = title1;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.title2 = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var title2 = {
@@ -32,5 +32,4 @@ var title2 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title2 = title2;
36
- //# sourceMappingURL=title2.js.map
35
+ exports.title2 = title2;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.title3 = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var title3 = {
@@ -32,5 +32,4 @@ var title3 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title3 = title3;
36
- //# sourceMappingURL=title3.js.map
35
+ exports.title3 = title3;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.title4 = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var title4 = {
@@ -32,5 +32,4 @@ var title4 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title4 = title4;
36
- //# sourceMappingURL=title4.js.map
35
+ exports.title4 = title4;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.title5 = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var title5 = {
@@ -32,5 +32,4 @@ var title5 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title5 = title5;
36
- //# sourceMappingURL=title5.js.map
35
+ exports.title5 = title5;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.title6 = void 0;
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var title6 = {
@@ -32,5 +32,4 @@ var title6 = {
32
32
  }
33
33
  }
34
34
  };
35
- exports.title6 = title6;
36
- //# sourceMappingURL=title6.js.map
35
+ exports.title6 = title6;
@@ -13,6 +13,12 @@ var DragBar = function DragBar(props) {
13
13
  onChange = _ref.onChange;
14
14
  var $dom = (0, _react.useRef)(null);
15
15
  var dragRef = (0, _react.useRef)();
16
+ var heightRef = (0, _react.useRef)(props.height);
17
+ (0, _react.useEffect)(function () {
18
+ if (heightRef.current !== props.height) {
19
+ heightRef.current = props.height;
20
+ }
21
+ }, [props.height]);
16
22
  function handleMouseMove(event) {
17
23
  if (dragRef.current) {
18
24
  var _changedTouches$;
@@ -36,7 +42,7 @@ var DragBar = function DragBar(props) {
36
42
  event.preventDefault();
37
43
  var clientY = event.clientY || ((_changedTouches$2 = event.changedTouches[0]) === null || _changedTouches$2 === void 0 ? void 0 : _changedTouches$2.clientY);
38
44
  dragRef.current = {
39
- height: props.height,
45
+ height: heightRef.current,
40
46
  dragY: clientY
41
47
  };
42
48
  document.addEventListener('mousemove', handleMouseMove);
@@ -83,5 +89,4 @@ var DragBar = function DragBar(props) {
83
89
  };
84
90
  var _default = DragBar;
85
91
  exports["default"] = _default;
86
- module.exports = exports.default;
87
- //# sourceMappingURL=index.js.map
92
+ module.exports = exports.default;
@@ -71,5 +71,4 @@ function Markdown(props) {
71
71
  }
72
72
  });
73
73
  }
74
- module.exports = exports.default;
75
- //# sourceMappingURL=Markdown.js.map
74
+ module.exports = exports.default;
@@ -87,5 +87,4 @@ function Textarea(props) {
87
87
  }
88
88
  }));
89
89
  }
90
- module.exports = exports.default;
91
- //# sourceMappingURL=Textarea.js.map
90
+ module.exports = exports.default;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export default function handleKeyDown(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, tabSize?: number, defaultTabEnable?: boolean): void;
@@ -83,5 +83,4 @@ function handleKeyDown(e) {
83
83
  return (0, _InsertTextAtPosition.insertTextAtPosition)(target, startStr);
84
84
  }
85
85
  }
86
- module.exports = exports.default;
87
- //# sourceMappingURL=handleKeyDown.js.map
86
+ module.exports = exports.default;
@@ -4,7 +4,7 @@ import { TextAreaProps } from './Textarea';
4
4
  import { IProps } from '../../Editor';
5
5
  import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
6
6
  import './index.less';
7
- declare type RenderTextareaHandle = {
7
+ type RenderTextareaHandle = {
8
8
  dispatch: ContextStore['dispatch'];
9
9
  onChange?: TextAreaProps['onChange'];
10
10
  useContext?: {
@@ -19,7 +19,7 @@ export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTe
19
19
  onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
20
20
  renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
21
21
  }
22
- export declare type TextAreaRef = {
22
+ export type TextAreaRef = {
23
23
  text?: HTMLTextAreaElement;
24
24
  warp?: HTMLDivElement;
25
25
  };
@@ -99,5 +99,4 @@ function TextArea(props) {
99
99
  })
100
100
  });
101
101
  }
102
- module.exports = exports.default;
103
- //# sourceMappingURL=index.js.map
102
+ module.exports = exports.default;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ICommand, TextAreaCommandOrchestrator } from '../../commands';
2
3
  import { ContextStore, ExecuteCommandState } from '../../Context';
3
4
  export default function shortcutsHandle(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands?: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
@@ -66,5 +66,4 @@ function shortcutsHandle(e) {
66
66
  return;
67
67
  }
68
68
  }
69
- module.exports = exports.default;
70
- //# sourceMappingURL=shortcuts.js.map
69
+ module.exports = exports.default;
@@ -1,6 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import './Child.less';
2
3
  import { IToolbarProps } from './';
3
- export declare type ChildProps = IToolbarProps & {
4
+ export type ChildProps = IToolbarProps & {
4
5
  children?: JSX.Element;
5
6
  groupName?: string;
6
7
  };
@@ -36,5 +36,4 @@ function Child(props) {
36
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
37
37
  [commands, barPopup, groupName, prefixCls]);
38
38
  }
39
- module.exports = exports.default;
40
- //# sourceMappingURL=Child.js.map
39
+ module.exports = exports.default;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { IProps } from '../../Editor';
2
3
  import { ICommand } from '../../commands';
3
4
  import './index.less';
@@ -134,5 +134,4 @@ function Toolbar() {
134
134
  commands: extraCommands || []
135
135
  }))]
136
136
  });
137
- }
138
- //# sourceMappingURL=index.js.map
137
+ }
package/lib/index.js CHANGED
@@ -60,5 +60,4 @@ Object.keys(_Context).forEach(function (key) {
60
60
  });
61
61
  });
62
62
  var _default = _Editor["default"];
63
- exports["default"] = _default;
64
- //# sourceMappingURL=index.js.map
63
+ exports["default"] = _default;
@@ -0,0 +1 @@
1
+ /// <reference types="react-scripts" />
@@ -142,5 +142,4 @@ function insertTextAtPosition(input, text) {
142
142
  e.initEvent('input', true, false);
143
143
  input.dispatchEvent(e);
144
144
  }
145
- }
146
- //# sourceMappingURL=InsertTextAtPosition.js.map
145
+ }
@@ -112,5 +112,4 @@ function getSurroundingWord(text, position) {
112
112
  start: start,
113
113
  end: end
114
114
  };
115
- }
116
- //# sourceMappingURL=markdownUtils.js.map
115
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.20.5",
3
+ "version": "3.20.7",
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>",
package/src/Editor.tsx CHANGED
@@ -265,6 +265,10 @@ const InternalMDEditor = (
265
265
  () => height !== state.height && onHeightChange && onHeightChange(state.height, height, state),
266
266
  [height, onHeightChange, state],
267
267
  );
268
+ // eslint-disable-next-line react-hooks/exhaustive-deps
269
+ useMemo(() => commands !== state.commands && dispatch({ commands: cmds }), [props.commands]);
270
+ // eslint-disable-next-line react-hooks/exhaustive-deps
271
+ useMemo(() => extraCommands !== state.extraCommands && dispatch({ extraCommands: extraCmds }), [props.extraCommands]);
268
272
 
269
273
  const textareaDomRef = useRef<HTMLDivElement>();
270
274
  const active = useRef<'text' | 'preview'>('preview');
@@ -152,7 +152,7 @@ it('MDEditor commands HR', async () => {
152
152
  }),
153
153
  );
154
154
  const inputNode = screen.getByTitle('test');
155
- expect(inputNode).toHaveValue('\n\n----------\n\ntitle');
155
+ expect(inputNode).toHaveValue('\n\n-----------\n\ntitle');
156
156
  });
157
157
 
158
158
  it('MDEditor commands strikethrough text', async () => {
@@ -206,7 +206,7 @@ it('MDEditor commands link', async () => {
206
206
  }),
207
207
  );
208
208
  const inputNode = screen.getByTitle('test');
209
- expect(inputNode).toHaveValue('[title](url)');
209
+ expect(inputNode).toHaveValue('[title](URL Here)');
210
210
  });
211
211
 
212
212
  it('MDEditor commands image', async () => {
@@ -233,7 +233,7 @@ it('MDEditor commands image', async () => {
233
233
  }),
234
234
  );
235
235
  const inputNode = screen.getByTitle('test');
236
- expect(inputNode).toHaveValue('![](title)');
236
+ expect(inputNode).toHaveValue('![image](title)');
237
237
  });
238
238
 
239
239
  it("MDEditor commands image === ''", async () => {
@@ -260,7 +260,7 @@ it("MDEditor commands image === ''", async () => {
260
260
  }),
261
261
  );
262
262
  const inputNode = screen.getByTitle('test');
263
- expect(inputNode).toHaveValue('![](https://example.com/your-image.png)');
263
+ expect(inputNode).toHaveValue('![image](https://example.com/your-image.png)');
264
264
  });
265
265
 
266
266
  it('MDEditor commands Add unordered list', async () => {
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { ICommand, TextState, TextAreaTextApi } from './';
3
3
  import {
4
4
  selectWord,
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { ICommand, TextState, TextAreaTextApi } from './';
2
3
  import { selectWord } from '../utils/markdownUtils';
3
4
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { ICommand } from './';
2
3
 
3
4
  export const divider: ICommand = {
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { ICommand, TextState, TextAreaTextApi } from './';
3
3
  import { ContextStore, ExecuteCommandState } from '../Context';
4
4