Fix Slate composition issues following Chrome 105 update

Related discussion: https://github.com/ianstormtaylor/slate/issues/5108

This block undoes the addition of div.onbeforeinput = () => {}. This is very, very
gross, but Slate uses the presence of this handler (Added in Chrome 105) to activate a
new version of it's event handling, which doesn't quite work properly in our old version
of Slate: https://github.com/ianstormtaylor/slate/issues/5108#issuecomment-1297591129

Since this was added to Chrome in v105, we can be fairly confident nothing else needs
it to exist, or will similarly fall back to document.addEventListener('beforeInput')

One day, we will update Slate to the latest version, but 0.50.x is effectively a rewrite
and we have /lots/ of custom plugins that need to be re-built and re-tested.
This commit is contained in:
Ben Gotow 2023-12-10 11:43:21 -06:00
parent 181e2fb11a
commit 79b4063ef7

View file

@ -1,5 +1,19 @@
/* /*
This file fixes a bug in Chrome where blurring / moving selection away from the composition This block undoes the addition of div.onbeforeinput = () => {}. This is very, very
gross, but Slate uses the presence of this handler (Added in Chrome 105) to activate a
new version of it's event handling, which doesn't quite work properly in our old version
of Slate: https://github.com/ianstormtaylor/slate/issues/5108#issuecomment-1297591129
Since this was added to Chrome in v105, we can be fairly confident nothing else needs
it to exist, or will similarly fall back to document.addEventListener('beforeInput')
One day, we will update Slate to the latest version, but 0.50.x is effectively a rewrite
and we have many custom plugins that need to be re-built and re-tested.
*/
delete HTMLElement.prototype.onbeforeinput;
/*
This block fixes a bug in Chrome where blurring / moving selection away from the composition
dropdown "commits" the composition but does NOT fire a textInput event to tell Slate. dropdown "commits" the composition but does NOT fire a textInput event to tell Slate.
To reproduce the bug, enter Japanese editing mode, type "korewa" and then exit the composition To reproduce the bug, enter Japanese editing mode, type "korewa" and then exit the composition