Skip to content

Commit

Permalink
fix: fix theme bug
Browse files Browse the repository at this point in the history
  • Loading branch information
2214962083 committed Nov 25, 2024
1 parent 9147a4e commit 2bdb68c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
48 changes: 3 additions & 45 deletions src/webview/components/chat/editor/chat-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
useEffect,
useId,
useImperativeHandle,
useState,
type FC,
type Ref
} from 'react'
import { useEffect, useId, useImperativeHandle, type FC, type Ref } from 'react'
import { $generateHtmlFromNodes } from '@lexical/html'
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin'
import {
Expand All @@ -20,7 +13,6 @@ import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin'
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin'
import { useQueryClient } from '@tanstack/react-query'
import { TypedText } from '@webview/components/ui/typed-text'
import { MentionNode } from '@webview/lexical/nodes/mention-node'
import {
MentionPlugin,
Expand Down Expand Up @@ -111,6 +103,7 @@ const ChatEditorInner: FC<ChatEditorProps> = ({
ref,
className,
contentEditableClassName,
// eslint-disable-next-line unused-imports/no-unused-vars
placeholder,
autoFocus,
onComplete,
Expand All @@ -120,21 +113,6 @@ const ChatEditorInner: FC<ChatEditorProps> = ({
...otherProps
}) => {
const [editor] = useLexicalComposerContext()
const [isHovered, setIsHovered] = useState(false)
const [showPlaceholder, setShowPlaceholder] = useState(true)

const handleMouseOver = () => {
setIsHovered(true)
}

const handleMouseOut = () => {
setIsHovered(false)
setShowPlaceholder(true)
}

const handleClick = () => {
setShowPlaceholder(false)
}

const insertSpaceAndAt = () => {
editor.focus()
Expand Down Expand Up @@ -266,9 +244,6 @@ const ChatEditorInner: FC<ChatEditorProps> = ({
<div
className={cn('editor-container relative', className)}
tabIndex={1}
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
onClick={handleClick}
{...otherProps}
>
<RichTextPlugin
Expand All @@ -280,24 +255,7 @@ const ChatEditorInner: FC<ChatEditorProps> = ({
)}
/>
}
placeholder={
showPlaceholder ? (
<div className="editor-placeholder absolute pointer-events-none top-2 left-0 text-foreground/50">
<TypedText
strings={
Array.isArray(placeholder) ? placeholder : [placeholder || '']
}
typeSpeed={40}
backSpeed={30}
backDelay={2000}
loop={Array.isArray(placeholder)}
showCursor={Array.isArray(placeholder)}
cursorChar=""
isPaused={isHovered}
/>
</div>
) : null
}
// placeholder={placeholder}
ErrorBoundary={LexicalErrorBoundary}
/>
<OnChangePlugin onChange={onChange!} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PopoverTrigger
} from '@webview/components/ui/popover'
import { SparklesText } from '@webview/components/ui/sparkles-text'
import { useGlobalContext } from '@webview/contexts/global-context'
import { useReadFile } from '@webview/hooks/api/use-read-file'
import { useControllableState } from '@webview/hooks/use-controllable-state'
import { getExtFromPath } from '@webview/utils/path'
Expand Down Expand Up @@ -44,6 +45,7 @@ export const ContentPreviewPopover: React.FC<ContentPreviewPopoverProps> = ({
defaultProp: false,
onChange: onOpenChange
})
const { isDarkTheme } = useGlobalContext()

const getFileType = (filePath: string) => {
const ext = getExtFromPath(filePath)?.toLowerCase() || 'txt'
Expand Down Expand Up @@ -126,7 +128,7 @@ export const ContentPreviewPopover: React.FC<ContentPreviewPopoverProps> = ({
return (
<ShikiHighlighter
language={getShikiLanguageFromPath(content.path)}
theme="dark-plus"
theme={isDarkTheme ? 'dark-plus' : 'light-plus'}
addDefaultStyles={false}
>
{fileContent}
Expand Down

0 comments on commit 2bdb68c

Please sign in to comment.