ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.9k stars 3.25k forks source link

Cannot input chinese directly after the mention in mention demo #3490

Closed zhaoyao91 closed 2 years ago

zhaoyao91 commented 4 years ago

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

Kapture 2020-02-10 at 12 41 17

https://www.slatejs.org/examples/mentions

Slate: I don't know Mac OS: 10.15.3 Chrome: 80.0.3987.87

What's the expected behavior?

When typing Chinese after the mention (void node), it could work fine, but it seems breaking the slate structure and the following typing is buggy.

tangzijun commented 4 years ago

It is used in safari. After entering Chinese, the cursor is always at the front of the paragraph. This problem is very disturbing. I don't know how the problem is solved. I use the latest version of 0.57.1.

pedily commented 4 years ago

I can confirm similar issues with Microsoft IME whenever using IME input at offset 0 behind another element.

The IME widget will modify the wrong dom element.

My workaround is to insert a character without IME first, then use IME input, then deleting the character again

scil commented 4 years ago

it's about IME. Chinsese can not be used well on slate right now. because IME related DOM event damage React Reconciliation.

3824

hardywu commented 3 years ago

confirm that it still appears on safari right now with version 0.59.0

xxxxxccc commented 3 years ago

version 0.65 still has this problem, input chinese after a void node; use macos ,when u 'ArrowLeft' or 'ArrowRight' choose a chinese word ,the cursor incorrect

jim-kk-hc commented 2 years ago

+1

dylans commented 2 years ago

I believe what needs to be done is to add an empty whitespace character after the mention gets inserted. At least I think that's what we did for the implementation in Plate.

pubuzhixing8 commented 2 years ago

In the earlier slate-angular fixed this problem, mention example: http://slate-angular.ngnice.com/mentions, probably the problem is that the tag containing the [data-slate-spacer="true"] will interrupt the IME input, so slate-angular move all [data-slate-spacer="true"] tag to the front of [void text] to avoid IME input being interrupted, it has been working fine in Prod environment for a while without any additional issues, I plan to submit a PR with such changes.

slate-react DOM:

slate-angular DOM:

jim-kk-hc commented 2 years ago

d

I asked you this question in Zhihu last week. It bothered me for a long time. Thank you

HUYIFU commented 3 months ago

image Changing it like I did fixed the topmost problem, but it introduced a new bug that triggered the whole editor to crash when moving the cursor left in Chinese input to the inline-block element itself, and then I couldn't stop cursor movement by disabling the call to event.preventDefault in the slate's onKeyDown event. 20240720230246_rec_ help