Overview
TheuseYooptaReadOnly hook returns a boolean indicating whether the editor is currently in read-only mode. When read-only is enabled, users cannot edit content but can still read and select text.
Usage
Signature
Returns
boolean - true if the editor is in read-only mode, false otherwise
Examples
Conditional Toolbar Rendering
Read-Only Indicator
Disable Edit Actions
Conditional Styling
Export-Only Mode
Toggle Read-Only Mode
Permission-Based Editing
Keyboard Shortcut Protection
Use Cases
- View Mode: Display content without allowing edits
- Permission Controls: Restrict editing based on user permissions
- Review Mode: Allow stakeholders to review content without changes
- Published Content: Show finalized documents in read-only mode
- Conditional UI: Show/hide editing tools based on mode
- Export Views: Provide read-only view with export options
- Archived Content: Display historical content that shouldn’t be modified
Setting Read-Only Mode
The read-only state is set on the editor instance and passed as a prop toYooptaEditor:
Implementation Details
Under the hood, this hook accesses thereadOnly property from the editor instance:
See Also
- useYooptaEditor - Access the editor instance
- useYooptaFocused - Check editor focus state
- YooptaEditor Component - Main editor component