mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1e0072eea | ||
|
|
1b2afb5f15 | ||
|
|
c811af9d48 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pan-converter",
|
||||
"version": "1.7.4",
|
||||
"version": "1.7.6",
|
||||
"description": "Cross-platform Markdown editor and converter using Pandoc",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
+35
-4
@@ -49,6 +49,41 @@ let currentFile = null; // This will now represent the active tab's file
|
||||
let pandocAvailable = null; // Cache pandoc availability check
|
||||
let rendererReady = false; // Track if renderer is ready to receive file data
|
||||
|
||||
// Handle single instance lock for Windows file association
|
||||
// When a file is double-clicked and the app is already running,
|
||||
// Windows tries to start a second instance. We prevent this and
|
||||
// pass the file to the existing instance instead.
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
if (!gotTheLock) {
|
||||
// Another instance is already running, quit this one
|
||||
app.quit();
|
||||
} else {
|
||||
// This is the first instance, handle second-instance events
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
// Someone tried to run a second instance, focus our window instead
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||
mainWindow.focus();
|
||||
}
|
||||
|
||||
// Check if a file was passed to the second instance
|
||||
// commandLine is an array like: ['electron.exe', 'app.asar', 'file.md']
|
||||
const fileArgs = commandLine.slice(2);
|
||||
for (const arg of fileArgs) {
|
||||
if ((arg.endsWith('.md') || arg.endsWith('.markdown')) && fs.existsSync(arg)) {
|
||||
// Open the file in the existing instance
|
||||
if (rendererReady) {
|
||||
openFileFromPath(arg);
|
||||
} else {
|
||||
app.pendingFile = arg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check if pandoc is available
|
||||
function checkPandocAvailability() {
|
||||
return new Promise((resolve) => {
|
||||
@@ -1584,15 +1619,11 @@ function openFileFromPath(filePath) {
|
||||
currentFile = filePath;
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
if (mainWindow && mainWindow.webContents && rendererReady) {
|
||||
console.log('Opening file (renderer ready):', filePath);
|
||||
mainWindow.webContents.send('file-opened', { path: filePath, content });
|
||||
} else {
|
||||
console.log('Renderer not ready, storing file:', filePath);
|
||||
// Store file to open after renderer is ready
|
||||
app.pendingFile = filePath;
|
||||
}
|
||||
} else {
|
||||
console.error('File does not exist:', filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,6 @@ body {
|
||||
|
||||
#preview table th, .preview-content table th {
|
||||
font-weight: 600;
|
||||
background-color: #f6f8fa;
|
||||
}
|
||||
|
||||
#preview table tr:nth-child(2n), .preview-content table tr:nth-child(2n) {
|
||||
@@ -449,9 +448,6 @@ body.theme-dark .preview-content table th, body.theme-dark .preview-content tabl
|
||||
border-color: #3e3e42;
|
||||
}
|
||||
|
||||
body.theme-dark #preview table th, body.theme-dark .preview-content table th {
|
||||
background-color: #2d2d30;
|
||||
}
|
||||
|
||||
body.theme-dark #preview table tr:nth-child(2n), body.theme-dark .preview-content table tr:nth-child(2n) {
|
||||
background-color: #2d2d30;
|
||||
|
||||
Reference in New Issue
Block a user