2026-02-17 12:47:39 +05:30
|
|
|
"use client";
|
2026-02-17 01:30:38 +05:30
|
|
|
|
2026-02-17 12:47:39 +05:30
|
|
|
import { createContext, useContext } from "react";
|
2026-02-17 01:30:38 +05:30
|
|
|
|
|
|
|
|
interface EditorSaveContextValue {
|
2026-02-17 12:47:39 +05:30
|
|
|
/** Callback to save the current editor content */
|
|
|
|
|
onSave?: () => void;
|
|
|
|
|
/** Whether there are unsaved changes */
|
|
|
|
|
hasUnsavedChanges: boolean;
|
|
|
|
|
/** Whether a save operation is in progress */
|
|
|
|
|
isSaving: boolean;
|
|
|
|
|
/** Whether the user can toggle between editing and viewing modes */
|
|
|
|
|
canToggleMode: boolean;
|
2026-02-17 01:30:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const EditorSaveContext = createContext<EditorSaveContextValue>({
|
2026-02-17 12:47:39 +05:30
|
|
|
hasUnsavedChanges: false,
|
|
|
|
|
isSaving: false,
|
|
|
|
|
canToggleMode: false,
|
2026-02-17 01:30:38 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export function useEditorSave() {
|
2026-02-17 12:47:39 +05:30
|
|
|
return useContext(EditorSaveContext);
|
2026-02-17 01:30:38 +05:30
|
|
|
}
|