@uiw/react-md-editor 3.24.1 → 3.25.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.
Files changed (54) hide show
  1. package/README.md +47 -2
  2. package/dist/mdeditor.js +4114 -4095
  3. package/dist/mdeditor.min.js +1 -1
  4. package/esm/Context.d.ts +1 -1
  5. package/esm/Editor.d.ts +4 -149
  6. package/esm/Editor.js +0 -1
  7. package/esm/Editor.nohighlight.d.ts +12 -0
  8. package/esm/Editor.nohighlight.js +255 -0
  9. package/esm/Types.d.ts +148 -0
  10. package/esm/Types.js +1 -0
  11. package/esm/components/DragBar/index.d.ts +1 -1
  12. package/esm/components/TextArea/Markdown.d.ts +1 -1
  13. package/esm/components/TextArea/Textarea.d.ts +1 -1
  14. package/esm/components/TextArea/index.d.ts +1 -1
  15. package/esm/components/TextArea/index.nohighlight.d.ts +27 -0
  16. package/esm/components/TextArea/index.nohighlight.js +93 -0
  17. package/esm/components/Toolbar/Child.d.ts +1 -1
  18. package/esm/components/Toolbar/index.d.ts +1 -1
  19. package/esm/index.d.ts +2 -0
  20. package/esm/index.js +2 -0
  21. package/esm/index.nohighlight.d.ts +13 -0
  22. package/esm/index.nohighlight.js +13 -0
  23. package/lib/Context.d.ts +1 -1
  24. package/lib/Editor.d.ts +4 -149
  25. package/lib/Editor.nohighlight.d.ts +12 -0
  26. package/lib/Editor.nohighlight.js +317 -0
  27. package/lib/Types.d.ts +148 -0
  28. package/lib/Types.js +1 -0
  29. package/lib/components/DragBar/index.d.ts +1 -1
  30. package/lib/components/TextArea/Markdown.d.ts +1 -1
  31. package/lib/components/TextArea/Textarea.d.ts +1 -1
  32. package/lib/components/TextArea/index.d.ts +1 -1
  33. package/lib/components/TextArea/index.nohighlight.d.ts +27 -0
  34. package/lib/components/TextArea/index.nohighlight.js +98 -0
  35. package/lib/components/Toolbar/Child.d.ts +1 -1
  36. package/lib/components/Toolbar/index.d.ts +1 -1
  37. package/lib/index.d.ts +2 -0
  38. package/lib/index.js +12 -0
  39. package/lib/index.nohighlight.d.ts +13 -0
  40. package/lib/index.nohighlight.js +98 -0
  41. package/package.json +16 -2
  42. package/src/Context.tsx +1 -1
  43. package/src/Editor.nohighlight.tsx +264 -0
  44. package/src/Editor.tsx +5 -151
  45. package/src/Types.ts +151 -0
  46. package/src/components/DragBar/index.tsx +1 -1
  47. package/src/components/TextArea/Markdown.tsx +2 -2
  48. package/src/components/TextArea/Textarea.tsx +1 -1
  49. package/src/components/TextArea/index.nohighlight.tsx +109 -0
  50. package/src/components/TextArea/index.tsx +1 -1
  51. package/src/components/Toolbar/Child.tsx +1 -1
  52. package/src/components/Toolbar/index.tsx +1 -1
  53. package/src/index.nohighlight.tsx +16 -0
  54. package/src/index.tsx +2 -0
@@ -0,0 +1,264 @@
1
+ import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
2
+ import MarkdownPreview from '@uiw/react-markdown-preview/nohighlight';
3
+ import TextArea from './components/TextArea/index.nohighlight';
4
+ import Toolbar from './components/Toolbar';
5
+ import DragBar from './components/DragBar';
6
+ import { getCommands, getExtraCommands, ICommand, TextState, TextAreaCommandOrchestrator } from './commands';
7
+ import { reducer, EditorContext, ContextStore } from './Context';
8
+ import type { MDEditorProps } from './Types';
9
+
10
+ function setGroupPopFalse(data: Record<string, boolean> = {}) {
11
+ Object.keys(data).forEach((keyname) => {
12
+ data[keyname] = false;
13
+ });
14
+ return data;
15
+ }
16
+
17
+ export interface RefMDEditor extends ContextStore {}
18
+
19
+ const InternalMDEditor = React.forwardRef<RefMDEditor, MDEditorProps>(
20
+ (props: MDEditorProps, ref: React.ForwardedRef<RefMDEditor>) => {
21
+ const {
22
+ prefixCls = 'w-md-editor',
23
+ className,
24
+ value: propsValue,
25
+ commands = getCommands(),
26
+ commandsFilter,
27
+ direction,
28
+ extraCommands = getExtraCommands(),
29
+ height = 200,
30
+ enableScroll = true,
31
+ visibleDragbar = typeof props.visiableDragbar === 'boolean' ? props.visiableDragbar : true,
32
+ highlightEnable = true,
33
+ preview: previewType = 'live',
34
+ fullscreen = false,
35
+ overflow = true,
36
+ previewOptions = {},
37
+ textareaProps,
38
+ maxHeight = 1200,
39
+ minHeight = 100,
40
+ autoFocus,
41
+ tabSize = 2,
42
+ defaultTabEnable = false,
43
+ onChange,
44
+ onStatistics,
45
+ onHeightChange,
46
+ hideToolbar,
47
+ toolbarBottom = false,
48
+ components,
49
+ renderTextarea,
50
+ ...other
51
+ } = props || {};
52
+ const cmds = commands
53
+ .map((item) => (commandsFilter ? commandsFilter(item, false) : item))
54
+ .filter(Boolean) as ICommand[];
55
+ const extraCmds = extraCommands
56
+ .map((item) => (commandsFilter ? commandsFilter(item, true) : item))
57
+ .filter(Boolean) as ICommand[];
58
+ let [state, dispatch] = useReducer(reducer, {
59
+ markdown: propsValue,
60
+ preview: previewType,
61
+ components,
62
+ height,
63
+ highlightEnable,
64
+ tabSize,
65
+ defaultTabEnable,
66
+ scrollTop: 0,
67
+ scrollTopPreview: 0,
68
+ commands: cmds,
69
+ extraCommands: extraCmds,
70
+ fullscreen,
71
+ barPopup: {},
72
+ });
73
+ const container = useRef<HTMLDivElement>(null);
74
+ const previewRef = useRef<HTMLDivElement>(null);
75
+ const enableScrollRef = useRef(enableScroll);
76
+
77
+ useImperativeHandle(ref, () => ({ ...state, container: container.current, dispatch }));
78
+ useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);
79
+ useEffect(() => {
80
+ const stateInit: ContextStore = {};
81
+ if (container.current) {
82
+ stateInit.container = container.current || undefined;
83
+ }
84
+ stateInit.markdown = propsValue || '';
85
+ stateInit.barPopup = {};
86
+ if (dispatch) {
87
+ dispatch({ ...state, ...stateInit });
88
+ }
89
+ // eslint-disable-next-line react-hooks/exhaustive-deps
90
+ }, []);
91
+
92
+ const cls = [
93
+ className,
94
+ 'wmde-markdown-var',
95
+ direction ? `${prefixCls}-${direction}` : null,
96
+ prefixCls,
97
+ state.preview ? `${prefixCls}-show-${state.preview}` : null,
98
+ state.fullscreen ? `${prefixCls}-fullscreen` : null,
99
+ ]
100
+ .filter(Boolean)
101
+ .join(' ')
102
+ .trim();
103
+
104
+ useMemo(
105
+ () => propsValue !== state.markdown && dispatch({ markdown: propsValue || '' }),
106
+ [propsValue, state.markdown],
107
+ );
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ useMemo(() => previewType !== state.preview && dispatch({ preview: previewType }), [previewType]);
110
+ // eslint-disable-next-line react-hooks/exhaustive-deps
111
+ useMemo(() => tabSize !== state.tabSize && dispatch({ tabSize }), [tabSize]);
112
+ useMemo(
113
+ () => highlightEnable !== state.highlightEnable && dispatch({ highlightEnable }),
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ [highlightEnable],
116
+ );
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ useMemo(() => autoFocus !== state.autoFocus && dispatch({ autoFocus: autoFocus }), [autoFocus]);
119
+ useMemo(
120
+ () => fullscreen !== state.fullscreen && dispatch({ fullscreen: fullscreen }),
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ [fullscreen],
123
+ );
124
+ // eslint-disable-next-line react-hooks/exhaustive-deps
125
+ useMemo(() => height !== state.height && dispatch({ height: height }), [height]);
126
+ useMemo(
127
+ () => height !== state.height && onHeightChange && onHeightChange(state.height, height, state),
128
+ [height, onHeightChange, state],
129
+ );
130
+ // eslint-disable-next-line react-hooks/exhaustive-deps
131
+ useMemo(() => commands !== state.commands && dispatch({ commands: cmds }), [props.commands]);
132
+ // eslint-disable-next-line react-hooks/exhaustive-deps
133
+ useMemo(
134
+ () => extraCommands !== state.extraCommands && dispatch({ extraCommands: extraCmds }),
135
+ [props.extraCommands],
136
+ );
137
+
138
+ const textareaDomRef = useRef<HTMLDivElement>();
139
+ const active = useRef<'text' | 'preview'>('preview');
140
+ const initScroll = useRef(false);
141
+
142
+ useMemo(() => {
143
+ textareaDomRef.current = state.textareaWarp;
144
+ if (state.textareaWarp) {
145
+ state.textareaWarp.addEventListener('mouseover', () => {
146
+ active.current = 'text';
147
+ });
148
+ state.textareaWarp.addEventListener('mouseleave', () => {
149
+ active.current = 'preview';
150
+ });
151
+ }
152
+ }, [state.textareaWarp]);
153
+
154
+ const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {
155
+ if (!enableScrollRef.current) return;
156
+ const textareaDom = textareaDomRef.current;
157
+ const previewDom = previewRef.current ? previewRef.current : undefined;
158
+ if (!initScroll.current) {
159
+ active.current = type;
160
+ initScroll.current = true;
161
+ }
162
+ if (textareaDom && previewDom) {
163
+ const scale =
164
+ (textareaDom.scrollHeight - textareaDom.offsetHeight) / (previewDom.scrollHeight - previewDom.offsetHeight);
165
+ if (e.target === textareaDom && active.current === 'text') {
166
+ previewDom.scrollTop = textareaDom.scrollTop / scale;
167
+ }
168
+ if (e.target === previewDom && active.current === 'preview') {
169
+ textareaDom.scrollTop = previewDom.scrollTop * scale;
170
+ }
171
+ let scrollTop = 0;
172
+ if (active.current === 'text') {
173
+ scrollTop = textareaDom.scrollTop || 0;
174
+ } else if (active.current === 'preview') {
175
+ scrollTop = previewDom.scrollTop || 0;
176
+ }
177
+ dispatch({ scrollTop });
178
+ }
179
+ };
180
+
181
+ const previewClassName = `${prefixCls}-preview ${previewOptions.className || ''}`;
182
+ const handlePreviewScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => handleScroll(e, 'preview');
183
+ let mdPreview = useMemo(
184
+ () => (
185
+ <div ref={previewRef} className={previewClassName}>
186
+ <MarkdownPreview {...previewOptions} onScroll={handlePreviewScroll} source={state.markdown || ''} />
187
+ </div>
188
+ ),
189
+ [previewClassName, previewOptions, state.markdown],
190
+ );
191
+ const preview = components?.preview && components?.preview(state.markdown || '', state, dispatch);
192
+ if (preview && React.isValidElement(preview)) {
193
+ mdPreview = (
194
+ <div className={previewClassName} ref={previewRef} onScroll={handlePreviewScroll}>
195
+ {preview}
196
+ </div>
197
+ );
198
+ }
199
+
200
+ const containerStyle = { ...other.style, height: state.height || '100%' };
201
+ const containerClick = () => dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });
202
+ const dragBarChange = (newHeight: number) => dispatch({ height: newHeight });
203
+
204
+ const changeHandle = (evn: React.ChangeEvent<HTMLTextAreaElement>) => {
205
+ onChange && onChange(evn.target.value, evn, state);
206
+ if (textareaProps && textareaProps.onChange) {
207
+ textareaProps.onChange(evn);
208
+ }
209
+ if (state.textarea && state.textarea instanceof HTMLTextAreaElement && onStatistics) {
210
+ const obj = new TextAreaCommandOrchestrator(state.textarea!);
211
+ const objState = (obj.getState() || {}) as TextState;
212
+ onStatistics({
213
+ ...objState,
214
+ lineCount: evn.target.value.split('\n').length,
215
+ length: evn.target.value.length,
216
+ });
217
+ }
218
+ };
219
+ return (
220
+ <EditorContext.Provider value={{ ...state, dispatch }}>
221
+ <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>
222
+ {!hideToolbar && !toolbarBottom && (
223
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
224
+ )}
225
+ <div className={`${prefixCls}-content`}>
226
+ {/(edit|live)/.test(state.preview || '') && (
227
+ <TextArea
228
+ className={`${prefixCls}-input`}
229
+ prefixCls={prefixCls}
230
+ autoFocus={autoFocus}
231
+ {...textareaProps}
232
+ onChange={changeHandle}
233
+ renderTextarea={components?.textarea || renderTextarea}
234
+ onScroll={(e) => handleScroll(e, 'text')}
235
+ />
236
+ )}
237
+ {/(live|preview)/.test(state.preview || '') && mdPreview}
238
+ </div>
239
+ {visibleDragbar && !state.fullscreen && (
240
+ <DragBar
241
+ prefixCls={prefixCls}
242
+ height={state.height as number}
243
+ maxHeight={maxHeight!}
244
+ minHeight={minHeight!}
245
+ onChange={dragBarChange}
246
+ />
247
+ )}
248
+ {!hideToolbar && toolbarBottom && (
249
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
250
+ )}
251
+ </div>
252
+ </EditorContext.Provider>
253
+ );
254
+ },
255
+ );
256
+
257
+ type EditorComponent = typeof InternalMDEditor & {
258
+ Markdown: typeof MarkdownPreview;
259
+ };
260
+
261
+ const Editor = InternalMDEditor as EditorComponent;
262
+ Editor.Markdown = MarkdownPreview;
263
+
264
+ export default Editor;
package/src/Editor.tsx CHANGED
@@ -1,157 +1,11 @@
1
- import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties } from 'react';
2
- import MarkdownPreview, { MarkdownPreviewProps } from '@uiw/react-markdown-preview';
3
- import TextArea, { ITextAreaProps } from './components/TextArea';
1
+ import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
2
+ import MarkdownPreview from '@uiw/react-markdown-preview';
3
+ import TextArea from './components/TextArea';
4
4
  import Toolbar from './components/Toolbar';
5
5
  import DragBar from './components/DragBar';
6
6
  import { getCommands, getExtraCommands, ICommand, TextState, TextAreaCommandOrchestrator } from './commands';
7
- import { reducer, EditorContext, ContextStore, PreviewType } from './Context';
8
- import './index.less';
9
-
10
- export interface IProps {
11
- prefixCls?: string;
12
- className?: string;
13
- }
14
-
15
- export interface Statistics extends TextState {
16
- /** total length of the document */
17
- length: number;
18
- /** Get the number of lines in the editor. */
19
- lineCount: number;
20
- }
21
-
22
- export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {
23
- /**
24
- * The Markdown value.
25
- */
26
- value?: string;
27
- /**
28
- * Event handler for the `onChange` event.
29
- */
30
- onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore) => void;
31
- /**
32
- * editor height change listener
33
- */
34
- onHeightChange?: (value?: CSSProperties['height'], oldValue?: CSSProperties['height'], state?: ContextStore) => void;
35
- /** Some data on the statistics editor. */
36
- onStatistics?: (data: Statistics) => void;
37
- /**
38
- * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.
39
- * it will be set to true when either the source `textarea` is focused,
40
- * or it has an `autofocus` attribute and no other element is focused.
41
- */
42
- autoFocus?: ITextAreaProps['autoFocus'];
43
- /**
44
- * The height of the editor.
45
- * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
46
- */
47
- height?: CSSProperties['height'];
48
- /**
49
- * Custom toolbar heigth
50
- * @default 29px
51
- *
52
- * @deprecated toolbar height adaptive: https://github.com/uiwjs/react-md-editor/issues/427
53
- *
54
- */
55
- toolbarHeight?: number;
56
- /**
57
- * Show drag and drop tool. Set the height of the editor.
58
- */
59
- visibleDragbar?: boolean;
60
- /**
61
- * @deprecated use `visibleDragbar`
62
- */
63
- visiableDragbar?: boolean;
64
- /**
65
- * Show markdown preview.
66
- */
67
- preview?: PreviewType;
68
- /**
69
- * Full screen display editor.
70
- */
71
- fullscreen?: boolean;
72
- /**
73
- * Disable `fullscreen` setting body styles
74
- */
75
- overflow?: boolean;
76
- /**
77
- * Maximum drag height. `visibleDragbar=true`
78
- */
79
- maxHeight?: number;
80
- /**
81
- * Minimum drag height. `visibleDragbar=true`
82
- */
83
- minHeight?: number;
84
- /**
85
- * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.
86
- */
87
- previewOptions?: Omit<MarkdownPreviewProps, 'source'>;
88
- /**
89
- * Set the `textarea` related props.
90
- */
91
- textareaProps?: ITextAreaProps;
92
- /**
93
- * Use div to replace TextArea or re-render TextArea
94
- * @deprecated Please use ~~`renderTextarea`~~ -> `components`
95
- */
96
- renderTextarea?: ITextAreaProps['renderTextarea'];
97
- /**
98
- * re-render element
99
- */
100
- components?: {
101
- /** Use div to replace TextArea or re-render TextArea */
102
- textarea?: ITextAreaProps['renderTextarea'];
103
- /**
104
- * Override the default command element
105
- * _`toolbar`_ < _`command[].render`_
106
- */
107
- toolbar?: ICommand['render'];
108
- /** Custom markdown preview */
109
- preview?: (source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element;
110
- };
111
- /** Theme configuration */
112
- 'data-color-mode'?: 'light' | 'dark';
113
- /**
114
- * Disable editing area code highlighting. The value is `false`, which increases the editing speed.
115
- * @default true
116
- */
117
- highlightEnable?: boolean;
118
- /**
119
- * The number of characters to insert when pressing tab key.
120
- * Default `2` spaces.
121
- */
122
- tabSize?: number;
123
- /**
124
- * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.
125
- */
126
- defaultTabEnable?: boolean;
127
- /**
128
- * You can create your own commands or reuse existing commands.
129
- */
130
- commands?: ICommand[];
131
- /**
132
- * Filter or modify your commands.
133
- * https://github.com/uiwjs/react-md-editor/issues/296
134
- */
135
- commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;
136
- /**
137
- * You can create your own commands or reuse existing commands.
138
- */
139
- extraCommands?: ICommand[];
140
- /**
141
- * Hide the tool bar
142
- */
143
- hideToolbar?: boolean;
144
- /** Whether to enable scrolling */
145
- enableScroll?: boolean;
146
- /** Toolbar on bottom */
147
- toolbarBottom?: boolean;
148
- /**
149
- * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).
150
- *
151
- * https://github.com/uiwjs/react-md-editor/issues/462
152
- */
153
- direction?: CSSProperties['direction'];
154
- }
7
+ import { reducer, EditorContext, ContextStore } from './Context';
8
+ import type { MDEditorProps } from './Types';
155
9
 
156
10
  function setGroupPopFalse(data: Record<string, boolean> = {}) {
157
11
  Object.keys(data).forEach((keyname) => {
package/src/Types.ts ADDED
@@ -0,0 +1,151 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { MarkdownPreviewProps } from '@uiw/react-markdown-preview/nohighlight';
3
+ import type { ITextAreaProps } from './components/TextArea/index.nohighlight';
4
+ import type { ICommand, TextState } from './commands';
5
+ import type { ContextStore, PreviewType } from './Context';
6
+
7
+ export interface IProps {
8
+ prefixCls?: string;
9
+ className?: string;
10
+ }
11
+
12
+ export interface Statistics extends TextState {
13
+ /** total length of the document */
14
+ length: number;
15
+ /** Get the number of lines in the editor. */
16
+ lineCount: number;
17
+ }
18
+
19
+ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {
20
+ /**
21
+ * The Markdown value.
22
+ */
23
+ value?: string;
24
+ /**
25
+ * Event handler for the `onChange` event.
26
+ */
27
+ onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore) => void;
28
+ /**
29
+ * editor height change listener
30
+ */
31
+ onHeightChange?: (value?: CSSProperties['height'], oldValue?: CSSProperties['height'], state?: ContextStore) => void;
32
+ /** Some data on the statistics editor. */
33
+ onStatistics?: (data: Statistics) => void;
34
+ /**
35
+ * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.
36
+ * it will be set to true when either the source `textarea` is focused,
37
+ * or it has an `autofocus` attribute and no other element is focused.
38
+ */
39
+ autoFocus?: ITextAreaProps['autoFocus'];
40
+ /**
41
+ * The height of the editor.
42
+ * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
43
+ */
44
+ height?: CSSProperties['height'];
45
+ /**
46
+ * Custom toolbar heigth
47
+ * @default 29px
48
+ *
49
+ * @deprecated toolbar height adaptive: https://github.com/uiwjs/react-md-editor/issues/427
50
+ *
51
+ */
52
+ toolbarHeight?: number;
53
+ /**
54
+ * Show drag and drop tool. Set the height of the editor.
55
+ */
56
+ visibleDragbar?: boolean;
57
+ /**
58
+ * @deprecated use `visibleDragbar`
59
+ */
60
+ visiableDragbar?: boolean;
61
+ /**
62
+ * Show markdown preview.
63
+ */
64
+ preview?: PreviewType;
65
+ /**
66
+ * Full screen display editor.
67
+ */
68
+ fullscreen?: boolean;
69
+ /**
70
+ * Disable `fullscreen` setting body styles
71
+ */
72
+ overflow?: boolean;
73
+ /**
74
+ * Maximum drag height. `visibleDragbar=true`
75
+ */
76
+ maxHeight?: number;
77
+ /**
78
+ * Minimum drag height. `visibleDragbar=true`
79
+ */
80
+ minHeight?: number;
81
+ /**
82
+ * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.
83
+ */
84
+ previewOptions?: Omit<MarkdownPreviewProps, 'source'>;
85
+ /**
86
+ * Set the `textarea` related props.
87
+ */
88
+ textareaProps?: ITextAreaProps;
89
+ /**
90
+ * Use div to replace TextArea or re-render TextArea
91
+ * @deprecated Please use ~~`renderTextarea`~~ -> `components`
92
+ */
93
+ renderTextarea?: ITextAreaProps['renderTextarea'];
94
+ /**
95
+ * re-render element
96
+ */
97
+ components?: {
98
+ /** Use div to replace TextArea or re-render TextArea */
99
+ textarea?: ITextAreaProps['renderTextarea'];
100
+ /**
101
+ * Override the default command element
102
+ * _`toolbar`_ < _`command[].render`_
103
+ */
104
+ toolbar?: ICommand['render'];
105
+ /** Custom markdown preview */
106
+ preview?: (source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element;
107
+ };
108
+ /** Theme configuration */
109
+ 'data-color-mode'?: 'light' | 'dark';
110
+ /**
111
+ * Disable editing area code highlighting. The value is `false`, which increases the editing speed.
112
+ * @default true
113
+ */
114
+ highlightEnable?: boolean;
115
+ /**
116
+ * The number of characters to insert when pressing tab key.
117
+ * Default `2` spaces.
118
+ */
119
+ tabSize?: number;
120
+ /**
121
+ * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.
122
+ */
123
+ defaultTabEnable?: boolean;
124
+ /**
125
+ * You can create your own commands or reuse existing commands.
126
+ */
127
+ commands?: ICommand[];
128
+ /**
129
+ * Filter or modify your commands.
130
+ * https://github.com/uiwjs/react-md-editor/issues/296
131
+ */
132
+ commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;
133
+ /**
134
+ * You can create your own commands or reuse existing commands.
135
+ */
136
+ extraCommands?: ICommand[];
137
+ /**
138
+ * Hide the tool bar
139
+ */
140
+ hideToolbar?: boolean;
141
+ /** Whether to enable scrolling */
142
+ enableScroll?: boolean;
143
+ /** Toolbar on bottom */
144
+ toolbarBottom?: boolean;
145
+ /**
146
+ * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).
147
+ *
148
+ * https://github.com/uiwjs/react-md-editor/issues/462
149
+ */
150
+ direction?: CSSProperties['direction'];
151
+ }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useMemo, useRef } from 'react';
2
- import { IProps } from '../../Editor';
2
+ import { 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 '../../Editor';
4
+ import { IProps } from '../../Types';
5
5
  import { EditorContext } from '../../Context';
6
6
 
7
7
  function html2Escape(sHtml: string) {
@@ -15,7 +15,7 @@ function html2Escape(sHtml: string) {
15
15
  // })
16
16
  .replace(
17
17
  /[<&"]/g,
18
- (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' } as Record<string, string>)[c]),
18
+ (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' }) as Record<string, string>)[c],
19
19
  )
20
20
  );
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useEffect } from 'react';
2
- import { IProps } from '../../Editor';
2
+ import { IProps } from '../../Types';
3
3
  import { EditorContext, ExecuteCommandState } from '../../Context';
4
4
  import { TextAreaCommandOrchestrator } from '../../commands';
5
5
  import handleKeyDown from './handleKeyDown';