2022-07-18 04:09:17 +00:00
|
|
|
import { ReactNode, useState } from "react"
|
|
|
|
import { EditingContext, EditingMode } from "./base"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component which stores the current editing mode (by default {@link EditingMode.VIEW}) using {@link useState} and provides it to its children through an {@link EditingContext}.
|
|
|
|
*/
|
2022-07-18 04:09:51 +00:00
|
|
|
export const EditingContextProvider = ({ children }: { children: ReactNode }): JSX.Element => {
|
2022-07-18 04:09:17 +00:00
|
|
|
return (
|
|
|
|
<EditingContext.Provider value={useState<EditingMode>(EditingMode.VIEW)}>
|
|
|
|
{children}
|
|
|
|
</EditingContext.Provider>
|
|
|
|
)
|
|
|
|
}
|