Skip to content

Fix spaces being overwritten by the next typed character - #2

Merged
kpaede merged 1 commit into
kpaede:mainfrom
Potzi123:fix/space-overwritten
Nov 1, 2026
Merged

kpaede merged 1 commit into
kpaede:mainfrom
Potzi123:fix/space-overwritten

Conversation

@Potzi123

Copy link
Copy Markdown
Contributor

Fixes #1

Problem

Typing a space and then a letter removed the space (e.g. hello world became helloworld), 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 to body. That element had white-space: normal, while ProseMirror requires pre-wrap (it logs a warning about it in the console). With normal, 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 in styles.css. The selector isn't scoped under .docxidian-host because the hidden editor sits directly in body.

Testing

  • Reproduced the bug in a browser harness with the plugin's DocxReactView, then confirmed that spaces are kept once the rule is added.
  • Tested in Obsidian with a fresh test vault: typing words separated by spaces now works.

Full disclosure: this fix was vibecoded too, but it should work now. We hope it gets merged!

🤖 Generated with Claude Code

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>
@kpaede
kpaede merged commit 5b4ed12 into kpaede:main Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cant type spaces when there is no text in front of it.

2 participants