From a598ade77c06582e5b972dffbc398c0e29b6b813 Mon Sep 17 00:00:00 2001 From: Yume <2839681263@qq.com> Date: Thu, 26 Jun 2025 16:43:01 +0800 Subject: [PATCH 1/2] fix(MentionList): change trigger character from '#' to '$' for mentions --- moon/apps/web/components/MarkdownEditor/MentionList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moon/apps/web/components/MarkdownEditor/MentionList.tsx b/moon/apps/web/components/MarkdownEditor/MentionList.tsx index 59a982485..a416d2b11 100644 --- a/moon/apps/web/components/MarkdownEditor/MentionList.tsx +++ b/moon/apps/web/components/MarkdownEditor/MentionList.tsx @@ -40,7 +40,7 @@ export function MentionList({ editor, defaultMentions, modal }: Props) { { const $from = state.doc.resolve(range.from) const type = state.schema.nodes[Mention.name] From a972e72069f32e13d7305cbaa0852d35ff631f92 Mon Sep 17 00:00:00 2001 From: Yume <2839681263@qq.com> Date: Thu, 26 Jun 2025 17:08:54 +0800 Subject: [PATCH 2/2] feat(UI): add dynamic language detection for code highlighting --- .../CodeView/BlobView/CodeContent.tsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/moon/apps/web/components/CodeView/BlobView/CodeContent.tsx b/moon/apps/web/components/CodeView/BlobView/CodeContent.tsx index af5290839..e99512a8c 100644 --- a/moon/apps/web/components/CodeView/BlobView/CodeContent.tsx +++ b/moon/apps/web/components/CodeView/BlobView/CodeContent.tsx @@ -8,6 +8,30 @@ import { DotsHorizontal } from '@gitmono/ui'; import 'github-markdown-css/github-markdown-light.css'; import styles from './CodeContent.module.css'; +const suffixToLangMap: Record = { + '.jsx': 'jsx', + '.tsx': 'tsx', + '.kt': 'kotlin', + '.json': 'json', + '.md': 'markdown', + '.py': 'python', + '.rs': 'rust', + '.cpp': 'cpp', + '.h': 'cpp', + '.go': 'go', + '.yml': 'yaml', + '.yaml': 'yaml', +} + +function getLangFromFileName(fileName: string): string { + const lastPart = fileName.toLowerCase().match(/\.[^./\\]+$/); + + if(lastPart) { + return suffixToLangMap[lastPart[0].toLowerCase()] ?? "markdown"; + } + return "markdown"; +} + const CodeContent = ({ fileContent, path }: { fileContent: string, path?: string[] }) => { const [lfs, setLfs] = useState(false) const [selectedLine, setSelectedLine] = useState(null) @@ -163,7 +187,7 @@ const CodeContent = ({ fileContent, path }: { fileContent: string, path?: string {/*todo: Dynamic support for language types*/} - + {({ style, tokens, getLineProps, getTokenProps }) => (