2024-06-25 15:48:20 +02:00
|
|
|
<template>
|
|
|
|
|
<UButtonGroup
|
|
|
|
|
size="sm"
|
|
|
|
|
orientation="horizontal"
|
2024-09-23 20:02:38 +02:00
|
|
|
class="shadow-none"
|
2024-06-25 15:48:20 +02:00
|
|
|
>
|
2024-07-17 16:07:19 +02:00
|
|
|
<UTooltip
|
|
|
|
|
text="Undo"
|
|
|
|
|
:shortcuts="[metaSymbol,'Z']"
|
|
|
|
|
:popper="{ placement: 'left' }"
|
|
|
|
|
>
|
2024-07-02 15:15:59 +02:00
|
|
|
<UButton
|
|
|
|
|
:disabled="!canUndo"
|
|
|
|
|
color="white"
|
|
|
|
|
icon="i-material-symbols-undo"
|
2024-09-23 20:02:38 +02:00
|
|
|
class="disabled:text-gray-500 shadow-none"
|
2024-07-02 15:15:59 +02:00
|
|
|
@click="undo"
|
|
|
|
|
/>
|
|
|
|
|
</UTooltip>
|
2024-07-17 16:07:19 +02:00
|
|
|
<UTooltip
|
|
|
|
|
text="Redo"
|
|
|
|
|
:shortcuts="[metaSymbol,'Shift','Z']"
|
|
|
|
|
:popper="{ placement: 'right' }"
|
|
|
|
|
>
|
2024-07-02 15:15:59 +02:00
|
|
|
<UButton
|
|
|
|
|
:disabled="!canRedo"
|
|
|
|
|
icon="i-material-symbols-redo"
|
|
|
|
|
color="white"
|
2024-09-23 20:02:38 +02:00
|
|
|
class="disabled:text-gray-500 shadow-none"
|
2024-07-02 15:15:59 +02:00
|
|
|
@click="redo"
|
|
|
|
|
/>
|
|
|
|
|
</UTooltip>
|
2024-06-25 15:48:20 +02:00
|
|
|
</UButtonGroup>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
const workingFormStore = useWorkingFormStore()
|
|
|
|
|
|
|
|
|
|
const { undo, redo, clearHistory } = workingFormStore
|
|
|
|
|
const { canUndo, canRedo } = storeToRefs(workingFormStore)
|
|
|
|
|
|
2024-07-02 15:15:59 +02:00
|
|
|
defineShortcuts({
|
|
|
|
|
meta_z: {
|
|
|
|
|
whenever: [canUndo],
|
|
|
|
|
handler: () => {
|
|
|
|
|
undo()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
meta_shift_z: {
|
|
|
|
|
whenever: [canRedo],
|
|
|
|
|
handler: () => {
|
|
|
|
|
redo()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-07-17 16:07:19 +02:00
|
|
|
const { metaSymbol } = useShortcuts()
|
2024-07-02 15:15:59 +02:00
|
|
|
|
2024-06-25 15:48:20 +02:00
|
|
|
onMounted(() => {
|
|
|
|
|
setTimeout(() => { clearHistory() }, 500)
|
|
|
|
|
})
|
2024-07-02 15:15:59 +02:00
|
|
|
|
2024-06-25 15:48:20 +02:00
|
|
|
</script>
|