viliusle / miniPaint

online image editor
http://viliusle.github.io/miniPaint/
Other
2.59k stars 602 forks source link

IME input compatible #396

Closed new-sankaku closed 3 months ago

new-sankaku commented 3 months ago

I believe this is an excellent project!

The issue is as follows: The text input needs to be compatible with IME string input.

Here's a brief overview of the problem: For languages like English, strings are directly input into the Input field. However, for some languages (such as Japanese and Chinese), input is done through an IME. The IME treats the input string as a buffer. Since this buffer passes the entire string being input each time the input event is called, the current process results in the string being displayed in duplicate.

For example, when typing "ABC", the Input fires events for "A", "AB", "ABC". As a result, "AABABC" is entered on the screen (this example uses English characters for illustration purposes). This can be critical for countries that standardly use an IME.

viliusle commented 3 months ago

Can you help me to reproduce issue on live? I see that I need to use text tool and add Chinese text. But no luck so far. Or this is only case with extra events, causing issues for other developers?

Test string used:

第一行。
第二行。
最后一行
new-sankaku commented 3 months ago

Are you asking for a test with Chinese input? I am a Japanese user, so I will install the Chinese language pack and check.

By additional events, are you referring to the ones implemented in the Pull Request, such as compositionstart and compositionend? These events occur in languages that use an IME, so I believe the impact would be on users in those language regions. If this doesn't answer your question, please correct me.

viliusle commented 3 months ago

I mean is there simple way to reproduce this issue, so I can double check that your PR works? But if you are Japanese user, I will trust you and only double check English. No need to install Chinese language.

viliusle commented 3 months ago

English is fine. I included your PR manually (wanted to ignore dist/* files). Thank you for PR.

viliusle commented 3 months ago

Pushed to live.

new-sankaku commented 3 months ago

We passed each other. I have confirmed that the PR has been approved. Thank you for your response.

I have attached a video of before and after the modification. Thank you for the quick response.

BEFORE

https://github.com/viliusle/miniPaint/assets/133557155/c527b422-f315-4d48-9628-bb4632acb160

AFTER

https://github.com/viliusle/miniPaint/assets/133557155/764f934d-256e-47ea-911e-46716b44c35c