Skip to content

Commit

Permalink
fix(portable-text-editor): specify InputEvent event type for TS-type
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Sep 26, 2023
1 parent e259a73 commit a128ae8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/@sanity/portable-text-editor/src/editor/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {PortableTextBlock} from '@sanity/types'
import {
EditorChange,
EditorSelection,
OnBeforeInputFn,
OnCopyFn,
OnPasteFn,
OnPasteResult,
Expand Down Expand Up @@ -54,10 +53,10 @@ const EMPTY_DECORATORS: BaseRange[] = []
*/
export type PortableTextEditableProps = Omit<
React.TextareaHTMLAttributes<HTMLDivElement>,
'onPaste' | 'onCopy'
'onPaste' | 'onCopy' | 'onBeforeInput'
> & {
hotkeys?: HotkeyOptions
onBeforeInput?: OnBeforeInputFn
onBeforeInput?: (event: InputEvent) => void
onPaste?: OnPasteFn
onCopy?: OnCopyFn
renderAnnotation?: RenderAnnotationFunction
Expand All @@ -76,7 +75,8 @@ export type PortableTextEditableProps = Omit<
* @public
*/
export const PortableTextEditable = forwardRef(function PortableTextEditable(
props: PortableTextEditableProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'onPaste'>,
props: PortableTextEditableProps &
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'onPaste' | 'onBeforeInput'>,
forwardedRef: React.ForwardedRef<HTMLDivElement>,
) {
const {
Expand Down Expand Up @@ -328,7 +328,7 @@ export const PortableTextEditable = forwardRef(function PortableTextEditable(
)

const handleOnBeforeInput = useCallback(
(event: Event) => {
(event: InputEvent) => {
if (onBeforeInput) {
onBeforeInput(event)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@sanity/portable-text-editor/src/types/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import {Subject, Observable} from 'rxjs'
import {Descendant, Node as SlateNode, Operation as SlateOperation} from 'slate'
import {ReactEditor} from 'slate-react'
import {FocusEvent} from 'react'
import {FocusEvent, FormEventHandler} from 'react'
import type {Patch} from '../types/patch'
import {PortableTextEditor} from '../editor/PortableTextEditor'

Expand Down Expand Up @@ -362,7 +362,7 @@ export interface PasteData {
export type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise

/** @beta */
export type OnBeforeInputFn = (event: Event) => void
export type OnBeforeInputFn = (event: InputEvent) => void

/** @beta */
export type OnCopyFn = (
Expand Down

0 comments on commit a128ae8

Please sign in to comment.