question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autofocus only works if Editor is created with a mobiledoc

See original GitHub issue

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
})

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sdhullcommented, 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.

1reaction
knownasilyacommented, Apr 5, 2017

Also ran into this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

autofocus in html input tag only works once. Is there a way I ...
I'm working on an in-browser editor that requires quick editing of single words. I'm trying to implement it by replacing specific words with ......
Read more >
bustlelabs/mobiledoc-kit
We're using mobiledoc to create image cards that contain captions. To create these captions, we're rendering a new mobiledoc editor.
Read more >
react-mobiledoc-editor: Documentation
react-mobiledoc-editor supports the creation of Mobiledoc Cards as React ... Please note that by itself, Container only renders an empty root-level ...
Read more >
Use Mobiledoc-Kit to build an auto-linking text editor
In this post I'll showcase one of the useful editing hooks that the Mobiledoc API offers: onTextInput . I'll create a text editor...
Read more >
Autofocus only works in Liveview mode. HELP!
Autofocus is struggling to operate in general when I'm looking through the ... However this is my only autofocusing lens made for FF, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found