Repository navigation
Fix spaces being overwritten by the next typed character - #2
Merged
Merged
Conversation
The editor types into a hidden ProseMirror element portaled to body. Without white-space: pre-wrap, a trailing space collapses, and the browser replaces it when the next character is typed. Add the base ProseMirror white-space rules for that element. Fixes kpaede#1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #1
Problem
Typing a space and then a letter removed the space (e.g.
hello worldbecamehelloworld), unless there was text to the right of the cursor on the same line.Cause
The editor types into a hidden ProseMirror element (
.paged-editor__hidden-pm) that is portaled tobody. That element hadwhite-space: normal, while ProseMirror requirespre-wrap(it logs a warning about it in the console). Withnormal, a space at the end of a line collapses, so the browser overwrites it when the next character is typed, and ProseMirror records that as a real edit, so the space is lost from the document.Fix
Add the base ProseMirror rules (
white-space: pre-wrap,word-wrap: break-word,font-variant-ligatures: none) for that element instyles.css. The selector isn't scoped under.docxidian-hostbecause the hidden editor sits directly inbody.Testing
DocxReactView, then confirmed that spaces are kept once the rule is added.Full disclosure: this fix was vibecoded too, but it should work now. We hope it gets merged!
🤖 Generated with Claude Code