diff --git a/package-lock.json b/package-lock.json index 245c6940e8..53be3e8b90 100644 --- a/package-lock.json +++ b/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", diff --git a/package.json b/package.json index e883b29fbb..20be99240f 100644 --- a/package.json +++ b/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", diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 176748303f..c2756ff28f 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/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();