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

autofocus "select all" #2181

Closed
1 task
dusty-phillips opened this issue Nov 21, 2021 · 1 comment
Closed
1 task

autofocus "select all" #2181

dusty-phillips opened this issue Nov 21, 2021 · 1 comment

Comments

@dusty-phillips
Copy link

dusty-phillips commented Nov 21, 2021

What problem are you facing?

In some cases when I initialize an editor, I want to immediately focus and select all the content.

What’s the solution you would like to see?

The autofocus property of editor accepts several parameters for what position in the text should be selected: start, end, or a number. I would like a new possible value of all or selectAll to be an option.

  const editor = useEditor({
    autofocus: "all"
    ...
  })

What alternatives did you consider?

I currently do this in a useEffect hook:

  useEffect(() => {
    if (editor) {
      setTimeout(() => {
        editor().focus().selectAll().run()
      })
    }
  }, [editor])

Anything to add? (optional)

No response

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@philippkuehn
Copy link
Contributor

added and released!

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