1
1
import React , { useEffect , useState } from "react" ;
2
2
3
3
import { NodeViewWrapper , NodeViewContent } from "@tiptap/react" ;
4
+ import classNames from "classnames" ;
4
5
import { Down } from "neetoicons" ;
5
6
import CopyToClipboardButton from "neetomolecules/CopyToClipboardButton" ;
6
7
import { Dropdown , Input } from "neetoui" ;
@@ -13,6 +14,7 @@ const { Menu, MenuItem } = Dropdown;
13
14
14
15
const CodeBlockComponent = ( { node, editor, updateAttributes } ) => {
15
16
const [ keyword , setKeyword ] = useState ( "" ) ;
17
+ const [ isDropdownOpen , setIsDropdownOpen ] = useState ( false ) ;
16
18
17
19
const { t } = useTranslation ( ) ;
18
20
@@ -35,14 +37,21 @@ const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
35
37
return (
36
38
< NodeViewWrapper data-cy = "neeto-editor-code-block" >
37
39
< pre >
38
- < div className = "neeto-editor-codeblock-options" >
40
+ < div
41
+ className = { classNames ( "neeto-editor-codeblock-options" , {
42
+ "neeto-editor-codeblock-options--open" : isDropdownOpen ,
43
+ } ) }
44
+ >
39
45
< Dropdown
40
46
appendTo = { ( ) => document . body }
41
47
buttonSize = "small"
42
48
buttonStyle = "secondary"
43
49
icon = { Down }
50
+ isOpen = { isDropdownOpen }
44
51
label = { node . attrs ?. language || t ( "neetoEditor.common.auto" ) }
45
52
strategy = "fixed"
53
+ onClick = { ( ) => setIsDropdownOpen ( isOpen => ! isOpen ) }
54
+ onClose = { ( ) => setIsDropdownOpen ( false ) }
46
55
>
47
56
< Input
48
57
autoFocus
0 commit comments