Skip to content

Commit

Permalink
use SyntaxHighlighterWrapper for mentionable preview
Browse files Browse the repository at this point in the history
  • Loading branch information
glowingjade committed Oct 23, 2024
1 parent e7030b6 commit e3f1f3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/components/chat-view/chat-input/ChatUserInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import {
} from 'src/utils/mentionable'

import { useApp } from '../../../contexts/app-context'
import { useDarkModeContext } from '../../../contexts/dark-mode-context'
import { Mentionable, SerializedMentionable } from '../../../types/mentionable'
import { fuzzySearch } from '../../../utils/fuzzy-search'
import { getMentionableKey } from '../../../utils/mentionable'
import { readTFileContent } from '../../../utils/obsidian'
import { MemoizedSyntaxHighlighterWrapper } from '../SyntaxHighlighterWrapper'

import MentionableBadge from './MentionableBadge'
import { ModelSelect } from './ModelSelect'
Expand Down Expand Up @@ -76,6 +78,7 @@ const ChatUserInput = forwardRef<ChatUserInputRef, ChatUserInputProps>(
ref,
) => {
const app = useApp()
const { isDarkMode } = useDarkModeContext()

const editorRef = useRef<LexicalEditor | null>(null)
const contentEditableRef = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -309,7 +312,14 @@ const ChatUserInput = forwardRef<ChatUserInputRef, ChatUserInputProps>(

{fileContent && (
<div className="smtcmp-chat-user-input-file-content-preview">
{fileContent}
<MemoizedSyntaxHighlighterWrapper
isDarkMode={isDarkMode}
language="markdown"
hasFilename={false}
wrapLines={false}
>
{fileContent}
</MemoizedSyntaxHighlighterWrapper>
</div>
)}

Expand Down
3 changes: 1 addition & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ button:not(.clickable-icon).smtcmp-chat-list-dropdown {
background-color: var(--background-primary);
border-radius: var(--radius-s);
border: 1px solid var(--background-modifier-border);
padding: var(--size-4-2);
max-height: 400px;
max-height: 350px;
overflow-y: auto;
white-space: pre-line;
}
Expand Down

0 comments on commit e3f1f3e

Please sign in to comment.