uiwjs / react-markdown-editor

A markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-markdown-editor
MIT License
337 stars 34 forks source link

How to avoid increasing width and just have auto line wrapping? #190

Closed lofti198 closed 2 years ago

lofti198 commented 2 years ago

Having the following issue: when number of characters in line is more, than its width - the whole editor is being increased. Any ideas how to make just auto line wrapping? Video demo: https://somup.com/c3jviXUlmF . Component is styled like this. Version 5.2.0

<MarkdownEditor style={{ height: "150px", overflow: "scroll", padding: "8px", }} value={markdown} onChange={(value, viewUpdate) => { setMarkdown(value); }} />

jaywcjlove commented 2 years ago

https://codesandbox.io/embed/react-markdown-editor-uiwjs-react-markdown-editor-issues-190-kpfm3e?fontsize=14&hidenavigation=1&theme=dark

I have no way to reproduce the problem. @lofti198

lofti198 commented 2 years ago

https://codesandbox.io/embed/react-markdown-editor-uiwjs-react-markdown-editor-issues-190-kpfm3e?fontsize=14&hidenavigation=1&theme=dark

I have no way to reproduce the problem. @lofti198

I see, tested it and it really works almost without changing control width. At the same time - is there a way to make autowrap (auto new line, when amount of text is longer than one line width)? Like this: image

In your case its by default like this: image

jaywcjlove commented 2 years ago

@lofti198 This might be the effect you want. https://codesandbox.io/embed/react-markdown-editor-uiwjs-react-markdown-editor-issues-190-kpfm3e?fontsize=14&hidenavigation=1&theme=dark

+ import { EditorView } from "@codemirror/view";

<MarkdownEditor
  value={markdownVal}
+  extensions={[EditorView.lineWrapping]}
  onChange={(value) => {
    setMarkdownVal(value);
  }}
/>

image

lofti198 commented 2 years ago

Cool! It works completely how I need! Can I somehow donate for your fast and accurate help?

jaywcjlove commented 2 years ago

GitHub does not support donations in China. You can star repositories.

@lofti198

lofti198 commented 2 years ago

Maybe I can buy you a coffee? Also I would appreciate if you check this issue with getting focus (a fixed codesandbox so you could see how it works for me)

jaywcjlove commented 2 years ago

@lofti198 oh, slow down, I've dealt with 4 issues.

lofti198 commented 2 years ago

@lofti198 oh, slow down, I've dealt with 4 issues.

Ok ok))) just let me know if I can somehow help