@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/esm/Context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ICommand, TextAreaCommandOrchestrator } from './commands';
|
|
2
|
+
import { ICommand, TextAreaCommandOrchestrator } from './commands/';
|
|
3
3
|
import { MDEditorProps } from './Types';
|
|
4
4
|
export type PreviewType = 'live' | 'edit' | 'preview';
|
|
5
5
|
export interface ContextStore {
|
|
@@ -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,13 +1,13 @@
|
|
|
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
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import DragBar from
|
|
9
|
-
import { getCommands, getExtraCommands, TextAreaCommandOrchestrator } from
|
|
10
|
-
import { reducer, EditorContext } from
|
|
6
|
+
import { ToolbarVisibility } from "./components/Toolbar/index.js";
|
|
7
|
+
import TextArea from "./components/TextArea/index.js";
|
|
8
|
+
import DragBar from "./components/DragBar/index.js";
|
|
9
|
+
import { getCommands, getExtraCommands, TextAreaCommandOrchestrator } from "./commands/index.js";
|
|
10
|
+
import { reducer, EditorContext } from "./Context.js";
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
function setGroupPopFalse(data) {
|
|
13
13
|
if (data === void 0) {
|
|
@@ -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,13 +1,13 @@
|
|
|
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';
|
|
7
|
-
import { ToolbarVisibility } from
|
|
8
|
-
import DragBar from
|
|
9
|
-
import { getCommands, getExtraCommands, TextAreaCommandOrchestrator } from
|
|
10
|
-
import { reducer, EditorContext } from
|
|
7
|
+
import { ToolbarVisibility } from "./components/Toolbar/index.js";
|
|
8
|
+
import DragBar from "./components/DragBar/index.js";
|
|
9
|
+
import { getCommands, getExtraCommands, TextAreaCommandOrchestrator } from "./commands/index.js";
|
|
10
|
+
import { reducer, EditorContext } from "./Context.js";
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
function setGroupPopFalse(data) {
|
|
13
13
|
if (data === void 0) {
|
|
@@ -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
|
|
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
|
|
92
|
+
* @deprecated Please use {@link components}
|
|
89
93
|
*/
|
|
90
94
|
renderTextarea?: ITextAreaProps['renderTextarea'];
|
|
91
95
|
/**
|
package/esm/commands/bold.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const bold: ICommand;
|
package/esm/commands/bold.js
CHANGED
package/esm/commands/code.d.ts
CHANGED
package/esm/commands/code.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord, executeCommand } from
|
|
2
|
+
import { selectWord, executeCommand } from "../utils/markdownUtils.js";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var codeBlock = {
|
|
5
5
|
name: 'codeBlock',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const comment: ICommand;
|
package/esm/commands/comment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord, executeCommand } from
|
|
2
|
+
import { selectWord, executeCommand } from "../utils/markdownUtils.js";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
export var comment = {
|
|
5
5
|
name: 'comment',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const divider: ICommand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const fullscreen: ICommand;
|
package/esm/commands/group.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommand, ICommandChildCommands, ICommandChildHandle } from './';
|
|
1
|
+
import { type ICommand, type ICommandChildCommands, type ICommandChildHandle } from './';
|
|
2
2
|
export type GroupOptions = Omit<ICommand<string>, 'children'> & {
|
|
3
3
|
children?: ICommandChildHandle['children'];
|
|
4
4
|
};
|
package/esm/commands/help.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const help: ICommand;
|
package/esm/commands/hr.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const hr: ICommand;
|
package/esm/commands/hr.js
CHANGED
package/esm/commands/image.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const image: ICommand;
|
package/esm/commands/image.js
CHANGED
package/esm/commands/index.cn.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { divider } from
|
|
3
|
-
import { group } from
|
|
4
|
-
import { bold as boldInit } from
|
|
5
|
-
import { code as codeInit, codeBlock as codeBlockInit } from
|
|
6
|
-
import { comment as commentInit } from
|
|
7
|
-
import { fullscreen as fullscreenInit } from
|
|
8
|
-
import { hr as hrInit } from
|
|
9
|
-
import { image as imageInit } from
|
|
10
|
-
import { italic as italicInit } from
|
|
11
|
-
import { link as linkInit } from
|
|
12
|
-
import { checkedListCommand as checkedListCommandInit, orderedListCommand as orderedListCommandInit, unorderedListCommand as unorderedListCommandInit } from
|
|
13
|
-
import { codeEdit as codeEditInit, codeLive as codeLiveInit, codePreview as codePreviewInit } from
|
|
14
|
-
import { quote as quoteInit } from
|
|
15
|
-
import { strikethrough as strikethroughInit } from
|
|
16
|
-
import { issue as issueInit } from
|
|
17
|
-
import { title as titleInit } from
|
|
18
|
-
import { title1 as title1Init } from
|
|
19
|
-
import { title2 as title2Init } from
|
|
20
|
-
import { title3 as title3Init } from
|
|
21
|
-
import { title4 as title4Init } from
|
|
22
|
-
import { title5 as title5Init } from
|
|
23
|
-
import { title6 as title6Init } from
|
|
24
|
-
import { table as tableInit } from
|
|
25
|
-
import { help as helpInit } from
|
|
2
|
+
import { divider } from "./divider.js";
|
|
3
|
+
import { group } from "./group.js";
|
|
4
|
+
import { bold as boldInit } from "./bold.js";
|
|
5
|
+
import { code as codeInit, codeBlock as codeBlockInit } from "./code.js";
|
|
6
|
+
import { comment as commentInit } from "./comment.js";
|
|
7
|
+
import { fullscreen as fullscreenInit } from "./fullscreen.js";
|
|
8
|
+
import { hr as hrInit } from "./hr.js";
|
|
9
|
+
import { image as imageInit } from "./image.js";
|
|
10
|
+
import { italic as italicInit } from "./italic.js";
|
|
11
|
+
import { link as linkInit } from "./link.js";
|
|
12
|
+
import { checkedListCommand as checkedListCommandInit, orderedListCommand as orderedListCommandInit, unorderedListCommand as unorderedListCommandInit } from "./list.js";
|
|
13
|
+
import { codeEdit as codeEditInit, codeLive as codeLiveInit, codePreview as codePreviewInit } from "./preview.js";
|
|
14
|
+
import { quote as quoteInit } from "./quote.js";
|
|
15
|
+
import { strikethrough as strikethroughInit } from "./strikeThrough.js";
|
|
16
|
+
import { issue as issueInit } from "./issue.js";
|
|
17
|
+
import { title as titleInit } from "./title.js";
|
|
18
|
+
import { title1 as title1Init } from "./title1.js";
|
|
19
|
+
import { title2 as title2Init } from "./title2.js";
|
|
20
|
+
import { title3 as title3Init } from "./title3.js";
|
|
21
|
+
import { title4 as title4Init } from "./title4.js";
|
|
22
|
+
import { title5 as title5Init } from "./title5.js";
|
|
23
|
+
import { title6 as title6Init } from "./title6.js";
|
|
24
|
+
import { table as tableInit } from "./table.js";
|
|
25
|
+
import { help as helpInit } from "./help.js";
|
|
26
26
|
var bold = _extends({}, boldInit, {
|
|
27
27
|
buttonProps: {
|
|
28
28
|
'aria-label': '添加粗体文本(ctrl + b)',
|
package/esm/commands/index.d.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 { bold } from './bold';
|
|
4
4
|
import { code, codeBlock } from './code';
|
|
5
5
|
import { comment } from './comment';
|
package/esm/commands/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { insertTextAtPosition } from
|
|
3
|
-
import { bold } from
|
|
4
|
-
import { code, codeBlock } from
|
|
5
|
-
import { comment } from
|
|
6
|
-
import { divider } from
|
|
7
|
-
import { fullscreen } from
|
|
8
|
-
import { group } from
|
|
9
|
-
import { hr } from
|
|
10
|
-
import { image } from
|
|
11
|
-
import { italic } from
|
|
12
|
-
import { link } from
|
|
13
|
-
import { checkedListCommand, orderedListCommand, unorderedListCommand } from
|
|
14
|
-
import { codeEdit, codeLive, codePreview } from
|
|
15
|
-
import { quote } from
|
|
16
|
-
import { strikethrough } from
|
|
17
|
-
import { title } from
|
|
18
|
-
import { title1 } from
|
|
19
|
-
import { title2 } from
|
|
20
|
-
import { title3 } from
|
|
21
|
-
import { title4 } from
|
|
22
|
-
import { title5 } from
|
|
23
|
-
import { title6 } from
|
|
24
|
-
import { table } from
|
|
25
|
-
import { issue } from
|
|
26
|
-
import { help } from
|
|
2
|
+
import { insertTextAtPosition } from "../utils/InsertTextAtPosition.js";
|
|
3
|
+
import { bold } from "./bold.js";
|
|
4
|
+
import { code, codeBlock } from "./code.js";
|
|
5
|
+
import { comment } from "./comment.js";
|
|
6
|
+
import { divider } from "./divider.js";
|
|
7
|
+
import { fullscreen } from "./fullscreen.js";
|
|
8
|
+
import { group } from "./group.js";
|
|
9
|
+
import { hr } from "./hr.js";
|
|
10
|
+
import { image } from "./image.js";
|
|
11
|
+
import { italic } from "./italic.js";
|
|
12
|
+
import { link } from "./link.js";
|
|
13
|
+
import { checkedListCommand, orderedListCommand, unorderedListCommand } from "./list.js";
|
|
14
|
+
import { codeEdit, codeLive, codePreview } from "./preview.js";
|
|
15
|
+
import { quote } from "./quote.js";
|
|
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";
|
|
24
|
+
import { table } from "./table.js";
|
|
25
|
+
import { issue } from "./issue.js";
|
|
26
|
+
import { help } from "./help.js";
|
|
27
27
|
var getCommands = () => [bold, italic, strikethrough, hr, group([title1, title2, title3, title4, title5, title6], {
|
|
28
28
|
name: 'title',
|
|
29
29
|
groupName: 'title',
|
package/esm/commands/issue.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const issue: ICommand;
|
package/esm/commands/issue.js
CHANGED
package/esm/commands/italic.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const italic: ICommand;
|
package/esm/commands/italic.js
CHANGED
package/esm/commands/link.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const link: ICommand;
|
package/esm/commands/link.js
CHANGED
package/esm/commands/list.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
1
|
+
import { type ICommand, type ExecuteState, TextAreaTextApi } from './';
|
|
2
2
|
import { AlterLineFunction } from '../utils/markdownUtils';
|
|
3
3
|
export declare const makeList: (state: ExecuteState, api: TextAreaTextApi, insertBefore: string | AlterLineFunction) => void;
|
|
4
4
|
export declare const unorderedListCommand: ICommand;
|
package/esm/commands/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, insertBeforeEachLine } from
|
|
2
|
+
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, insertBeforeEachLine } from "../utils/markdownUtils.js";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var makeList = (state, api, insertBefore) => {
|
|
5
5
|
var newSelectionRange = selectWord({
|
package/esm/commands/quote.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { type ICommand } from './';
|
|
2
2
|
export declare const quote: ICommand;
|
package/esm/commands/quote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord, insertBeforeEachLine } from
|
|
2
|
+
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord, insertBeforeEachLine } from "../utils/markdownUtils.js";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var quote = {
|
|
5
5
|
name: 'quote',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord, executeCommand } from
|
|
2
|
+
import { selectWord, executeCommand } from "../utils/markdownUtils.js";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var strikethrough = {
|
|
5
5
|
name: 'strikethrough',
|
package/esm/commands/table.js
CHANGED
package/esm/commands/title.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { title1 } from
|
|
4
|
-
import { selectLine, executeCommand } from
|
|
3
|
+
import { title1 } from "./title1.js";
|
|
4
|
+
import { selectLine, executeCommand } from "../utils/markdownUtils.js";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export function titleExecute(_ref) {
|
|
7
7
|
var {
|
package/esm/commands/title1.js
CHANGED
package/esm/commands/title2.js
CHANGED
package/esm/commands/title3.js
CHANGED
package/esm/commands/title4.js
CHANGED
package/esm/commands/title5.js
CHANGED
package/esm/commands/title6.js
CHANGED
|
@@ -3,7 +3,7 @@ var _templateObject;
|
|
|
3
3
|
import React, { useContext, useEffect } from 'react';
|
|
4
4
|
import { rehype } from 'rehype';
|
|
5
5
|
import rehypePrism from 'rehype-prism-plus';
|
|
6
|
-
import { EditorContext } from
|
|
6
|
+
import { EditorContext } from "../../Context.js";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
function html2Escape(sHtml) {
|
|
9
9
|
return sHtml
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
import { EditorContext } from
|
|
7
|
-
import { TextAreaCommandOrchestrator } from
|
|
8
|
-
import handleKeyDown from
|
|
9
|
-
import shortcuts from
|
|
6
|
+
import { EditorContext } from "../../Context.js";
|
|
7
|
+
import { TextAreaCommandOrchestrator } from "../../commands/index.js";
|
|
8
|
+
import handleKeyDown from "./handleKeyDown.js";
|
|
9
|
+
import shortcuts from "./shortcuts.js";
|
|
10
10
|
import "./index.css";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
export default function Textarea(props) {
|
|
@@ -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);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { insertTextAtPosition } from
|
|
2
|
-
import { insertBeforeEachLine, selectLine } from
|
|
3
|
-
import { TextAreaTextApi } from
|
|
4
|
-
|
|
1
|
+
import { insertTextAtPosition } from "../../utils/InsertTextAtPosition.js";
|
|
2
|
+
import { insertBeforeEachLine, selectLine } from "../../utils/markdownUtils.js";
|
|
3
|
+
import { TextAreaTextApi } from "../../commands/index.js";
|
|
5
4
|
/**
|
|
6
5
|
* - `13` - `Enter`
|
|
7
6
|
* - `9` - `Tab`
|
|
@@ -2,7 +2,7 @@ import React, { JSX } from 'react';
|
|
|
2
2
|
import { ContextStore, ExecuteCommandState } from '../../Context';
|
|
3
3
|
import { TextAreaProps } from './Textarea';
|
|
4
4
|
import { IProps } from '../../Types';
|
|
5
|
-
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
5
|
+
import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
|
|
6
6
|
import './index.less';
|
|
7
7
|
type RenderTextareaHandle = {
|
|
8
8
|
dispatch: ContextStore['dispatch'];
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
var _excluded = ["prefixCls", "className", "onScroll", "renderTextarea"];
|
|
4
4
|
import React, { useEffect, Fragment, useContext } from 'react';
|
|
5
|
-
import { EditorContext } from
|
|
6
|
-
import shortcuts from
|
|
7
|
-
import Markdown from
|
|
8
|
-
import Textarea from
|
|
9
|
-
import { TextAreaCommandOrchestrator } from
|
|
5
|
+
import { EditorContext } from "../../Context.js";
|
|
6
|
+
import shortcuts from "./shortcuts.js";
|
|
7
|
+
import Markdown from "./Markdown.js";
|
|
8
|
+
import Textarea from "./Textarea.js";
|
|
9
|
+
import { TextAreaCommandOrchestrator } from "../../commands/index.js";
|
|
10
10
|
import "./index.css";
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
export default function TextArea(props) {
|
|
@@ -2,7 +2,7 @@ import React, { JSX } from 'react';
|
|
|
2
2
|
import { ContextStore, ExecuteCommandState } from '../../Context';
|
|
3
3
|
import { TextAreaProps } from './Textarea';
|
|
4
4
|
import { IProps } from '../../Types';
|
|
5
|
-
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
5
|
+
import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
|
|
6
6
|
import './index.less';
|
|
7
7
|
type RenderTextareaHandle = {
|
|
8
8
|
dispatch: ContextStore['dispatch'];
|