Skip to content

registerInsertTextListener? #2057

Answered by trueadm
diegohaz asked this question in Q&A
May 3, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The way you describe above is correct – comparing the text before and after. The reason why event.inputType is unreliable is because it's not always fired for all text inputs. For example, it's not guaranteed to fire for composition, and in most cases we actually let the browser do the default thing and read the DOM to ensure cross-browser consistency (especially on Android). Another thing to note, is that the text might not have been inserted the same way – if a transform changes the input or blocks it.

So the most consistent way is to use editor.registerTextContentListener() and store the previous value, so you can easily compare. registerTextContentListener will only fire if the text c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@diegohaz
Comment options

Answer selected by diegohaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants