mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
28 lines
764 B
JavaScript
28 lines
764 B
JavaScript
import React, { createContext, useContext, useEffect } from 'react';
|
|
import { useFileManagementContext } from './FileManagementContext';
|
|
|
|
const EditorContentContext = createContext();
|
|
|
|
export const EditorContentProvider = ({ children }) => {
|
|
const { content, handleContentChange, handleSave, selectedFile } =
|
|
useFileManagementContext();
|
|
|
|
return (
|
|
<EditorContentContext.Provider
|
|
value={{ content, handleContentChange, handleSave }}
|
|
>
|
|
{children}
|
|
</EditorContentContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useEditorContent = () => {
|
|
const context = useContext(EditorContentContext);
|
|
if (context === undefined) {
|
|
throw new Error(
|
|
'useEditorContent must be used within an EditorContentProvider'
|
|
);
|
|
}
|
|
return context;
|
|
};
|