Skip to content

Commit

Permalink
增加图注功能 (#9)
Browse files Browse the repository at this point in the history
* Added plugin to support image captions

* Added plugin to support image lightbox

* Fixed style issues to resolve build failure

* GLightbox shows close button by default

* Fixed GLightbox not reloaded in SPA mode

* chore(styles): omit sass deprecation warnings (jackyzha0#1737)

update to newer API

* chore(deps): bump the production-dependencies group across 1 directory with 3 updates (jackyzha0#1744)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(graph): enable radial mode (jackyzha0#1738)

* feat(explorer): collapsible mobile explorer (jackyzha0#1471)

Co-authored-by: Aaron Pham <[email protected]>

* 测试效果

---------

Co-authored-by: Stephen Tse <[email protected]>
Co-authored-by: Anton Bulakh <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aaron Pham <[email protected]>
Co-authored-by: Emile Bangma <[email protected]>
Co-authored-by: Aaron Pham <[email protected]>
  • Loading branch information
7 people authored Feb 4, 2025
1 parent acb15b6 commit 405c5b8
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 90 deletions.
5 changes: 4 additions & 1 deletion content/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ comments: false
*纯中文斜体*
_中英文混合斜体 Chinese & English_
**粗体 _嵌套斜体_**
`代码块不受影响`
`代码块不受影响`

![[Pic_20250204.png]]
*This is a caption.*
2 changes: 2 additions & 0 deletions docs/features/graph view.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Component.Graph({
opacityScale: 1, // how quickly do we fade out the labels when zooming out?
removeTags: [], // what tags to remove from the graph
showTags: true, // whether to show tags in the graph
enableRadial: false, // whether to constrain the graph, similar to Obsidian
},
globalGraph: {
drag: true,
Expand All @@ -49,6 +50,7 @@ Component.Graph({
opacityScale: 1,
removeTags: [], // what tags to remove from the graph
showTags: true, // whether to show tags in the graph
enableRadial: true, // whether to constrain the graph, similar to Obsidian
},
})
```
Expand Down
81 changes: 65 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@
"mdast-util-to-hast": "^13.2.0",
"mdast-util-to-string": "^4.0.0",
"micromorph": "^0.4.5",
"pixi.js": "^8.6.6",
"pixi.js": "^8.7.3",
"preact": "^10.25.4",
"preact-render-to-string": "^6.5.13",
"pretty-bytes": "^6.1.1",
"pretty-time": "^1.1.0",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.2.2",
"rehype-image-caption": "^2.0.10",
"rehype-katex": "^7.0.1",
"rehype-mathjax": "^6.0.0",
"rehype-pretty-code": "^0.14.0",
Expand Down Expand Up @@ -102,10 +103,10 @@
"@types/d3": "^7.4.3",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.6",
"@types/node": "^22.12.0",
"@types/pretty-time": "^1.1.5",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.5.13",
"@types/ws": "^8.5.14",
"@types/yargs": "^17.0.33",
"esbuild": "^0.24.2",
"prettier": "^3.4.2",
Expand Down
8 changes: 8 additions & 0 deletions quartz.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ const config: QuartzConfig = {
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
Plugin.Description(),
Plugin.Latex({ renderEngine: "katex" }),
// Adds image caption support. Syntax:
// ```md
// ![alt text](image.jpg)
// *caption text*
// ```
Plugin.FigureCaptions(),
// Adds image lightbox support
Plugin.Lightbox(),
],
filters: [Plugin.RemoveDrafts()],
emitters: [
Expand Down
38 changes: 33 additions & 5 deletions quartz/components/Explorer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import explorerStyle from "./styles/explorer.scss"
import style from "./styles/explorer.scss"

// @ts-ignore
import script from "./scripts/explorer.inline"
Expand Down Expand Up @@ -83,18 +83,46 @@ export default ((userOpts?: Partial<Options>) => {
lastBuildId = ctx.buildId
constructFileTree(allFiles)
}

return (
<div class={classNames(displayClass, "explorer")}>
<button
type="button"
id="explorer"
id="mobile-explorer"
class="collapsed hide-until-loaded"
data-behavior={opts.folderClickBehavior}
data-collapsed={opts.folderDefaultState}
data-savestate={opts.useSavedState}
data-tree={jsonTree}
data-mobile={true}
aria-controls="explorer-content"
aria-expanded={false}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-menu"
>
<line x1="4" x2="20" y1="12" y2="12" />
<line x1="4" x2="20" y1="6" y2="6" />
<line x1="4" x2="20" y1="18" y2="18" />
</svg>
</button>
<button
type="button"
id="desktop-explorer"
class="title-button"
data-behavior={opts.folderClickBehavior}
data-collapsed={opts.folderDefaultState}
data-savestate={opts.useSavedState}
data-tree={jsonTree}
data-mobile={false}
aria-controls="explorer-content"
aria-expanded={opts.folderDefaultState === "open"}
aria-expanded={true}
>
<h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2>
<svg
Expand Down Expand Up @@ -122,7 +150,7 @@ export default ((userOpts?: Partial<Options>) => {
)
}

Explorer.css = explorerStyle
Explorer.css = style
Explorer.afterDOMLoaded = script
return Explorer
}) satisfies QuartzComponentConstructor
5 changes: 4 additions & 1 deletion quartz/components/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface D3Config {
removeTags: string[]
showTags: boolean
focusOnHover?: boolean
enableRadial?: boolean
}

interface GraphOptions {
Expand All @@ -39,6 +40,7 @@ const defaultOptions: GraphOptions = {
showTags: true,
removeTags: [],
focusOnHover: false,
enableRadial: false,
},
globalGraph: {
drag: true,
Expand All @@ -53,10 +55,11 @@ const defaultOptions: GraphOptions = {
showTags: true,
removeTags: [],
focusOnHover: true,
enableRadial: true,
},
}

export default ((opts?: GraphOptions) => {
export default ((opts?: Partial<GraphOptions>) => {
const Graph: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph }
const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph }
Expand Down
Loading

0 comments on commit 405c5b8

Please sign in to comment.