mirror of
https://github.com/ershisan99/md-preview-desktop.git
synced 2025-12-16 12:33:38 +00:00
Compare commits
4 Commits
feat/watch
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d7512ab79 | |||
| ad2b590281 | |||
| 5fd5d68411 | |||
| fb5383775b |
2323
package-lock.json
generated
2323
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -15,19 +15,22 @@
|
||||
"dev": "electron-vite dev",
|
||||
"build": "npm run typecheck && electron-vite build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:win": "npm run build && electron-builder --win --config",
|
||||
"build:mac": "electron-vite build && electron-builder --mac --config",
|
||||
"build:linux": "electron-vite build && electron-builder --linux --config"
|
||||
"build:win": "electron-builder --win --config --x64",
|
||||
"build:mac": "electron-builder --mac --config --x64",
|
||||
"build:mac:arm": "electron-builder --mac --config --arm64",
|
||||
"build:linux": "electron-builder --linux --config --x64",
|
||||
"build:all": "npm run build && npm run build:win && npm run build:mac && npm run build:mac:arm && npm run build:linux"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron-toolkit/preload": "^2.0.0",
|
||||
"@electron-toolkit/utils": "^2.0.1",
|
||||
"@fontsource/roboto": "^5.0.8",
|
||||
"@it-incubator/md-bundler": "0.0.10",
|
||||
"@it-incubator/mdx-components": "0.0.8",
|
||||
"@it-incubator/ui-kit": "0.2.20",
|
||||
"@it-incubator/mdx-components": "0.0.11",
|
||||
"@it-incubator/ui-kit": "0.2.24",
|
||||
"builtin-modules": "^3.3.0",
|
||||
"chokidar": "^3.5.3",
|
||||
"electron-log": "^5.0.3",
|
||||
"electron-store": "^8.1.0",
|
||||
"electron-updater": "^6.1.4",
|
||||
"esbuild": "^0.19.5",
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from 'fs'
|
||||
|
||||
import { is } from '@electron-toolkit/utils'
|
||||
import { BrowserWindow, app, ipcMain } from 'electron'
|
||||
import log from 'electron-log/main'
|
||||
|
||||
import { bundleMdxAndSend } from './bundle-mdx-and-send'
|
||||
import { handleAppReady } from './handlers/handle-app-ready'
|
||||
@@ -10,6 +11,11 @@ import { prepareAndSendDir } from './prepare-and-send-dir'
|
||||
import { setupWatcher } from './setup-watcher'
|
||||
import { store } from './store'
|
||||
|
||||
// Optional, initialize the logger for any renderer process
|
||||
log.initialize()
|
||||
|
||||
log.info('Log from the main process')
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
|
||||
function setMainWindow(win: BrowserWindow) {
|
||||
@@ -89,9 +95,12 @@ ipcMain.on('open-file', (_event, filePath) => {
|
||||
|
||||
process
|
||||
.on('unhandledRejection', (reason, p) => {
|
||||
console.error(reason, 'Unhandled Rejection at Promise', p)
|
||||
log.error('Unhandled Rejection at Promise', reason, p)
|
||||
console.error('Unhandled Rejection at Promise', reason, p)
|
||||
})
|
||||
.on('uncaughtException', err => {
|
||||
log.error('Uncaught Exception', err)
|
||||
|
||||
// https://github.com/paulmillr/chokidar/issues/566
|
||||
// this has been open for over 7 years, still hasn't been fixed.
|
||||
// for some reason it doesn't even go into the chokidar error handler, so had to do it here
|
||||
@@ -107,3 +116,5 @@ process
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
log.errorHandler.startCatching()
|
||||
|
||||
@@ -38,7 +38,7 @@ export const TableOfContents = ({ tocMap }: Props) => {
|
||||
const headingsObserver = headingsObserverRef.current
|
||||
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
|
||||
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
|
||||
}, 100)
|
||||
|
||||
return () => {
|
||||
@@ -53,13 +53,22 @@ export const TableOfContents = ({ tocMap }: Props) => {
|
||||
// Disconnect and reconnect the observer to refresh it
|
||||
headingsObserver.disconnect()
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('article :is(h1,h2,h3)').forEach(h => headingsObserver.observe(h))
|
||||
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
|
||||
}, 100)
|
||||
}
|
||||
}, [tocMap])
|
||||
|
||||
const onLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
||||
setCurrentHeading(e.currentTarget.getAttribute('href')!.replace('#', ''))
|
||||
if (headingsObserverRef.current) {
|
||||
const headingsObserver = headingsObserverRef.current
|
||||
|
||||
// Disconnect and reconnect the observer to refresh it
|
||||
headingsObserver.disconnect()
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('article :is(h2,h3,h4)').forEach(h => headingsObserver.observe(h))
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user