Now able to save the HTML text from tip tap element.
This commit is contained in:
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user