@uiw/react-md-editor 4.0.6 → 4.0.8

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 (69) hide show
  1. package/README.md +83 -2
  2. package/commands.d.ts +14 -7
  3. package/dist/mdeditor.js +61 -17
  4. package/dist/mdeditor.min.js +1 -1
  5. package/esm/Context.d.ts +2 -0
  6. package/esm/Editor.js +5 -1
  7. package/esm/Editor.nohighlight.js +5 -1
  8. package/esm/Types.d.ts +6 -2
  9. package/esm/commands/index.cn.js +4 -4
  10. package/esm/commands/index.d.ts +8 -8
  11. package/esm/commands/index.js +8 -8
  12. package/esm/commands/title.d.ts +7 -1
  13. package/esm/commands/title.js +11 -4
  14. package/esm/commands/title1.d.ts +6 -0
  15. package/esm/commands/title1.js +16 -9
  16. package/esm/commands/title2.d.ts +6 -0
  17. package/esm/commands/title2.js +16 -9
  18. package/esm/commands/title3.d.ts +6 -0
  19. package/esm/commands/title3.js +16 -9
  20. package/esm/commands/title4.d.ts +6 -0
  21. package/esm/commands/title4.js +16 -9
  22. package/esm/commands/title5.d.ts +6 -0
  23. package/esm/commands/title5.js +16 -9
  24. package/esm/commands/title6.d.ts +6 -0
  25. package/esm/commands/title6.js +16 -9
  26. package/esm/components/TextArea/Textarea.js +18 -1
  27. package/esm/index.d.ts +1 -0
  28. package/esm/index.js +1 -0
  29. package/lib/Context.d.ts +2 -0
  30. package/lib/Editor.js +8 -1
  31. package/lib/Editor.nohighlight.js +8 -1
  32. package/lib/Types.d.ts +6 -2
  33. package/lib/commands/index.cn.js +4 -4
  34. package/lib/commands/index.d.ts +8 -8
  35. package/lib/commands/index.js +42 -0
  36. package/lib/commands/title.d.ts +7 -1
  37. package/lib/commands/title.js +12 -4
  38. package/lib/commands/title1.d.ts +6 -0
  39. package/lib/commands/title1.js +16 -9
  40. package/lib/commands/title2.d.ts +6 -0
  41. package/lib/commands/title2.js +16 -9
  42. package/lib/commands/title3.d.ts +6 -0
  43. package/lib/commands/title3.js +16 -9
  44. package/lib/commands/title4.d.ts +6 -0
  45. package/lib/commands/title4.js +16 -9
  46. package/lib/commands/title5.d.ts +6 -0
  47. package/lib/commands/title5.js +16 -9
  48. package/lib/commands/title6.d.ts +6 -0
  49. package/lib/commands/title6.js +16 -9
  50. package/lib/components/TextArea/Textarea.js +18 -1
  51. package/lib/index.d.ts +1 -0
  52. package/lib/index.js +9 -1
  53. package/nohighlight.d.ts +2 -0
  54. package/package.json +1 -1
  55. package/src/Context.tsx +1 -0
  56. package/src/Editor.nohighlight.tsx +2 -0
  57. package/src/Editor.tsx +2 -0
  58. package/src/Types.ts +6 -2
  59. package/src/commands/index.cn.ts +3 -3
  60. package/src/commands/index.ts +14 -7
  61. package/src/commands/title.tsx +11 -4
  62. package/src/commands/title1.tsx +14 -7
  63. package/src/commands/title2.tsx +14 -7
  64. package/src/commands/title3.tsx +14 -7
  65. package/src/commands/title4.tsx +14 -7
  66. package/src/commands/title5.tsx +14 -7
  67. package/src/commands/title6.tsx +14 -7
  68. package/src/components/TextArea/Textarea.tsx +18 -0
  69. package/src/index.tsx +1 -0
package/esm/Context.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface ContextStore {
12
12
  fullscreen?: boolean;
13
13
  highlightEnable?: boolean;
14
14
  autoFocus?: boolean;
15
+ autoFocusEnd?: boolean;
15
16
  textarea?: HTMLTextAreaElement;
16
17
  commandOrchestrator?: TextAreaCommandOrchestrator;
17
18
  textareaWarp?: HTMLDivElement;
@@ -37,6 +38,7 @@ export declare function reducer(state: ContextStore, action: ContextStore): {
37
38
  fullscreen?: boolean;
38
39
  highlightEnable?: boolean;
39
40
  autoFocus?: boolean;
41
+ autoFocusEnd?: boolean;
40
42
  textarea?: HTMLTextAreaElement;
41
43
  commandOrchestrator?: TextAreaCommandOrchestrator;
42
44
  textareaWarp?: HTMLDivElement;
package/esm/Editor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "direction", "extraCommands", "height", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onStatistics", "onHeightChange", "hideToolbar", "toolbarBottom", "components", "renderTextarea"];
3
+ var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "direction", "extraCommands", "height", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "autoFocusEnd", "tabSize", "defaultTabEnable", "onChange", "onStatistics", "onHeightChange", "hideToolbar", "toolbarBottom", "components", "renderTextarea"];
4
4
  import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
5
5
  import MarkdownPreview from '@uiw/react-markdown-preview';
6
6
  import { ToolbarVisibility } from "./components/Toolbar/index.js";
@@ -40,6 +40,7 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
40
40
  maxHeight = 1200,
41
41
  minHeight = 100,
42
42
  autoFocus,
43
+ autoFocusEnd = false,
43
44
  tabSize = 2,
44
45
  defaultTabEnable = false,
45
46
  onChange,
@@ -110,6 +111,9 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
110
111
  useMemo(() => autoFocus !== state.autoFocus && dispatch({
111
112
  autoFocus: autoFocus
112
113
  }), [autoFocus]);
114
+ useMemo(() => autoFocusEnd !== state.autoFocusEnd && dispatch({
115
+ autoFocusEnd: autoFocusEnd
116
+ }), [autoFocusEnd]);
113
117
  useMemo(() => fullscreen !== state.fullscreen && dispatch({
114
118
  fullscreen: fullscreen
115
119
  }),
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "direction", "extraCommands", "height", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onStatistics", "onHeightChange", "hideToolbar", "toolbarBottom", "components", "renderTextarea"];
3
+ var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "direction", "extraCommands", "height", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "autoFocusEnd", "tabSize", "defaultTabEnable", "onChange", "onStatistics", "onHeightChange", "hideToolbar", "toolbarBottom", "components", "renderTextarea"];
4
4
  import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
5
5
  import MarkdownPreview from '@uiw/react-markdown-preview/nohighlight';
6
6
  import TextArea from './components/TextArea/index.nohighlight';
@@ -40,6 +40,7 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
40
40
  maxHeight = 1200,
41
41
  minHeight = 100,
42
42
  autoFocus,
43
+ autoFocusEnd = false,
43
44
  tabSize = 2,
44
45
  defaultTabEnable = false,
45
46
  onChange,
@@ -110,6 +111,9 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
110
111
  useMemo(() => autoFocus !== state.autoFocus && dispatch({
111
112
  autoFocus: autoFocus
112
113
  }), [autoFocus]);
114
+ useMemo(() => autoFocusEnd !== state.autoFocusEnd && dispatch({
115
+ autoFocusEnd: autoFocusEnd
116
+ }), [autoFocusEnd]);
113
117
  useMemo(() => fullscreen !== state.fullscreen && dispatch({
114
118
  fullscreen: fullscreen
115
119
  }),
package/esm/Types.d.ts CHANGED
@@ -34,6 +34,10 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
34
34
  * or it has an `autofocus` attribute and no other element is focused.
35
35
  */
36
36
  autoFocus?: ITextAreaProps['autoFocus'];
37
+ /**
38
+ * Can be used to make `Markdown Editor` focus on the end of text on initialization.
39
+ */
40
+ autoFocusEnd?: boolean;
37
41
  /**
38
42
  * The height of the editor.
39
43
  * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
@@ -52,7 +56,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
52
56
  */
53
57
  visibleDragbar?: boolean;
54
58
  /**
55
- * @deprecated use `visibleDragbar`
59
+ * @deprecated use {@link MDEditorProps.visibleDragbar}
56
60
  */
57
61
  visiableDragbar?: boolean;
58
62
  /**
@@ -85,7 +89,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
85
89
  textareaProps?: ITextAreaProps;
86
90
  /**
87
91
  * Use div to replace TextArea or re-render TextArea
88
- * @deprecated Please use ~~`renderTextarea`~~ -> `components`
92
+ * @deprecated Please use {@link components}
89
93
  */
90
94
  renderTextarea?: ITextAreaProps['renderTextarea'];
91
95
  /**
@@ -55,8 +55,8 @@ var fullscreen = _extends({}, fullscreenInit, {
55
55
  });
56
56
  var hr = _extends({}, hrInit, {
57
57
  buttonProps: {
58
- 'aria-label': '插入HR (ctrl + h)',
59
- title: '插入HR (ctrl + h)'
58
+ 'aria-label': '插入分割线 (ctrl + h)',
59
+ title: '插入分割线 (ctrl + h)'
60
60
  }
61
61
  });
62
62
  var image = _extends({}, imageInit, {
@@ -121,8 +121,8 @@ var quote = _extends({}, quoteInit, {
121
121
  });
122
122
  var strikethrough = _extends({}, strikethroughInit, {
123
123
  buttonProps: {
124
- 'aria-label': 'Add strikethrough text (ctrl + shift + x)',
125
- title: 'Add strikethrough text (ctrl + shift + x)'
124
+ 'aria-label': '添加删除线文本 (ctrl + shift + x)',
125
+ title: '添加删除线文本 (ctrl + shift + x)'
126
126
  }
127
127
  });
128
128
  var issue = _extends({}, issueInit, {
@@ -14,13 +14,13 @@ import { checkedListCommand, orderedListCommand, unorderedListCommand } from './
14
14
  import { codeEdit, codeLive, codePreview } from './preview';
15
15
  import { quote } from './quote';
16
16
  import { strikethrough } from './strikeThrough';
17
- import { title } from './title';
18
- import { title1 } from './title1';
19
- import { title2 } from './title2';
20
- import { title3 } from './title3';
21
- import { title4 } from './title4';
22
- import { title5 } from './title5';
23
- import { title6 } from './title6';
17
+ import { title, heading } from './title';
18
+ import { title1, heading1 } from './title1';
19
+ import { title2, heading2 } from './title2';
20
+ import { title3, heading3 } from './title3';
21
+ import { title4, heading4 } from './title4';
22
+ import { title5, heading5 } from './title5';
23
+ import { title6, heading6 } from './title6';
24
24
  import { table } from './table';
25
25
  import { issue } from './issue';
26
26
  import { help } from './help';
@@ -93,4 +93,4 @@ declare class TextAreaCommandOrchestrator implements CommandOrchestrator {
93
93
  getState(): false | TextState;
94
94
  executeCommand(command: ICommand<string>, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState, shortcuts?: string[]): void;
95
95
  }
96
- export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, table, issue, help, codeEdit, codeLive, codePreview, fullscreen, getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi, };
96
+ export { title, title1, title2, title3, title4, title5, title6, heading, heading1, heading2, heading3, heading4, heading5, heading6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, table, issue, help, codeEdit, codeLive, codePreview, fullscreen, getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi, };
@@ -14,13 +14,13 @@ import { checkedListCommand, orderedListCommand, unorderedListCommand } from "./
14
14
  import { codeEdit, codeLive, codePreview } from "./preview.js";
15
15
  import { quote } from "./quote.js";
16
16
  import { strikethrough } from "./strikeThrough.js";
17
- import { title } from "./title.js";
18
- import { title1 } from "./title1.js";
19
- import { title2 } from "./title2.js";
20
- import { title3 } from "./title3.js";
21
- import { title4 } from "./title4.js";
22
- import { title5 } from "./title5.js";
23
- import { title6 } from "./title6.js";
17
+ import { title, heading } from "./title.js";
18
+ import { title1, heading1 } from "./title1.js";
19
+ import { title2, heading2 } from "./title2.js";
20
+ import { title3, heading3 } from "./title3.js";
21
+ import { title4, heading4 } from "./title4.js";
22
+ import { title5, heading5 } from "./title5.js";
23
+ import { title6, heading6 } from "./title6.js";
24
24
  import { table } from "./table.js";
25
25
  import { issue } from "./issue.js";
26
26
  import { help } from "./help.js";
@@ -88,6 +88,6 @@ class TextAreaCommandOrchestrator {
88
88
  }, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
89
89
  }
90
90
  }
91
- export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, table, issue, help, codeEdit, codeLive, codePreview, fullscreen,
91
+ export { title, title1, title2, title3, title4, title5, title6, heading, heading1, heading2, heading3, heading4, heading5, heading6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, table, issue, help, codeEdit, codeLive, codePreview, fullscreen,
92
92
  // Tool method.
93
93
  getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
@@ -1,8 +1,14 @@
1
1
  import { ICommand, ExecuteState, TextAreaTextApi } from './';
2
- export declare function titleExecute({ state, api, prefix, suffix, }: {
2
+ export declare function headingExecute({ state, api, prefix, suffix, }: {
3
3
  state: ExecuteState;
4
4
  api: TextAreaTextApi;
5
5
  prefix: string;
6
6
  suffix?: string;
7
7
  }): void;
8
+ export declare const heading: ICommand;
9
+ /**
10
+ * @deprecated Use `heading` instead.
11
+ * This command is now deprecated and will be removed in future versions.
12
+ * Use `title` for inserting headings.
13
+ */
8
14
  export declare const title: ICommand;
@@ -1,9 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import { title1 } from "./title1.js";
3
+ import { heading1 } from "./title1.js";
4
4
  import { selectLine, executeCommand } from "../utils/markdownUtils.js";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- export function titleExecute(_ref) {
6
+ export function headingExecute(_ref) {
7
7
  var {
8
8
  state,
9
9
  api,
@@ -23,7 +23,7 @@ export function titleExecute(_ref) {
23
23
  suffix
24
24
  });
25
25
  }
26
- export var title = _extends({}, title1, {
26
+ export var heading = _extends({}, heading1, {
27
27
  icon: /*#__PURE__*/_jsx("svg", {
28
28
  width: "12",
29
29
  height: "12",
@@ -33,4 +33,11 @@ export var title = _extends({}, title1, {
33
33
  d: "M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z"
34
34
  })
35
35
  })
36
- });
36
+ });
37
+
38
+ /**
39
+ * @deprecated Use `heading` instead.
40
+ * This command is now deprecated and will be removed in future versions.
41
+ * Use `title` for inserting headings.
42
+ */
43
+ export var title = heading;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading1: ICommand;
3
+ /**
4
+ * @deprecated Use `heading1` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title1` for inserting Heading 1.
7
+ */
2
8
  export declare const title1: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title1 = {
5
- name: 'title1',
6
- keyCommand: 'title1',
4
+ export var heading1 = {
5
+ name: 'heading1',
6
+ keyCommand: 'heading1',
7
7
  shortcuts: 'ctrlcmd+1',
8
8
  prefix: '# ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title1 (ctrl + 1)',
12
- title: 'Insert title1 (ctrl + 1)'
11
+ 'aria-label': 'Insert Heading 1 (ctrl + 1)',
12
+ title: 'Insert Heading 1 (ctrl + 1)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 18,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 1"
19
+ children: "Heading 1"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading1` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title1` for inserting Heading 1.
35
+ */
36
+ export var title1 = heading1;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading2: ICommand;
3
+ /**
4
+ * @deprecated Use `heading2` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title2` for inserting Heading 2.
7
+ */
2
8
  export declare const title2: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title2 = {
5
- name: 'title2',
6
- keyCommand: 'title2',
4
+ export var heading2 = {
5
+ name: 'heading2',
6
+ keyCommand: 'heading2',
7
7
  shortcuts: 'ctrlcmd+2',
8
8
  prefix: '## ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title2 (ctrl + 2)',
12
- title: 'Insert title2 (ctrl + 2)'
11
+ 'aria-label': 'Insert Heading 2 (ctrl + 2)',
12
+ title: 'Insert Heading 2 (ctrl + 2)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 16,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 2"
19
+ children: "Heading 2"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading2` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title2` for inserting Heading 2.
35
+ */
36
+ export var title2 = heading2;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading3: ICommand;
3
+ /**
4
+ * @deprecated Use `heading3` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title3` for inserting Heading 3.
7
+ */
2
8
  export declare const title3: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title3 = {
5
- name: 'title3',
6
- keyCommand: 'title3',
4
+ export var heading3 = {
5
+ name: 'heading3',
6
+ keyCommand: 'heading3',
7
7
  shortcuts: 'ctrlcmd+3',
8
8
  prefix: '### ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title3 (ctrl + 3)',
12
- title: 'Insert title3 (ctrl + 3)'
11
+ 'aria-label': 'Insert Heading 3 (ctrl + 3)',
12
+ title: 'Insert Heading 3 (ctrl + 3)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 15,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 3"
19
+ children: "Heading 3"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading3` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title3` for inserting Heading 3.
35
+ */
36
+ export var title3 = heading3;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading4: ICommand;
3
+ /**
4
+ * @deprecated Use `heading4` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title4` for inserting Heading 4.
7
+ */
2
8
  export declare const title4: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title4 = {
5
- name: 'title4',
6
- keyCommand: 'title4',
4
+ export var heading4 = {
5
+ name: 'heading4',
6
+ keyCommand: 'heading4',
7
7
  shortcuts: 'ctrlcmd+4',
8
8
  prefix: '#### ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title4 (ctrl + 4)',
12
- title: 'Insert title4 (ctrl + 4)'
11
+ 'aria-label': 'Insert Heading 4 (ctrl + 4)',
12
+ title: 'Insert Heading 4 (ctrl + 4)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 14,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 4"
19
+ children: "Heading 4"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading4` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title4` for inserting Heading 4.
35
+ */
36
+ export var title4 = heading4;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading5: ICommand;
3
+ /**
4
+ * @deprecated Use `heading5` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title5` for inserting Heading 5.
7
+ */
2
8
  export declare const title5: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title5 = {
5
- name: 'title5',
6
- keyCommand: 'title5',
4
+ export var heading5 = {
5
+ name: 'heading5',
6
+ keyCommand: 'heading5',
7
7
  shortcuts: 'ctrlcmd+5',
8
8
  prefix: '##### ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title5 (ctrl + 5)',
12
- title: 'Insert title5 (ctrl + 5)'
11
+ 'aria-label': 'Insert Heading 5 (ctrl + 5)',
12
+ title: 'Insert Heading 5 (ctrl + 5)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 12,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 5"
19
+ children: "Heading 5"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading5` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title5` for inserting Heading 5.
35
+ */
36
+ export var title5 = heading5;
@@ -1,2 +1,8 @@
1
1
  import { ICommand } from './';
2
+ export declare const heading6: ICommand;
3
+ /**
4
+ * @deprecated Use `heading6` instead.
5
+ * This command is now deprecated and will be removed in future versions.
6
+ * Use `title6` for inserting Heading 6.
7
+ */
2
8
  export declare const title6: ICommand;
@@ -1,29 +1,36 @@
1
1
  import React from 'react';
2
- import { titleExecute } from "../commands/title.js";
2
+ import { headingExecute } from "../commands/title.js";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
- export var title6 = {
5
- name: 'title6',
6
- keyCommand: 'title6',
4
+ export var heading6 = {
5
+ name: 'heading6',
6
+ keyCommand: 'heading6',
7
7
  shortcuts: 'ctrlcmd+6',
8
8
  prefix: '###### ',
9
9
  suffix: '',
10
10
  buttonProps: {
11
- 'aria-label': 'Insert title6 (ctrl + 6)',
12
- title: 'Insert title6 (ctrl + 6)'
11
+ 'aria-label': 'Insert Heading 6 (ctrl + 6)',
12
+ title: 'Insert Heading 6 (ctrl + 6)'
13
13
  },
14
14
  icon: /*#__PURE__*/_jsx("div", {
15
15
  style: {
16
16
  fontSize: 12,
17
17
  textAlign: 'left'
18
18
  },
19
- children: "Title 6"
19
+ children: "Heading 6"
20
20
  }),
21
21
  execute: (state, api) => {
22
- titleExecute({
22
+ headingExecute({
23
23
  state,
24
24
  api,
25
25
  prefix: state.command.prefix,
26
26
  suffix: state.command.suffix
27
27
  });
28
28
  }
29
- };
29
+ };
30
+
31
+ /**
32
+ * @deprecated Use `heading6` instead.
33
+ * This command is now deprecated and will be removed in future versions.
34
+ * Use `title6` for inserting Heading 6.
35
+ */
36
+ export var title6 = heading6;
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["prefixCls", "onChange"],
4
- _excluded2 = ["markdown", "commands", "fullscreen", "preview", "highlightEnable", "extraCommands", "tabSize", "defaultTabEnable", "dispatch"];
4
+ _excluded2 = ["markdown", "commands", "fullscreen", "preview", "highlightEnable", "extraCommands", "tabSize", "defaultTabEnable", "autoFocusEnd", "textareaWarp", "dispatch"];
5
5
  import React, { useContext, useEffect } from 'react';
6
6
  import { EditorContext } from "../../Context.js";
7
7
  import { TextAreaCommandOrchestrator } from "../../commands/index.js";
@@ -25,6 +25,8 @@ export default function Textarea(props) {
25
25
  extraCommands,
26
26
  tabSize,
27
27
  defaultTabEnable,
28
+ autoFocusEnd,
29
+ textareaWarp,
28
30
  dispatch
29
31
  } = _useContext,
30
32
  otherStore = _objectWithoutPropertiesLoose(_useContext, _excluded2);
@@ -52,6 +54,21 @@ export default function Textarea(props) {
52
54
  }
53
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
56
  }, []);
57
+ useEffect(() => {
58
+ if (autoFocusEnd && textRef.current && textareaWarp) {
59
+ textRef.current.focus();
60
+ var length = textRef.current.value.length;
61
+ textRef.current.setSelectionRange(length, length);
62
+ setTimeout(() => {
63
+ if (textareaWarp) {
64
+ textareaWarp.scrollTop = textareaWarp.scrollHeight;
65
+ }
66
+ if (textRef.current) {
67
+ textRef.current.scrollTop = textRef.current.scrollHeight;
68
+ }
69
+ }, 0);
70
+ }
71
+ }, [textareaWarp]);
55
72
  var onKeyDown = e => {
56
73
  handleKeyDown(e, tabSize, defaultTabEnable);
57
74
  shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);
package/esm/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import MDEditor from './Editor';
2
2
  import * as commands from './commands/';
3
3
  import * as MarkdownUtil from './utils/markdownUtils';
4
4
  import './index.less';
5
+ export { headingExecute } from './commands/title';
5
6
  export * from './commands/';
6
7
  export * from './commands/group';
7
8
  export * from './utils/markdownUtils';
package/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import MDEditor from "./Editor.js";
2
2
  import * as commands from "./commands/index.js";
3
3
  import * as MarkdownUtil from "./utils/markdownUtils.js";
4
4
  import "./index.css";
5
+ export { headingExecute } from "./commands/title.js";
5
6
  export * from "./commands/index.js";
6
7
  export * from "./commands/group.js";
7
8
  export * from "./utils/markdownUtils.js";
package/lib/Context.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface ContextStore {
12
12
  fullscreen?: boolean;
13
13
  highlightEnable?: boolean;
14
14
  autoFocus?: boolean;
15
+ autoFocusEnd?: boolean;
15
16
  textarea?: HTMLTextAreaElement;
16
17
  commandOrchestrator?: TextAreaCommandOrchestrator;
17
18
  textareaWarp?: HTMLDivElement;
@@ -37,6 +38,7 @@ export declare function reducer(state: ContextStore, action: ContextStore): {
37
38
  fullscreen?: boolean;
38
39
  highlightEnable?: boolean;
39
40
  autoFocus?: boolean;
41
+ autoFocusEnd?: boolean;
40
42
  textarea?: HTMLTextAreaElement;
41
43
  commandOrchestrator?: TextAreaCommandOrchestrator;
42
44
  textareaWarp?: HTMLDivElement;