mirror of
https://github.com/aelve/guide.git
synced 2024-11-29 14:35:35 +03:00
Markdown editor confirmation of unsaved changes on escape
This commit is contained in:
parent
d20e5f99b0
commit
4ac5c1820c
@ -10,7 +10,7 @@
|
||||
@keydown.exact.capture.enter="onEnterDown"
|
||||
@keydown.exact.ctrl.enter="onCtrlEnterDown"
|
||||
@keydown.exact.meta.enter="onCtrlEnterDown"
|
||||
@keydown.exact.esc="cancel"
|
||||
@keydown.exact.esc="onEsc"
|
||||
v-show="editor && isReady"
|
||||
>
|
||||
<textarea
|
||||
@ -227,6 +227,22 @@ export default class MarkdownEditor extends Vue {
|
||||
this.$emit('save', this.editor.value())
|
||||
}
|
||||
|
||||
async onEsc () {
|
||||
let isConfirmed = true
|
||||
if (this.value !== this.editor.value()) {
|
||||
isConfirmed = await this._confirm({
|
||||
fullText: 'You have unsaved changes. Do you really want to discard them?',
|
||||
confirmBtnText: 'Disacrd',
|
||||
confirmBtnProps: {
|
||||
color: 'error'
|
||||
}
|
||||
})
|
||||
}
|
||||
if (isConfirmed) {
|
||||
this.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
cancel () {
|
||||
this.$emit('cancel')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user