Skip to content

Commit ac1bf06

Browse files
committed
Quartz sync: May 23, 2025, 12:12 AM
1 parent ce0b294 commit ac1bf06

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

quartz/components/scripts/markmap.inline.ts

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ const externalIcon = `
88
<path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"/>
99
</svg>`.trim()
1010

11+
const fullIcon = `
12+
<svg xmlns="http://www.w3.org/2000/svg" height="15" viewBox="0 -960 960 960" width="15" aria-hidden="true">
13+
<path stroke="none" fill="currentColor" fill-rule="evenodd"
14+
d="M120-120v-320h80v184l504-504H520v-80h320v320h-80v-184L256-200h184v80H120Z"/>
15+
</svg>`
16+
17+
const closeIcon = `
18+
<svg xmlns="http://www.w3.org/2000/svg" height="15" viewBox="0 -960 960 960" width="15" aria-hidden="true">
19+
<path stroke="none" fill="currentColor" fill-rule="evenodd"
20+
d="m136-80-56-56 264-264H160v-80h320v320h-80v-184L136-80Zm344-400v-320h80v184l264-264 56 56-264 264h184v80H480Z"/>
21+
</svg>`
22+
23+
const exitIcon = `
24+
<svg xmlns="http://www.w3.org/2000/svg" height="18" viewBox="0 -960 960 960" width="18" >
25+
<path stroke="none" fill="currentColor" fill-rule="evenodd"
26+
d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/>
27+
</svg>
28+
`
29+
1130
function renderGlobalMarkmap() {
1231
const transformer = new Transformer()
1332
const { styles } = transformer.getAssets();
@@ -47,18 +66,6 @@ function renderGlobalMarkmap() {
4766
toolbarEl.append(mmToolbar)
4867
mm.fit()
4968

50-
const customToolbar = document.createElement("div");
51-
customToolbar.className = "mm-toolbar-item";
52-
customToolbar.title = "Toggle fullscreen";
53-
54-
customToolbar.innerHTML = `
55-
<svg xmlns="http://www.w3.org/2000/svg" height="15" viewBox="0 -960 960 960" width="15" aria-hidden="true">
56-
<path stroke="none" fill="currentColor" fill-rule="evenodd"
57-
d="M120-120v-320h80v184l504-504H520v-80h320v320h-80v-184L256-200h184v80H120Z"/>
58-
</svg>
59-
`;
60-
mmToolbar.append(customToolbar);
61-
6269
svg.querySelectorAll<HTMLAnchorElement>('a[href^="http"]').forEach(a => {
6370
a.classList.add('external')
6471
})
@@ -67,12 +74,39 @@ function renderGlobalMarkmap() {
6774
a.insertAdjacentHTML('beforeend', externalIcon)
6875
})
6976

77+
const customToolbar = document.createElement("div");
78+
customToolbar.className = "mm-toolbar-item";
79+
customToolbar.title = "Toggle fullscreen";
80+
customToolbar.innerHTML = fullIcon
81+
82+
const customExit = document.createElement("div");
83+
customExit.className = "mm-toolbar-item";
84+
customExit.title = "Exit";
85+
customExit.innerHTML = exitIcon
86+
87+
mmToolbar.append(customToolbar);
88+
mmToolbar.append(customExit);
89+
7090
container.classList.add("active")
7191

92+
let isToggled = false;
7293
customToolbar.addEventListener('click', () => {
7394
containerInner.classList.toggle('fullscreen')
95+
isToggled = !isToggled;
96+
customToolbar.innerHTML = isToggled ? closeIcon : fullIcon;
7497
})
7598

99+
customExit.addEventListener("click", () => {
100+
const escEvent = new KeyboardEvent("keydown", {
101+
key: "Escape",
102+
code: "Escape",
103+
keyCode: 27,
104+
which: 27,
105+
bubbles: true,
106+
});
107+
document.dispatchEvent(escEvent);
108+
});
109+
76110
registerEscapeHandler(container, hideGlobalMarkmap)
77111
}
78112

quartz/components/styles/markmap.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
#global-markmap-toolbar {
8383
position: absolute;
84-
bottom: 0;
84+
top: 10;
8585
left: 0;
8686
right: 0;
8787
width: 100%;

0 commit comments

Comments
 (0)