소스 검색

fix: triple backtick enter rich text input

Timothy Jaeryang Baek 2 달 전
부모
커밋
e6726d8444
3개의 변경된 파일44개의 추가작업 그리고 0개의 파일을 삭제
  1. 31 0
      package-lock.json
  2. 1 0
      package.json
  3. 12 0
      src/lib/components/common/RichTextInput.svelte

+ 31 - 0
package-lock.json

@@ -30,6 +30,7 @@
 				"@tiptap/extension-image": "^3.0.7",
 				"@tiptap/extension-link": "^3.0.7",
 				"@tiptap/extension-list": "^3.0.7",
+				"@tiptap/extension-mention": "^3.0.9",
 				"@tiptap/extension-table": "^3.0.7",
 				"@tiptap/extension-typography": "^3.0.7",
 				"@tiptap/extension-youtube": "^3.0.7",
@@ -3624,6 +3625,21 @@
 				"@tiptap/extension-list": "^3.0.7"
 			}
 		},
+		"node_modules/@tiptap/extension-mention": {
+			"version": "3.0.9",
+			"resolved": "https://registry.npmjs.org/@tiptap/extension-mention/-/extension-mention-3.0.9.tgz",
+			"integrity": "sha512-DTQNAQkHZ+7Enlt3KvjqN6eECINlqPpET4Drzwj8Mmz9kMILc87cz3G2cwEKRrS9A1Xn3H3VpWvElWE2Wq9JHw==",
+			"license": "MIT",
+			"funding": {
+				"type": "github",
+				"url": "https://github.com/sponsors/ueberdosis"
+			},
+			"peerDependencies": {
+				"@tiptap/core": "^3.0.9",
+				"@tiptap/pm": "^3.0.9",
+				"@tiptap/suggestion": "^3.0.9"
+			}
+		},
 		"node_modules/@tiptap/extension-node-range": {
 			"version": "3.0.7",
 			"resolved": "https://registry.npmjs.org/@tiptap/extension-node-range/-/extension-node-range-3.0.7.tgz",
@@ -3838,6 +3854,21 @@
 				"url": "https://github.com/sponsors/ueberdosis"
 			}
 		},
+		"node_modules/@tiptap/suggestion": {
+			"version": "3.0.9",
+			"resolved": "https://registry.npmjs.org/@tiptap/suggestion/-/suggestion-3.0.9.tgz",
+			"integrity": "sha512-irthqfUybezo3IwR6AXvyyTOtkzwfvvst58VXZtTnR1nN6NEcrs3TQoY3bGKGbN83bdiquKh6aU2nLnZfAhoXg==",
+			"license": "MIT",
+			"peer": true,
+			"funding": {
+				"type": "github",
+				"url": "https://github.com/sponsors/ueberdosis"
+			},
+			"peerDependencies": {
+				"@tiptap/core": "^3.0.9",
+				"@tiptap/pm": "^3.0.9"
+			}
+		},
 		"node_modules/@tiptap/y-tiptap": {
 			"version": "3.0.0",
 			"resolved": "https://registry.npmjs.org/@tiptap/y-tiptap/-/y-tiptap-3.0.0.tgz",

+ 1 - 0
package.json

@@ -74,6 +74,7 @@
 		"@tiptap/extension-image": "^3.0.7",
 		"@tiptap/extension-link": "^3.0.7",
 		"@tiptap/extension-list": "^3.0.7",
+		"@tiptap/extension-mention": "^3.0.9",
 		"@tiptap/extension-table": "^3.0.7",
 		"@tiptap/extension-typography": "^3.0.7",
 		"@tiptap/extension-youtube": "^3.0.7",

+ 12 - 0
src/lib/components/common/RichTextInput.svelte

@@ -136,6 +136,8 @@
 	import Highlight from '@tiptap/extension-highlight';
 	import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight';
 
+	import Mention from '@tiptap/extension-mention';
+
 	import { all, createLowlight } from 'lowlight';
 
 	import { PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants';
@@ -1136,6 +1138,16 @@
 							if (event.key === 'Enter') {
 								const isCtrlPressed = event.ctrlKey || event.metaKey; // metaKey is for Cmd key on Mac
 								if (event.shiftKey && !isCtrlPressed) {
+									const { state } = view;
+									const { $from } = state.selection;
+									const lineStart = $from.before($from.depth);
+									const lineEnd = $from.after($from.depth);
+									const lineText = state.doc.textBetween(lineStart, lineEnd, '\n', '\0').trim();
+									if (lineText === '```') {
+										// Fix GitHub issue #16337: prevent backtick removal for lines starting with ```
+										return false; // Let ProseMirror handle the Enter key normally
+									}
+
 									editor.commands.enter(); // Insert a new line
 									view.dispatch(view.state.tr.scrollIntoView()); // Move viewport to the cursor
 									event.preventDefault();