Is it possible to get the block ID of the current cursor position?
I’ve read the editorApi but only
getTextSelection are available.
I’d like to be able to insert some text at the current cursor position, or if that’s not possible add a block after the current active block. Any ideas on how to achieve this?
Hi, getSelection will give you the block ID, even if you are editing the block, so you can use that in the mac app.
The cursor position is not yet available, but in the future we are planning to surface a lot more information about the editor’s state and this should be available then.
In the developer preview there are still some differences in the way this works across the mac and web app, so on the web clicking on a button in an extension actually takes away the focus from the currently edited block and makes it difficult to use this API. Over time we will fix these differences so extensions can rely on a consistent behavior across platforms.
Thanks for responding. I was testing this out in the web app so no wonder getSelection didn’t work. That makes total sense with it losing focus.