/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */ import React, { ComponentProps, HTMLAttributes, Suspense, forwardRef, lazy } from 'react'; import classNames from 'classnames'; import { Box, Chip, Header, Icon, IconButton, Icons, Scroll, Text, as } from 'folds'; import { ErrorBoundary } from 'react-error-boundary'; import * as css from './TextViewer.css'; import { copyToClipboard } from '../../utils/dom'; const ReactPrism = lazy(() => import('../../plugins/react-prism/ReactPrism')); type TextViewerContentProps = { text: string; langName: string; size?: ComponentProps['size']; } & HTMLAttributes; export const TextViewerContent = forwardRef( ({ text, langName, size, className, ...props }, ref) => ( {text}}> {text}}> {(codeRef) => {text}} ) ); export type TextViewerProps = { name: string; text: string; langName: string; requestClose: () => void; }; export const TextViewer = as<'div', TextViewerProps>( ({ className, name, text, langName, requestClose, ...props }, ref) => { const handleCopy = () => { copyToClipboard(text); }; return (
{name} Copy All
); } );