Skip to content

Commit

Permalink
fix: enable text selection codeblock
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 9, 2024
1 parent 6c9cc9b commit 067eb4e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web/screens/Chat/SimpleTextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
const codeBlockCopyEvent = useRef((e: Event) => {
const target: HTMLElement = e.target as HTMLElement
if (typeof target.className !== 'string') return null

const isCopyActionClassName = target?.className.includes('copy-action')
const isCodeBlockParent =
target.parentElement?.parentElement?.className.includes('code-block')

if (isCopyActionClassName || isCodeBlockParent) {
if (isCopyActionClassName) {
const content = target?.parentNode?.querySelector('code')?.innerText ?? ''
clipboard.copy(content)
}
Expand Down

0 comments on commit 067eb4e

Please sign in to comment.