Remove Zero Width Spaces on MDAST operations #2720
Merged
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.
Description
Fixes #2717
Removes
​/\u200bthat gets injected by some browsers (Chromium).We don't generate the ZWS in our editor, but can be copied and pasted from somewhere else. Since this character can spawn in other circumstances (HTML import, node replacements, some Android IMEs), the most effective place to remove this character is inside the markdown strings we give to the MDAST pipelines (export/import).
Screenshots
tbd
Additional Context
Removing the ZWS inside the editor, while editing, involves selection heuristics that we're better off not touching. Lexical uses it on any device that's not Apple.
This character can't spawn unwillingly on iOS devices, it's a Chrom(ium) thing afaict
Checklist
Are your changes backward compatible? Please answer below:
For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.
Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7, touches only textnode visitors
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
Not a frontend change, but I've tested this on Android which is the most impacted platform.
Did you introduce any new environment variables? If so, call them out explicitly here:
n/a
Did you use AI for this? If so, how much did it assist you?
No
Note
Ensures markdown passed through Lexical and MDAST is free of zero‑width spaces that some browsers inject.
removeZeroWidthSpaceand apply it in$getMarkdown,markdownToLexical(pre-import), andlexicalToMarkdown(post-export)FormikBridgePluginto use$getMarkdown()for syncing, instead of rawgetTextContent()$isMarkdownEmpty()unchangedWritten by Cursor Bugbot for commit ac64e59. This will update automatically on new commits. Configure here.