Download slate/packages/slate-react/src/hooks/use-slate-selection.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/slate/packages/slate-react/src/hooks/use-slate-selection.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/slate/packages/slate-react/src/hooks/use-slate-selection.tsx
-
curl -L -o use-slate-selection.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/slate/packages/slate-react/src/hooks/use-slate-selection.tsx
481 Bytes
| import { BaseSelection, Range } from 'slate' | |
| import { useSlateSelector } from './use-slate-selector' | |
| /** | |
| * Get the current slate selection. | |
| * Only triggers a rerender when the selection actually changes | |
| */ | |
| export const useSlateSelection = () => { | |
| return useSlateSelector(editor => editor.selection, isSelectionEqual) | |
| } | |
| const isSelectionEqual = (a: BaseSelection, b: BaseSelection) => { | |
| if (!a && !b) return true | |
| if (!a || !b) return false | |
| return Range.equals(a, b) | |
| } | |