Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change the editor height based on the screen #515

Open
Udayendu opened this issue May 5, 2023 · 1 comment
Open

Unable to change the editor height based on the screen #515

Udayendu opened this issue May 5, 2023 · 1 comment

Comments

@Udayendu
Copy link

Udayendu commented May 5, 2023

Currently I am unable to change the height of the editor based on the screen. Is there any way we can fix it ?
Here is how my current editor setting is looking like:

<MDEditor
    height={600}
    value={content}
    onChange={handleContent}
    preview="live"
/>

I am expecting the setting something like the below based on the screen size:

<MDEditor
    height={{ xs: 300, sm: 500, md: 600, lg: 700 }}
    value={content}
    onChange={handleContent}
    preview="live"
/>
@jaywcjlove
Copy link
Member

@Udayendu https://codesandbox.io/embed/markdown-editor-for-react-https-github-com-uiwjs-react-md-editor-issues-515-tpu706?fontsize=14&hidenavigation=1&theme=dark

import React, { Fragment, useState } from "react";
import ReactDOM from "react-dom";
import MDEditor, { selectWord } from "@uiw/react-md-editor";
import "./index.css";

const mkdStr = `
# Markdown Editor

---

**Hello world!!!**

[![](https://avatars.githubusercontent.com/u/1680273?s=80&v=4)](https://avatars.githubusercontent.com/u/1680273?v=4)

\`\`\`javascript
import React from "react";
import ReactDOM from "react-dom";
import MEDitor from '@uiw/react-md-editor';

\`\`\`
`;

function App() {
  const [height, setHeight] = useState(300);
  const [value, setValue] = useState(mkdStr);
  const styl = { height };
  return (
    <Fragment>
      <input
        type="number"
        value={height}
        onChange={(evn) => setHeight(Number(evn.target.value))}
      />
      {height}
      <div className="container" style={styl}>
        <MDEditor height="100%" value={value} onChange={setValue} />
      </div>
    </Fragment>
  );
}

ReactDOM.render(<App />, document.getElementById("container"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants