refactor: ♻️ Rewrite composer code
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 0s
Deploy to GitHub Pages / build (push) Failing after 0s
Deploy to GitHub Pages / deploy (push) Has been skipped
Docker / build (push) Failing after 0s
Mirror to Codeberg / Mirror (push) Failing after 0s

This commit is contained in:
Jesse Wierzbinski 2025-06-27 00:28:14 +02:00
parent fa8603d816
commit 18cf63de51
No known key found for this signature in database
12 changed files with 492 additions and 348 deletions

View file

@ -17,6 +17,7 @@ import { Emoji } from "./emoji.ts";
import suggestion from "./suggestion.ts";
const content = defineModel<string>("content");
const rawContent = defineModel<string>("rawContent");
const {
placeholder,
disabled,
@ -27,6 +28,10 @@ const {
disabled?: boolean;
}>();
const emit = defineEmits<{
pasteFiles: [files: File[]];
}>();
const editor = new Editor({
extensions: [
StarterKit,
@ -49,6 +54,15 @@ const editor = new Editor({
content: content.value,
onUpdate: ({ editor }) => {
content.value = mode === "rich" ? editor.getHTML() : editor.getText();
rawContent.value = editor.getText();
},
onPaste: (event) => {
// If pasting files, prevent the default behavior
if (event.clipboardData && event.clipboardData.files.length > 0) {
event.preventDefault();
const files = Array.from(event.clipboardData.files);
emit("pasteFiles", files);
}
},
autofocus: true,
editable: !disabled,