@uiw/react-md-editor 3.17.0 → 3.17.1

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 (37) hide show
  1. package/dist/mdeditor.css +15 -5
  2. package/dist/mdeditor.js +69 -652
  3. package/dist/mdeditor.min.css +1 -1
  4. package/dist/mdeditor.min.js +1 -1
  5. package/esm/Editor.d.ts +3 -0
  6. package/esm/Editor.js +1 -7
  7. package/esm/Editor.js.map +2 -3
  8. package/esm/components/DragBar/index.css +1 -0
  9. package/esm/components/DragBar/index.less +1 -0
  10. package/esm/components/Toolbar/Child.js +0 -1
  11. package/esm/components/Toolbar/Child.js.map +2 -2
  12. package/esm/components/Toolbar/index.css +2 -1
  13. package/esm/components/Toolbar/index.d.ts +0 -2
  14. package/esm/components/Toolbar/index.js +0 -4
  15. package/esm/components/Toolbar/index.js.map +2 -3
  16. package/esm/components/Toolbar/index.less +2 -1
  17. package/esm/index.css +10 -3
  18. package/esm/index.less +9 -3
  19. package/lib/Editor.d.ts +3 -0
  20. package/lib/Editor.js +1 -8
  21. package/lib/Editor.js.map +2 -3
  22. package/lib/components/DragBar/index.less +1 -0
  23. package/lib/components/Toolbar/Child.js +0 -1
  24. package/lib/components/Toolbar/Child.js.map +2 -2
  25. package/lib/components/Toolbar/index.d.ts +0 -2
  26. package/lib/components/Toolbar/index.js +0 -5
  27. package/lib/components/Toolbar/index.js.map +2 -3
  28. package/lib/components/Toolbar/index.less +2 -1
  29. package/lib/index.less +9 -3
  30. package/markdown-editor.css +13 -4
  31. package/package.json +2 -2
  32. package/src/Editor.tsx +6 -9
  33. package/src/components/DragBar/index.less +1 -0
  34. package/src/components/Toolbar/Child.tsx +1 -1
  35. package/src/components/Toolbar/index.less +2 -1
  36. package/src/components/Toolbar/index.tsx +2 -3
  37. package/src/index.less +9 -3
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
1
  import { IProps } from '../../Editor';
3
2
  import { ICommand } from '../../commands';
4
3
  import './index.less';
5
4
  export interface IToolbarProps extends IProps {
6
5
  overflow?: boolean;
7
- height?: React.CSSProperties['height'];
8
6
  toolbarBottom?: boolean;
9
7
  onCommand?: (command: ICommand<string>, groupName?: string) => void;
10
8
  commands?: ICommand<string>[];
@@ -140,8 +140,6 @@ function ToolbarItems(props) {
140
140
  function Toolbar() {
141
141
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
142
142
  var prefixCls = props.prefixCls,
143
- _props$height = props.height,
144
- height = _props$height === void 0 ? 29 : _props$height,
145
143
  toolbarBottom = props.toolbarBottom,
146
144
  isChild = props.isChild;
147
145
 
@@ -152,9 +150,6 @@ function Toolbar() {
152
150
  var bottomClassName = toolbarBottom ? 'bottom' : '';
153
151
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
154
152
  className: "".concat(prefixCls, "-toolbar ").concat(bottomClassName),
155
- style: {
156
- height: height
157
- },
158
153
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ToolbarItems, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
159
154
  commands: props.commands || commands || []
160
155
  })), !isChild && /*#__PURE__*/(0, _jsxRuntime.jsx)(ToolbarItems, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
@@ -67,7 +67,6 @@
67
67
  "Array",
68
68
  "isArray",
69
69
  "Toolbar",
70
- "height",
71
70
  "toolbarBottom",
72
71
  "isChild",
73
72
  "extraCommands",
@@ -77,7 +76,7 @@
77
76
  "../../../src/components/Toolbar/index.tsx"
78
77
  ],
79
78
  "sourcesContent": [
80
- "import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n height?: React.CSSProperties['height'];\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, height = 29, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`} style={{ height }}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
79
+ "import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
81
80
  ],
82
- "mappings": ";;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;AAYO,SAASA,YAAT,CAAsBC,KAAtB,EAA4C;EACjD,IAAQC,SAAR,GAAgCD,KAAhC,CAAQC,SAAR;EAAA,IAAmBC,QAAnB,GAAgCF,KAAhC,CAAmBE,QAAnB;;EACA,kBAA0F,IAAAC,iBAAA,EAAWC,sBAAX,CAA1F;EAAA,IAAQC,UAAR,eAAQA,UAAR;EAAA,IAAoBC,OAApB,eAAoBA,OAApB;EAAA,uCAA6BC,QAA7B;EAAA,IAA6BA,QAA7B,qCAAwC,EAAxC;EAAA,IAA4CC,UAA5C,eAA4CA,UAA5C;EAAA,IAAwDC,mBAAxD,eAAwDA,mBAAxD;EAAA,IAA6EC,QAA7E,eAA6EA,QAA7E;;EACA,IAAMC,gBAAgB,GAAG,IAAAC,aAAA,EAAO,EAAP,CAAzB;;EAEA,SAASC,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SAAR;EAAA,IAAmBgE,aAAnB,GAA8CjE,KAA9C,CAAmBiE,aAAnB;EAAA,IAAkCC,OAAlC,GAA8ClE,KAA9C,CAAkCkE,OAAlC;;EACA,mBAAoC,IAAA/D,iBAAA,EAAWC,sBAAX,CAApC;EAAA,IAAQe,QAAR,gBAAQA,QAAR;EAAA,IAAkBgD,aAAlB,gBAAkBA,aAAlB;;EACA,IAAMC,eAAe,GAAGH,aAAa,GAAG,QAAH,GAAc,EAAnD;EACA,oBACE;IAAK,SAAS,YAAKhE,SAAL,sBAA0BmE,eAA1B,CAAd;IAAA,wBACE,qBAAC,YAAD,oEAAkBpE,KAAlB;MAAyB,QAAQ,EAAEA,KAAK,CAACmB,QAAN,IAAkBA,QAAlB,IAA8B;IAAjE,GADF,EAEG,CAAC+C,OAAD,iBAAY,qBAAC,YAAD,oEAAkBlE,KAAlB;MAAyB,QAAQ,EAAEmE,aAAa,IAAI;IAApD,GAFf;EAAA,EADF;AAMD"
83
82
  }
@@ -4,12 +4,13 @@
4
4
  &-toolbar {
5
5
  border-bottom: 1px solid var(--color-border-default);
6
6
  background-color: var(--color-canvas-default);
7
- padding: 0 5px 0 5px;
7
+ padding: 5px;
8
8
  display: flex;
9
9
  justify-content: space-between;
10
10
  align-items: center;
11
11
  border-radius: 3px 3px 0 0;
12
12
  user-select: none;
13
+ flex-wrap: wrap;
13
14
  &.bottom {
14
15
  border-bottom: 0px;
15
16
  border-top: 1px solid var(--color-border-default);
package/lib/index.less CHANGED
@@ -10,13 +10,19 @@
10
10
  0 1px 1px var(--color-border-default);
11
11
  background-color: var(--color-canvas-default);
12
12
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13
- .copied {
14
- display: none !important;
13
+ display: flex;
14
+ flex-direction: column;
15
+ &-toolbar {
16
+ height: fit-content;
15
17
  }
16
18
  &-content {
19
+ height: 100%;
20
+ overflow: auto;
17
21
  position: relative;
18
22
  border-radius: 0 0 3px 0;
19
- height: calc(100% - 39.1px);
23
+ }
24
+ .copied {
25
+ display: none !important;
20
26
  }
21
27
  &-input {
22
28
  width: 50%;
@@ -2,6 +2,7 @@
2
2
  position: absolute;
3
3
  cursor: s-resize;
4
4
  right: 0;
5
+ bottom: 0;
5
6
  margin-top: -11px;
6
7
  margin-right: 0;
7
8
  width: 14px;
@@ -174,13 +175,14 @@
174
175
  .w-md-editor-toolbar {
175
176
  border-bottom: 1px solid var(--color-border-default);
176
177
  background-color: var(--color-canvas-default);
177
- padding: 0 5px 0 5px;
178
+ padding: 5px;
178
179
  display: flex;
179
180
  justify-content: space-between;
180
181
  align-items: center;
181
182
  border-radius: 3px 3px 0 0;
182
183
  -webkit-user-select: none;
183
184
  user-select: none;
185
+ flex-wrap: wrap;
184
186
  }
185
187
  .w-md-editor-toolbar.bottom {
186
188
  border-bottom: 0px;
@@ -251,14 +253,21 @@
251
253
  box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default), 0 1px 1px var(--color-border-default);
252
254
  background-color: var(--color-canvas-default);
253
255
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
256
+ display: flex;
257
+ flex-direction: column;
254
258
  }
255
- .w-md-editor .copied {
256
- display: none !important;
259
+ .w-md-editor-toolbar {
260
+ height: -webkit-fit-content;
261
+ height: fit-content;
257
262
  }
258
263
  .w-md-editor-content {
264
+ height: 100%;
265
+ overflow: auto;
259
266
  position: relative;
260
267
  border-radius: 0 0 3px 0;
261
- height: calc(100% - 39.1px);
268
+ }
269
+ .w-md-editor .copied {
270
+ display: none !important;
262
271
  }
263
272
  .w-md-editor-input {
264
273
  width: 50%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.17.0",
3
+ "version": "3.17.1",
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>",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.14.6",
39
- "@uiw/react-markdown-preview": "^4.0.22",
39
+ "@uiw/react-markdown-preview": "^4.0.24",
40
40
  "rehype": "~12.0.1"
41
41
  },
42
42
  "keywords": [
package/src/Editor.tsx CHANGED
@@ -39,6 +39,9 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
39
39
  /**
40
40
  * Custom toolbar heigth
41
41
  * @default 29px
42
+ *
43
+ * @deprecated toolbar height adaptive: https://github.com/uiwjs/react-md-editor/issues/427
44
+ *
42
45
  */
43
46
  toolbarHeight?: number;
44
47
  /**
@@ -150,7 +153,6 @@ const InternalMDEditor = (
150
153
  commandsFilter,
151
154
  extraCommands = getExtraCommands(),
152
155
  height = 200,
153
- toolbarHeight = 29,
154
156
  enableScroll = true,
155
157
  visibleDragbar = typeof props.visiableDragbar === 'boolean' ? props.visiableDragbar : true,
156
158
  highlightEnable = true,
@@ -320,14 +322,9 @@ const InternalMDEditor = (
320
322
  }}
321
323
  >
322
324
  {!hideToolbar && !toolbarBottom && (
323
- <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
325
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
324
326
  )}
325
- <div
326
- className={`${prefixCls}-content`}
327
- style={{
328
- height: `calc(100% - ${toolbarHeight}px)`,
329
- }}
330
- >
327
+ <div className={`${prefixCls}-content`}>
331
328
  {/(edit|live)/.test(state.preview || '') && (
332
329
  <TextArea
333
330
  className={`${prefixCls}-input`}
@@ -358,7 +355,7 @@ const InternalMDEditor = (
358
355
  />
359
356
  )}
360
357
  {!hideToolbar && toolbarBottom && (
361
- <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
358
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
362
359
  )}
363
360
  </div>
364
361
  </EditorContext.Provider>
@@ -5,6 +5,7 @@
5
5
  position: absolute;
6
6
  cursor: s-resize;
7
7
  right: 0;
8
+ bottom: 0;
8
9
  margin-top: -11px;
9
10
  margin-right: 0;
10
11
  width: 14px;
@@ -17,7 +17,7 @@ export default function Child(props: ChildProps) {
17
17
  className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}
18
18
  onClick={(e) => e.stopPropagation()}
19
19
  >
20
- {Array.isArray(commands) ? <Toolbar commands={commands} {...props} height="" isChild /> : children}
20
+ {Array.isArray(commands) ? <Toolbar commands={commands} {...props} isChild /> : children}
21
21
  </div>
22
22
  ),
23
23
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -4,12 +4,13 @@
4
4
  &-toolbar {
5
5
  border-bottom: 1px solid var(--color-border-default);
6
6
  background-color: var(--color-canvas-default);
7
- padding: 0 5px 0 5px;
7
+ padding: 5px;
8
8
  display: flex;
9
9
  justify-content: space-between;
10
10
  align-items: center;
11
11
  border-radius: 3px 3px 0 0;
12
12
  user-select: none;
13
+ flex-wrap: wrap;
13
14
  &.bottom {
14
15
  border-bottom: 0px;
15
16
  border-top: 1px solid var(--color-border-default);
@@ -7,7 +7,6 @@ import './index.less';
7
7
 
8
8
  export interface IToolbarProps extends IProps {
9
9
  overflow?: boolean;
10
- height?: React.CSSProperties['height'];
11
10
  toolbarBottom?: boolean;
12
11
  onCommand?: (command: ICommand<string>, groupName?: string) => void;
13
12
  commands?: ICommand<string>[];
@@ -125,11 +124,11 @@ export function ToolbarItems(props: IToolbarProps) {
125
124
  }
126
125
 
127
126
  export default function Toolbar(props: IToolbarProps = {}) {
128
- const { prefixCls, height = 29, toolbarBottom, isChild } = props;
127
+ const { prefixCls, toolbarBottom, isChild } = props;
129
128
  const { commands, extraCommands } = useContext(EditorContext);
130
129
  const bottomClassName = toolbarBottom ? 'bottom' : '';
131
130
  return (
132
- <div className={`${prefixCls}-toolbar ${bottomClassName}`} style={{ height }}>
131
+ <div className={`${prefixCls}-toolbar ${bottomClassName}`}>
133
132
  <ToolbarItems {...props} commands={props.commands || commands || []} />
134
133
  {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}
135
134
  </div>
package/src/index.less CHANGED
@@ -10,13 +10,19 @@
10
10
  0 1px 1px var(--color-border-default);
11
11
  background-color: var(--color-canvas-default);
12
12
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13
- .copied {
14
- display: none !important;
13
+ display: flex;
14
+ flex-direction: column;
15
+ &-toolbar {
16
+ height: fit-content;
15
17
  }
16
18
  &-content {
19
+ height: 100%;
20
+ overflow: auto;
17
21
  position: relative;
18
22
  border-radius: 0 0 3px 0;
19
- height: calc(100% - 39.1px);
23
+ }
24
+ .copied {
25
+ display: none !important;
20
26
  }
21
27
  &-input {
22
28
  width: 50%;