import * as React from "react"; import Code from "../Code"; export default function UndoRedo() { return (
When instantiating kbar, we can optionally enable undo/redo
functionality through options.enableHistory:
`}
/>
When we use enableHistory, we let kbar know that we would
like to use the internal HistoryImpl object to store
actions that are undoable in a history stack.
When enabled, keyboard shortcuts meta
z and meta
shift
z will appropriately undo and redo actions in the stack.
You may notice that we only have a perform property on an{" "}
Action. To define the negate action, simply return a
function from the perform:
{
// logic to perform action
return () => {
// logic to undo the action
}
},
// ...
})
`}
/>