mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
fix: add missing rendererReady call and fix temporal dead zone crash
- App.tsx: call electronAPI.file.rendererReady() on mount so main process opens pendingFile (files passed via CLI or file associations) - FindReplaceBar: move updateMatchCount declaration before executeCommand to fix 'Cannot access d before initialization' crash in minified build (executeCommand referenced updateMatchCount via closure before its const declaration in the same scope)
This commit is contained in:
@@ -15,6 +15,10 @@ function App() {
|
|||||||
useAutoUpdateCheck();
|
useAutoUpdateCheck();
|
||||||
const [printOpen, setPrintOpen] = useState(false);
|
const [printOpen, setPrintOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.electronAPI?.file?.rendererReady?.();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handler = () => setPrintOpen(true);
|
const handler = () => setPrintOpen(true);
|
||||||
window.addEventListener('mc:print', handler);
|
window.addEventListener('mc:print', handler);
|
||||||
|
|||||||
@@ -25,18 +25,6 @@ export function FindReplaceBar() {
|
|||||||
const [useRegex, setUseRegex] = useState(false);
|
const [useRegex, setUseRegex] = useState(false);
|
||||||
const [matchInfo, setMatchInfo] = useState<{ current: number; total: number } | null>(null);
|
const [matchInfo, setMatchInfo] = useState<{ current: number; total: number } | null>(null);
|
||||||
|
|
||||||
const executeCommand = useCallback(
|
|
||||||
(fn: (view: EditorView) => boolean | void) => {
|
|
||||||
const view = getActiveView();
|
|
||||||
if (!view) return false;
|
|
||||||
const result = fn(view);
|
|
||||||
updateMatchCount();
|
|
||||||
view.focus();
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
[updateMatchCount]
|
|
||||||
);
|
|
||||||
|
|
||||||
const updateMatchCount = useCallback(() => {
|
const updateMatchCount = useCallback(() => {
|
||||||
const view = getActiveView();
|
const view = getActiveView();
|
||||||
if (!view) {
|
if (!view) {
|
||||||
@@ -77,6 +65,18 @@ export function FindReplaceBar() {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const executeCommand = useCallback(
|
||||||
|
(fn: (view: EditorView) => boolean | void) => {
|
||||||
|
const view = getActiveView();
|
||||||
|
if (!view) return false;
|
||||||
|
const result = fn(view);
|
||||||
|
updateMatchCount();
|
||||||
|
view.focus();
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
[updateMatchCount]
|
||||||
|
);
|
||||||
|
|
||||||
const handleFindNext = useCallback(() => {
|
const handleFindNext = useCallback(() => {
|
||||||
executeCommand(findNext);
|
executeCommand(findNext);
|
||||||
}, [executeCommand]);
|
}, [executeCommand]);
|
||||||
|
|||||||
Reference in New Issue
Block a user