ds-markdown
Version:
> π React Markdown ζεε¨η»η»δ»ΆοΌζδΎη°δ»£θ倩ηι’ζζ
24 lines β’ 1.05 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { CopyIcon } from '../Icon/index.js';
import { useConfig } from '../../context/ConfigProvider/index.js';
import SuccessButton from '../ui/SuccessButton/index.js';
const CopyButton = ({ codeContent, style, className }) => {
const { locale } = useConfig();
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(codeContent || '');
return true;
}
catch (err) {
// Fallback: use traditional method
const textArea = document.createElement('textarea');
textArea.value = codeContent || '';
textArea.select();
document.execCommand('copy');
return true;
}
};
return (_jsx(SuccessButton, { onClick: handleCopy, icon: _jsx(CopyIcon, { size: 24 }), executeText: locale.codeBlock.copied || 'copied', style: style, className: className, children: locale.codeBlock.copy || 'copy' }));
};
export default CopyButton;
//# sourceMappingURL=index.js.map