slate-react 0.77.4 → 0.78.1-202233022229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2999,8 +2999,20 @@
2999
2999
  }
3000
3000
  }, [readOnly, attributes.onFocus]),
3001
3001
  onKeyDown: React.useCallback(function (event) {
3002
- if (!readOnly && hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onKeyDown) && !state.isComposing) {
3003
- var nativeEvent = event.nativeEvent;
3002
+ if (!readOnly && hasEditableTarget(editor, event.target)) {
3003
+ var nativeEvent = event.nativeEvent; // COMPAT: The composition end event isn't fired reliably in all browsers,
3004
+ // so we sometimes might end up stuck in a composition state even though we
3005
+ // aren't composing any more.
3006
+
3007
+ if (state.isComposing && nativeEvent.isComposing === false) {
3008
+ state.isComposing = false;
3009
+ setIsComposing(false);
3010
+ }
3011
+
3012
+ if (isEventHandled(event, attributes.onKeyDown) || state.isComposing) {
3013
+ return;
3014
+ }
3015
+
3004
3016
  var selection = editor.selection;
3005
3017
  var element = editor.children[selection !== null ? selection.focus.path[0] : 0];
3006
3018
  var isRTL = direction_1(slate.Node.string(element)) === 'rtl'; // COMPAT: Since we prevent the default behavior on