hexo-theme-gnix 4.2.4 → 4.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/source/js/pjax.js +1 -2
- package/source/js/shiki/shiki.js +9 -38
package/package.json
CHANGED
package/source/js/pjax.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
(() => {
|
|
2
|
-
// biome-ignore lint/correctness/noUnusedVariables: will be used
|
|
3
2
|
let pjax;
|
|
4
3
|
|
|
5
4
|
function initPjax() {
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
});
|
|
12
11
|
|
|
13
12
|
window.addEventListener("popstate", () => {
|
|
14
|
-
if (pjax
|
|
13
|
+
if (pjax?.loadUrl) {
|
|
15
14
|
pjax.loadUrl(window.location.href);
|
|
16
15
|
}
|
|
17
16
|
});
|
package/source/js/shiki/shiki.js
CHANGED
|
@@ -56,58 +56,29 @@ const FeatureHandlers = {
|
|
|
56
56
|
expandCode(figure) {
|
|
57
57
|
const expandBtn = figure.querySelector(SELECTORS.expandBtn);
|
|
58
58
|
const pre = figure.querySelector(SELECTORS.preShiki);
|
|
59
|
-
|
|
60
59
|
const isExpanded = figure.classList.contains("expanded");
|
|
61
60
|
const showLines = parseInt(figure.dataset.showLines || "10", 10);
|
|
62
61
|
|
|
63
62
|
if (isExpanded) {
|
|
64
|
-
// 记录折叠前的状态
|
|
65
|
-
const beforeCollapseHeight = pre.scrollHeight;
|
|
66
|
-
|
|
67
|
-
// 计算折叠后的目标高度
|
|
68
63
|
const computedStyle = getComputedStyle(pre);
|
|
69
64
|
const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
|
|
70
65
|
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
71
66
|
const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
|
|
72
67
|
const targetHeight = showLines * lineHeight + paddingTop + paddingBottom;
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
pre.style.maxHeight = `${
|
|
76
|
-
|
|
77
|
-
// 应用折叠状态
|
|
78
|
-
requestAnimationFrame(() => {
|
|
79
|
-
figure.classList.remove("expanded");
|
|
80
|
-
pre.style.maxHeight = `${targetHeight}px`;
|
|
81
|
-
|
|
82
|
-
// 延迟箭头旋转,等待折叠动画完成
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
expandBtn.classList.remove(CLASSES.expandDone);
|
|
85
|
-
}, 300); // 与CSS transition时间同步
|
|
86
|
-
});
|
|
69
|
+
figure.classList.remove("expanded");
|
|
70
|
+
pre.style.maxHeight = `${targetHeight}px`;
|
|
71
|
+
expandBtn.classList.remove(CLASSES.expandDone);
|
|
87
72
|
} else {
|
|
88
|
-
// 展开代码
|
|
89
|
-
const currentHeight = pre.offsetHeight;
|
|
90
73
|
const fullHeight = pre.scrollHeight;
|
|
91
74
|
|
|
92
|
-
// 先设置当前高度作为起点
|
|
93
|
-
pre.style.maxHeight = `${currentHeight}px`;
|
|
94
|
-
|
|
95
|
-
// 应用展开状态
|
|
96
75
|
figure.classList.add("expanded");
|
|
76
|
+
pre.style.maxHeight = `${fullHeight}px`;
|
|
77
|
+
expandBtn.classList.add(CLASSES.expandDone);
|
|
97
78
|
|
|
98
|
-
|
|
99
|
-
pre.style.maxHeight =
|
|
100
|
-
|
|
101
|
-
// 立即开始箭头旋转动画
|
|
102
|
-
expandBtn.classList.add(CLASSES.expandDone);
|
|
103
|
-
|
|
104
|
-
// 动画结束后清除max-height限制,允许内容自然增长
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
if (figure.classList.contains("expanded")) {
|
|
107
|
-
pre.style.maxHeight = "none";
|
|
108
|
-
}
|
|
109
|
-
}, 300);
|
|
110
|
-
});
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
pre.style.maxHeight = "none";
|
|
81
|
+
}, 300);
|
|
111
82
|
}
|
|
112
83
|
},
|
|
113
84
|
};
|
|
@@ -117,7 +88,7 @@ function handleToolbarClick(event) {
|
|
|
117
88
|
const classList = target.classList;
|
|
118
89
|
|
|
119
90
|
const handlers = {
|
|
120
|
-
expand: () => FeatureHandlers.
|
|
91
|
+
"expand": () => FeatureHandlers.expandCode(this),
|
|
121
92
|
"copy-button": () => FeatureHandlers.copy(this, target),
|
|
122
93
|
"toggle-wrap": () => FeatureHandlers.toggleWrap(this),
|
|
123
94
|
};
|