MCPcopy Create free account
hub / github.com/editablejs/editable / composeEventHandlers

Function composeEventHandlers

packages/editor/src/utils/event.ts:1–13  ·  view source on GitHub ↗
(
  originalEventHandler?: (event: E) => void,
  ourEventHandler?: (event: E) => void,
  { checkForDefaultPrevented = true } = {},
)

Source from the content-addressed store, hash-verified

1export const composeEventHandlers = <E>(
2 originalEventHandler?: (event: E) => void,
3 ourEventHandler?: (event: E) => void,
4 { checkForDefaultPrevented = true } = {},
5) => {
6 return function handleEvent(event: E) {
7 originalEventHandler?.(event)
8
9 if (checkForDefaultPrevented === false || !(event as unknown as Event).defaultPrevented) {
10 return ourEventHandler?.(event)
11 }
12 }
13}
14
15export const isTouchEvent = (event: any): event is TouchEvent => {
16 return typeof window.TouchEvent !== 'undefined' && event instanceof TouchEvent

Callers 1

handlePasteFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…