Skip to content

Commit

Permalink
fix: fix minHeight props issue. (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Nov 10, 2023
1 parent 64319c2 commit a7d9a2c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
24 changes: 24 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,30 @@ export default function App() {
}
```

### Editor height adapts to text

The initial height can be adjusted through `minHeight={100}`. Dragbar will automatically expire. You can hide the drag button through `visibleDragbar={true}`

```jsx mdx:preview
import React from "react";
import MDEditor from '@uiw/react-md-editor';

export default function App() {
const [value, setValue] = React.useState("**Hello world!!!**");
return (
<div className="container">
<MDEditor
value={value}
height="100%"
// minHeight={50}
visibleDragbar={false}
onChange={setValue}
/>
</div>
);
}
```

### Preview Markdown

[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/react-md-editor-preview-markdown-vrucl?fontsize=14&hidenavigation=1&theme=dark)
Expand Down
1 change: 1 addition & 0 deletions core/src/Editor.nohighlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const InternalMDEditor = React.forwardRef<RefMDEditor, MDEditorProps>(
preview: previewType,
components,
height,
minHeight,
highlightEnable,
tabSize,
defaultTabEnable,
Expand Down
1 change: 1 addition & 0 deletions core/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const InternalMDEditor = React.forwardRef<RefMDEditor, MDEditorProps>(
preview: previewType,
components,
height,
minHeight,
highlightEnable,
tabSize,
defaultTabEnable,
Expand Down
5 changes: 3 additions & 2 deletions core/src/components/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export type TextAreaRef = {

export default function TextArea(props: ITextAreaProps) {
const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};
const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);
const { markdown, scrollTop, commands, minHeight, highlightEnable, extraCommands, dispatch } =
useContext(EditorContext);
const textRef = React.useRef<HTMLTextAreaElement>(null);
const executeRef = React.useRef<TextAreaCommandOrchestrator>();
const warp = React.createRef<HTMLDivElement>();
Expand Down Expand Up @@ -71,7 +72,7 @@ export default function TextArea(props: ITextAreaProps) {

return (
<div ref={warp} className={`${prefixCls}-area ${className || ''}`} onScroll={onScroll}>
<div className={`${prefixCls}-text`}>
<div className={`${prefixCls}-text`} style={{ minHeight }}>
{renderTextarea ? (
React.cloneElement(
renderTextarea(
Expand Down

1 comment on commit a7d9a2c

@vercel
Copy link

@vercel vercel bot commented on a7d9a2c Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.