Skip to content

fix: relax split-block IME detection for heading composition#471

Merged
xiaolai merged 1 commit intomainfrom
fix/heading-ime-split-block
Mar 19, 2026
Merged

fix: relax split-block IME detection for heading composition#471
xiaolai merged 1 commit intomainfrom
fix/heading-ime-split-block

Conversation

@xiaolai
Copy link
Owner

@xiaolai xiaolai commented Mar 19, 2026

Summary

  • Replace brittle pinyin text matching with structural heading detection in splitBlockFix
  • Scan for ASCII pinyin residue instead of deleting everything to heading end (prevents data loss of user content after preedit)
  • Remove compositionPinyin emptiness guard so the fix triggers for abbreviated pinyin and browser-cleared preedit
  • Add heading type check (the split-block bug only affects headings)

Root cause: The previous fix required exact pinyin text at the original position, but by the time requestAnimationFrame fired after compositionend, the browser had already modified or cleared the heading content. The match always failed → fix never triggered.

Closes #66

Test plan

  • Unit tests: suffix preservation, abbreviated pinyin, empty heading, scan mode
  • Manual: Chinese IME in H1 heading — composed text stays in heading
  • pnpm check:all passes

The splitBlockFix required exact pinyin text to match in the heading
at the original position, but by the time requestAnimationFrame fired,
the browser had already cleared or transformed the preedit content.
This caused the fix to silently fail for all Chinese IME input in
headings — abbreviated pinyin, multi-syllable input, and even standard
pinyin were all affected.

Replace brittle pinyin matching with structural detection:
- Check original block is a heading (not just any block)
- Remove everything from startPos to heading end (handles any
  preedit state the browser left behind)
- Remove compositionPinyin guard so fix runs even when pinyin is empty
@github-actions github-actions bot enabled auto-merge (squash) March 19, 2026 09:57
@xiaolai xiaolai merged commit 59ac7af into main Mar 19, 2026
3 checks passed
@xiaolai xiaolai deleted the fix/heading-ime-split-block branch March 20, 2026 22:13
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.

中文加粗换行之后,内容会写不上,打出来按空格就会消失

1 participant