Parcourir la source

refac: rich text input behaviour

Timothy Jaeryang Baek il y a 5 mois
Parent
commit
c567185cb1
2 fichiers modifiés avec 15 ajouts et 2 suppressions
  1. 10 0
      src/app.css
  2. 5 2
      src/lib/components/common/RichTextInput.svelte

+ 10 - 0
src/app.css

@@ -231,6 +231,16 @@ input[type='number'] {
 	@apply dark:bg-gray-800 bg-gray-100;
 	@apply dark:bg-gray-800 bg-gray-100;
 }
 }
 
 
+
+.tiptap p code {
+	color: #eb5757;
+	border-width: 0px;
+	padding: 3px 8px;
+	font-size: 0.8em;
+	font-weight: 600;
+	@apply rounded-md dark:bg-gray-800 bg-gray-100 mx-0.5;
+}
+
 /* Code styling */
 /* Code styling */
 .hljs-comment,
 .hljs-comment,
 .hljs-quote {
 .hljs-quote {

+ 5 - 2
src/lib/components/common/RichTextInput.svelte

@@ -1,7 +1,10 @@
 <script lang="ts">
 <script lang="ts">
 	import { marked } from 'marked';
 	import { marked } from 'marked';
 	import TurndownService from 'turndown';
 	import TurndownService from 'turndown';
-	const turndownService = new TurndownService();
+	const turndownService = new TurndownService({
+		codeBlockStyle: 'fenced'
+	});
+	turndownService.escape = (string) => string;
 
 
 	import { onMount, onDestroy } from 'svelte';
 	import { onMount, onDestroy } from 'svelte';
 	import { createEventDispatcher } from 'svelte';
 	import { createEventDispatcher } from 'svelte';
@@ -154,7 +157,7 @@
 
 
 				const newValue = turndownService.turndown(editor.getHTML());
 				const newValue = turndownService.turndown(editor.getHTML());
 				if (value !== newValue) {
 				if (value !== newValue) {
-					value = newValue; // Trigger parent updates
+					value = newValue;
 				}
 				}
 			},
 			},
 			editorProps: {
 			editorProps: {