1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-11 17:53:59 +02:00

feat: add useComposing hook (#5695)

This commit is contained in:
yf-yang
2024-08-21 07:03:03 +08:00
committed by GitHub
parent e5fed793e7
commit 6cb38e37a4
4 changed files with 854 additions and 813 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': minor
---
feat: Add useComposing hook"

View File

@@ -8,6 +8,10 @@
React hooks for Slate editors
#### `useComposing(): boolean`
Get the current `composing` state of the editor. It deals with `compositionstart`, `compositionupdate`, `compositionend` events.
#### `useFocused(): boolean`
Get the current `focused` state of the editor.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
import { createContext, useContext } from 'react'
/**
* A React context for sharing the `composing` state of the editor.
*/
export const ComposingContext = createContext(false)
/**
* Get the current `composing` state of the editor.
*/
export const useComposing = (): boolean => {
return useContext(ComposingContext)
}