@uiw/react-md-editor 3.20.1 → 3.20.3
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 +3 -0
- package/dist/mdeditor.css +1 -1
- package/dist/mdeditor.js +6656 -5020
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +2 -2
- package/esm/Context.js.map +1 -1
- package/esm/Editor.d.ts +3 -1
- package/esm/Editor.js +4 -1
- package/esm/Editor.js.map +2 -2
- package/esm/commands/title1.js.map +1 -1
- package/esm/commands/title2.js.map +1 -1
- package/esm/commands/title3.js.map +1 -1
- package/esm/commands/title4.js.map +1 -1
- package/esm/commands/title5.js.map +1 -1
- package/esm/commands/title6.js.map +1 -1
- package/esm/components/TextArea/index.css +1 -1
- package/esm/components/TextArea/index.js +1 -1
- package/esm/components/TextArea/index.js.map +1 -1
- package/esm/components/TextArea/index.less +1 -1
- package/lib/Context.d.ts +2 -2
- package/lib/Context.js.map +1 -1
- package/lib/Editor.d.ts +3 -1
- package/lib/Editor.js +4 -1
- package/lib/Editor.js.map +3 -3
- package/lib/commands/title1.js.map +1 -1
- package/lib/commands/title2.js.map +1 -1
- package/lib/commands/title3.js.map +1 -1
- package/lib/commands/title4.js.map +1 -1
- package/lib/commands/title5.js.map +1 -1
- package/lib/commands/title6.js.map +1 -1
- package/lib/components/TextArea/index.js +1 -1
- package/lib/components/TextArea/index.js.map +1 -1
- package/lib/components/TextArea/index.less +1 -1
- package/markdown-editor.css +1 -1
- package/package.json +1 -1
- package/src/Context.tsx +2 -2
- package/src/Editor.tsx +5 -3
- package/src/components/TextArea/index.less +1 -1
- package/src/components/TextArea/index.tsx +1 -1
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"../../../src/components/TextArea/index.tsx"
|
|
49
49
|
],
|
|
50
50
|
"sourcesContent": [
|
|
51
|
-
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea, { TextAreaProps } from './Textarea';\nimport { IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: TextAreaProps['onChange'];\n useContext?: {\n commands: ContextStore['commands'];\n extraCommands: ContextStore['extraCommands'];\n commandOrchestrator?: TextAreaCommandOrchestrator;\n };\n shortcuts?: (\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ) => void;\n};\n\nexport interface ITextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,\n IProps {\n value?: string;\n onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;\n renderTextarea?: (\n props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>,\n opts: RenderTextareaHandle,\n ) => JSX.Element;\n}\n\nexport type TextAreaRef = {\n text?: HTMLTextAreaElement;\n warp?: HTMLDivElement;\n};\n\nexport default function TextArea(props: ITextAreaProps) {\n const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};\n const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const warp = React.createRef<HTMLDivElement>();\n useEffect(() => {\n const state: ContextStore = {};\n if (warp.current) {\n state.textareaWarp = warp.current || undefined;\n warp.current.scrollTop = scrollTop || 0;\n }\n if (dispatch) {\n dispatch({ ...state });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const textStyle: React.CSSProperties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };\n\n return (\n <div ref={warp} className={`${prefixCls}-
|
|
51
|
+
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea, { TextAreaProps } from './Textarea';\nimport { IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: TextAreaProps['onChange'];\n useContext?: {\n commands: ContextStore['commands'];\n extraCommands: ContextStore['extraCommands'];\n commandOrchestrator?: TextAreaCommandOrchestrator;\n };\n shortcuts?: (\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ) => void;\n};\n\nexport interface ITextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,\n IProps {\n value?: string;\n onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;\n renderTextarea?: (\n props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>,\n opts: RenderTextareaHandle,\n ) => JSX.Element;\n}\n\nexport type TextAreaRef = {\n text?: HTMLTextAreaElement;\n warp?: HTMLDivElement;\n};\n\nexport default function TextArea(props: ITextAreaProps) {\n const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};\n const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const warp = React.createRef<HTMLDivElement>();\n useEffect(() => {\n const state: ContextStore = {};\n if (warp.current) {\n state.textareaWarp = warp.current || undefined;\n warp.current.scrollTop = scrollTop || 0;\n }\n if (dispatch) {\n dispatch({ ...state });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const textStyle: React.CSSProperties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };\n\n return (\n <div ref={warp} className={`${prefixCls}-area ${className || ''}`} onScroll={onScroll}>\n <div className={`${prefixCls}-text`}>\n {renderTextarea ? (\n React.cloneElement(\n renderTextarea(\n {\n ...otherProps,\n value: markdown,\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n autoCapitalize: 'off',\n className: `${prefixCls}-text-input`,\n style: {\n WebkitTextFillColor: 'inherit',\n overflow: 'auto',\n },\n },\n {\n dispatch,\n onChange: otherProps.onChange,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n {highlightEnable && <Markdown prefixCls={prefixCls} />}\n <Textarea prefixCls={prefixCls} {...otherProps} style={textStyle} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
|
|
52
52
|
],
|
|
53
53
|
"mappings": ";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAAuE;AAAA;AAoCxD,SAASA,QAAQ,CAACC,KAAqB,EAAE;EACtD,WAA0EA,KAAK,IAAI,CAAC,CAAC;IAA7EC,SAAS,QAATA,SAAS;IAAEC,SAAS,QAATA,SAAS;IAAEC,QAAQ,QAARA,QAAQ;IAAEC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H,oBACE;IAAK,GAAG,EAAEZ,IAAK;IAAC,SAAS,YAAKjB,SAAS,mBAASC,SAAS,IAAI,EAAE,CAAG;IAAC,QAAQ,EAAEC,QAAS;IAAA,uBACpF;MAAK,SAAS,YAAKF,SAAS,UAAQ;MAAA,UACjCG,cAAc,gBACbW,iBAAK,CAACgB,YAAY,CAChB3B,cAAc,mEAEPC,UAAU;QACb2B,KAAK,EAAExB,QAAQ;QACfyB,YAAY,EAAE,KAAK;QACnBC,WAAW,EAAE,KAAK;QAClBC,UAAU,EAAE,OAAO;QACnBC,cAAc,EAAE,KAAK;QACrBlC,SAAS,YAAKD,SAAS,gBAAa;QACpCoC,KAAK,EAAE;UACLR,mBAAmB,EAAE,SAAS;UAC9BC,QAAQ,EAAE;QACZ;MAAC,IAEH;QACEjB,QAAQ,EAARA,QAAQ;QACRyB,QAAQ,EAAEjC,UAAU,CAACiC,QAAQ;QAC7BC,SAAS,EAATA,qBAAS;QACTjC,UAAU,EAAE;UAAEI,QAAQ,EAARA,QAAQ;UAAEE,aAAa,EAAbA,aAAa;UAAEa,mBAAmB,EAAER,UAAU,CAACK;QAAQ;MACjF,CAAC,CACF,EACD;QACEkB,GAAG,EAAE1B;MACP,CAAC,CACF,gBAED,sBAAC,eAAQ;QAAA,WACNH,eAAe,iBAAI,qBAAC,oBAAQ;UAAC,SAAS,EAAEV;QAAU,EAAG,eACtD,qBAAC,oBAAQ;UAAC,SAAS,EAAEA;QAAU,GAAKI,UAAU;UAAE,KAAK,EAAEuB;QAAU,GAAG;MAAA;IAEvE;EACG,EACF;AAEV;AAAC"
|
|
54
54
|
}
|
package/markdown-editor.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.3",
|
|
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
|
@@ -4,7 +4,7 @@ import { MDEditorProps } from './Editor';
|
|
|
4
4
|
|
|
5
5
|
export type PreviewType = 'live' | 'edit' | 'preview';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export interface ContextStore {
|
|
8
8
|
components?: MDEditorProps['components'];
|
|
9
9
|
commands?: ICommand<string>[];
|
|
10
10
|
extraCommands?: ICommand<string>[];
|
|
@@ -25,7 +25,7 @@ export type ContextStore = {
|
|
|
25
25
|
scrollTopPreview?: number;
|
|
26
26
|
tabSize?: number;
|
|
27
27
|
defaultTabEnable?: boolean;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
|
|
30
30
|
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
31
31
|
|
package/src/Editor.tsx
CHANGED
|
@@ -35,7 +35,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
35
35
|
* The height of the editor.
|
|
36
36
|
* ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
|
|
37
37
|
*/
|
|
38
|
-
height?:
|
|
38
|
+
height?: number;
|
|
39
39
|
/**
|
|
40
40
|
* Custom toolbar heigth
|
|
41
41
|
* @default 29px
|
|
@@ -151,9 +151,11 @@ function setGroupPopFalse(data: Record<string, boolean> = {}) {
|
|
|
151
151
|
return data;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
export interface RefMDEditor extends ContextStore {}
|
|
155
|
+
|
|
154
156
|
const InternalMDEditor = (
|
|
155
157
|
props: MDEditorProps,
|
|
156
|
-
ref?: ((instance:
|
|
158
|
+
ref?: ((instance: RefMDEditor) => void) | React.RefObject<RefMDEditor> | null,
|
|
157
159
|
) => {
|
|
158
160
|
const {
|
|
159
161
|
prefixCls = 'w-md-editor',
|
|
@@ -210,7 +212,7 @@ const InternalMDEditor = (
|
|
|
210
212
|
const previewRef = useRef<HTMLDivElement>(null);
|
|
211
213
|
const enableScrollRef = useRef(enableScroll);
|
|
212
214
|
|
|
213
|
-
useImperativeHandle(ref, () => ({ ...state }));
|
|
215
|
+
useImperativeHandle(ref, () => ({ ...state, container: container.current, dispatch }));
|
|
214
216
|
useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);
|
|
215
217
|
useEffect(() => {
|
|
216
218
|
const stateInit: ContextStore = {};
|
|
@@ -70,7 +70,7 @@ export default function TextArea(props: ITextAreaProps) {
|
|
|
70
70
|
const textStyle: React.CSSProperties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };
|
|
71
71
|
|
|
72
72
|
return (
|
|
73
|
-
<div ref={warp} className={`${prefixCls}-
|
|
73
|
+
<div ref={warp} className={`${prefixCls}-area ${className || ''}`} onScroll={onScroll}>
|
|
74
74
|
<div className={`${prefixCls}-text`}>
|
|
75
75
|
{renderTextarea ? (
|
|
76
76
|
React.cloneElement(
|