mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 00:54:43 -04:00

* Change copyright year from 2020 to 2021 Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Change copyright year in jetbrains copyright template Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
32 lines
1,009 B
TypeScript
32 lines
1,009 B
TypeScript
/*
|
|
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import React, { Fragment, useRef } from 'react'
|
|
import { Button } from 'react-bootstrap'
|
|
import { Variant } from 'react-bootstrap/types'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { ForkAwesomeIcon } from '../../fork-awesome/fork-awesome-icon'
|
|
import { CopyOverlay } from '../copy-overlay'
|
|
|
|
export interface CopyToClipboardButtonProps {
|
|
content: string
|
|
size?: 'sm' | 'lg'
|
|
variant?: Variant
|
|
}
|
|
|
|
export const CopyToClipboardButton: React.FC<CopyToClipboardButtonProps> = ({ content, size = 'sm', variant = 'dark' }) => {
|
|
const { t } = useTranslation()
|
|
const button = useRef<HTMLButtonElement>(null)
|
|
|
|
return (
|
|
<Fragment>
|
|
<Button ref={button} size={size} variant={variant} title={t('renderer.highlightCode.copyCode')}>
|
|
<ForkAwesomeIcon icon='files-o'/>
|
|
</Button>
|
|
<CopyOverlay content={content} clickComponent={button}/>
|
|
</Fragment>
|
|
)
|
|
}
|