diff --git a/bun.lockb b/bun.lockb index 0d3869a..8337cdd 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/composer/action-buttons.vue b/components/composer/action-buttons.vue new file mode 100644 index 0000000..d02b603 --- /dev/null +++ b/components/composer/action-buttons.vue @@ -0,0 +1,55 @@ + + + \ No newline at end of file diff --git a/components/composer/composer.vue b/components/composer/composer.vue index 5583a2d..5090665 100644 --- a/components/composer/composer.vue +++ b/components/composer/composer.vue @@ -1,59 +1,36 @@ \ No newline at end of file diff --git a/components/composer/responding-to.vue b/components/composer/responding-to.vue new file mode 100644 index 0000000..4811e6e --- /dev/null +++ b/components/composer/responding-to.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/components/composer/rich-text-box.vue b/components/composer/rich-text-box.vue new file mode 100644 index 0000000..401990d --- /dev/null +++ b/components/composer/rich-text-box.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/components/composer/uploader/uploader.vue b/components/composer/uploader/uploader.vue index 5fdb310..c2cfc70 100644 --- a/components/composer/uploader/uploader.vue +++ b/components/composer/uploader/uploader.vue @@ -2,7 +2,7 @@
-
@@ -35,6 +35,12 @@ defineExpose({ openFilePicker, }); +const emit = defineEmits<{ + changeFile: [changedFile: FileData]; + addFile: [newFile: FileData]; + removeFile: [id: string]; +}>(); + const handleFileInput = (event: Event) => { const target = event.target as HTMLInputElement; if (target.files) { @@ -64,54 +70,49 @@ watch( }, ); -const removeFile = (id: string) => { - files.value = files.value.filter((data) => data.id !== id); -}; - const updateAltText = (id: string, altText?: string) => { - files.value = files.value.map((data) => { - if (data.id === id) { - return { ...data, uploading: true }; - } - return data; + const foundFile = files.value.find((data) => data.id === id); + + if (!foundFile) { + throw new Error("File with ID doesn't exist"); + } + + emit("changeFile", { + ...foundFile, + uploading: true, }); client.value - ?.updateMedia( - files.value.find((data) => data.id === id)?.api_id as string, - { description: altText }, - ) + ?.updateMedia(foundFile.api_id as string, { description: altText }) .then(() => { - files.value = files.value.map((data) => { - if (data.id === id) { - return { ...data, uploading: false }; - } - return data; + emit("changeFile", { + ...foundFile, + uploading: false, }); }); }; const uploadFile = async (file: File) => { - files.value = files.value.map((data) => { - if (data.file === file) { - return { ...data, uploading: true, progress: 0.1 }; - } - return data; + const foundFile = files.value.find((data) => data.file === file); + + if (!foundFile) { + throw new Error("File doesn't exist"); + } + + emit("changeFile", { + ...foundFile, + uploading: true, + progress: 0.1, }); client.value.uploadMedia(file).then((response) => { const attachment = response.data; - files.value = files.value.map((data) => { - if (data.file === file) { - return { - ...data, - api_id: attachment.id, - uploading: false, - progress: 1.0, - }; - } - return data; + emit("changeFile", { + ...foundFile, + uploading: false, + progress: 1.0, + api_id: attachment.id, }); }); }; diff --git a/components/inputs/rich-textbox-input.vue b/components/inputs/rich-textbox-input.vue index c89b7c2..d0fd58c 100644 --- a/components/inputs/rich-textbox-input.vue +++ b/components/inputs/rich-textbox-input.vue @@ -25,28 +25,16 @@ defineOptions({ }); const props = defineProps<{ maxCharacters?: number; - modelContent: string; }>(); -const emit = defineEmits<{ - "update:modelContent": [value: string]; -}>(); +const modelContent = defineModel("modelContent", { + required: true, +}); const textarea = ref(undefined); const { input: content } = useTextareaAutosize({ element: textarea, - input: props.modelContent, -}); - -watch( - () => props.modelContent, - (value) => { - content.value = value; - }, -); - -watch(content, (newValue) => { - emit("update:modelContent", newValue); + input: modelContent, }); const remainingCharacters = computed(