feat: implement EditorSaveContext and integrate save functionality in PlateEditor and FixedToolbarButtons

This commit is contained in:
Anish Sarkar 2026-02-17 01:30:38 +05:30
parent 0edfd116af
commit 1768887be8
8 changed files with 446 additions and 290 deletions

View file

@ -0,0 +1,25 @@
'use client';
import { createContext, useContext } from 'react';
interface EditorSaveContextValue {
/** 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;
}
export const EditorSaveContext = createContext<EditorSaveContextValue>({
hasUnsavedChanges: false,
isSaving: false,
canToggleMode: false,
});
export function useEditorSave() {
return useContext(EditorSaveContext);
}