@uiw/react-md-editor 3.6.6 → 3.7.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/esm/components/TextArea/Textarea.js +4 -2
- package/esm/components/TextArea/Textarea.js.map +4 -3
- package/esm/components/TextArea/index.d.ts +1 -1
- package/esm/components/TextArea/index.js.map +1 -1
- package/lib/components/TextArea/Textarea.js +3 -1
- package/lib/components/TextArea/Textarea.js.map +4 -3
- package/lib/components/TextArea/index.d.ts +1 -1
- package/lib/components/TextArea/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TextArea/Textarea.tsx +2 -1
- package/src/components/TextArea/index.tsx +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["prefixCls"];
|
|
3
|
+
var _excluded = ["prefixCls", "onChange"];
|
|
4
4
|
import React, { useContext, useEffect } from 'react';
|
|
5
5
|
import { EditorContext } from '../../Context';
|
|
6
6
|
import { TextAreaCommandOrchestrator } from '../../commands';
|
|
@@ -10,7 +10,8 @@ import "./index.css";
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export default function Textarea(props) {
|
|
12
12
|
var {
|
|
13
|
-
prefixCls
|
|
13
|
+
prefixCls,
|
|
14
|
+
onChange: onChangeFromProps
|
|
14
15
|
} = props,
|
|
15
16
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
16
17
|
|
|
@@ -81,6 +82,7 @@ export default function Textarea(props) {
|
|
|
81
82
|
markdown: e.target.value
|
|
82
83
|
});
|
|
83
84
|
_onChange && _onChange(e.target.value);
|
|
85
|
+
onChangeFromProps && onChangeFromProps(e);
|
|
84
86
|
}
|
|
85
87
|
}));
|
|
86
88
|
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"Textarea",
|
|
15
15
|
"props",
|
|
16
16
|
"prefixCls",
|
|
17
|
+
"onChange",
|
|
18
|
+
"onChangeFromProps",
|
|
17
19
|
"other",
|
|
18
20
|
"markdown",
|
|
19
21
|
"commands",
|
|
@@ -22,7 +24,6 @@
|
|
|
22
24
|
"highlightEnable",
|
|
23
25
|
"extraCommands",
|
|
24
26
|
"tabSize",
|
|
25
|
-
"onChange",
|
|
26
27
|
"dispatch",
|
|
27
28
|
"textRef",
|
|
28
29
|
"useRef",
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
"target",
|
|
40
41
|
"value"
|
|
41
42
|
],
|
|
42
|
-
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,QAA6C,OAA7C;AAEA,SAASC,aAAT,QAAmD,eAAnD;AACA,SAASC,2BAAT,QAA4C,gBAA5C;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA;;AAIA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAM;AAAEC,IAAAA;
|
|
43
|
+
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,QAA6C,OAA7C;AAEA,SAASC,aAAT,QAAmD,eAAnD;AACA,SAASC,2BAAT,QAA4C,gBAA5C;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA;;AAIA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAQ,EAAEC;AAAvB,MAAuDH,KAA7D;AAAA,MAAmDI,KAAnD,iCAA6DJ,KAA7D;;AACA,MAAM;AAAEK,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,UAAtB;AAAkCC,IAAAA,OAAlC;AAA2CC,IAAAA,eAA3C;AAA4DC,IAAAA,aAA5D;A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vB,EAAAA,SAAS,CAAC,MAAM;AACd,QAAImB,OAAO,CAACI,OAAZ,EAAqB;AACnBJ,MAAAA,OAAO,CAACI,OAAR,CAAgBK,gBAAhB,CAAiC,SAAjC,EAA4CF,SAA5C;AACD;;AACD,WAAO,MAAM;AACX,UAAIP,OAAO,CAACI,OAAZ,EAAqB;AACnB;AACAJ,QAAAA,OAAO,CAACI,OAAR,CAAgBM,mBAAhB,CAAoC,SAApC,EAA+CH,SAA/C;AACD;AACF,KALD,CAJc,CAUd;AACD,GAXQ,EAWN,EAXM,CAAT;AAaA,sBACE;AACE,IAAA,YAAY,EAAC,KADf;AAEE,IAAA,WAAW,EAAC,KAFd;AAGE,IAAA,cAAc,EAAC,KAHjB;AAIE,IAAA,UAAU,EAAE;AAJd,KAKMhB,KALN;AAME,IAAA,GAAG,EAAES,OANP;AAOE,IAAA,SAAS,EAAKZ,SAAL,qBAA6BG,KAAK,CAACoB,SAAN,GAAkBpB,KAAK,CAACoB,SAAxB,GAAoC,EAAjE,CAPX;AAQE,IAAA,KAAK,EAAEnB,QART;AASE,IAAA,QAAQ,EAAGgB,CAAD,IAAO;AACfT,MAAAA,QAAQ,IAAIA,QAAQ,CAAC;AAAEP,QAAAA,QAAQ,EAAEgB,CAAC,CAACI,MAAF,CAASC;AAArB,OAAD,CAApB;AACAxB,MAAAA,SAAQ,IAAIA,SAAQ,CAACmB,CAAC,CAACI,MAAF,CAASC,KAAV,CAApB;AACAvB,MAAAA,iBAAiB,IAAIA,iBAAiB,CAACkB,CAAD,CAAtC;AACD;AAbH,KADF;AAiBD",
|
|
43
44
|
"sourcesContent": [
|
|
44
|
-
"import React, { useContext, useEffect } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, ExecuteCommandState } from '../../Context';\nimport { TextAreaCommandOrchestrator } from '../../commands';\nimport handleKeyDown from './handleKeyDown';\nimport shortcuts from './shortcuts';\nimport './index.less';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}\n\nexport default function Textarea(props: TextAreaProps) {\n const { prefixCls, ...other } = props;\n const { markdown, commands, fullscreen, preview, highlightEnable, extraCommands, tabSize, onChange, dispatch } =\n useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const statesRef = React.useRef<ExecuteCommandState>({ fullscreen, preview });\n\n useEffect(() => {\n statesRef.current = { fullscreen, preview, highlightEnable };\n }, [fullscreen, preview, highlightEnable]);\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 onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {\n handleKeyDown(e, tabSize);\n shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);\n };\n useEffect(() => {\n if (textRef.current) {\n textRef.current.addEventListener('keydown', onKeyDown);\n }\n return () => {\n if (textRef.current) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n textRef.current.removeEventListener('keydown', onKeyDown);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <textarea\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n {...other}\n ref={textRef}\n className={`${prefixCls}-text-input ${other.className ? other.className : ''}`}\n value={markdown}\n onChange={(e) => {\n dispatch && dispatch({ markdown: e.target.value });\n onChange && onChange(e.target.value);\n }}\n />\n );\n}\n"
|
|
45
|
+
"import React, { useContext, useEffect } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, ExecuteCommandState } from '../../Context';\nimport { TextAreaCommandOrchestrator } from '../../commands';\nimport handleKeyDown from './handleKeyDown';\nimport shortcuts from './shortcuts';\nimport './index.less';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}\n\nexport default function Textarea(props: TextAreaProps) {\n const { prefixCls, onChange: onChangeFromProps, ...other } = props;\n const { markdown, commands, fullscreen, preview, highlightEnable, extraCommands, tabSize, onChange, dispatch } =\n useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const statesRef = React.useRef<ExecuteCommandState>({ fullscreen, preview });\n\n useEffect(() => {\n statesRef.current = { fullscreen, preview, highlightEnable };\n }, [fullscreen, preview, highlightEnable]);\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 onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {\n handleKeyDown(e, tabSize);\n shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);\n };\n useEffect(() => {\n if (textRef.current) {\n textRef.current.addEventListener('keydown', onKeyDown);\n }\n return () => {\n if (textRef.current) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n textRef.current.removeEventListener('keydown', onKeyDown);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <textarea\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n {...other}\n ref={textRef}\n className={`${prefixCls}-text-input ${other.className ? other.className : ''}`}\n value={markdown}\n onChange={(e) => {\n dispatch && dispatch({ markdown: e.target.value });\n onChange && onChange(e.target.value);\n onChangeFromProps && onChangeFromProps(e);\n }}\n />\n );\n}\n"
|
|
45
46
|
]
|
|
46
47
|
}
|
|
@@ -13,7 +13,7 @@ declare type RenderTextareaHandle = {
|
|
|
13
13
|
};
|
|
14
14
|
shortcuts?: (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState) => void;
|
|
15
15
|
};
|
|
16
|
-
export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | '
|
|
16
|
+
export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>, IProps {
|
|
17
17
|
value?: string;
|
|
18
18
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
19
19
|
renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
],
|
|
51
51
|
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,EAAqCC,UAArC,QAAuD,OAAvD;AACA,SAASC,aAAT,QAAiE,eAAjE;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,QAAP,MAAqB,YAArB;AAEA,SAASC,2BAAT,QAAsD,gBAAtD;AACA;;;AAmCA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAyC;AACtD,aAA0EA,KAAK,IAAI,EAAnF;AAAA,MAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,SAAb;AAAwBC,IAAAA,QAAxB;AAAkCC,IAAAA;AAAlC,GAAN;AAAA,MAA2DC,UAA3D;;AACA,MAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA,QAAvB;AAAiCC,IAAAA,aAAjC;AAAgDC,IAAAA,QAAhD;AAA0DC,IAAAA;AAA1D,MAAuElB,UAAU,CAACC,aAAD,CAAvF;AACA,MAAMkB,OAA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Y,EAAE,KAJJ;AAKVC,QAAAA,WAAW,EAAE,KALH;AAMVC,QAAAA,UAAU,EAAE,OANF;AAOVC,QAAAA,cAAc,EAAE,KAPN;AAQV1B,QAAAA,SAAS,EAAKD,SAAL,gBARC;AASV4B,QAAAA,KAAK,EAAE;AACLC,UAAAA,mBAAmB,EAAE,SADhB;AAELC,UAAAA,QAAQ,EAAE;AAFL;AATG,UAcZ;AACEpB,QAAAA,QADF;AAEED,QAAAA,QAFF;AAGEf,QAAAA,SAHF;AAIEF,QAAAA,UAAU,EAAE;AAAEe,UAAAA,QAAF;AAAYC,UAAAA,aAAZ;AAA2BY,UAAAA,mBAAmB,EAAEP,UAAU,CAACI;AAA3D;AAJd,OAdY,CADhB,EAsBE;AACEc,QAAAA,GAAG,EAAEpB;AADP,OAtBF,CADa,gBA4Bb,MAAC,QAAD;AAAA,gCACE,KAAC,QAAD;AAAU,UAAA,SAAS,EAAEX;AAArB,UADF,eAEE,KAAC,QAAD;AAAU,UAAA,SAAS,EAAEA;AAArB,WAAoCI,UAApC,EAFF;AAAA;AA7BJ;AADF,IADF;AAuCD",
|
|
52
52
|
"sourcesContent": [
|
|
53
|
-
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea from './Textarea';\nimport { MDEditorProps, IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: MDEditorProps['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' | '
|
|
53
|
+
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea from './Textarea';\nimport { MDEditorProps, IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: MDEditorProps['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, extraCommands, onChange, 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 return (\n <div ref={warp} className={`${prefixCls}-aree ${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,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n <Markdown prefixCls={prefixCls} />\n <Textarea prefixCls={prefixCls} {...otherProps} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
|
|
54
54
|
]
|
|
55
55
|
}
|
|
@@ -27,10 +27,11 @@ var _shortcuts = _interopRequireDefault(require("./shortcuts"));
|
|
|
27
27
|
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
|
|
30
|
-
var _excluded = ["prefixCls"];
|
|
30
|
+
var _excluded = ["prefixCls", "onChange"];
|
|
31
31
|
|
|
32
32
|
function Textarea(props) {
|
|
33
33
|
var prefixCls = props.prefixCls,
|
|
34
|
+
onChangeFromProps = props.onChange,
|
|
34
35
|
other = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
35
36
|
|
|
36
37
|
var _useContext = (0, _react.useContext)(_Context.EditorContext),
|
|
@@ -103,6 +104,7 @@ function Textarea(props) {
|
|
|
103
104
|
markdown: e.target.value
|
|
104
105
|
});
|
|
105
106
|
_onChange && _onChange(e.target.value);
|
|
107
|
+
onChangeFromProps && onChangeFromProps(e);
|
|
106
108
|
}
|
|
107
109
|
}));
|
|
108
110
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"Textarea",
|
|
8
8
|
"props",
|
|
9
9
|
"prefixCls",
|
|
10
|
+
"onChangeFromProps",
|
|
11
|
+
"onChange",
|
|
10
12
|
"other",
|
|
11
13
|
"EditorContext",
|
|
12
14
|
"markdown",
|
|
@@ -16,7 +18,6 @@
|
|
|
16
18
|
"highlightEnable",
|
|
17
19
|
"extraCommands",
|
|
18
20
|
"tabSize",
|
|
19
|
-
"onChange",
|
|
20
21
|
"dispatch",
|
|
21
22
|
"textRef",
|
|
22
23
|
"React",
|
|
@@ -35,8 +36,8 @@
|
|
|
35
36
|
"target",
|
|
36
37
|
"value"
|
|
37
38
|
],
|
|
38
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAKe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAQC,SAAR,
|
|
39
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAKe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAQC,SAAR,GAA6DD,KAA7D,CAAQC,SAAR;AAAA,MAA6BC,iBAA7B,GAA6DF,KAA7D,CAAmBG,QAAnB;AAAA,MAAmDC,KAAnD,0CAA6DJ,KAA7D;;AACA,oBACE,uBAAWK,sBAAX,CADF;AAAA,MAAQC,QAAR,eAAQA,QAAR;AAAA,MAAkBC,QAAlB,eAAkBA,QAAlB;AAAA,MAA4BC,UAA5B,eAA4BA,UAA5B;AAAA,MAAwCC,OAAxC,eAAwCA,OAAxC;AAAA,MAAiDC,eAAjD,eAAiDA,eAAjD;AAAA,MAAkEC,aAAlE,eAAkEA,aAAlE;AAAA,MAAiFC,OAAjF,eAAiF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MAAAA,OAAO,CAACK,OAAR,CAAgBM,gBAAhB,CAAiC,SAAjC,EAA4CF,SAA5C;AACD;;AACD,WAAO,YAAM;AACX,UAAIT,OAAO,CAACK,OAAZ,EAAqB;AACnB;AACAL,QAAAA,OAAO,CAACK,OAAR,CAAgBO,mBAAhB,CAAoC,SAApC,EAA+CH,SAA/C;AACD;AACF,KALD,CAJc,CAUd;AACD,GAXD,EAWG,EAXH;AAaA,sBACE;AACE,IAAA,YAAY,EAAC,KADf;AAEE,IAAA,WAAW,EAAC,KAFd;AAGE,IAAA,cAAc,EAAC,KAHjB;AAIE,IAAA,UAAU,EAAE;AAJd,KAKMnB,KALN;AAME,IAAA,GAAG,EAAEU,OANP;AAOE,IAAA,SAAS,YAAKb,SAAL,yBAA6BG,KAAK,CAACuB,SAAN,GAAkBvB,KAAK,CAACuB,SAAxB,GAAoC,EAAjE,CAPX;AAQE,IAAA,KAAK,EAAErB,QART;AASE,IAAA,QAAQ,EAAE,kBAACkB,CAAD,EAAO;AACfX,MAAAA,QAAQ,IAAIA,QAAQ,CAAC;AAAEP,QAAAA,QAAQ,EAAEkB,CAAC,CAACI,MAAF,CAASC;AAArB,OAAD,CAApB;AACA1B,MAAAA,SAAQ,IAAIA,SAAQ,CAACqB,CAAC,CAACI,MAAF,CAASC,KAAV,CAApB;AACA3B,MAAAA,iBAAiB,IAAIA,iBAAiB,CAACsB,CAAD,CAAtC;AACD;AAbH,KADF;AAiBD",
|
|
39
40
|
"sourcesContent": [
|
|
40
|
-
"import React, { useContext, useEffect } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, ExecuteCommandState } from '../../Context';\nimport { TextAreaCommandOrchestrator } from '../../commands';\nimport handleKeyDown from './handleKeyDown';\nimport shortcuts from './shortcuts';\nimport './index.less';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}\n\nexport default function Textarea(props: TextAreaProps) {\n const { prefixCls, ...other } = props;\n const { markdown, commands, fullscreen, preview, highlightEnable, extraCommands, tabSize, onChange, dispatch } =\n useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const statesRef = React.useRef<ExecuteCommandState>({ fullscreen, preview });\n\n useEffect(() => {\n statesRef.current = { fullscreen, preview, highlightEnable };\n }, [fullscreen, preview, highlightEnable]);\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 onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {\n handleKeyDown(e, tabSize);\n shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);\n };\n useEffect(() => {\n if (textRef.current) {\n textRef.current.addEventListener('keydown', onKeyDown);\n }\n return () => {\n if (textRef.current) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n textRef.current.removeEventListener('keydown', onKeyDown);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <textarea\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n {...other}\n ref={textRef}\n className={`${prefixCls}-text-input ${other.className ? other.className : ''}`}\n value={markdown}\n onChange={(e) => {\n dispatch && dispatch({ markdown: e.target.value });\n onChange && onChange(e.target.value);\n }}\n />\n );\n}\n"
|
|
41
|
+
"import React, { useContext, useEffect } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, ExecuteCommandState } from '../../Context';\nimport { TextAreaCommandOrchestrator } from '../../commands';\nimport handleKeyDown from './handleKeyDown';\nimport shortcuts from './shortcuts';\nimport './index.less';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}\n\nexport default function Textarea(props: TextAreaProps) {\n const { prefixCls, onChange: onChangeFromProps, ...other } = props;\n const { markdown, commands, fullscreen, preview, highlightEnable, extraCommands, tabSize, onChange, dispatch } =\n useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const statesRef = React.useRef<ExecuteCommandState>({ fullscreen, preview });\n\n useEffect(() => {\n statesRef.current = { fullscreen, preview, highlightEnable };\n }, [fullscreen, preview, highlightEnable]);\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 onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {\n handleKeyDown(e, tabSize);\n shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);\n };\n useEffect(() => {\n if (textRef.current) {\n textRef.current.addEventListener('keydown', onKeyDown);\n }\n return () => {\n if (textRef.current) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n textRef.current.removeEventListener('keydown', onKeyDown);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <textarea\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n {...other}\n ref={textRef}\n className={`${prefixCls}-text-input ${other.className ? other.className : ''}`}\n value={markdown}\n onChange={(e) => {\n dispatch && dispatch({ markdown: e.target.value });\n onChange && onChange(e.target.value);\n onChangeFromProps && onChangeFromProps(e);\n }}\n />\n );\n}\n"
|
|
41
42
|
]
|
|
42
43
|
}
|
|
@@ -13,7 +13,7 @@ declare type RenderTextareaHandle = {
|
|
|
13
13
|
};
|
|
14
14
|
shortcuts?: (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState) => void;
|
|
15
15
|
};
|
|
16
|
-
export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | '
|
|
16
|
+
export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>, IProps {
|
|
17
17
|
value?: string;
|
|
18
18
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
19
19
|
renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
],
|
|
47
47
|
"mappings": ";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAoCe,SAASA,QAAT,CAAkBC,KAAlB,EAAyC;AACtD,aAA0EA,KAAK,IAAI,EAAnF;AAAA,MAAQC,SAAR,QAAQA,SAAR;AAAA,MAAmBC,SAAnB,QAAmBA,SAAnB;AAAA,MAA8BC,QAA9B,QAA8BA,QAA9B;AAAA,MAAwCC,cAAxC,QAAwCA,cAAxC;AAAA,MAA2DC,UAA3D;;AACA,oBAA6E,uBAAWC,sBAAX,CAA7E;AAAA,MAAQC,QAAR,eAAQA,QAAR;AAAA,MAAkBC,SAAlB,eAAkBA,SAAlB;AAAA,MAA6BC,QAA7B,eAA6BA,QAA7B;AAAA,MAAuCC,aAAvC,eAAuCA,aAAvC;AAAA,MAAsDC,QAAtD,eAAsDA,QAAtD;AAAA,MAAgEC,QAAhE,eAAgEA,QAAhE;;AACA,MAAMC,OAAO,GAAGC,eAAMC,MAAN,CAAkC,IAAlC,CAAhB;;AACA,MAAMC,UAAU,GAAGF,eAAMC,MAAN,EAAnB;;AACA,MAAME,IAAI,gBAAGH,eAAMI,SAAN,EAAb;;AACA,wBAAU,YAAM;AAC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AA,QAAQ,EAAE;AAFL;AATG,UAcZ;AACEtB,QAAAA,QAAQ,EAARA,QADF;AAEED,QAAAA,QAAQ,EAARA,QAFF;AAGEwB,QAAAA,SAAS,EAATA,kBAHF;AAIEC,QAAAA,UAAU,EAAE;AAAE3B,UAAAA,QAAQ,EAARA,QAAF;AAAYC,UAAAA,aAAa,EAAbA,aAAZ;AAA2Ba,UAAAA,mBAAmB,EAAEP,UAAU,CAACI;AAA3D;AAJd,OAdY,CADhB,EAsBE;AACEiB,QAAAA,GAAG,EAAExB;AADP,OAtBF,CADa,gBA4Bb,sBAAC,eAAD;AAAA,gCACE,qBAAC,iBAAD;AAAU,UAAA,SAAS,EAAEZ;AAArB,UADF,eAEE,qBAAC,iBAAD;AAAU,UAAA,SAAS,EAAEA;AAArB,WAAoCI,UAApC,EAFF;AAAA;AA7BJ;AADF,IADF;AAuCD",
|
|
48
48
|
"sourcesContent": [
|
|
49
|
-
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea from './Textarea';\nimport { MDEditorProps, IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: MDEditorProps['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' | '
|
|
49
|
+
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea from './Textarea';\nimport { MDEditorProps, IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: MDEditorProps['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, extraCommands, onChange, 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 return (\n <div ref={warp} className={`${prefixCls}-aree ${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,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n <Markdown prefixCls={prefixCls} />\n <Textarea prefixCls={prefixCls} {...otherProps} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
|
|
50
50
|
]
|
|
51
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.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>",
|
|
@@ -9,7 +9,7 @@ import './index.less';
|
|
|
9
9
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}
|
|
10
10
|
|
|
11
11
|
export default function Textarea(props: TextAreaProps) {
|
|
12
|
-
const { prefixCls, ...other } = props;
|
|
12
|
+
const { prefixCls, onChange: onChangeFromProps, ...other } = props;
|
|
13
13
|
const { markdown, commands, fullscreen, preview, highlightEnable, extraCommands, tabSize, onChange, dispatch } =
|
|
14
14
|
useContext(EditorContext);
|
|
15
15
|
const textRef = React.useRef<HTMLTextAreaElement>(null);
|
|
@@ -59,6 +59,7 @@ export default function Textarea(props: TextAreaProps) {
|
|
|
59
59
|
onChange={(e) => {
|
|
60
60
|
dispatch && dispatch({ markdown: e.target.value });
|
|
61
61
|
onChange && onChange(e.target.value);
|
|
62
|
+
onChangeFromProps && onChangeFromProps(e);
|
|
62
63
|
}}
|
|
63
64
|
/>
|
|
64
65
|
);
|
|
@@ -25,7 +25,7 @@ type RenderTextareaHandle = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export interface ITextAreaProps
|
|
28
|
-
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | '
|
|
28
|
+
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,
|
|
29
29
|
IProps {
|
|
30
30
|
value?: string;
|
|
31
31
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|