@codeperate/form-builder-vue
Advanced tools
@@ -23,16 +23,16 @@ import { computed, Ref, ref, watch } from 'vue'; | ||
| ) => { | ||
| const history = ref<any[]>([]); | ||
| const undoHistory = ref<any[]>([]); | ||
| const currentIndex = ref(-1); | ||
| const canUndo = computed(() => currentIndex.value >= 0); | ||
| const canRedo = computed(() => currentIndex.value < history.value.length - 1); | ||
| const canRedo = computed(() => currentIndex.value < undoHistory.value.length - 1); | ||
| const saveHistory = () => { | ||
| if (JSON.stringify(history.value[currentIndex.value]) !== JSON.stringify(formValue.value)) { | ||
| if (currentIndex.value < history.value.length - 1) { | ||
| history.value = history.value.slice(0, currentIndex.value + 1); | ||
| if (JSON.stringify(undoHistory.value[currentIndex.value]) !== JSON.stringify(formValue.value)) { | ||
| if (currentIndex.value < undoHistory.value.length - 1) { | ||
| undoHistory.value = undoHistory.value.slice(0, currentIndex.value + 1); | ||
| } | ||
| history.value.push(deepCloneJSON(formValue.value)); | ||
| currentIndex.value = history.value.length - 1; | ||
| if (history.value.length > historyLength) { | ||
| history.value = history.value.slice(-historyLength); | ||
| currentIndex.value = history.value.length - 1; | ||
| undoHistory.value.push(deepCloneJSON(formValue.value)); | ||
| currentIndex.value = undoHistory.value.length - 1; | ||
| if (undoHistory.value.length > historyLength) { | ||
| undoHistory.value = undoHistory.value.slice(-historyLength); | ||
| currentIndex.value = undoHistory.value.length - 1; | ||
| } | ||
@@ -53,3 +53,3 @@ } | ||
| currentIndex.value--; | ||
| setValue('', history.value[currentIndex.value]); | ||
| setValue('', undoHistory.value[currentIndex.value]); | ||
| } | ||
@@ -61,3 +61,3 @@ }; | ||
| currentIndex.value++; | ||
| setValue('', history.value[currentIndex.value]); | ||
| setValue('', undoHistory.value[currentIndex.value]); | ||
| } | ||
@@ -67,3 +67,3 @@ }; | ||
| return { | ||
| history, | ||
| undoHistory, | ||
| canUndo, | ||
@@ -70,0 +70,0 @@ canRedo, |
+2
-2
| { | ||
| "name": "@codeperate/form-builder-vue", | ||
| "version": "0.7.16", | ||
| "version": "0.7.17", | ||
| "private": false, | ||
@@ -23,3 +23,3 @@ "author": "", | ||
| "version": "npx tsx version.ts", | ||
| "release": "npm run build && npx np --no-cleanup --contents ./dist --no-release-draft --yolo" | ||
| "release": "npm run build && npx np --any-branch --no-cleanup --contents ./dist --no-release-draft --yolo" | ||
| }, | ||
@@ -26,0 +26,0 @@ "keywords": [], |
87442
0.08%