2 Commits

Author SHA1 Message Date
5fd5d68411 update packages 2024-01-08 15:32:56 +01:00
fb5383775b chore: update mdx-components 2024-01-08 11:58:04 +01:00
3 changed files with 20 additions and 10 deletions

9
package-lock.json generated
View File

@@ -13,7 +13,7 @@
"@electron-toolkit/utils": "^2.0.1", "@electron-toolkit/utils": "^2.0.1",
"@fontsource/roboto": "^5.0.8", "@fontsource/roboto": "^5.0.8",
"@it-incubator/md-bundler": "0.0.10", "@it-incubator/md-bundler": "0.0.10",
"@it-incubator/mdx-components": "0.0.8", "@it-incubator/mdx-components": "0.0.11",
"@it-incubator/ui-kit": "0.2.20", "@it-incubator/ui-kit": "0.2.20",
"builtin-modules": "^3.3.0", "builtin-modules": "^3.3.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
@@ -1724,9 +1724,9 @@
} }
}, },
"node_modules/@it-incubator/mdx-components": { "node_modules/@it-incubator/mdx-components": {
"version": "0.0.8", "version": "0.0.11",
"resolved": "https://registry.npmjs.org/@it-incubator/mdx-components/-/mdx-components-0.0.8.tgz", "resolved": "https://registry.npmjs.org/@it-incubator/mdx-components/-/mdx-components-0.0.11.tgz",
"integrity": "sha512-L/yxluL90gSCQfnr2RzqTM89gJ8bd5upwM9/VrpPG4CGxoSMfsWkWBoybzLr98ClVH01Qd0+gzBe2Wz+fxaYoQ==", "integrity": "sha512-U2JOVdnImiApCNfayX08j7A/9tD+eiCRkoUF4p9gvABS+aHRyFaiFttDuamU0rN2NqEE26Pxq51vriNXdsl9wg==",
"dependencies": { "dependencies": {
"@radix-ui/react-checkbox": "1.0.4", "@radix-ui/react-checkbox": "1.0.4",
"@radix-ui/react-scroll-area": "1.0.4", "@radix-ui/react-scroll-area": "1.0.4",
@@ -1735,6 +1735,7 @@
"mdx-bundler": "^9.2.1" "mdx-bundler": "^9.2.1"
}, },
"peerDependencies": { "peerDependencies": {
"@fontsource/roboto": "5.0.8",
"react": ">=18.0.2", "react": ">=18.0.2",
"react-dom": ">=18.0.2" "react-dom": ">=18.0.2"
} }

View File

@@ -15,16 +15,16 @@
"dev": "electron-vite dev", "dev": "electron-vite dev",
"build": "npm run typecheck && electron-vite build", "build": "npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps", "postinstall": "electron-builder install-app-deps",
"build:win": "npm run build && electron-builder --win --config", "build:win": "npm run build && electron-builder --win --config --x64",
"build:mac": "electron-vite build && electron-builder --mac --config", "build:mac": "electron-vite build && electron-builder --mac --config --universal",
"build:linux": "electron-vite build && electron-builder --linux --config" "build:linux": "electron-vite build && electron-builder --linux --config --x64"
}, },
"dependencies": { "dependencies": {
"@electron-toolkit/preload": "^2.0.0", "@electron-toolkit/preload": "^2.0.0",
"@electron-toolkit/utils": "^2.0.1", "@electron-toolkit/utils": "^2.0.1",
"@fontsource/roboto": "^5.0.8", "@fontsource/roboto": "^5.0.8",
"@it-incubator/md-bundler": "0.0.10", "@it-incubator/md-bundler": "0.0.10",
"@it-incubator/mdx-components": "0.0.8", "@it-incubator/mdx-components": "0.0.11",
"@it-incubator/ui-kit": "0.2.20", "@it-incubator/ui-kit": "0.2.20",
"builtin-modules": "^3.3.0", "builtin-modules": "^3.3.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",

View File

@@ -38,7 +38,7 @@ export const TableOfContents = ({ tocMap }: Props) => {
const headingsObserver = headingsObserverRef.current const headingsObserver = headingsObserverRef.current
setTimeout(() => { 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) }, 100)
return () => { return () => {
@@ -53,13 +53,22 @@ export const TableOfContents = ({ tocMap }: Props) => {
// Disconnect and reconnect the observer to refresh it // Disconnect and reconnect the observer to refresh it
headingsObserver.disconnect() headingsObserver.disconnect()
setTimeout(() => { 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) }, 100)
} }
}, [tocMap]) }, [tocMap])
const onLinkClick = (e: MouseEvent<HTMLAnchorElement>) => { const onLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
setCurrentHeading(e.currentTarget.getAttribute('href')!.replace('#', '')) 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 ( return (