uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.63k stars 129 forks source link

How can I put focus on the last element <Codemirror />? #619

Open TigranGithub opened 8 months ago

TigranGithub commented 8 months ago

for example clicking edit button and want to focus will be on last element. Thanks!

jaywcjlove commented 8 months ago

@TigranGithub I don't understand your exact need.

HenryHengZJ commented 5 months ago

@jaywcjlove here's an example:

1.) I have a custom UI that allow user to edit: image

2.) When user click edit, I set the editable={true}, the component should has the blinking indicator placed at the last character. But instead the indicator displayed at the very first character

Expected: image

Actual: image

jaywcjlove commented 5 months ago

@HenryHengZJ

<CodeMirror
    value={`console.log('hello')`}
    theme="none"
    height="400px !important"
    width="100%"
+    selection={EditorSelection.cursor(0)}
    style={{ margin: '0 0 23px 0', flex: 1 }}
    extensions={[langs.markdown()]}
/>