Hi there, thanks so much for your work on this!
I'm using insert() to add a new block when a user clicks a button:
insert(blockType) {
// need to be explicit with index, otherwise editor.js adds block at the beginning...
const index = editor.blocks.getBlocksCount() + 1
editor.blocks.insert(blockType, {}, {}, index, true)
}
<ul>
<li @click="insert('header')">Title</li>
<li @click="insert('paragraph')">Text</li>
</ul>
Even though I set the last param (needToFocus) to true, it doesn't focus the newly inserted block.
Of course, you can use the Caret API to focus the last inserted block like so:
editor.caret.setToLastBlock('start', 0)
... but then what is the needToFocus param for in the insert() method? :)
BUMP -> What's the status of this? I'm running into this issue as well.
We've found some misunderstanding in usage of needToFocus param. Actually, it does not set a caret for now but changes the focused (highlighted) state of the block.
We will change its behaviour in the next versions.
I tried to use ‘api.caret.setToBlock('end', blockIndex)’ to make it work fine. But it always returns false.
By the way,How can I move the cursor to this new block