11'use client' ;
22
3- import {
4- DocumentDuplicateIcon ,
5- CodeBracketIcon ,
6- } from '@heroicons/react/24/outline' ;
3+ import { DocumentDuplicateIcon } from '@heroicons/react/24/outline' ;
74import classNames from 'classnames' ;
8- import type { FC , PropsWithChildren , ReactElement , ReactNode } from 'react' ;
5+ import type { FC , PropsWithChildren , ReactElement } from 'react' ;
96import { Fragment , isValidElement , useRef } from 'react' ;
107
118import BaseButton from '#ui/Common/BaseButton' ;
@@ -69,10 +66,9 @@ const transformCode = <T extends ReactElement<PropsWithChildren>>(
6966interface CodeBoxProps {
7067 language : string ;
7168 className ?: string ;
72- onCopy : ( text : string , message : ReactNode ) => void ;
69+ onCopy : ( text : string ) => void ;
7370 as ?: LinkLike ;
74- copyText : string ;
75- copiedText : string ;
71+ buttonText : string ;
7672 showCopyButton ?: boolean ;
7773}
7874
@@ -81,8 +77,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
8177 language,
8278 className,
8379 onCopy,
84- copiedText,
85- copyText,
80+ buttonText,
8681 as = 'a' ,
8782 showCopyButton = true ,
8883} : PropsWithChildren < CodeBoxProps > ) => {
@@ -91,13 +86,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
9186 const handleCopy = ( ) : void => {
9287 const text = containerRef . current ?. textContent ;
9388 if ( text ) {
94- onCopy (
95- text ,
96- < div className = { styles . notification } >
97- < CodeBracketIcon className = { styles . icon } />
98- { copiedText }
99- </ div >
100- ) ;
89+ onCopy ( text ) ;
10190 }
10291 } ;
10392
@@ -121,7 +110,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
121110 onClick = { handleCopy }
122111 >
123112 < DocumentDuplicateIcon className = { styles . icon } />
124- { copyText }
113+ { buttonText }
125114 </ BaseButton >
126115 ) }
127116 </ div >
0 commit comments