More work on the new rich text editor. It may have a few bugs still.

This commit is contained in:
Scott Idem
2024-12-02 19:24:00 -05:00
parent 44907bc01f
commit c6631e221c
3 changed files with 26 additions and 310 deletions

View File

@@ -44,6 +44,7 @@
showToolbar?: boolean;
// html_text?: string;
new_html?: string;
placeholder?: string;
}
let { class:
@@ -52,6 +53,7 @@
showToolbar = true,
// html_text = '',
new_html = $bindable(''),
placeholder = $bindable('Start typing...')
}: Props = $props();
let editor = $state<Editor>();
@@ -141,11 +143,12 @@
editor = transaction.editor;
console.log(editor.isActive('bold'));
content = editor.getHTML();
console.log(content);
if (content == '<p></p>') {
// console.log(content);
let html = editor.getHTML();
if (html == '<p></p>') {
new_html = '';
} else {
new_html = content ?? '';
new_html = html ?? '';
}
}
});
@@ -160,5 +163,14 @@
{#if editor && showToolbar}
<EditorToolbar {editor} />
{/if}
<div bind:this={element} spellcheck="false" class="h-full w-full flex-1 overflow-auto"></div>
<div
bind:this={element}
spellcheck="false"
class="tiptap h-full w-full overflow-auto relative">
<span
class="placeholder text-sm text-gray-400 italic absolute p-3"
contenteditable="false"
hidden={editor?.getHTML() !== '<p></p>'}
>{placeholder}</span>
</div>
</div>