Skip to content

Expose textarea element #97

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lucasmotta
Copy link
Contributor

@lucasmotta lucasmotta commented Sep 15, 2022

Motivation

My main motiviation is to access textarea methods, like focus() or to set the caret at specific parts of the editor.

Test plan

const Example = () => {
  const [code, setCode] = React.useState('');
  const ref = useRef<Editor>(null);

  const onFocus = () => ref.current?.textarea?.focus();

  return (
    <div>
      <button type="button" onClick={onFocus}>
        Focus
      </button>

      <Editor
        ref={ref}
        value={code}
        onValueChange={setCode}
        highlight={(code) => highlight(code, languages.jsx!, 'jsx')}
      />
    </div>
  );
};

Closes #69 and Closes #25

@alexandernst
Copy link

@oliviertassinari 👀 can we get this merged? 🙏

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

Successfully merging this pull request may close these issues.

Expose lower-API to modify text and selection, and to query selection Implement a focus method
2 participants