@lexiwind/history
v3.1.0
Published
Undo/redo history plugin for Lexiwind
Maintainers
Readme
@lexiwind/history
Undo/redo history plugin for Lexiwind — manage editor state history with keyboard shortcuts.
Overview
This plugin adds complete undo/redo functionality to your Lexiwind editor. It manages the editor's state history and provides keyboard shortcuts (Ctrl+Z / Cmd+Z for undo, Ctrl+Shift+Z / Cmd+Shift+Z for redo).
Installation
npm install @lexiwind/historyFeatures
- Undo/Redo — Navigate through editor state history
- Keyboard shortcuts — Built-in Ctrl+Z and Ctrl+Shift+Z support
- History limit — Configurable history size to manage memory
- State snapshots — Efficient state management
Quick Start
Add the plugin to your editor:
import { LexicalComposer } from "@lexical/react/LexicalComposer";
import { HistoryPlugin } from "@lexiwind/history";
export function MyEditor() {
return (
<LexicalComposer initialConfig={editorConfig}>
<HistoryPlugin />
{/* other plugins... */}
</LexicalComposer>
);
}Usage with Hooks
import { useHistory } from "@lexiwind/history";
function UndoRedoButtons() {
const { canUndo, canRedo, undo, redo } = useHistory();
return (
<>
<button onClick={undo} disabled={!canUndo}>
Undo
</button>
<button onClick={redo} disabled={!canRedo}>
Redo
</button>
</>
);
}API
HistoryPlugin
Main plugin component for history management.
Props:
maxHistorySize(optional): Maximum history states to keep. Default:100
useHistory Hook
const { canUndo, canRedo, undo, redo } = useHistory();Returns:
canUndo: Boolean indicating if undo is availablecanRedo: Boolean indicating if redo is availableundo(): Function to perform undoredo(): Function to perform redo
Learn More
See the main Lexiwind documentation for more examples.
