Skip to content

Commit 5f184e6

Browse files
committed
feat(terminal): open .md file links in built-in markdown viewer
Clicking a .md file link in the terminal opens it in a resizable markdown viewer dialog with syntax highlighting. Cmd+click opens the file externally instead. Non-.md files always open externally.
1 parent 81d9da5 commit 5f184e6

5 files changed

Lines changed: 255 additions & 135 deletions

File tree

electron/ipc/channels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export enum IPC {
100100

101101
// File links
102102
OpenPath = 'open_path',
103+
ReadFileText = 'read_file_text',
103104

104105
// Notifications
105106
ShowNotification = 'show_notification',

electron/ipc/register.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,11 @@ export function registerAllHandlers(win: BrowserWindow): void {
458458
return shell.openPath(args.filePath);
459459
});
460460

461+
ipcMain.handle(IPC.ReadFileText, (_e, args) => {
462+
validatePath(args.filePath, 'filePath');
463+
return fs.readFileSync(args.filePath, 'utf8');
464+
});
465+
461466
// --- System ---
462467
ipcMain.handle(IPC.GetSystemFonts, () => getSystemMonospaceFonts());
463468

electron/preload.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const ALLOWED_CHANNELS = new Set([
9292
'get_system_fonts',
9393
// File links
9494
'open_path',
95+
'read_file_text',
9596
// Notifications
9697
'show_notification',
9798
'notification_clicked',

0 commit comments

Comments
 (0)