feat: insert chat message to notes

This commit is contained in:
Timothy Jaeryang Baek
2025-07-07 21:22:07 +04:00
parent a3c2018a4a
commit ade4b0d691
6 changed files with 91 additions and 32 deletions

View File

@@ -204,6 +204,23 @@
focus();
};
export const insertContent = (content) => {
if (!editor) return;
const { state, view } = editor;
const { schema, tr } = state;
// If content is a string, convert it to a ProseMirror node
const htmlContent = marked.parse(content, {
breaks: true,
gfm: true
});
// insert the HTML content at the current selection
editor.commands.insertContent(htmlContent);
focus();
};
export const replaceVariables = (variables) => {
if (!editor) return;
const { state, view } = editor;

View File

@@ -10,6 +10,7 @@
export let className =
'w-full rounded-lg px-3.5 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden h-full';
export let onBlur = () => {};
let textareaElement;
// Adjust height on mount and after setting the element.
@@ -59,4 +60,5 @@
on:focus={() => {
resize();
}}
on:blur={onBlur}
/>