feat: cancel edit mode in QuoteCard with Escape key
This commit is contained in:
parent
75e0d99ba9
commit
35151deb76
@ -17,6 +17,7 @@
|
|||||||
:no-html="true"
|
:no-html="true"
|
||||||
@returned="saveQuote"
|
@returned="saveQuote"
|
||||||
@blur="saveQuote"
|
@blur="saveQuote"
|
||||||
|
@keydown="keydown"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,11 +58,8 @@ if (props.instantEdit) {
|
|||||||
|
|
||||||
const deleteQuote = () => useEngine().deleteQuote(props.quote.id)
|
const deleteQuote = () => useEngine().deleteQuote(props.quote.id)
|
||||||
|
|
||||||
const saveQuote = async () => {
|
const editModeEnd = async () => {
|
||||||
isEditMode.value = false
|
isEditMode.value = false
|
||||||
if (props.quote.quote) {
|
|
||||||
useEngine().saveQuote(props.quote.id || ':new:', props.quote.quote)
|
|
||||||
}
|
|
||||||
emit('edit-end')
|
emit('edit-end')
|
||||||
await useEngine().loadQuotes()
|
await useEngine().loadQuotes()
|
||||||
|
|
||||||
@ -74,6 +72,20 @@ const saveQuote = async () => {
|
|||||||
}
|
}
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const saveQuote = async () => {
|
||||||
|
if (props.quote.quote) {
|
||||||
|
useEngine().saveQuote(props.quote.id || ':new:', props.quote.quote)
|
||||||
|
}
|
||||||
|
|
||||||
|
await editModeEnd()
|
||||||
|
}
|
||||||
|
|
||||||
|
const keydown = async (ev: KeyboardEvent) => {
|
||||||
|
if (ev.key === 'Escape') {
|
||||||
|
await editModeEnd()
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
Loading…
Reference in New Issue
Block a user