-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: embedded image replaced by plain text unicode when adding Chinese text #2505
base: master
Are you sure you want to change the base?
Conversation
…when inputting Chinese with Sogou Pinyin.
I'm going to test these changes as soon as I can to see if it doesn't damage or break anything (i.e. works for both Chinese and other languages) |
@mchangtian could you test if this fix actually works on the web as well? That's where I get the most errors when using Note For example, when I tried to select the line below while the cursor was in a Header block ( |
@CatHood0 Based on my testing, the issue with |
To test this even better, I'll first merge PR #2512 into the main branch, and then add some test for the |
Description
Fix cursor misalignment when inputting Chinese with Sogou Pinyin. Prevent images from being converted to
obj
after inserting Chinese text.Related Issues
Technical Context for Chinese IMEs
IME Composition Behavior
Chinese input methods like Sogou Pinyin use multi-step composition:
Users type phonetic text (e.g., "nihao") → IME shows candidate characters (e.g., "你好")
During composition, the cursor position is managed by the IME's temporary text buffer.
Unlike Microsoft Pinyin (which tightly integrates with OS-level text APIs), third-party IMEs like Sogou may not always synchronize composition ranges correctly with the framework.
Why This Fix Is Needed
Sogou Pinyin Issue:
During composition,
selection.extentOffset
might point to the phonetic input position (e.g., after "niha"), not the final character position. This causes cursor misalignment when text is committed.Microsoft Pinyin Workaround:
It automatically adjusts cursor positions through OS-level text services, making explicit handling unnecessary.
Key Implementation Logic
isComposingRangeValid
: Checks if the IME is in composition mode.value.composing.end
: Uses the end position of the IME's composition range instead of the default cursor position.getDiff()
: Calculates positional adjustments based on the actual committed text vs. intermediate composition state.References for Further Discussion
Type of Change