fix: [AndroidEditor] Solve input association problems and add click events. #4734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I asked some questions about Android devices earlier in #4705 . I tried to switch to
DefaultEditable
but that didn't resolve my questions. After i read source code aboutAndroidEditable
. I may sum up a few questions and try to resolve them.Q:
A:
MutationObserver
is used inAndroidEditable
to monitor DOM changes. Whenever we input a character,MutationObserver
will be triggered andinsertText
into the editor. However, in the keyboard association state, performing a delete operation or inputting characters may trigger character association, and then unexpected characters are added between triggering the onDOMBeforeInput event and triggering the MutationObserver event. I haven't figured out the reason yet, but I try to solve it in another way. The association function will trigger thecomposition
event, so I attempt to record the characters that originally wanted to insertText in the MutationObserver event in theisComposing
, and theninsertText
in theonCompositionend
event.Editable
. By the way, i also synchronize some other code fromEditable
like fix: flush selection change on before input #4669 .Example
before
Record_2021-12-15-23-11-37_40deb401b9ffe8e1df2f1c.mp4
after
Record_2021-12-15-23-12-28_40deb401b9ffe8e1df2f1c.mp4
Image can be clicked.
Record_2021-12-16-01-44-28_40deb401b9ffe8e1df2f1c.mp4
Context
There are still some minor problems. When the above method is triggered, the mark setting cannot take effect immediately, but it takes effect after
onCompositionend
.Record_2021-12-16-01-04-40_40deb401b9ffe8e1df2f1c.mp4
Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)