@uiw/react-md-editor 3.9.7 → 3.10.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/README.md +49 -23
- package/dist/mdeditor.css +0 -2
- package/dist/mdeditor.js +477 -232
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Editor.d.ts +4 -0
- package/esm/Editor.js +4 -2
- package/esm/Editor.js.map +3 -2
- package/esm/components/Toolbar/index.d.ts +1 -0
- package/esm/components/Toolbar/index.js +7 -4
- package/esm/components/Toolbar/index.js.map +4 -3
- package/lib/Editor.d.ts +4 -0
- package/lib/Editor.js +5 -2
- package/lib/Editor.js.map +3 -2
- package/lib/components/Toolbar/index.d.ts +1 -0
- package/lib/components/Toolbar/index.js +7 -4
- package/lib/components/Toolbar/index.js.map +4 -3
- package/package.json +5 -4
- package/src/Editor.tsx +6 -1
- package/src/components/Toolbar/index.tsx +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.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>",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"css:watch": "compile-less -d src -o esm --watch",
|
|
16
16
|
"css:build:dist": "compile-less -d src --combine markdown-editor.css --rm-global",
|
|
17
17
|
"bundle": "ncc build src/index.tsx --target web --filename mdeditor",
|
|
18
|
+
"bundle:watch": "ncc watch src/index.tsx --target web --filename mdeditor",
|
|
18
19
|
"bundle:min": "ncc build src/index.tsx --target web --filename mdeditor --minify",
|
|
19
20
|
"watch": "tsbb watch & npm run css:watch",
|
|
20
21
|
"build": "tsbb build && npm run css:build && npm run css:build:dist",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@kkt/less-modules": "~7.1.1",
|
|
44
|
-
"@kkt/ncc": "~1.0.
|
|
45
|
+
"@kkt/ncc": "~1.0.9",
|
|
45
46
|
"@kkt/raw-modules": "~7.1.1",
|
|
46
47
|
"@kkt/scope-plugin-options": "~7.1.1",
|
|
47
48
|
"@types/katex": "~0.11.1",
|
|
@@ -49,13 +50,13 @@
|
|
|
49
50
|
"@types/react-dom": "~17.0.11",
|
|
50
51
|
"@types/react-test-renderer": "~17.0.1",
|
|
51
52
|
"@uiw/react-github-corners": "~1.5.3",
|
|
52
|
-
"@uiw/react-codesandbox": "~1.1.4",
|
|
53
53
|
"@uiw/react-shields": "~1.1.2",
|
|
54
54
|
"compile-less-cli": "~1.8.11",
|
|
55
55
|
"katex": "~0.15.2",
|
|
56
56
|
"husky": "~7.0.4",
|
|
57
57
|
"kkt": "~7.1.5",
|
|
58
58
|
"lint-staged": "~12.3.4",
|
|
59
|
+
"mermaid": "~8.14.0",
|
|
59
60
|
"prettier": "~2.5.1",
|
|
60
61
|
"react": "~17.0.2",
|
|
61
62
|
"react-dom": "~17.0.2",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@babel/runtime": "^7.14.6",
|
|
68
|
-
"@uiw/react-markdown-preview": "~3.
|
|
69
|
+
"@uiw/react-markdown-preview": "~3.5.0",
|
|
69
70
|
"rehype-sanitize": "~5.0.1",
|
|
70
71
|
"rehype": "~12.0.1"
|
|
71
72
|
},
|
package/src/Editor.tsx
CHANGED
|
@@ -48,6 +48,10 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
48
48
|
* Full screen display editor.
|
|
49
49
|
*/
|
|
50
50
|
fullscreen?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Disable `fullscreen` setting body styles
|
|
53
|
+
*/
|
|
54
|
+
overflow?: boolean;
|
|
51
55
|
/**
|
|
52
56
|
* Maximum drag height. `visiableDragbar=true`
|
|
53
57
|
*/
|
|
@@ -126,6 +130,7 @@ const InternalMDEditor = (
|
|
|
126
130
|
highlightEnable = true,
|
|
127
131
|
preview: previewType = 'live',
|
|
128
132
|
fullscreen = false,
|
|
133
|
+
overflow = true,
|
|
129
134
|
previewOptions = {},
|
|
130
135
|
textareaProps,
|
|
131
136
|
maxHeight = 1200,
|
|
@@ -280,7 +285,7 @@ const InternalMDEditor = (
|
|
|
280
285
|
height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,
|
|
281
286
|
}}
|
|
282
287
|
>
|
|
283
|
-
{!hideToolbar && <Toolbar prefixCls={prefixCls} height={toolbarHeight} />}
|
|
288
|
+
{!hideToolbar && <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} />}
|
|
284
289
|
<div
|
|
285
290
|
className={`${prefixCls}-content`}
|
|
286
291
|
style={{
|
|
@@ -6,6 +6,7 @@ import Child from './Child';
|
|
|
6
6
|
import './index.less';
|
|
7
7
|
|
|
8
8
|
export interface IToolbarProps extends IProps {
|
|
9
|
+
overflow?: boolean;
|
|
9
10
|
height?: React.CSSProperties['height'];
|
|
10
11
|
onCommand?: (command: ICommand<string>, groupName?: string) => void;
|
|
11
12
|
commands?: ICommand<string>[];
|
|
@@ -13,7 +14,7 @@ export interface IToolbarProps extends IProps {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function ToolbarItems(props: IToolbarProps) {
|
|
16
|
-
const { prefixCls } = props;
|
|
17
|
+
const { prefixCls, overflow } = props;
|
|
17
18
|
const { fullscreen, preview, barPopup = {}, commandOrchestrator, dispatch } = useContext(EditorContext);
|
|
18
19
|
const originalOverflow = useRef('');
|
|
19
20
|
|
|
@@ -47,7 +48,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
useEffect(() => {
|
|
50
|
-
if (document) {
|
|
51
|
+
if (document && overflow) {
|
|
51
52
|
if (fullscreen) {
|
|
52
53
|
// prevent scroll on fullscreen
|
|
53
54
|
document.body.style.overflow = 'hidden';
|
|
@@ -60,7 +61,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
60
61
|
document.body.style.overflow = originalOverflow.current;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
}, [fullscreen, originalOverflow]);
|
|
64
|
+
}, [fullscreen, originalOverflow, overflow]);
|
|
64
65
|
|
|
65
66
|
return (
|
|
66
67
|
<ul>
|
|
@@ -68,7 +69,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
68
69
|
if (item.keyCommand === 'divider') {
|
|
69
70
|
return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;
|
|
70
71
|
}
|
|
71
|
-
if (!item.keyCommand) return <Fragment />;
|
|
72
|
+
if (!item.keyCommand) return <Fragment key={idx} />;
|
|
72
73
|
const activeBtn =
|
|
73
74
|
(fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);
|
|
74
75
|
const childNode =
|
|
@@ -89,6 +90,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
89
90
|
'button',
|
|
90
91
|
{
|
|
91
92
|
type: 'button',
|
|
93
|
+
key: idx,
|
|
92
94
|
disabled,
|
|
93
95
|
'data-name': item.name,
|
|
94
96
|
...item.buttonProps,
|
|
@@ -101,6 +103,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
101
103
|
)}
|
|
102
104
|
{item.children && (
|
|
103
105
|
<Child
|
|
106
|
+
overflow={overflow}
|
|
104
107
|
groupName={item.groupName}
|
|
105
108
|
prefixCls={prefixCls}
|
|
106
109
|
children={childNode}
|