fix: message input issue

This commit is contained in:
Timothy J. Baek
2024-10-21 03:17:30 -07:00
parent d105be9ca2
commit f99facf383
4 changed files with 90 additions and 76 deletions

View File

@@ -31,8 +31,10 @@
}
}}
>
<div class=" w-fit font-medium transition flex items-center justify-between gap-2">
<div>
<div
class=" w-fit font-medium flex items-center justify-between gap-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition"
>
<div class=" ">
{title}
</div>
@@ -56,9 +58,7 @@
}
}}
>
<div
class="flex items-center gap-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition"
>
<div>
<slot />
</div>
</div>

View File

@@ -30,6 +30,7 @@
export let id = '';
export let value = '';
export let placeholder = 'Type here...';
export let trim = false;
let element: HTMLElement; // Element where ProseMirror will attach
let state;
@@ -128,7 +129,11 @@
// Utility function to convert ProseMirror content back to markdown text
function serializeEditorContent(doc) {
const markdown = customMarkdownSerializer.serialize(doc);
return unescapeMarkdown(markdown);
if (trim) {
return unescapeMarkdown(markdown).trim();
} else {
return unescapeMarkdown(markdown);
}
}
// ---- Input Rules ----
@@ -381,6 +386,8 @@
value = serializeEditorContent(newState.doc); // Convert ProseMirror content to markdown text
eventDispatch('input', { value });
console.log('Editor content:', value);
},
handleDOMEvents: {
focus: (view, event) => {