fix: treat marks with unset inclusive as inclusive when configuring text style - #81
Open
frioux wants to merge 1 commit into
Open
fix: treat marks with unset inclusive as inclusive when configuring text style#81frioux wants to merge 1 commit into
frioux wants to merge 1 commit into
Conversation
…ext style ProseMirror's MarkSpec.inclusive defaults to true when unset, and mainstream marks (bold, italic, strike, code, ...) never set it. The truthiness check mapped "unset" to expand "none", so ProseMirror extended these marks over text typed at their end while Loro did not, making the two sides disagree about mark boundaries on every keystroke of styled typing.
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.
Summary
configLoroTextStylemaps a mark's expand behavior withmarkType.spec.inclusive ? "after" : "none". But ProseMirror'sMarkSpec.inclusivedefaults totruewhen unset, and mainstream marks (Tiptap's bold, italic, strike, code, ...) never set it. The truthiness check maps "unset" to"none", so for every default-inclusive mark ProseMirror extends the mark over text typed at its end while Loro does not — the two sides of the binding permanently disagree about mark boundaries.The practical cost: every character typed while extending a bold/italic/code run lands at the run's end, so on every such keystroke the PM document and the Loro doc diverge and the binding has to emit extra style ops to repair the difference. Those redundant mark ops leave style anchors behind in the container state forever, so heavily edited styled paragraphs get permanently slower to read.
Fix
Only an explicit
inclusive: falsenow maps to"none", matching ProseMirror's documented semantics.Validation
Added
tests/text-style.test.tscovering the three cases (unset, explicitlytrue, explicitlyfalse); the unset case fails without this change.pnpm test,pnpm lint, andpnpm check-formatall pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01KQw7nfh6KaUhQy6ZQUZwMm