1.13.1原版

This commit is contained in:
2026-07-19 01:16:28 +08:00
commit c6ba83f5d7
133 changed files with 19136 additions and 0 deletions
@@ -0,0 +1,40 @@
import type { Directive } from "vue";
import { hasShikiPlugin } from "./util";
const ShikiDirective: Directive = {
mounted: (el: HTMLElement) => {
renderShikiCode(el);
},
updated: (el: HTMLElement) => {
renderShikiCode(el);
},
};
function renderShikiCode(el: HTMLElement) {
if (!hasShikiPlugin()) {
return;
}
const preElements = el.querySelectorAll<HTMLPreElement>("pre:has(code)");
for (const preElement of preElements) {
const parent = preElement.parentElement;
if (!parent) {
continue;
}
if (preElement.parentElement.tagName === "SHIKI-CODE") {
continue;
}
preElement.style.padding = "1rem";
preElement.style.filter = "blur(10px)";
const shikiElement = document.createElement("shiki-code");
shikiElement.style.padding = "0 1px";
parent.insertBefore(shikiElement, preElement);
shikiElement.appendChild(preElement);
}
}
export default ShikiDirective;