-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Add code highlighting component and update styling in ChatInp…
…utArea - Import hooks and components - Create new component for highlighting code snippets - Modify styling and functionality in various components - Remove theme prop and update styling in multiple components These changes add a new code highlighting component and improve the styling and functionality in the ChatInputArea directory. The theme prop is removed and styling is updated in multiple components.
- Loading branch information
1 parent
d5bb2d4
commit a9a316f
Showing
12 changed files
with
156 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useScroll, useSize } from 'ahooks'; | ||
import { memo, useEffect, useRef } from 'react'; | ||
|
||
import { SyntaxHighlighter } from '@/Highlighter'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
interface InputHighlightProps { | ||
target: string; | ||
value: string; | ||
} | ||
|
||
const InputHighlight = memo<InputHighlightProps>(({ value, target }) => { | ||
const ref: any = useRef(null); | ||
|
||
const { styles } = useStyles(); | ||
|
||
const nativeTextarea = document.querySelector(`#${target}`); | ||
|
||
const size = useSize(nativeTextarea); | ||
const scroll = useScroll(nativeTextarea); | ||
|
||
useEffect(() => { | ||
ref.current.scroll(0, scroll?.top || 0); | ||
}, [scroll?.top]); | ||
|
||
return ( | ||
<div | ||
className={styles.highlight} | ||
data-code-type="highlighter" | ||
ref={ref} | ||
style={{ height: size?.height, width: size?.width }} | ||
> | ||
<SyntaxHighlighter language="markdown">{value.trim()}</SyntaxHighlighter> | ||
</div> | ||
); | ||
}); | ||
|
||
export default InputHighlight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a9a316f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lobe-ui – ./
lobe-ui.vercel.app
lobe-ui-git-master-lobehub.vercel.app
ui.lobehub.com
lobe-ui-lobehub.vercel.app