Files
klz-cables.com/.pnpm-store/v10/files/57/3e1feaf3e7ca3cc7c2e442c9cffb37e7624732b92e04429ee87383b3593cc2a809c5e32f2d65cea350f9d4e828e6e3a1a5ceadb1ae3b6738c6776e8759de88
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

33 lines
1.1 KiB
Plaintext

# `@lexical/history`
[![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/lexical_history)
This package contains history helpers for Lexical.
### Methods
#### `registerHistory`
Registers necessary listeners to manage undo/redo history stack and related editor commands. It returns `unregister` callback that cleans up all listeners and should be called on editor unmount.
```js
function registerHistory(
editor: LexicalEditor,
externalHistoryState: HistoryState,
delay: number,
): () => void
```
### Commands
History package handles `UNDO_COMMAND`, `REDO_COMMAND` and `CLEAR_HISTORY_COMMAND` commands. It also triggers `CAN_UNDO_COMMAND` and `CAN_REDO_COMMAND` commands when history state is changed. These commands could be used to work with history state:
```jsx
import {UNDO_COMMAND, REDO_COMMAND} from 'lexical';
<Toolbar>
<Button onClick={() => editor.dispatchCommand(UNDO_COMMAND, undefined)}>Undo</Button>
<Button onClick={() => editor.dispatchCommand(REDO_COMMAND, undefined)}>Redo</Button>
</Toolbar>;
```