udecode / plate

A rich-text editor powered by AI
https://platejs.org
Other
12.14k stars 741 forks source link

Floating toolbar is always hidden in "Viewing" mode. #3492

Closed DuncanLHS closed 2 months ago

DuncanLHS commented 2 months ago

Description

Looking at the FloatingToolbarButtons component it appears to be expected that the floating toolbar is visible in Viewing mode showing only the CommentToolbarButton and MoreDropdownMenu, however the floating toolbar is not shown at all.

I've tried adjusting the floatingToolbarState to no avail:

ignoreReadOnly: true // Appears to hide the toolbar in both modes
hideToolbar: false // Appears to have no affect.

Even commenting out if (hidden) return null; in floating-toolbar doesn't allow it to render correctly.

The useFloatingToolbarState hook doesn't appear to be documented anywhere and the properties don't seem to behave as their names would suggest.

It seems the intention of the standard components is to allow comments when the editor is readOnly, this is very useful, but having only the main toolbar button to add a comment is a bit clunky. I'm struggling to find what's causing the floating toolbar to be hidden.

Oddly, clicking around to look at the state in react devtools seems to make it render intermittently, not sure what that means but maybe some kind of circular reference going on somewhere??

Reproduction URL

No response

Reproduction steps

1. Go to the playground
2. Click on mode dropdown and select "Viewing"
3. Highlighting any section of the editor value does not show the floating toolbar.

Plate version

37

Slate React version

0.109.0

Screenshots

No response

Logs

No response

Browsers

Chrome

Funding

Fund with Polar

zbeyens commented 2 months ago

Let me know if that's fixed in next release

DuncanLHS commented 2 months ago

Can confirm fixed when state showWhenReadOnly is true