1- import { useEffect , useRef , useState } from "react" ;
1+ import { useEffect , useRef , useState } from "react" ;
22import MonacoEditor from "./MonacoEditor" ;
33import styles from "../styles/EditorTabs.module.css" ;
4- import { Dropdown , Toast } from "react-bootstrap" ;
4+ import { Dropdown , Toast } from "react-bootstrap" ;
55import PasswordModal from "./PasswordModal" ;
66import Tab from "./Tab" ;
77import NewTabButton from "./NewTabButton" ;
88import pasteDispatcher from "../dispatchers/PasteDispatcher" ;
99import getLanguage from "../stores/languageStore" ;
1010import config from "../config.json" ;
1111import ArrowDownwardIcon from "@material-ui/icons/ArrowDownward" ;
12- import { Button } from "@material-ui/core" ;
12+ import { Button } from "@material-ui/core" ;
1313import DropdownItem from "react-bootstrap/DropdownItem" ;
1414import React from "react" ;
15- import InsertPhotoIcon from ' @material-ui/icons/InsertPhoto' ;
15+ import InsertPhotoIcon from " @material-ui/icons/InsertPhoto" ;
1616
1717const languages = {
1818 py : "python" ,
@@ -78,7 +78,7 @@ export default function EditorTabs({
7878 const id = pid ;
7979 const [ initialState , setInitialState ] = useState ( false ) ;
8080 const [ langDropDown , setLangDropDown ] = useState ( false ) ;
81- const [ dropLang , setDropLang ] = useState ( null )
81+ const [ dropLang , setDropLang ] = useState ( null ) ;
8282
8383 const tabRef = useRef ( ) ;
8484
@@ -110,10 +110,9 @@ export default function EditorTabs({
110110 } , [ value ] ) ;
111111
112112 useEffect ( ( ) => {
113- let newLang = [ ...lang ]
114- newLang . splice ( currTab , 1 , dropLang )
115- setLang ( newLang )
116-
113+ let newLang = [ ...lang ] ;
114+ newLang . splice ( currTab , 1 , dropLang ) ;
115+ setLang ( newLang ) ;
117116 } , [ langDropDown ] ) ;
118117
119118 useEffect ( ( ) => {
@@ -186,32 +185,45 @@ export default function EditorTabs({
186185 let newValue = [ ...value ] ;
187186 newValue . splice ( i , 1 ) ;
188187 setValue ( newValue ) ;
189- } } >
190- { ! ! pid ?
191- < div className = { styles . dropdownContainer } ref = { tabRef } >
192- < Button type = "submit" className = { styles . langButton } onClick = { ( ) => setLangDropDown ( ! langDropDown ) } >
193- < ArrowDownwardIcon />
194- </ Button >
195- { langDropDown ?
188+ } }
189+ >
190+ { ! ! pid ? (
191+ < div className = { styles . dropdownContainer } ref = { tabRef } >
192+ < Button
193+ type = "submit"
194+ className = { styles . langButton }
195+ onClick = { ( ) => setLangDropDown ( ! langDropDown ) }
196+ >
197+ < ArrowDownwardIcon />
198+ </ Button >
199+ { langDropDown ? (
196200 < div className = { styles . langParent } >
197201 < Dropdown className = { styles . dropDown } autoClose >
198202 { Object . keys ( languages ) . map ( ( v , index ) => {
199203 if ( i !== currTab ) {
200- return < > </ >
204+ return < > </ > ;
201205 }
202- return ( < DropdownItem
206+ return (
207+ < DropdownItem
203208 key = { v }
204209 className = { styles . dropdownItem }
205- onBlur = { ( e ) => { e . preventDefault ( ) } }
210+ onBlur = { ( e ) => {
211+ e . preventDefault ( ) ;
212+ } }
206213 onClick = { ( ) => {
207- setLangDropDown ( false )
208- setDropLang ( v )
209- } } > { v } </ DropdownItem > ) } ) }
214+ setLangDropDown ( false ) ;
215+ setDropLang ( v ) ;
216+ } }
217+ >
218+ { v }
219+ </ DropdownItem >
220+ ) ;
221+ } ) }
210222 </ Dropdown >
211223 </ div >
212- : null }
213- </ div >
214- : null }
224+ ) : null }
225+ </ div >
226+ ) : null }
215227 </ Tab >
216228 ) ) }
217229 < NewTabButton
@@ -223,14 +235,14 @@ export default function EditorTabs({
223235 } }
224236 enabled = { value . length <= 4 && ! id }
225237 />
226- { ! pid ?
227- < div className = { styles . addAttachmentIconContainer } >
228- < Button >
229- < InsertPhotoIcon className = { styles . addAttachmentIcon } />
230- </ Button >
231- < span className = { styles . addAttachmentsText } > Add Images</ span >
232- </ div >
233- : null }
238+ { ! pid ? (
239+ < div className = { styles . addAttachmentIconContainer } >
240+ < Button >
241+ < InsertPhotoIcon className = { styles . addAttachmentIcon } />
242+ </ Button >
243+ < span className = { styles . addAttachmentsText } > Add Images</ span >
244+ </ div >
245+ ) : null }
234246 </ div >
235247
236248 { value . map ( ( v , i , arr ) => (
0 commit comments