Fix text starting with numbers cut off in preview#14385
Closed
Fix text starting with numbers cut off in preview#14385
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The issue was caused by `sanitizeEditorHtml` using `filterEditorState` from `draftjs-filters` library with default block text rules. These rules automatically detect text patterns like "1. hello" and convert them to ordered-list-item blocks, stripping the prefix in the process. Since the filter configuration has `blocks: []`, these list blocks are then filtered out, but the text has already been stripped of the numbers. The fix is to explicitly disable block text rules by passing an empty array `blockTextRules: []` to `filterEditorState`, which prevents the automatic list detection and preserves the original text content. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix text starting with numbers cut off in preview
Fix text starting with numbers cut off in preview
Oct 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text starting with numbered list patterns (e.g., "1. hello", "2. world") was being stripped in DisplayText preview mode, showing only "hello" and "world".
Root Cause
sanitizeEditorHtmlusesdraftjs-filters'sfilterEditorStatewhich applies default block text rules that:^1{0,1}\d\.[ \t]as ordered list markersordered-list-itemtypeWith
blocks: []in the filter config, these converted blocks are then filtered out, but the text has already lost the number prefix.Changes
blockTextRules: []tofilterEditorStatefilterEditorState( { blocks: [], styles, entities: [], maxNesting: 1, whitespacedCharacters: [], + blockTextRules: [], }, editorState )Fixes #14092
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.ampproject.orgcurl --output-dir -O -f REDACTED(dns block)googlechromelabs.github.iohttps://storage.googleapis.com/chrome-for-testing-public/141.0.7390.54/linux64/chrome-headless-shell-linux64.zipnode install.mjs(http block)https://storage.googleapis.com/chrome-for-testing-public/141.0.7390.54/linux64/chrome-linux64.zipIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.