vivid-planet / comet

Comet DXP

Home Page:https://comet-dxp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React-admin-rte - option to disable ControlButtons

chernylu opened this issue · comments

What use case do you have in mind?

The 'disabled' state of each button is currently implemented individually for each button.
The link-button is disabled when no text is selected. The tab-buttons are disabled when the selected text-block is neither an ordered nor an unordered list. (Tabs work only with lists at the moment).

An alternative approach could be hiding the complete toolbar (depending on your use-case).

There is also a final-form-wrapper for the rte https://github.com/vivid-planet/comet-admin/blob/master/packages/comet-admin-rte/src/field/createFinalFormRte.tsx.
It might be a good idea to support the 'disabled'-attribute for the rte-final-form-field. Hence it could be used like any other -text-input-field.
Setting the disabled-attribute could be implemented like so:

  • draftjs' "readonly"-prop is set to true (text can not be edited)
  • control-bar is hidden

Depending on the use-case you might not want to hide the toolbar but disable all buttons. Usually a disabled field is fully visible, but you can't interact with it.

If the use case is to show non-editable content, hiding the control bar is perfectly fine

The use-case is to show the field disabled. I would prefer to show the control bar, but you can't interact with it.