Preserve active formats when applying annotations. - #48
Conversation
- Updated the `__experimentalCreatePrepareEditableTree` method to preserve user-defined active formats when applying annotations, ensuring that formats like bold are not lost. - Modified the `addInvisibleFormats` function to pass the entire value object, allowing for better management of active formats. - Enhanced the `getActiveFormats` function to filter out editor-only formats (like annotations) from active formats, ensuring they do not interfere with user selections. - Adjusted the `useRichText` hook to maintain active formats during updates when only formats change. - Updated event listeners to filter out editor-only formats when updating active formats during typing. These changes improve the user experience by maintaining formatting consistency when annotations are applied programmatically. Refs WordPress#71698
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Size Change: +158 B (+0.01%) Total Size: 2.2 MB
ℹ️ View Unchanged
|
What?
Fixes WordPress#71698
Preserve active formatting during programmatic annotation changes.
Why?
See the original report in WordPress#71698.
When typing with active formatting, programmatic changes to the annotations would cause active formats to be lost.
How?
Filters out annotation formats (editor-only) from activeFormats in getActiveFormats and related code paths, and preserves user activeFormats (e.g., bold) when annotations are applied programmatically, so annotations don't interfere with typing.
Testing Instructions
Instructions copied from the original issue:
Testing Instructions for Keyboard
This change is entirely about typing in editable areas.
Screenshots or screencast
before.mp4
after.mp4