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 only works if Editor is created with a mobiledoc #511

Open
gpoitch opened this issue Nov 7, 2016 · 5 comments
Open

autofocus only works if Editor is created with a mobiledoc #511

gpoitch opened this issue Nov 7, 2016 · 5 comments
Milestone

Comments

@gpoitch
Copy link
Member

gpoitch commented Nov 7, 2016

This currently will not autofocus, because there is no document, therefore nowhere to place the cursor:

const editor = new Mobiledoc.Editor({
  placeholder: 'Write here...',
  autofocus: true
})

This works:

const editor = new Mobiledoc.Editor({
  placeholder: 'Write here...',
  autofocus: true,
  mobiledoc: {
    version: '0.3.0',
    markups: [],
    atoms: [],
    cards: [],
    sections: [[1, "p", [[0, [], 0, ""]]]]
  }
})

Auto-creating a blank mobiledoc if not provided may have some unwanted side effects.
Perhaps offering a public constant to a blank doc could be a compromise:

const editor = new Mobiledoc.Editor({
  placeholder: 'Write here...',
  autofocus: true,
  mobiledoc: Mobiledoc.BlankMobiledoc
})
@mixonic
Copy link
Contributor

mixonic commented Nov 7, 2016

Agreed, added this to the draft features 1.0 doc, will make a milestone or something today.

@gpoitch gpoitch added this to the 1.0 milestone Nov 7, 2016
@knownasilya
Copy link

Also ran into this issue.

@sdhull
Copy link

sdhull commented May 16, 2018

Minor nit: autofocus only works if Editor is created with a mobiledoc with sections. That is to say, the EMPTY_MOBILEDOC in ember-mobiledoc-editor will not suffice.

@sdhull
Copy link

sdhull commented Dec 16, 2018

FWIW, seems like this fix doesn't work in Safari. It's unclear if it's due to something specific in our implementation or a more general problem.

@sdhull
Copy link

sdhull commented Dec 16, 2018

Seems that editor.selectRange(editor.post.headPosition()) does not work in Safari

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

No branches or pull requests

4 participants