mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 09:43:58 +02:00
feat: add useComposing hook (#5695)
This commit is contained in:
5
.changeset/ten-queens-walk.md
Normal file
5
.changeset/ten-queens-walk.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: Add useComposing hook"
|
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
React hooks for Slate editors
|
React hooks for Slate editors
|
||||||
|
|
||||||
|
#### `useComposing(): boolean`
|
||||||
|
|
||||||
|
Get the current `composing` state of the editor. It deals with `compositionstart`, `compositionupdate`, `compositionend` events.
|
||||||
|
|
||||||
#### `useFocused(): boolean`
|
#### `useFocused(): boolean`
|
||||||
|
|
||||||
Get the current `focused` state of the editor.
|
Get the current `focused` state of the editor.
|
||||||
|
File diff suppressed because it is too large
Load Diff
15
packages/slate-react/src/hooks/use-composing.ts
Normal file
15
packages/slate-react/src/hooks/use-composing.ts
Normal 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)
|
||||||
|
}
|
Reference in New Issue
Block a user