toeverything/blocksuite

EdgelessElementToolbarWidget is not extensible

goldsam opened this issue · 1 comments

EdgelessElementToolbarWidget has hardcoded logic which supports very specific buttons for various block types. This makes it impossible for 3d party library vendors to add support for their own element toolbar buttons and customization.

Instead, it would be desirable to have a service or other other mechanism through which a block could register its own element toolbar buttons and capabilities.

Looks like it was supported after all.

For the benefit of others, the solution (observed in the ai preset code) is to implement the setup method of your BlockSpec to handle when EdgelessElementToolbarWidget is connected and call registerEntry with your custom toolbar button handler:

if (view.component instanceof EdgelessElementToolbarWidget) {
setupEdgelessElementToolbarEntry(view.component);
}