• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alkem-io / client-web / #8415

19 Jul 2024 02:05PM UTC coverage: 5.749%. First build
#8415

Pull #6612

travis-ci

Pull Request #6612: Package updates to reduce vulnerabilities

188 of 9965 branches covered (1.89%)

Branch coverage included in aggregate %.

0 of 13 new or added lines in 7 files covered. (0.0%)

1407 of 17778 relevant lines covered (7.91%)

0.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/ui/forms/MarkdownInputControls/InsertEmojiButton.tsx
1
import { Editor } from '@tiptap/react';
2
import { useRef, useState } from 'react';
3
import { EmojiEmotionsOutlined } from '@mui/icons-material';
4
import { useNotification } from '@/core/ui/notifications/useNotification';
5
import EmojiSelector from '../emoji/EmojiSelector';
6
import { useTranslation } from 'react-i18next';
7
import MarkdownInputToolbarButton, { MarkdownInputToolbarButtonProps } from './MarkdownInputToolbarButton';
8

9
interface InsertEmojiButtonProps extends Omit<MarkdownInputToolbarButtonProps, 'tooltip'> {
10
  editor: Editor | null;
11
  onDialogOpen?: () => void;
12
  onDialogClose?: () => void;
13
}
14

15
const InsertEmojiButton = ({ editor, onDialogOpen, onDialogClose, ...buttonProps }: InsertEmojiButtonProps) => {
×
16
  const { t } = useTranslation();
×
17
  const [isDialogOpen, setIsDialogOpen] = useState(false);
×
18

19
  const openDialog = () => {
×
20
    onDialogOpen?.();
×
21
    setIsDialogOpen(true);
×
22
  };
23

24
  const closeDialog = () => {
×
25
    setIsDialogOpen(false);
×
26
    editor?.commands.focus();
×
27
    onDialogClose?.();
×
28
  };
29

30
  const notify = useNotification();
×
31

32
  const insertEmoji = (emoji: string) => {
×
33
    try {
×
34
      editor?.commands.insertContent(emoji);
×
35
    } catch (error) {
NEW
36
      if (error instanceof Error) {
×
NEW
37
        notify(error.message, 'error');
×
38
      }
39
      throw error;
×
40
    }
41
    closeDialog();
×
42
  };
43

44
  const isDisabled = !editor || !editor.can().insertContent('');
×
45

46
  const buttonRef = useRef<HTMLButtonElement>(null);
×
47

48
  return (
×
49
    <>
50
      <MarkdownInputToolbarButton
51
        ref={buttonRef as React.RefObject<HTMLButtonElement>}
52
        onClick={openDialog}
53
        disabled={isDisabled}
54
        tooltip={t('components.wysiwyg-editor.toolbar.emoji.emoji')}
55
        {...buttonProps}
56
      >
57
        <EmojiEmotionsOutlined />
58
      </MarkdownInputToolbarButton>
59
      <EmojiSelector
60
        open={isDialogOpen}
61
        onClose={closeDialog}
62
        anchorElement={buttonRef.current}
63
        onEmojiClick={insertEmoji}
64
      />
65
    </>
66
  );
67
};
68

69
export default InsertEmojiButton;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc