@@ -68,6 +68,11 @@ export default function App() {
6868
6969 const files = e . dataTransfer ?. files ;
7070 if ( files && files . length > 0 ) {
71+ // If this is the welcome tab and it's not modified, close it before adding new files
72+ if ( tabs . length === 1 && tabs [ 0 ] . fileName === 'Welcome to MarkView Pro' && ! tabs [ 0 ] . isModified ) {
73+ closeTab ( tabs [ 0 ] . id ) ;
74+ }
75+
7176 for ( let i = 0 ; i < files . length ; i ++ ) {
7277 const file = files [ i ] ;
7378 if ( file . name . endsWith ( '.md' ) || file . name . endsWith ( '.markdown' ) ) {
@@ -93,7 +98,7 @@ export default function App() {
9398 document . removeEventListener ( 'dragleave' , handleDragLeave ) ;
9499 document . removeEventListener ( 'drop' , handleDrop ) ;
95100 } ;
96- } , [ addTab ] ) ;
101+ } , [ addTab , closeTab , tabs ] ) ;
97102
98103 // Apply zoom level
99104 useEffect ( ( ) => {
@@ -103,14 +108,25 @@ export default function App() {
103108 const handleOpen = useCallback ( async ( ) => {
104109 const result = await openFile ( ) ;
105110 if ( result ) {
111+ // If this is the welcome tab and it's not modified, replace it
112+ if ( tabs . length === 1 && tabs [ 0 ] . fileName === 'Welcome to MarkView Pro' && ! tabs [ 0 ] . isModified ) {
113+ closeTab ( tabs [ 0 ] . id ) ;
114+ }
106115 addTab ( fileName || 'Untitled' , filePath , content ) ;
107116 }
108- } , [ openFile , addTab , fileName , filePath , content ] ) ;
117+ } , [ openFile , addTab , closeTab , tabs , fileName , filePath , content ] ) ;
109118
110119 const handleNew = useCallback ( ( ) => {
120+ // If this is the welcome tab and it's not modified, replace it
121+ if ( tabs . length === 1 && tabs [ 0 ] . fileName === 'Welcome to MarkView Pro' && ! tabs [ 0 ] . isModified ) {
122+ closeTab ( tabs [ 0 ] . id ) ;
123+ }
111124 newFile ( ) ;
112125 addTab ( 'New Document' , null , '' ) ;
113- } , [ newFile , addTab ] ) ;
126+ } , [ newFile , addTab , closeTab , tabs ] ) ;
127+
128+ // Check if we have any real files open (not just welcome screen)
129+ const hasOpenFiles = tabs . length > 1 || ( tabs . length === 1 && tabs [ 0 ] . fileName !== 'Welcome to MarkView Pro' ) ;
114130
115131 const handleSave = useCallback ( async ( ) => {
116132 if ( filePath ) {
@@ -191,8 +207,7 @@ export default function App() {
191207 ) }
192208
193209 < Titlebar
194- fileName = { fileName }
195- isModified = { isModified }
210+ hasOpenFiles = { hasOpenFiles }
196211 onNew = { handleNew }
197212 onOpen = { handleOpen }
198213 onSave = { handleSave }
@@ -206,12 +221,14 @@ export default function App() {
206221 isFullscreen = { isFullscreen }
207222 />
208223
209- < TabBar
210- tabs = { tabs }
211- activeTabId = { activeTabId }
212- onTabClick = { setActiveTabId }
213- onTabClose = { closeTab }
214- />
224+ { hasOpenFiles && (
225+ < TabBar
226+ tabs = { tabs }
227+ activeTabId = { activeTabId }
228+ onTabClick = { setActiveTabId }
229+ onTabClose = { closeTab }
230+ />
231+ ) }
215232
216233 < div className = "flex flex-1 overflow-hidden" >
217234 < Sidebar
0 commit comments