Created
July 8, 2021 18:24
-
-
Save mattmaribojoc/a1d7b197e452ed11cc4e646b65027a04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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