diff --git a/libs/horizon/src/event/HorizonEventMain.ts b/libs/horizon/src/event/HorizonEventMain.ts index e099dda8..c550fdbe 100644 --- a/libs/horizon/src/event/HorizonEventMain.ts +++ b/libs/horizon/src/event/HorizonEventMain.ts @@ -7,7 +7,6 @@ import { EVENT_TYPE_BUBBLE, EVENT_TYPE_CAPTURE, } from './const'; -import { getListeners as getBeforeInputListeners } from './simulatedEvtHandler/BeforeInputEventHandler'; import { getListeners as getChangeListeners } from './simulatedEvtHandler/ChangeEventHandler'; import { getListeners as getSelectionListeners } from './simulatedEvtHandler/SelectionEventHandler'; import { @@ -105,15 +104,6 @@ function getProcessListeners( target, )); } - - if (horizonEventToNativeMap.get('onBeforeInput').includes(nativeEvtName)) { - listenerList = listenerList.concat(getBeforeInputListeners( - nativeEvtName, - nativeEvent, - vNode, - target, - )); - } } return listenerList; } diff --git a/libs/horizon/src/event/const.ts b/libs/horizon/src/event/const.ts index 7aebfa15..449663e9 100644 --- a/libs/horizon/src/event/const.ts +++ b/libs/horizon/src/event/const.ts @@ -27,7 +27,6 @@ export const horizonEventToNativeMap = new Map([ ['onCompositionEnd', ['compositionend']], ['onCompositionStart', ['compositionstart']], ['onCompositionUpdate', ['compositionupdate']], - ['onBeforeInput', ['compositionend', 'keypress', 'textInput']], ['onChange', ['change', 'click', 'focusout', 'input']], ['onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin', 'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']], @@ -71,7 +70,6 @@ export const CommonEventToHorizonMap = { compositionupdate: 'compositionUpdate', }; -export const CHAR_CODE_ENTER = 13; export const CHAR_CODE_SPACE = 32; diff --git a/libs/horizon/src/event/simulatedEvtHandler/BeforeInputEventHandler.ts b/libs/horizon/src/event/simulatedEvtHandler/BeforeInputEventHandler.ts deleted file mode 100644 index e05b175f..00000000 --- a/libs/horizon/src/event/simulatedEvtHandler/BeforeInputEventHandler.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type {VNode} from '../../renderer/Types'; -import type {AnyNativeEvent} from '../Types'; -import {getListenersFromTree} from '../ListenerGetter'; -import {decorateNativeEvent} from '../customEvents/EventFactory'; -import {CHAR_CODE_SPACE, EVENT_TYPE_ALL} from '../const'; -import {ListenerUnitList} from '../Types'; -const SPACE_CHAR = String.fromCharCode(CHAR_CODE_SPACE); - -function getInputCharsByNative( - eventName: string, - nativeEvent: any, -): string | null { - if (eventName === 'compositionend') { - return (nativeEvent.detail && nativeEvent.detail.data) || null; - } - if (eventName === 'keypress') { - return nativeEvent.which === CHAR_CODE_SPACE ? SPACE_CHAR : null; - } - if (eventName === 'textInput') { - return nativeEvent.data === SPACE_CHAR ? null : nativeEvent.data; - } - return null; -} - -// 自定义beforeInput的hook事件处理 -export function getListeners( - nativeEvtName: string, - nativeEvent: AnyNativeEvent, - vNode: null | VNode, - target: null | EventTarget, -): ListenerUnitList { - const chars = getInputCharsByNative(nativeEvtName, nativeEvent); - // 无字符将要输入,无需处理 - if (!chars) { - return []; - } - - const event: AnyNativeEvent = decorateNativeEvent( - 'onBeforeInput', - 'beforeinput', - nativeEvent, - ); - event.data = chars; - - return getListenersFromTree(vNode, 'onBeforeInput', event, EVENT_TYPE_ALL); -}