Skip to content

Commit

Permalink
fix:不显示复制和语言
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhihang committed Oct 26, 2022
1 parent 0997866 commit 5a06fb5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/run/halo/prismjs/PrismJSHeadProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public Mono<Void> process(ITemplateContext context, IModel model, IElementModelS
}

private String highlightJsScript(String css, String customCss, Boolean lineNumber) {
// language=html
return """
<!-- PluginPrismJS start -->
<link rel="stylesheet" href="/plugins/PluginPrismJS/assets/static/themes/%s"/>
<!-- 工具栏 css -->
<link rel="stylesheet" th:href="/plugins/PluginPrismJS/assets/static/plugins/toolbar/prism-toolbar.min.css"/>
<link rel="stylesheet" href="/plugins/PluginPrismJS/assets/static/plugins/toolbar/prism-toolbar.min.css"/>
<script src="/plugins/PluginPrismJS/assets/static/prism.js"></script>
Expand All @@ -57,22 +58,20 @@ private String highlightJsScript(String css, String customCss, Boolean lineNumbe
document.addEventListener("DOMContentLoaded", async function () {
var customCss = %s;
if (customCss !== null || customCss !== undefined || customCss !== '') {
if (customCss !== null && customCss !== undefined && customCss !== '') {
await loadCss(`customCss`);
s
console.log("CustomCss: ", customCss);
}
if (%s) {
console.log("ShowLineNumber");
await loadCss(`/plugins/PluginPrismJS/assets/static/plugins/line-numbers/prism-line-numbers.min.css`);
await loadScript(`/plugins/PluginPrismJS/assets/static/plugins/line-numbers/prism-line-numbers.min.js`);
console.log("ShowLineNumber");
}
});
})
function loadScript(url) {
return new Promise(function (resolve, reject) {
Expand All @@ -88,10 +87,11 @@ function loadScript(url) {
function loadCss(url) {
return new Promise(function (resolve, reject) {
const css = document.createElement("link");
css.rel = 'stylesheet';
css.rel = "stylesheet";
css.href = url;
css.onload = resolve;
css.onerror = reject;
document.head.appendChild(css);
});
}
Expand Down

0 comments on commit 5a06fb5

Please sign in to comment.