#Open Drawer on insert for custom Block component

3 messages · Page 1 of 1 (latest)

undone wraith
#

Is there an easy way to open the drawer when a custom block gets inserted into the editor? I've noticed that an InlineBlock does this - looked into that code and while I can get the drawer to open with a button + useLexicalDrawer, I'd like to open the drawer automatically when it first gets inserted in the editor. I tried a bunch of things with opening the drawer when the Block component gets mounted, but that then always happens (not just on insert).

InlineBlock seems to use createdInlineBlock/setCreatedInlineBlock from useEditorConfigContext to keep track of the most recent added inline block. Wonder if something similar has to be added for the non-inline version.

Thanks!

undone wraith