Skip to content

Instantly share code, notes, and snippets.

@mattmaribojoc
Created July 8, 2021 18:24
Show Gist options
  • Save mattmaribojoc/a1d7b197e452ed11cc4e646b65027a04 to your computer and use it in GitHub Desktop.
Save mattmaribojoc/a1d7b197e452ed11cc4e646b65027a04 to your computer and use it in GitHub Desktop.
<template>
<p>
<button @click="undo"> Undo </button>
<button @click="redo"> Redo </button>
</p>
<textarea v-model="text"/>
<ul>
<li v-for="entry in history" :key="entry.timestamp">
{{ entry }}
</li>
</ul>
</template>
<script setup>
import { ref } from 'vue'
import { useRefHistory } from '@vueuse/core'
const text = ref('')
const { history, undo, redo } = useRefHistory(text)
</script>
<style scoped>
button {
border: none;
outline: none;
margin-right: 10px;
background-color: #2ecc71;
color: white;
padding: 5px 10px;;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment