blob: bf332e706e89f03d9b3211b9726fe45152ef7672 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkModal
ref="modal"
:preferType="'dialog'"
@click="onBgClick()"
@closed="onModalClosed()"
@esc="onEsc"
>
<MkPostForm
ref="form"
:class="$style.form"
v-bind="props"
autofocus
freezeAfterPosted
@posted="onPosted"
@cancel="_close()"
@esc="_close()"
/>
</MkModal>
</template>
<script lang="ts" setup>
import { useTemplateRef } from 'vue';
import type { PostFormProps } from '@/types/post-form.js';
import MkModal from '@/components/MkModal.vue';
import MkPostForm from '@/components/MkPostForm.vue';
const props = withDefaults(defineProps<PostFormProps & {
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
}>(), {
initialLocalOnly: undefined,
});
const emit = defineEmits<{
(ev: 'closed'): void;
}>();
const modal = useTemplateRef('modal');
const form = useTemplateRef('form');
function onPosted() {
modal.value?.close({
useSendAnimation: true,
});
}
async function _close() {
const canClose = await form.value?.canClose();
if (!canClose) return;
modal.value?.close();
}
function onEsc() {
_close();
}
function onBgClick() {
_close();
}
function onModalClosed() {
emit('closed');
}
</script>
<style lang="scss" module>
.form {
max-height: 100%;
margin: 0 auto auto auto;
}
</style>
|