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-read-only.ts
1698 views
1
import { createContext, useContext } from "react";
2
3
/**
4
* A React context for sharing the `readOnly` state of the editor.
5
*/
6
7
export const ReadOnlyContext = createContext(false);
8
9
/**
10
* Get the current `readOnly` state of the editor.
11
*/
12
13
export const useReadOnly = (): boolean => {
14
return useContext(ReadOnlyContext);
15
};
16
17