@uiw/react-md-editor 3.20.10 → 3.21.1

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/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;
@@ -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> {
@@ -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
- markdown,
19
- commands,
20
- fullscreen,
21
- preview,
22
- highlightEnable,
23
- extraCommands,
24
- tabSize,
25
- defaultTabEnable,
26
- dispatch
27
- } = useContext(EditorContext);
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({
@@ -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 {};
@@ -5,4 +5,4 @@ export type ChildProps = IToolbarProps & {
5
5
  children?: JSX.Element;
6
6
  groupName?: string;
7
7
  };
8
- export default function Child(props: ChildProps): JSX.Element;
8
+ export default function Child(props: ChildProps): import("react/jsx-runtime").JSX.Element;
@@ -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;
@@ -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> {
@@ -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({
@@ -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 {};
@@ -5,4 +5,4 @@ export type ChildProps = IToolbarProps & {
5
5
  children?: JSX.Element;
6
6
  groupName?: string;
7
7
  };
8
- export default function Child(props: ChildProps): JSX.Element;
8
+ export default function Child(props: ChildProps): import("react/jsx-runtime").JSX.Element;
@@ -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.20.10",
3
+ "version": "3.21.1",
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
@@ -25,6 +25,7 @@ export interface ContextStore {
25
25
  scrollTopPreview?: number;
26
26
  tabSize?: number;
27
27
  defaultTabEnable?: boolean;
28
+ [key: string]: any;
28
29
  }
29
30
 
30
31
  export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
@@ -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>();
@@ -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';