More work on the new rich text editor. It may have a few bugs still.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user