Undo/redo form editor (#452)

* Undo/redo form editor

* Fix undo/redo

* Fix history with version check

* Increase default history size

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2024-06-25 19:18:20 +05:30
committed by GitHub
parent f40b95977d
commit 0334f7c883
7 changed files with 217 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<template>
<UButtonGroup
size="sm"
orientation="horizontal"
>
<UButton
:disabled="!canUndo"
color="white"
icon="i-material-symbols-undo"
class="disabled:text-gray-500"
@click="undo"
/>
<UButton
:disabled="!canRedo"
icon="i-material-symbols-redo"
color="white"
class="disabled:text-gray-500"
@click="redo"
/>
</UButtonGroup>
</template>
<script setup>
const workingFormStore = useWorkingFormStore()
const { undo, redo, clearHistory } = workingFormStore
const { canUndo, canRedo } = storeToRefs(workingFormStore)
onMounted(() => {
setTimeout(() => { clearHistory() }, 500)
})
</script>

View File

@@ -28,6 +28,9 @@
</svg>
Go back
</a>
<UndoRedo />
<div class="hidden md:flex items-center ml-3">
<h3 class="font-semibold text-lg max-w-[14rem] truncate text-gray-500">
{{ form.title }}
@@ -118,6 +121,7 @@
</template>
<script>
import UndoRedo from "../../editors/UndoRedo.vue"
import FormEditorSidebar from "./form-components/FormEditorSidebar.vue"
import FormErrorModal from "./form-components/FormErrorModal.vue"
import FormInformation from "./form-components/FormInformation.vue"
@@ -136,6 +140,7 @@ import { captureException } from "@sentry/core"
export default {
name: "FormEditor",
components: {
UndoRedo,
FormEditorSidebar,
FormEditorPreview,
FormAboutSubmission,