mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: ♻️ Rewrite composer code
Some checks failed
Some checks failed
This commit is contained in:
parent
fa8603d816
commit
18cf63de51
12 changed files with 492 additions and 348 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue