2024-04-27 09:04:02 +02:00
|
|
|
<template>
|
2025-05-27 21:45:54 +02:00
|
|
|
<div v-if="relation" class="overflow-auto max-h-72">
|
2024-12-01 18:29:54 +01:00
|
|
|
<Note :note="relation.note" :hide-actions="true" :small-layout="true" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
<ContentWarning v-if="state.sensitive" v-model="state.contentWarning" />
|
2025-03-27 22:20:04 +01:00
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
<EditorContent @paste-files="uploadFiles" v-model:content="state.content" v-model:raw-content="state.rawContent" :placeholder="getRandomSplash()"
|
2025-07-12 21:17:14 +02:00
|
|
|
class="[&>.tiptap]:!border-none [&>.tiptap]:!ring-0 [&>.tiptap]:!outline-none [&>.tiptap]:rounded-none p-0 [&>.tiptap]:max-h-[50dvh] [&>.tiptap]:overflow-y-auto [&>.tiptap]:min-h-48 [&>.tiptap]:!ring-offset-0 [&>.tiptap]:h-full"
|
2025-06-27 00:28:14 +02:00
|
|
|
:disabled="state.sending" :mode="state.contentType === 'text/html' ? 'rich' : 'plain'" />
|
2024-12-01 15:30:42 +01:00
|
|
|
|
2024-12-01 17:20:21 +01:00
|
|
|
<div class="w-full flex flex-row gap-2 overflow-x-auto *:shrink-0 pb-2">
|
2025-06-27 00:28:14 +02:00
|
|
|
<input type="file" ref="fileInput" @change="uploadFileFromEvent" class="hidden" multiple />
|
2024-12-01 17:20:21 +01:00
|
|
|
<Files v-model:files="state.files" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
<DialogFooter class="items-center flex-row overflow-x-auto">
|
|
|
|
|
<ComposerButtons @submit="send" @pick-file="fileInput?.click()" v-model:content-type="state.contentType" v-model:sensitive="state.sensitive" v-model:visibility="state.visibility" :relation="state.relation" :sending="state.sending" :can-send="state.canSend" :raw-content="state.rawContent" />
|
2024-12-01 15:30:42 +01:00
|
|
|
</DialogFooter>
|
2024-04-27 09:04:02 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-12-01 18:29:54 +01:00
|
|
|
import Note from "~/components/notes/note.vue";
|
2024-12-25 20:46:14 +01:00
|
|
|
import EditorContent from "../editor/content.vue";
|
2025-03-28 01:16:24 +01:00
|
|
|
import { DialogFooter } from "../ui/dialog";
|
2025-06-27 00:28:14 +02:00
|
|
|
import ComposerButtons from "./buttons.vue";
|
|
|
|
|
import {
|
|
|
|
|
type ComposerState,
|
|
|
|
|
getRandomSplash,
|
|
|
|
|
send,
|
|
|
|
|
state,
|
|
|
|
|
stateFromRelation,
|
|
|
|
|
uploadFile,
|
|
|
|
|
} from "./composer";
|
|
|
|
|
import ContentWarning from "./content-warning.vue";
|
2025-03-28 01:16:24 +01:00
|
|
|
import Files from "./files.vue";
|
2024-12-01 15:30:42 +01:00
|
|
|
|
|
|
|
|
const { Control_Enter, Command_Enter } = useMagicKeys();
|
2025-06-27 00:28:14 +02:00
|
|
|
const fileInput = useTemplateRef<HTMLInputElement>("fileInput");
|
2024-11-30 19:15:23 +01:00
|
|
|
|
2024-12-01 15:30:42 +01:00
|
|
|
watch([Control_Enter, Command_Enter], () => {
|
2025-06-27 00:28:14 +02:00
|
|
|
if (state.sending || !preferences.ctrl_enter_send.value) {
|
2024-12-01 15:30:42 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
send();
|
2024-12-01 15:30:42 +01:00
|
|
|
});
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
|
relation?: ComposerState["relation"];
|
2024-04-27 09:04:02 +02:00
|
|
|
}>();
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
watch(
|
|
|
|
|
props,
|
|
|
|
|
async (props) => {
|
|
|
|
|
if (props.relation) {
|
|
|
|
|
await stateFromRelation(
|
|
|
|
|
props.relation.type,
|
|
|
|
|
props.relation.note,
|
|
|
|
|
props.relation.source,
|
|
|
|
|
);
|
2024-12-02 10:29:03 +01:00
|
|
|
}
|
2025-06-27 00:28:14 +02:00
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
);
|
2024-12-01 15:30:42 +01:00
|
|
|
|
2024-12-01 17:20:21 +01:00
|
|
|
const uploadFileFromEvent = (e: Event) => {
|
|
|
|
|
const target = e.target as HTMLInputElement;
|
|
|
|
|
const files = Array.from(target.files ?? []);
|
|
|
|
|
|
2025-06-27 00:28:14 +02:00
|
|
|
for (const file of files) {
|
|
|
|
|
uploadFile(file);
|
|
|
|
|
}
|
2024-12-01 17:20:21 +01:00
|
|
|
|
|
|
|
|
target.value = "";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const uploadFiles = (files: File[]) => {
|
|
|
|
|
for (const file of files) {
|
2025-06-27 00:28:14 +02:00
|
|
|
uploadFile(file);
|
2024-12-01 17:20:21 +01:00
|
|
|
}
|
|
|
|
|
};
|
2024-12-17 12:30:01 +01:00
|
|
|
</script>
|