🐛 fix the export dialogue
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { ExportDialog } from './components/Export/ExportDialog'
|
import { ExportDialog } from './components/Export/ExportDialog'
|
||||||
import type { ExportOptions } from './components/Export/ExportDialog'
|
import type { ExportOptions } from './components/Export/ExportDialog'
|
||||||
import { FileTree } from './components/FileTree/FileTree'
|
import { FileTree } from './components/FileTree/FileTree'
|
||||||
@@ -58,6 +58,7 @@ export default function App(): JSX.Element {
|
|||||||
const [isFirstRun, setIsFirstRun] = useState(false)
|
const [isFirstRun, setIsFirstRun] = useState(false)
|
||||||
const [focusPeek, setFocusPeek] = useState(false)
|
const [focusPeek, setFocusPeek] = useState(false)
|
||||||
const [projectTitle, setProjectTitle] = useState('')
|
const [projectTitle, setProjectTitle] = useState('')
|
||||||
|
const menuHandlerRef = useRef<((action: string) => Promise<void>) | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!focusMode) {
|
if (!focusMode) {
|
||||||
@@ -99,8 +100,7 @@ export default function App(): JSX.Element {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Handle menu actions sent from the main process
|
// Handle menu actions sent from the main process
|
||||||
useEffect(() => {
|
menuHandlerRef.current = async (action: string): Promise<void> => {
|
||||||
return window.api.onMenuAction(async (action) => {
|
|
||||||
if (action === 'save') {
|
if (action === 'save') {
|
||||||
if (activeFilePath && isDirty) {
|
if (activeFilePath && isDirty) {
|
||||||
await window.api.writeFile(activeFilePath, activeFileContent)
|
await window.api.writeFile(activeFilePath, activeFileContent)
|
||||||
@@ -140,8 +140,11 @@ export default function App(): JSX.Element {
|
|||||||
} else if (action === 'exportProjectPDF') {
|
} else if (action === 'exportProjectPDF') {
|
||||||
setExportOpen(true)
|
setExportOpen(true)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}, [activeFilePath, isDirty, activeFileContent, fontSize])
|
|
||||||
|
useEffect(() => {
|
||||||
|
return window.api.onMenuAction((action) => menuHandlerRef.current?.(action))
|
||||||
|
}, [])
|
||||||
|
|
||||||
// Handle Cmd+S / Ctrl+S and Cmd+Shift+F / Ctrl+Shift+F
|
// Handle Cmd+S / Ctrl+S and Cmd+Shift+F / Ctrl+Shift+F
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user