Open Matrixbirds opened 1 year ago
My colleague find a way to break out this case, the solution is binding events on beforeinput, we can force delete the content before prosemirror-view
do some procedure, but it seems will not generate save editing history.
Composition input with a cross-block selection is really difficult to handle. The browser will do its messy and implementation-dependent DOM mangling, and then immediately start an input composition, generally in a DOM structure that doesn't correspond to what ProseMirror would have created for that action. Touching the DOM or selection during a composition will break it in unpredictable ways (sometimes you get no input, as seems to be the case for you here, sometimes Chrome will duplicate the input).
By the time compositionstart
(or even beforeinput
) fires, the browser has already committed to the composition, so there doesn't seem to be a way to detect this happening in advance and prepare the DOM structure either.
Which demo can reproduce it?
prosemirror offical website: https://prosemirror.net/examples/dino/
What’s the bug you are facing?
Inputing characters with Pinyin Input Method the first characters will be dropped and it will not replaced content which was selected.
What browser are you using?
Chrome
Code example
https://prosemirror.net/examples/dino/
What did you expect to happen?
It should be replaced by Pinyin Input Method characters which did input as expect.
Anything to add? (optional)
Expected Result:
The selection of content will be replaced by Chinese Pinyin Input Method characters.
Actually Result:
The selection of content will be replaced but the prosemirror-view don't insert correct characters in the editor dom content area. It seems something ate the characters, until typing the second characters that will be visible in editor content.
Here is the video record to reproduce
https://github.com/ProseMirror/prosemirror/assets/9990676/f3133d47-6ac5-4a77-96c5-a6c97f072a5d