@@ -24,20 +24,15 @@ import { Button, IconButton, IconSvg, Loader, Spinner, Tab, Typography } from "@
2424import { AKRoundLogo } from "@assets/image" ;
2525import { Close , CompressIcon , ExpandIcon , SaveIcon } from "@assets/image/icons" ;
2626
27- export const EditorTabs = ( {
28- isExpanded,
29- setExpanded,
30- } : {
31- isExpanded : boolean ;
32- setExpanded : ( expandedState : boolean ) => void ;
33- } ) => {
34- const { projectId } = useParams ( ) ;
27+ export const EditorTabs = ( ) => {
28+ const { projectId } = useParams ( ) as { projectId : string } ;
3529 const { t : tErrors } = useTranslation ( "errors" ) ;
3630 const { t } = useTranslation ( "tabs" , { keyPrefix : "editor" } ) ;
37- const { closeOpenedFile, openFileAsActive, openFiles, saveFile } = useFileOperations ( projectId ! ) ;
31+ const { closeOpenedFile, openFileAsActive, openFiles, saveFile } = useFileOperations ( projectId ) ;
3832 const { currentProjectId, fetchResources } = useCacheStore ( ) ;
3933 const addToast = useToastStore ( ( state ) => state . addToast ) ;
40- const { cursorPositionPerProject, setCursorPosition } = useSharedBetweenProjectsStore ( ) ;
34+ const { cursorPositionPerProject, setCursorPosition, fullScreenEditor, setFullScreenEditor } =
35+ useSharedBetweenProjectsStore ( ) ;
4136 const activeEditorFileName =
4237 ( projectId && openFiles [ projectId ] ?. find ( ( { isActive } : { isActive : boolean } ) => isActive ) ?. name ) || "" ;
4338 const fileExtension = "." + last ( activeEditorFileName . split ( "." ) ) ;
@@ -197,7 +192,7 @@ export const EditorTabs = ({
197192 setIsFirstCursorPositionChange ( false ) ;
198193 return ;
199194 }
200- const cursorPosition = cursorPositionPerProject [ projectId ! ] ?. [ activeEditorFileName ] ;
195+ const cursorPosition = cursorPositionPerProject [ projectId ] ?. [ activeEditorFileName ] ;
201196 const codeEditor = editorRef . current ;
202197 if ( ! cursorPosition && codeEditor ) {
203198 revealAndFocusOnLineInEditor ( codeEditor , { lineNumber : 0 , column : 0 } ) ;
@@ -288,21 +283,25 @@ export const EditorTabs = ({
288283 } , [ debouncedManualSave ] ) ;
289284
290285 const activeCloseIcon = ( fileName : string ) => {
291- const isActiveFile = openFiles [ projectId ! ] . find ( ( { isActive, name } ) => name === fileName && isActive ) ;
286+ const isActiveFile = openFiles [ projectId ] . find ( ( { isActive, name } ) => name === fileName && isActive ) ;
292287
293288 return cn ( "size-4 p-0.5 opacity-0 hover:bg-gray-1100 group-hover:opacity-100" , {
294289 "opacity-100" : isActiveFile ,
295290 } ) ;
296291 } ;
297292
293+ const toggleFullScreenEditor = ( ) => {
294+ setFullScreenEditor ( projectId , ! fullScreenEditor [ projectId ] ) ;
295+ } ;
296+
298297 const handleCloseButtonClick = (
299298 event : React . MouseEvent < HTMLButtonElement | HTMLDivElement , MouseEvent > ,
300299 name : string
301300 ) : void => {
302301 event . stopPropagation ( ) ;
303302 closeOpenedFile ( name ) ;
304- if ( ! isExpanded || openFiles [ projectId ! ] ?. length !== 1 ) return ;
305- setExpanded ( false ) ;
303+ if ( ! fullScreenEditor [ projectId ] || openFiles [ projectId ] ?. length !== 1 ) return ;
304+ toggleFullScreenEditor ( ) ;
306305 } ;
307306
308307 const isMarkdownFile = useMemo ( ( ) => activeEditorFileName . endsWith ( ".md" ) , [ activeEditorFileName ] ) ;
@@ -387,8 +386,8 @@ export const EditorTabs = ({
387386 </ Button >
388387 ) }
389388 </ div >
390- < IconButton className = "hover:bg-gray-1100" onClick = { ( ) => setExpanded ( ! isExpanded ) } >
391- { isExpanded ? (
389+ < IconButton className = "hover:bg-gray-1100" onClick = { toggleFullScreenEditor } >
390+ { fullScreenEditor [ projectId ] ? (
392391 < CompressIcon className = "size-4 fill-white" />
393392 ) : (
394393 < ExpandIcon className = "size-4 fill-white" />
0 commit comments