Browse Source

refac: rich text input

Timothy Jaeryang Baek 7 months ago
parent
commit
fda26b4ad0
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/lib/components/common/RichTextInput.svelte

+ 8 - 3
src/lib/components/common/RichTextInput.svelte

@@ -2,7 +2,8 @@
 	import { marked } from 'marked';
 	import TurndownService from 'turndown';
 	const turndownService = new TurndownService({
-		codeBlockStyle: 'fenced'
+		codeBlockStyle: 'fenced',
+		headingStyle: 'atx'
 	});
 	turndownService.escape = (string) => string;
 
@@ -124,6 +125,7 @@
 	};
 
 	onMount(async () => {
+		console.log(value);
 		async function tryParse(value, attempts = 3, interval = 100) {
 			try {
 				// Try parsing the value
@@ -181,8 +183,11 @@
 				if (value !== newValue) {
 					value = newValue;
 
-					if (value === '') {
-						editor.commands.clearContent();
+					// check if the node is paragraph as well
+					if (editor.isActive('paragraph')) {
+						if (value === '') {
+							editor.commands.clearContent();
+						}
 					}
 				}
 			},