@uiw/react-md-editor 3.20.10 → 3.21.0
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 +44 -24
- package/dist/mdeditor.js +1110 -566
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +2 -0
- package/esm/commands/index.d.ts +1 -0
- package/esm/commands/index.js +1 -0
- package/esm/components/TextArea/Markdown.d.ts +1 -1
- package/esm/components/TextArea/Textarea.d.ts +1 -1
- package/esm/components/TextArea/Textarea.js +16 -12
- package/esm/components/TextArea/index.d.ts +1 -1
- package/esm/components/Toolbar/Child.d.ts +1 -1
- package/esm/components/Toolbar/index.d.ts +2 -3
- package/esm/components/Toolbar/index.js +2 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/lib/Context.d.ts +2 -0
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/components/TextArea/Markdown.d.ts +1 -1
- package/lib/components/TextArea/Textarea.d.ts +1 -1
- package/lib/components/TextArea/Textarea.js +5 -2
- package/lib/components/TextArea/index.d.ts +1 -1
- package/lib/components/Toolbar/Child.d.ts +1 -1
- package/lib/components/Toolbar/index.d.ts +2 -3
- package/lib/components/Toolbar/index.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/package.json +1 -1
- package/src/Context.tsx +1 -0
- package/src/commands/index.ts +2 -0
- package/src/components/TextArea/Textarea.tsx +2 -0
- package/src/components/Toolbar/index.tsx +1 -0
- package/src/index.tsx +1 -0
package/esm/Context.d.ts
CHANGED
|
@@ -23,9 +23,11 @@ export interface ContextStore {
|
|
|
23
23
|
scrollTopPreview?: number;
|
|
24
24
|
tabSize?: number;
|
|
25
25
|
defaultTabEnable?: boolean;
|
|
26
|
+
[key: string]: any;
|
|
26
27
|
}
|
|
27
28
|
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
28
29
|
export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
30
|
+
[x: string]: any;
|
|
29
31
|
components?: {
|
|
30
32
|
textarea?: ((props: React.HTMLAttributes<HTMLDivElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>, opts: {
|
|
31
33
|
dispatch: React.Dispatch<ContextStore> | undefined;
|
package/esm/commands/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface ICommandChildHandle<T = string> extends ICommandBase<T> {
|
|
|
30
30
|
execute: () => void;
|
|
31
31
|
getState?: TextAreaCommandOrchestrator['getState'];
|
|
32
32
|
textApi?: TextAreaTextApi;
|
|
33
|
+
dispatch?: React.Dispatch<ContextStore>;
|
|
33
34
|
}) => React.ReactElement;
|
|
34
35
|
}
|
|
35
36
|
export interface ICommandChildCommands<T = string> extends ICommandBase<T> {
|
package/esm/commands/index.js
CHANGED
|
@@ -80,6 +80,7 @@ class TextAreaCommandOrchestrator {
|
|
|
80
80
|
return getStateFromTextArea(this.textArea);
|
|
81
81
|
}
|
|
82
82
|
executeCommand(command, dispatch, state, shortcuts) {
|
|
83
|
+
console.log('state:', state);
|
|
83
84
|
command.execute && command.execute(_extends({
|
|
84
85
|
command
|
|
85
86
|
}, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
|
|
@@ -2,4 +2,4 @@ import React from 'react';
|
|
|
2
2
|
import { IProps } from '../../Editor';
|
|
3
3
|
export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {
|
|
4
4
|
}
|
|
5
|
-
export default function Markdown(props: MarkdownProps): JSX.Element;
|
|
5
|
+
export default function Markdown(props: MarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { IProps } from '../../Editor';
|
|
|
3
3
|
import './index.less';
|
|
4
4
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {
|
|
5
5
|
}
|
|
6
|
-
export default function Textarea(props: TextAreaProps): JSX.Element;
|
|
6
|
+
export default function Textarea(props: TextAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["prefixCls", "onChange"]
|
|
3
|
+
var _excluded = ["prefixCls", "onChange"],
|
|
4
|
+
_excluded2 = ["markdown", "commands", "fullscreen", "preview", "highlightEnable", "extraCommands", "tabSize", "defaultTabEnable", "dispatch"];
|
|
4
5
|
import React, { useContext, useEffect } from 'react';
|
|
5
6
|
import { EditorContext } from '../../Context';
|
|
6
7
|
import { TextAreaCommandOrchestrator } from '../../commands';
|
|
@@ -14,17 +15,19 @@ export default function Textarea(props) {
|
|
|
14
15
|
onChange: _onChange
|
|
15
16
|
} = props,
|
|
16
17
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
var _useContext = useContext(EditorContext),
|
|
19
|
+
{
|
|
20
|
+
markdown,
|
|
21
|
+
commands,
|
|
22
|
+
fullscreen,
|
|
23
|
+
preview,
|
|
24
|
+
highlightEnable,
|
|
25
|
+
extraCommands,
|
|
26
|
+
tabSize,
|
|
27
|
+
defaultTabEnable,
|
|
28
|
+
dispatch
|
|
29
|
+
} = _useContext,
|
|
30
|
+
otherStore = _objectWithoutPropertiesLoose(_useContext, _excluded2);
|
|
28
31
|
var textRef = React.useRef(null);
|
|
29
32
|
var executeRef = React.useRef();
|
|
30
33
|
var statesRef = React.useRef({
|
|
@@ -51,6 +54,7 @@ export default function Textarea(props) {
|
|
|
51
54
|
}, []);
|
|
52
55
|
var onKeyDown = e => {
|
|
53
56
|
handleKeyDown(e, tabSize, defaultTabEnable);
|
|
57
|
+
console.log('otherStore:', otherStore);
|
|
54
58
|
shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);
|
|
55
59
|
};
|
|
56
60
|
useEffect(() => {
|
|
@@ -23,5 +23,5 @@ export type TextAreaRef = {
|
|
|
23
23
|
text?: HTMLTextAreaElement;
|
|
24
24
|
warp?: HTMLDivElement;
|
|
25
25
|
};
|
|
26
|
-
export default function TextArea(props: ITextAreaProps): JSX.Element;
|
|
26
|
+
export default function TextArea(props: ITextAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IProps } from '../../Editor';
|
|
3
2
|
import { ICommand } from '../../commands';
|
|
4
3
|
import './index.less';
|
|
@@ -9,5 +8,5 @@ export interface IToolbarProps extends IProps {
|
|
|
9
8
|
commands?: ICommand<string>[];
|
|
10
9
|
isChild?: boolean;
|
|
11
10
|
}
|
|
12
|
-
export declare function ToolbarItems(props: IToolbarProps): JSX.Element;
|
|
13
|
-
export default function Toolbar(props?: IToolbarProps): JSX.Element;
|
|
11
|
+
export declare function ToolbarItems(props: IToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function Toolbar(props?: IToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -78,7 +78,8 @@ export function ToolbarItems(props) {
|
|
|
78
78
|
close: () => handleClick({}, item.groupName),
|
|
79
79
|
execute: () => handleClick({
|
|
80
80
|
execute: item.execute
|
|
81
|
-
})
|
|
81
|
+
}),
|
|
82
|
+
dispatch
|
|
82
83
|
}) : undefined;
|
|
83
84
|
var disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);
|
|
84
85
|
var render = (components == null ? void 0 : components.toolbar) || item.render;
|
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
|
export * from './commands';
|
|
5
|
+
export * from './commands/group';
|
|
5
6
|
export * from './utils/markdownUtils';
|
|
6
7
|
export * from './utils/InsertTextAtPosition';
|
|
7
8
|
export * from './Editor';
|
package/esm/index.js
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
|
export * from './commands';
|
|
5
|
+
export * from './commands/group';
|
|
5
6
|
export * from './utils/markdownUtils';
|
|
6
7
|
export * from './utils/InsertTextAtPosition';
|
|
7
8
|
export * from './Editor';
|
package/lib/Context.d.ts
CHANGED
|
@@ -23,9 +23,11 @@ export interface ContextStore {
|
|
|
23
23
|
scrollTopPreview?: number;
|
|
24
24
|
tabSize?: number;
|
|
25
25
|
defaultTabEnable?: boolean;
|
|
26
|
+
[key: string]: any;
|
|
26
27
|
}
|
|
27
28
|
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
28
29
|
export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
30
|
+
[x: string]: any;
|
|
29
31
|
components?: {
|
|
30
32
|
textarea?: ((props: React.HTMLAttributes<HTMLDivElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>, opts: {
|
|
31
33
|
dispatch: React.Dispatch<ContextStore> | undefined;
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface ICommandChildHandle<T = string> extends ICommandBase<T> {
|
|
|
30
30
|
execute: () => void;
|
|
31
31
|
getState?: TextAreaCommandOrchestrator['getState'];
|
|
32
32
|
textApi?: TextAreaTextApi;
|
|
33
|
+
dispatch?: React.Dispatch<ContextStore>;
|
|
33
34
|
}) => React.ReactElement;
|
|
34
35
|
}
|
|
35
36
|
export interface ICommandChildCommands<T = string> extends ICommandBase<T> {
|
package/lib/commands/index.js
CHANGED
|
@@ -267,6 +267,7 @@ var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
|
|
|
267
267
|
}, {
|
|
268
268
|
key: "executeCommand",
|
|
269
269
|
value: function executeCommand(command, dispatch, state, shortcuts) {
|
|
270
|
+
console.log('state:', state);
|
|
270
271
|
command.execute && command.execute((0, _objectSpread2["default"])({
|
|
271
272
|
command: command
|
|
272
273
|
}, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
|
|
@@ -2,4 +2,4 @@ import React from 'react';
|
|
|
2
2
|
import { IProps } from '../../Editor';
|
|
3
3
|
export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {
|
|
4
4
|
}
|
|
5
|
-
export default function Markdown(props: MarkdownProps): JSX.Element;
|
|
5
|
+
export default function Markdown(props: MarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { IProps } from '../../Editor';
|
|
|
3
3
|
import './index.less';
|
|
4
4
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {
|
|
5
5
|
}
|
|
6
|
-
export default function Textarea(props: TextAreaProps): JSX.Element;
|
|
6
|
+
export default function Textarea(props: TextAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,7 +15,8 @@ var _commands = require("../../commands");
|
|
|
15
15
|
var _handleKeyDown = _interopRequireDefault(require("./handleKeyDown"));
|
|
16
16
|
var _shortcuts = _interopRequireDefault(require("./shortcuts"));
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
var _excluded = ["prefixCls", "onChange"]
|
|
18
|
+
var _excluded = ["prefixCls", "onChange"],
|
|
19
|
+
_excluded2 = ["markdown", "commands", "fullscreen", "preview", "highlightEnable", "extraCommands", "tabSize", "defaultTabEnable", "dispatch"];
|
|
19
20
|
function Textarea(props) {
|
|
20
21
|
var prefixCls = props.prefixCls,
|
|
21
22
|
_onChange = props.onChange,
|
|
@@ -29,7 +30,8 @@ function Textarea(props) {
|
|
|
29
30
|
extraCommands = _useContext.extraCommands,
|
|
30
31
|
tabSize = _useContext.tabSize,
|
|
31
32
|
defaultTabEnable = _useContext.defaultTabEnable,
|
|
32
|
-
dispatch = _useContext.dispatch
|
|
33
|
+
dispatch = _useContext.dispatch,
|
|
34
|
+
otherStore = (0, _objectWithoutProperties2["default"])(_useContext, _excluded2);
|
|
33
35
|
var textRef = _react["default"].useRef(null);
|
|
34
36
|
var executeRef = _react["default"].useRef();
|
|
35
37
|
var statesRef = _react["default"].useRef({
|
|
@@ -56,6 +58,7 @@ function Textarea(props) {
|
|
|
56
58
|
}, []);
|
|
57
59
|
var onKeyDown = function onKeyDown(e) {
|
|
58
60
|
(0, _handleKeyDown["default"])(e, tabSize, defaultTabEnable);
|
|
61
|
+
console.log('otherStore:', otherStore);
|
|
59
62
|
(0, _shortcuts["default"])(e, [].concat((0, _toConsumableArray2["default"])(commands || []), (0, _toConsumableArray2["default"])(extraCommands || [])), executeRef.current, dispatch, statesRef.current);
|
|
60
63
|
};
|
|
61
64
|
(0, _react.useEffect)(function () {
|
|
@@ -23,5 +23,5 @@ export type TextAreaRef = {
|
|
|
23
23
|
text?: HTMLTextAreaElement;
|
|
24
24
|
warp?: HTMLDivElement;
|
|
25
25
|
};
|
|
26
|
-
export default function TextArea(props: ITextAreaProps): JSX.Element;
|
|
26
|
+
export default function TextArea(props: ITextAreaProps): import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IProps } from '../../Editor';
|
|
3
2
|
import { ICommand } from '../../commands';
|
|
4
3
|
import './index.less';
|
|
@@ -9,5 +8,5 @@ export interface IToolbarProps extends IProps {
|
|
|
9
8
|
commands?: ICommand<string>[];
|
|
10
9
|
isChild?: boolean;
|
|
11
10
|
}
|
|
12
|
-
export declare function ToolbarItems(props: IToolbarProps): JSX.Element;
|
|
13
|
-
export default function Toolbar(props?: IToolbarProps): JSX.Element;
|
|
11
|
+
export declare function ToolbarItems(props: IToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function Toolbar(props?: IToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -89,7 +89,8 @@ function ToolbarItems(props) {
|
|
|
89
89
|
return handleClick({
|
|
90
90
|
execute: item.execute
|
|
91
91
|
});
|
|
92
|
-
}
|
|
92
|
+
},
|
|
93
|
+
dispatch: dispatch
|
|
93
94
|
}) : undefined;
|
|
94
95
|
var disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);
|
|
95
96
|
var render = (components === null || components === void 0 ? void 0 : components.toolbar) || item.render;
|
package/lib/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
|
export * from './commands';
|
|
5
|
+
export * from './commands/group';
|
|
5
6
|
export * from './utils/markdownUtils';
|
|
6
7
|
export * from './utils/InsertTextAtPosition';
|
|
7
8
|
export * from './Editor';
|
package/lib/index.js
CHANGED
|
@@ -47,6 +47,18 @@ Object.keys(MarkdownUtil).forEach(function (key) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
var _group = require("./commands/group");
|
|
51
|
+
Object.keys(_group).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
54
|
+
if (key in exports && exports[key] === _group[key]) return;
|
|
55
|
+
Object.defineProperty(exports, key, {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _group[key];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
50
62
|
var _InsertTextAtPosition = require("./utils/InsertTextAtPosition");
|
|
51
63
|
Object.keys(_InsertTextAtPosition).forEach(function (key) {
|
|
52
64
|
if (key === "default" || key === "__esModule") return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
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/Context.tsx
CHANGED
package/src/commands/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface ICommandChildHandle<T = string> extends ICommandBase<T> {
|
|
|
33
33
|
execute: () => void;
|
|
34
34
|
getState?: TextAreaCommandOrchestrator['getState'];
|
|
35
35
|
textApi?: TextAreaTextApi;
|
|
36
|
+
dispatch?: React.Dispatch<ContextStore>;
|
|
36
37
|
}) => React.ReactElement;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -166,6 +167,7 @@ class TextAreaCommandOrchestrator implements CommandOrchestrator {
|
|
|
166
167
|
state?: ExecuteCommandState,
|
|
167
168
|
shortcuts?: string[],
|
|
168
169
|
): void {
|
|
170
|
+
console.log('state:', state);
|
|
169
171
|
command.execute &&
|
|
170
172
|
command.execute({ command, ...getStateFromTextArea(this.textArea) }, this.textApi, dispatch, state, shortcuts);
|
|
171
173
|
}
|
|
@@ -20,6 +20,7 @@ export default function Textarea(props: TextAreaProps) {
|
|
|
20
20
|
tabSize,
|
|
21
21
|
defaultTabEnable,
|
|
22
22
|
dispatch,
|
|
23
|
+
...otherStore
|
|
23
24
|
} = useContext(EditorContext);
|
|
24
25
|
const textRef = React.useRef<HTMLTextAreaElement>(null);
|
|
25
26
|
const executeRef = React.useRef<TextAreaCommandOrchestrator>();
|
|
@@ -40,6 +41,7 @@ export default function Textarea(props: TextAreaProps) {
|
|
|
40
41
|
|
|
41
42
|
const onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
42
43
|
handleKeyDown(e, tabSize, defaultTabEnable);
|
|
44
|
+
console.log('otherStore:', otherStore);
|
|
43
45
|
shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);
|
|
44
46
|
};
|
|
45
47
|
useEffect(() => {
|
|
@@ -79,6 +79,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
79
79
|
textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,
|
|
80
80
|
close: () => handleClick({}, item.groupName),
|
|
81
81
|
execute: () => handleClick({ execute: item.execute }),
|
|
82
|
+
dispatch,
|
|
82
83
|
})
|
|
83
84
|
: undefined;
|
|
84
85
|
const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);
|
package/src/index.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import * as commands from './commands';
|
|
|
3
3
|
import * as MarkdownUtil from './utils/markdownUtils';
|
|
4
4
|
|
|
5
5
|
export * from './commands';
|
|
6
|
+
export * from './commands/group';
|
|
6
7
|
export * from './utils/markdownUtils';
|
|
7
8
|
export * from './utils/InsertTextAtPosition';
|
|
8
9
|
export * from './Editor';
|