Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/slate-react/hooks/use-selected.ts
1698 views
1
import { createContext, useContext } from "react";
2
3
/**
4
* A React context for sharing the `selected` state of an element.
5
*/
6
7
export const SelectedContext = createContext(false);
8
9
/**
10
* Get the current `selected` state of an element.
11
*/
12
13
export const useSelected = (): boolean => {
14
return useContext(SelectedContext);
15
};
16
17