Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions resources/js/Components/AppTextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ const props = defineProps({
},
});

const emit = defineEmits(['update:modelValue']);
const emit = defineEmits(['update:modelValue', 'escape']);

function handleKeyDown(event) {
if (event.key === 'Escape' && !event.defaultPrevented) {
emit('escape');
}
}

const editorValue = computed({
get: () => props.modelValue,
Expand Down Expand Up @@ -80,7 +86,7 @@ const editorInit = computed(() => ({
{{ label }}
</label>

<Editor v-model="editorValue" :init="editorInit" />
<Editor v-model="editorValue" :init="editorInit" @keydown="handleKeyDown" />

<div v-if="error" class="text-red-600 text-caption mt-1">
{{ error }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ const dialogTitle = computed(() => {

const isOpen = computed({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val),
set: (val) => {
if (!val) {
closeDialog();
return;
}

emit('update:modelValue', val);
},
});

const form = useForm({
Expand Down Expand Up @@ -282,7 +289,7 @@ watch(
</script>

<template>
<v-dialog v-model="isOpen" max-width="900" :retain-focus="false" persistent>
<v-dialog v-model="isOpen" max-width="900" :retain-focus="false">
<v-card class="rounded-lg flex flex-col" :height="dialogHeight">
<v-card-title class="font-weight-bold shrink-0">
{{ dialogTitle }}
Expand Down Expand Up @@ -339,6 +346,7 @@ watch(
:error="form.errors.content"
class="flex-grow"
data-cy="document-text-area"
@escape="closeDialog"
/>

<!-- FOOTER TYPE -->
Expand Down
Loading