hippofish/packages/client/src/components/MkPostFormDialog.vue

64 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2023-04-08 02:01:42 +02:00
<MkModal
ref="modal"
:prefer-type="'dialog'"
@click="modal.close()"
@closed="onModalClosed()"
>
<MkPostForm
ref="form"
style="margin: 0 auto auto auto"
v-bind="props"
autofocus
freeze-after-posted
@posted="onPosted"
@cancel="modal.close()"
@esc="modal.close()"
/>
2023-02-19 00:27:12 +01:00
</MkModal>
2023-02-19 00:53:19 +01:00
</template>
2023-02-19 00:53:19 +01:00
<script lang="ts" setup>
import { shallowRef } from "vue";
import { noteVisibilities, languages, type entities } from "firefish-js";
2023-04-08 02:01:42 +02:00
import MkModal from "@/components/MkModal.vue";
import MkPostForm from "@/components/MkPostForm.vue";
2023-02-19 00:53:19 +01:00
const props = defineProps<{
reply?: entities.Note;
renote?: entities.Note;
2023-02-19 00:53:19 +01:00
channel?: any; // TODO
mention?: entities.User;
specified?: entities.User;
2023-02-19 00:53:19 +01:00
initialText?: string;
initialVisibility?: typeof noteVisibilities;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
2023-02-19 00:53:19 +01:00
initialLocalOnly?: boolean;
initialVisibleUsers?: entities.User[];
initialNote?: entities.Note;
2023-02-19 00:53:19 +01:00
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
editId?: entities.Note["id"];
2023-02-19 00:53:19 +01:00
}>();
2023-02-19 00:27:12 +01:00
2023-02-19 00:53:19 +01:00
const emit = defineEmits<{
2023-04-08 02:01:42 +02:00
(ev: "closed"): void;
2023-02-19 00:53:19 +01:00
}>();
2023-02-19 00:27:12 +01:00
2023-09-02 01:27:33 +02:00
const modal = shallowRef<InstanceType<typeof MkModal>>();
const form = shallowRef<InstanceType<typeof MkPostForm>>();
2023-02-19 00:27:12 +01:00
2023-02-19 00:53:19 +01:00
function onPosted() {
modal.value.close({
2023-02-19 00:53:19 +01:00
useSendAnimation: true,
});
}
2023-02-19 00:27:12 +01:00
2023-02-19 00:53:19 +01:00
function onModalClosed() {
2023-04-08 02:01:42 +02:00
emit("closed");
2023-02-19 00:53:19 +01:00
}
</script>