mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Add combined floating menu for comment, tracked changes, writefull GitOrigin-RevId: 4de5b9d3b1717fc76394f7c0edfe4d7230394c8d
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { FC, useCallback } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
import OLTooltip from '@/shared/components/ol/ol-tooltip'
|
|
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
|
import { sendMB } from '@/infrastructure/event-tracking'
|
|
|
|
const AddCommentAction: FC = () => {
|
|
const { t } = useTranslation()
|
|
const permissions = usePermissionsContext()
|
|
|
|
const handleClick = useCallback(() => {
|
|
sendMB('add-comment', { location: 'tooltip' })
|
|
window.dispatchEvent(new Event('add-new-review-comment'))
|
|
}, [])
|
|
|
|
if (!permissions.comment) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<OLTooltip
|
|
id="editor-floating-menu-add-comment"
|
|
description={t('add_comment')}
|
|
overlayProps={{ placement: 'right' }}
|
|
>
|
|
<button
|
|
className="editor-floating-menu-button"
|
|
onClick={handleClick}
|
|
aria-label={t('add_comment')}
|
|
>
|
|
<MaterialIcon type="chat" />
|
|
</button>
|
|
</OLTooltip>
|
|
)
|
|
}
|
|
|
|
export default AddCommentAction
|