Now able to save the HTML text from tip tap element.

This commit is contained in:
Scott Idem
2024-11-01 17:52:39 -04:00
parent 8ec01a1d64
commit 2d047f5a10
3 changed files with 104 additions and 103 deletions

View File

@@ -81,7 +81,7 @@ if (show_button_kv) {
show_button_kv = show_button_kv_defaults;
}
export let new_json = editor?.getJSON();
// export let new_json = editor?.getJSON();
export let new_html: string = '';
onMount(() => {
@@ -96,8 +96,22 @@ onMount(() => {
onTransaction: () => {
// force re-render so `editor.isActive` works as expected
editor = editor;
new_html = editor.getHTML();
let updated_html = editor.getHTML();
if (updated_html == '<p></p>') {
new_html = '';
} else {
new_html = updated_html;
}
},
onUpdate: ({ editor }) => {
let updated_html = editor.getHTML();
if (updated_html == '<p></p>') {
new_html = '';
} else {
new_html = updated_html;
}
}
});
});
@@ -106,6 +120,13 @@ onDestroy(() => {
editor.destroy();
}
});
function getContent() {
if (editor) {
return editor.getHTML();
}
return '';
}
</script>
<!-- svelte-ignore a11y-no-static-element-interactions -->