@uiw/react-md-editor 4.0.8 → 4.0.9

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 (39) hide show
  1. package/README.md +95 -28
  2. package/dist/mdeditor.css +1 -1
  3. package/dist/mdeditor.js +178 -222
  4. package/dist/mdeditor.min.js +1 -1
  5. package/esm/Editor.d.ts +1 -1
  6. package/esm/Editor.nohighlight.d.ts +1 -1
  7. package/esm/components/DragBar/index.d.ts +1 -1
  8. package/esm/components/TextArea/Markdown.d.ts +1 -1
  9. package/esm/components/TextArea/Textarea.d.ts +1 -1
  10. package/esm/components/TextArea/index.d.ts +4 -4
  11. package/esm/components/TextArea/index.nohighlight.d.ts +3 -3
  12. package/esm/components/Toolbar/Child.d.ts +1 -1
  13. package/esm/components/Toolbar/index.d.ts +1 -1
  14. package/esm/index.css +1 -0
  15. package/esm/index.d.ts +2 -0
  16. package/esm/index.js +2 -0
  17. package/lib/Editor.d.ts +1 -1
  18. package/lib/Editor.nohighlight.d.ts +1 -1
  19. package/lib/components/DragBar/index.d.ts +1 -1
  20. package/lib/components/TextArea/Markdown.d.ts +1 -1
  21. package/lib/components/TextArea/Textarea.d.ts +1 -1
  22. package/lib/components/TextArea/index.d.ts +4 -4
  23. package/lib/components/TextArea/index.nohighlight.d.ts +3 -3
  24. package/lib/components/Toolbar/Child.d.ts +1 -1
  25. package/lib/components/Toolbar/index.d.ts +1 -1
  26. package/lib/index.d.ts +2 -0
  27. package/lib/index.js +18 -1
  28. package/markdown-editor.css +1 -0
  29. package/package.json +1 -1
  30. package/src/Editor.nohighlight.tsx +2 -2
  31. package/src/Editor.tsx +3 -3
  32. package/src/components/DragBar/index.tsx +1 -1
  33. package/src/components/TextArea/Markdown.tsx +1 -1
  34. package/src/components/TextArea/Textarea.tsx +2 -2
  35. package/src/components/TextArea/index.nohighlight.tsx +5 -4
  36. package/src/components/TextArea/index.tsx +6 -5
  37. package/src/components/Toolbar/Child.tsx +1 -1
  38. package/src/components/Toolbar/index.tsx +2 -2
  39. package/src/index.tsx +2 -0
package/esm/Editor.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import MarkdownPreview from '@uiw/react-markdown-preview';
3
- import { ContextStore } from './Context';
3
+ import { type ContextStore } from './Context';
4
4
  import type { MDEditorProps } from './Types';
5
5
  export interface RefMDEditor extends ContextStore {
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import MarkdownPreview from '@uiw/react-markdown-preview/nohighlight';
3
- import { ContextStore } from './Context';
3
+ import { type ContextStore } from './Context';
4
4
  import type { MDEditorProps } from './Types';
5
5
  export interface RefMDEditor extends ContextStore {
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  import './index.less';
4
4
  export interface IDragBarProps extends IProps {
5
5
  height: number;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {
4
4
  }
5
5
  export default function Markdown(props: MarkdownProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  import './index.less';
4
4
  export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import React, { JSX } from 'react';
2
- import { ContextStore, ExecuteCommandState } from '../../Context';
3
- import { TextAreaProps } from './Textarea';
4
- import { IProps } from '../../Types';
5
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
2
+ import { type ContextStore, type ExecuteCommandState } from '../../Context';
3
+ import { type TextAreaProps } from './Textarea';
4
+ import { type IProps } from '../../Types';
5
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
6
6
  import './index.less';
7
7
  type RenderTextareaHandle = {
8
8
  dispatch: ContextStore['dispatch'];
@@ -1,8 +1,8 @@
1
1
  import React, { JSX } from 'react';
2
- import { ContextStore, ExecuteCommandState } from '../../Context';
2
+ import { type ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import { TextAreaProps } from './Textarea';
4
- import { IProps } from '../../Types';
5
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
4
+ import { type IProps } from '../../Types';
5
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
6
6
  import './index.less';
7
7
  type RenderTextareaHandle = {
8
8
  dispatch: ContextStore['dispatch'];
@@ -1,4 +1,4 @@
1
- import { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import './Child.less';
3
3
  import { type IToolbarProps } from './';
4
4
  export type ChildProps = IToolbarProps & {
@@ -1,4 +1,4 @@
1
- import { IProps } from '../../Types';
1
+ import { type IProps } from '../../Types';
2
2
  import { ICommand } from '../../commands/';
3
3
  import './index.less';
4
4
  export interface IToolbarProps extends IProps {
package/esm/index.css CHANGED
@@ -27,6 +27,7 @@
27
27
  text-align: right !important;
28
28
  }
29
29
  .w-md-editor-toolbar {
30
+ height: -webkit-fit-content;
30
31
  height: fit-content;
31
32
  }
32
33
  .w-md-editor-content {
package/esm/index.d.ts CHANGED
@@ -10,5 +10,7 @@ export * from './utils/InsertTextAtPosition';
10
10
  export * from './Editor';
11
11
  export * from './Context';
12
12
  export * from './Types';
13
+ export { default as handleKeyDown } from './components/TextArea/handleKeyDown';
14
+ export { default as shortcuts } from './components/TextArea/shortcuts';
13
15
  export { MarkdownUtil, commands };
14
16
  export default MDEditor;
package/esm/index.js CHANGED
@@ -10,5 +10,7 @@ export * from "./utils/InsertTextAtPosition.js";
10
10
  export * from "./Editor.js";
11
11
  export * from "./Context.js";
12
12
  export * from "./Types.js";
13
+ export { default as handleKeyDown } from "./components/TextArea/handleKeyDown.js";
14
+ export { default as shortcuts } from "./components/TextArea/shortcuts.js";
13
15
  export { MarkdownUtil, commands };
14
16
  export default MDEditor;
package/lib/Editor.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import MarkdownPreview from '@uiw/react-markdown-preview';
3
- import { ContextStore } from './Context';
3
+ import { type ContextStore } from './Context';
4
4
  import type { MDEditorProps } from './Types';
5
5
  export interface RefMDEditor extends ContextStore {
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import MarkdownPreview from '@uiw/react-markdown-preview/nohighlight';
3
- import { ContextStore } from './Context';
3
+ import { type ContextStore } from './Context';
4
4
  import type { MDEditorProps } from './Types';
5
5
  export interface RefMDEditor extends ContextStore {
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  import './index.less';
4
4
  export interface IDragBarProps extends IProps {
5
5
  height: number;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {
4
4
  }
5
5
  export default function Markdown(props: MarkdownProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  import './index.less';
4
4
  export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import React, { JSX } from 'react';
2
- import { ContextStore, ExecuteCommandState } from '../../Context';
3
- import { TextAreaProps } from './Textarea';
4
- import { IProps } from '../../Types';
5
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
2
+ import { type ContextStore, type ExecuteCommandState } from '../../Context';
3
+ import { type TextAreaProps } from './Textarea';
4
+ import { type IProps } from '../../Types';
5
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
6
6
  import './index.less';
7
7
  type RenderTextareaHandle = {
8
8
  dispatch: ContextStore['dispatch'];
@@ -1,8 +1,8 @@
1
1
  import React, { JSX } from 'react';
2
- import { ContextStore, ExecuteCommandState } from '../../Context';
2
+ import { type ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import { TextAreaProps } from './Textarea';
4
- import { IProps } from '../../Types';
5
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
4
+ import { type IProps } from '../../Types';
5
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
6
6
  import './index.less';
7
7
  type RenderTextareaHandle = {
8
8
  dispatch: ContextStore['dispatch'];
@@ -1,4 +1,4 @@
1
- import { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import './Child.less';
3
3
  import { type IToolbarProps } from './';
4
4
  export type ChildProps = IToolbarProps & {
@@ -1,4 +1,4 @@
1
- import { IProps } from '../../Types';
1
+ import { type IProps } from '../../Types';
2
2
  import { ICommand } from '../../commands/';
3
3
  import './index.less';
4
4
  export interface IToolbarProps extends IProps {
package/lib/index.d.ts CHANGED
@@ -10,5 +10,7 @@ export * from './utils/InsertTextAtPosition';
10
10
  export * from './Editor';
11
11
  export * from './Context';
12
12
  export * from './Types';
13
+ export { default as handleKeyDown } from './components/TextArea/handleKeyDown';
14
+ export { default as shortcuts } from './components/TextArea/shortcuts';
13
15
  export { MarkdownUtil, commands };
14
16
  export default MDEditor;
package/lib/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
@@ -7,15 +8,29 @@ Object.defineProperty(exports, "__esModule", {
7
8
  var _exportNames = {
8
9
  commands: true,
9
10
  MarkdownUtil: true,
10
- headingExecute: true
11
+ headingExecute: true,
12
+ handleKeyDown: true,
13
+ shortcuts: true
11
14
  };
12
15
  exports["default"] = exports.commands = exports.MarkdownUtil = void 0;
16
+ Object.defineProperty(exports, "handleKeyDown", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _handleKeyDown["default"];
20
+ }
21
+ });
13
22
  Object.defineProperty(exports, "headingExecute", {
14
23
  enumerable: true,
15
24
  get: function get() {
16
25
  return _title.headingExecute;
17
26
  }
18
27
  });
28
+ Object.defineProperty(exports, "shortcuts", {
29
+ enumerable: true,
30
+ get: function get() {
31
+ return _shortcuts["default"];
32
+ }
33
+ });
19
34
  var _Editor = _interopRequireWildcard(require("./Editor"));
20
35
  Object.keys(_Editor).forEach(function (key) {
21
36
  if (key === "default" || key === "__esModule") return;
@@ -103,4 +118,6 @@ Object.keys(_Types).forEach(function (key) {
103
118
  }
104
119
  });
105
120
  });
121
+ var _handleKeyDown = _interopRequireDefault(require("./components/TextArea/handleKeyDown"));
122
+ var _shortcuts = _interopRequireDefault(require("./components/TextArea/shortcuts"));
106
123
  var _default = exports["default"] = _Editor["default"];
@@ -271,6 +271,7 @@
271
271
  text-align: right !important;
272
272
  }
273
273
  .w-md-editor-toolbar {
274
+ height: -webkit-fit-content;
274
275
  height: fit-content;
275
276
  }
276
277
  .w-md-editor-content {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
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
  "funding": "https://jaywcjlove.github.io/#/sponsor",
@@ -3,8 +3,8 @@ import MarkdownPreview from '@uiw/react-markdown-preview/nohighlight';
3
3
  import TextArea from './components/TextArea/index.nohighlight';
4
4
  import { ToolbarVisibility } from './components/Toolbar/';
5
5
  import DragBar from './components/DragBar/';
6
- import { getCommands, getExtraCommands, ICommand, TextState, TextAreaCommandOrchestrator } from './commands/';
7
- import { reducer, EditorContext, ContextStore } from './Context';
6
+ import { getCommands, getExtraCommands, type ICommand, type TextState, TextAreaCommandOrchestrator } from './commands/';
7
+ import { reducer, EditorContext, type ContextStore } from './Context';
8
8
  import type { MDEditorProps } from './Types';
9
9
 
10
10
  function setGroupPopFalse(data: Record<string, boolean> = {}) {
package/src/Editor.tsx CHANGED
@@ -1,10 +1,10 @@
1
- import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, Fragment } from 'react';
1
+ import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
2
2
  import MarkdownPreview from '@uiw/react-markdown-preview';
3
3
  import { ToolbarVisibility } from './components/Toolbar/';
4
4
  import TextArea from './components/TextArea/';
5
5
  import DragBar from './components/DragBar/';
6
- import { getCommands, getExtraCommands, ICommand, TextState, TextAreaCommandOrchestrator } from './commands/';
7
- import { reducer, EditorContext, ContextStore } from './Context';
6
+ import { getCommands, getExtraCommands, type ICommand, type TextState, TextAreaCommandOrchestrator } from './commands/';
7
+ import { reducer, EditorContext, type ContextStore } from './Context';
8
8
  import type { MDEditorProps } from './Types';
9
9
 
10
10
  function setGroupPopFalse(data: Record<string, boolean> = {}) {
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useMemo, useRef } from 'react';
2
- import { IProps } from '../../Types';
2
+ import { type IProps } from '../../Types';
3
3
  import './index.less';
4
4
 
5
5
  export interface IDragBarProps extends IProps {
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect } from 'react';
2
2
  import { rehype } from 'rehype';
3
3
  import rehypePrism from 'rehype-prism-plus';
4
- import { IProps } from '../../Types';
4
+ import { type IProps } from '../../Types';
5
5
  import { EditorContext } from '../../Context';
6
6
 
7
7
  function html2Escape(sHtml: string) {
@@ -1,6 +1,6 @@
1
1
  import React, { useContext, useEffect } from 'react';
2
- import { IProps } from '../../Types';
3
- import { EditorContext, ExecuteCommandState } from '../../Context';
2
+ import { type IProps } from '../../Types';
3
+ import { EditorContext, type ExecuteCommandState } from '../../Context';
4
4
  import { TextAreaCommandOrchestrator } from '../../commands/';
5
5
  import handleKeyDown from './handleKeyDown';
6
6
  import shortcuts from './shortcuts';
@@ -1,9 +1,10 @@
1
1
  import React, { useEffect, Fragment, useContext, JSX } from 'react';
2
- import { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';
2
+ import type * as CSS from 'csstype';
3
+ import { EditorContext, type ContextStore, ExecuteCommandState } from '../../Context';
3
4
  import shortcuts from './shortcuts';
4
5
  import Textarea, { TextAreaProps } from './Textarea';
5
- import { IProps } from '../../Types';
6
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
6
+ import { type IProps } from '../../Types';
7
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
7
8
  import './index.less';
8
9
 
9
10
  type RenderTextareaHandle = {
@@ -66,7 +67,7 @@ export default function TextArea(props: ITextAreaProps) {
66
67
  // eslint-disable-next-line react-hooks/exhaustive-deps
67
68
  }, []);
68
69
 
69
- const textStyle: React.CSSProperties = { WebkitTextFillColor: 'initial', overflow: 'auto' };
70
+ const textStyle: CSS.Properties = { WebkitTextFillColor: 'initial', overflow: 'auto' };
70
71
 
71
72
  return (
72
73
  <div ref={warp} className={`${prefixCls}-area ${className || ''}`} onScroll={onScroll}>
@@ -1,10 +1,11 @@
1
1
  import React, { useEffect, Fragment, useContext, JSX } from 'react';
2
- import { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';
2
+ import type * as CSS from 'csstype';
3
+ import { EditorContext, type ContextStore, type ExecuteCommandState } from '../../Context';
3
4
  import shortcuts from './shortcuts';
4
5
  import Markdown from './Markdown';
5
- import Textarea, { TextAreaProps } from './Textarea';
6
- import { IProps } from '../../Types';
7
- import { TextAreaCommandOrchestrator, ICommand } from '../../commands/';
6
+ import Textarea, { type TextAreaProps } from './Textarea';
7
+ import { type IProps } from '../../Types';
8
+ import { TextAreaCommandOrchestrator, type ICommand } from '../../commands/';
8
9
  import './index.less';
9
10
 
10
11
  type RenderTextareaHandle = {
@@ -68,7 +69,7 @@ export default function TextArea(props: ITextAreaProps) {
68
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
70
  }, []);
70
71
 
71
- const textStyle: React.CSSProperties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };
72
+ const textStyle: CSS.Properties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };
72
73
 
73
74
  return (
74
75
  <div ref={warp} className={`${prefixCls}-area ${className || ''}`} onScroll={onScroll}>
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo, JSX } from 'react';
1
+ import React, { useContext, useMemo, type JSX } from 'react';
2
2
  import './Child.less';
3
3
  import Toolbar, { type IToolbarProps } from './';
4
4
  import { EditorContext } from '../../Context';
@@ -1,6 +1,6 @@
1
1
  import React, { Fragment, useContext, useEffect, useRef } from 'react';
2
- import { IProps } from '../../Types';
3
- import { EditorContext, PreviewType, ContextStore } from '../../Context';
2
+ import { type IProps } from '../../Types';
3
+ import { EditorContext, type PreviewType, type ContextStore } from '../../Context';
4
4
  import { ICommand } from '../../commands/';
5
5
  import Child from './Child';
6
6
  import './index.less';
package/src/index.tsx CHANGED
@@ -11,6 +11,8 @@ export * from './utils/InsertTextAtPosition';
11
11
  export * from './Editor';
12
12
  export * from './Context';
13
13
  export * from './Types';
14
+ export { default as handleKeyDown } from './components/TextArea/handleKeyDown';
15
+ export { default as shortcuts } from './components/TextArea/shortcuts';
14
16
 
15
17
  export { MarkdownUtil, commands };
16
18