Skip to content

useGridUndoRedo

Composable for programmatic undo/redo control.

Must be used within a component that contains a TbwGrid with undoRedo and editing enabled.

useGridUndoRedo(selector: string): UndoRedoMethods
NameTypeDescription
selectorstringOptional CSS selector to target a specific grid element via
DOM query instead of using Vue’s provide/inject. Use when the component
contains multiple grids, e.g. 'tbw-grid.primary' or '#my-grid'.
<script setup>
import { useGridUndoRedo } from '@toolbox-web/grid-vue/features/undo-redo';
const { undo, redo, canUndo, canRedo, clearHistory } = useGridUndoRedo();
</script>
<template>
<div class="toolbar">
<button @click="undo" :disabled="!canUndo()">Undo</button>
<button @click="redo" :disabled="!canRedo()">Redo</button>
<button @click="clearHistory">Clear History</button>
</div>
</template>
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt