@uiw/react-md-editor 4.0.5 → 4.0.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.
- package/README.md +57 -3
- package/dist/mdeditor.css +107 -107
- package/dist/mdeditor.js +7866 -3903
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +3 -1
- package/esm/Editor.js +10 -6
- package/esm/Editor.nohighlight.js +9 -5
- package/esm/Types.d.ts +6 -2
- package/esm/commands/bold.d.ts +1 -1
- package/esm/commands/bold.js +1 -1
- package/esm/commands/code.d.ts +1 -1
- package/esm/commands/code.js +1 -1
- package/esm/commands/comment.d.ts +1 -1
- package/esm/commands/comment.js +1 -1
- package/esm/commands/divider.d.ts +1 -1
- package/esm/commands/fullscreen.d.ts +1 -1
- package/esm/commands/group.d.ts +1 -1
- package/esm/commands/help.d.ts +1 -1
- package/esm/commands/hr.d.ts +1 -1
- package/esm/commands/hr.js +1 -1
- package/esm/commands/image.d.ts +1 -1
- package/esm/commands/image.js +1 -1
- package/esm/commands/index.cn.js +24 -24
- package/esm/commands/index.d.ts +1 -1
- package/esm/commands/index.js +25 -25
- package/esm/commands/issue.d.ts +1 -1
- package/esm/commands/issue.js +1 -1
- package/esm/commands/italic.d.ts +1 -1
- package/esm/commands/italic.js +1 -1
- package/esm/commands/link.d.ts +1 -1
- package/esm/commands/link.js +1 -1
- package/esm/commands/list.d.ts +1 -1
- package/esm/commands/list.js +1 -1
- package/esm/commands/preview.d.ts +1 -1
- package/esm/commands/quote.d.ts +1 -1
- package/esm/commands/quote.js +1 -1
- package/esm/commands/strikeThrough.js +1 -1
- package/esm/commands/table.js +1 -1
- package/esm/commands/title.js +2 -2
- package/esm/commands/title1.js +1 -1
- package/esm/commands/title2.js +1 -1
- package/esm/commands/title3.js +1 -1
- package/esm/commands/title4.js +1 -1
- package/esm/commands/title5.js +1 -1
- package/esm/commands/title6.js +1 -1
- package/esm/components/TextArea/Markdown.js +1 -1
- package/esm/components/TextArea/Textarea.js +22 -5
- package/esm/components/TextArea/handleKeyDown.js +3 -4
- package/esm/components/TextArea/index.d.ts +1 -1
- package/esm/components/TextArea/index.js +5 -5
- package/esm/components/TextArea/index.nohighlight.d.ts +1 -1
- package/esm/components/TextArea/index.nohighlight.js +4 -4
- package/esm/components/TextArea/shortcuts.d.ts +1 -1
- package/esm/components/Toolbar/Child.js +2 -2
- package/esm/components/Toolbar/index.d.ts +1 -1
- package/esm/components/Toolbar/index.js +2 -2
- package/esm/index.d.ts +2 -2
- package/esm/index.js +10 -10
- package/esm/index.nohighlight.d.ts +2 -2
- package/esm/index.nohighlight.js +8 -8
- package/esm/utils/markdownUtils.d.ts +1 -2
- package/lib/Context.d.ts +3 -1
- package/lib/Editor.js +12 -5
- package/lib/Editor.nohighlight.js +11 -4
- package/lib/Types.d.ts +6 -2
- package/lib/commands/bold.d.ts +1 -1
- package/lib/commands/code.d.ts +1 -1
- package/lib/commands/comment.d.ts +1 -1
- package/lib/commands/divider.d.ts +1 -1
- package/lib/commands/fullscreen.d.ts +1 -1
- package/lib/commands/group.d.ts +1 -1
- package/lib/commands/help.d.ts +1 -1
- package/lib/commands/hr.d.ts +1 -1
- package/lib/commands/image.d.ts +1 -1
- package/lib/commands/index.d.ts +1 -1
- package/lib/commands/issue.d.ts +1 -1
- package/lib/commands/italic.d.ts +1 -1
- package/lib/commands/link.d.ts +1 -1
- package/lib/commands/list.d.ts +1 -1
- package/lib/commands/preview.d.ts +1 -1
- package/lib/commands/quote.d.ts +1 -1
- package/lib/components/TextArea/Textarea.js +19 -2
- package/lib/components/TextArea/handleKeyDown.js +1 -1
- package/lib/components/TextArea/index.d.ts +1 -1
- package/lib/components/TextArea/index.js +1 -1
- package/lib/components/TextArea/index.nohighlight.d.ts +1 -1
- package/lib/components/TextArea/index.nohighlight.js +1 -1
- package/lib/components/TextArea/shortcuts.d.ts +1 -1
- package/lib/components/Toolbar/index.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/index.nohighlight.d.ts +2 -2
- package/lib/index.nohighlight.js +1 -1
- package/lib/utils/markdownUtils.d.ts +1 -2
- package/package.json +1 -1
- package/src/Context.tsx +2 -1
- package/src/Editor.nohighlight.tsx +5 -3
- package/src/Editor.tsx +6 -4
- package/src/Types.ts +6 -2
- package/src/commands/bold.tsx +1 -1
- package/src/commands/code.tsx +1 -1
- package/src/commands/comment.tsx +1 -1
- package/src/commands/divider.tsx +1 -1
- package/src/commands/fullscreen.tsx +2 -2
- package/src/commands/group.tsx +1 -1
- package/src/commands/help.tsx +1 -1
- package/src/commands/hr.tsx +1 -1
- package/src/commands/image.tsx +1 -1
- package/src/commands/index.ts +1 -1
- package/src/commands/issue.tsx +1 -1
- package/src/commands/italic.tsx +1 -1
- package/src/commands/link.tsx +1 -1
- package/src/commands/list.tsx +1 -1
- package/src/commands/preview.tsx +2 -2
- package/src/commands/quote.tsx +1 -1
- package/src/components/TextArea/Textarea.tsx +19 -1
- package/src/components/TextArea/handleKeyDown.tsx +1 -1
- package/src/components/TextArea/index.nohighlight.tsx +1 -1
- package/src/components/TextArea/index.tsx +1 -1
- package/src/components/TextArea/shortcuts.ts +1 -1
- package/src/components/Toolbar/index.tsx +1 -1
- package/src/index.nohighlight.tsx +2 -2
- package/src/index.tsx +2 -2
- package/src/utils/markdownUtils.ts +1 -2
package/src/Types.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
37
37
|
* or it has an `autofocus` attribute and no other element is focused.
|
|
38
38
|
*/
|
|
39
39
|
autoFocus?: ITextAreaProps['autoFocus'];
|
|
40
|
+
/**
|
|
41
|
+
* Can be used to make `Markdown Editor` focus on the end of text on initialization.
|
|
42
|
+
*/
|
|
43
|
+
autoFocusEnd?: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* The height of the editor.
|
|
42
46
|
* ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
|
|
@@ -55,7 +59,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
55
59
|
*/
|
|
56
60
|
visibleDragbar?: boolean;
|
|
57
61
|
/**
|
|
58
|
-
* @deprecated use
|
|
62
|
+
* @deprecated use {@link MDEditorProps.visibleDragbar}
|
|
59
63
|
*/
|
|
60
64
|
visiableDragbar?: boolean;
|
|
61
65
|
/**
|
|
@@ -88,7 +92,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
88
92
|
textareaProps?: ITextAreaProps;
|
|
89
93
|
/**
|
|
90
94
|
* Use div to replace TextArea or re-render TextArea
|
|
91
|
-
* @deprecated Please use
|
|
95
|
+
* @deprecated Please use {@link components}
|
|
92
96
|
*/
|
|
93
97
|
renderTextarea?: ITextAreaProps['renderTextarea'];
|
|
94
98
|
/**
|
package/src/commands/bold.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const bold: ICommand = {
|
package/src/commands/code.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const codeBlock: ICommand = {
|
package/src/commands/comment.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const comment: ICommand = {
|
package/src/commands/divider.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, TextState, TextAreaTextApi } from './';
|
|
3
|
-
import { ContextStore, ExecuteCommandState } from '../Context';
|
|
2
|
+
import { type ICommand, TextState, type TextAreaTextApi } from './';
|
|
3
|
+
import { type ContextStore, type ExecuteCommandState } from '../Context';
|
|
4
4
|
|
|
5
5
|
export const fullscreen: ICommand = {
|
|
6
6
|
name: 'fullscreen',
|
package/src/commands/group.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ICommandChildCommands, ICommandChildHandle } from './';
|
|
2
|
+
import { type ICommand, type ICommandChildCommands, type ICommandChildHandle } from './';
|
|
3
3
|
|
|
4
4
|
export type GroupOptions = Omit<ICommand<string>, 'children'> & {
|
|
5
5
|
children?: ICommandChildHandle['children'];
|
package/src/commands/help.tsx
CHANGED
package/src/commands/hr.tsx
CHANGED
package/src/commands/image.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const image: ICommand = {
|
package/src/commands/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ContextStore, ExecuteCommandState } from '../Context';
|
|
2
|
+
import { type ContextStore, ExecuteCommandState } from '../Context';
|
|
3
3
|
import { insertTextAtPosition } from '../utils/InsertTextAtPosition';
|
|
4
4
|
import { bold } from './bold';
|
|
5
5
|
import { code, codeBlock } from './code';
|
package/src/commands/issue.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const issue: ICommand = {
|
package/src/commands/italic.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const italic: ICommand = {
|
package/src/commands/link.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
3
3
|
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export const link: ICommand = {
|
package/src/commands/list.tsx
CHANGED
package/src/commands/preview.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, TextState, TextAreaTextApi } from './';
|
|
3
|
-
import { ContextStore, ExecuteCommandState } from '../Context';
|
|
2
|
+
import { type ICommand, type TextState, TextAreaTextApi } from './';
|
|
3
|
+
import { type ContextStore, type ExecuteCommandState } from '../Context';
|
|
4
4
|
|
|
5
5
|
export const codePreview: ICommand = {
|
|
6
6
|
name: 'preview',
|
package/src/commands/quote.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { IProps } from '../../Types';
|
|
3
3
|
import { EditorContext, ExecuteCommandState } from '../../Context';
|
|
4
|
-
import { TextAreaCommandOrchestrator } from '../../commands';
|
|
4
|
+
import { TextAreaCommandOrchestrator } from '../../commands/';
|
|
5
5
|
import handleKeyDown from './handleKeyDown';
|
|
6
6
|
import shortcuts from './shortcuts';
|
|
7
7
|
import './index.less';
|
|
@@ -19,6 +19,8 @@ export default function Textarea(props: TextAreaProps) {
|
|
|
19
19
|
extraCommands,
|
|
20
20
|
tabSize,
|
|
21
21
|
defaultTabEnable,
|
|
22
|
+
autoFocusEnd,
|
|
23
|
+
textareaWarp,
|
|
22
24
|
dispatch,
|
|
23
25
|
...otherStore
|
|
24
26
|
} = useContext(EditorContext);
|
|
@@ -39,6 +41,22 @@ export default function Textarea(props: TextAreaProps) {
|
|
|
39
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
42
|
}, []);
|
|
41
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (autoFocusEnd && textRef.current && textareaWarp) {
|
|
46
|
+
textRef.current.focus();
|
|
47
|
+
const length = textRef.current.value.length;
|
|
48
|
+
textRef.current.setSelectionRange(length, length);
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
if (textareaWarp) {
|
|
51
|
+
textareaWarp.scrollTop = textareaWarp.scrollHeight;
|
|
52
|
+
}
|
|
53
|
+
if (textRef.current) {
|
|
54
|
+
textRef.current.scrollTop = textRef.current.scrollHeight;
|
|
55
|
+
}
|
|
56
|
+
}, 0);
|
|
57
|
+
}
|
|
58
|
+
}, [textareaWarp]);
|
|
59
|
+
|
|
42
60
|
const onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
43
61
|
handleKeyDown(e, tabSize, defaultTabEnable);
|
|
44
62
|
shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { insertTextAtPosition } from '../../utils/InsertTextAtPosition';
|
|
2
2
|
import { insertBeforeEachLine, selectLine } from '../../utils/markdownUtils';
|
|
3
|
-
import { TextAreaTextApi } from '../../commands';
|
|
3
|
+
import { TextAreaTextApi } from '../../commands/';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* - `13` - `Enter`
|
|
@@ -3,7 +3,7 @@ import { EditorContext, ContextStore, ExecuteCommandState } from '../../Context'
|
|
|
3
3
|
import shortcuts from './shortcuts';
|
|
4
4
|
import Textarea, { TextAreaProps } from './Textarea';
|
|
5
5
|
import { IProps } from '../../Types';
|
|
6
|
-
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
6
|
+
import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
|
|
7
7
|
import './index.less';
|
|
8
8
|
|
|
9
9
|
type RenderTextareaHandle = {
|
|
@@ -4,7 +4,7 @@ import shortcuts from './shortcuts';
|
|
|
4
4
|
import Markdown from './Markdown';
|
|
5
5
|
import Textarea, { TextAreaProps } from './Textarea';
|
|
6
6
|
import { IProps } from '../../Types';
|
|
7
|
-
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
7
|
+
import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
|
|
8
8
|
import './index.less';
|
|
9
9
|
|
|
10
10
|
type RenderTextareaHandle = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommand, TextAreaCommandOrchestrator } from '../../commands';
|
|
1
|
+
import { ICommand, TextAreaCommandOrchestrator } from '../../commands/';
|
|
2
2
|
import { ContextStore, ExecuteCommandState } from '../../Context';
|
|
3
3
|
|
|
4
4
|
function getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Fragment, useContext, useEffect, useRef } from 'react';
|
|
2
2
|
import { IProps } from '../../Types';
|
|
3
3
|
import { EditorContext, PreviewType, ContextStore } from '../../Context';
|
|
4
|
-
import { ICommand } from '../../commands';
|
|
4
|
+
import { ICommand } from '../../commands/';
|
|
5
5
|
import Child from './Child';
|
|
6
6
|
import './index.less';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import MDEditor from './Editor.nohighlight';
|
|
2
|
-
import * as commands from './commands';
|
|
2
|
+
import * as commands from './commands/';
|
|
3
3
|
import * as MarkdownUtil from './utils/markdownUtils';
|
|
4
4
|
import './index.less';
|
|
5
5
|
|
|
6
|
-
export * from './commands';
|
|
6
|
+
export * from './commands/';
|
|
7
7
|
export * from './commands/group';
|
|
8
8
|
export * from './utils/markdownUtils';
|
|
9
9
|
export * from './utils/InsertTextAtPosition';
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import MDEditor from './Editor';
|
|
2
|
-
import * as commands from './commands';
|
|
2
|
+
import * as commands from './commands/';
|
|
3
3
|
import * as MarkdownUtil from './utils/markdownUtils';
|
|
4
4
|
import './index.less';
|
|
5
5
|
|
|
6
|
-
export * from './commands';
|
|
6
|
+
export * from './commands/';
|
|
7
7
|
export * from './commands/group';
|
|
8
8
|
export * from './utils/markdownUtils';
|
|
9
9
|
export * from './utils/InsertTextAtPosition';
|