Feat: add config whether to enable the code wrapper

Resolved #462
This commit is contained in:
Cell
2024-07-24 10:59:01 +08:00
parent 7c836776c0
commit 537ad1df3f
5 changed files with 27 additions and 16 deletions
+8 -3
View File
@@ -93,6 +93,13 @@ pre:not(.mermaid[data-processed='true']) {
@include border-radius($global-border-radius);
@include transition(border-radius 0.2s ease);
// delayed loading table-wrapper
& + .table-wrapper {
max-height: 0;
@include border-radius(0 0 $global-border-radius $global-border-radius);
@include details-transition-open;
}
[data-theme='dark'] & {
color: $code-info-color-dark;
--#{$prefix}bg-code-header: #{darken($code-background-color-dark, 3%)};
@@ -164,10 +171,8 @@ pre:not(.mermaid[data-processed='true']) {
// delayed loading table-wrapper
.table-wrapper {
max-height: 0;
overflow: hidden;
@include border-radius(0 0 $global-border-radius $global-border-radius);
@include details-transition-open;
@include border-radius($global-border-radius);
}
table {
+4
View File
@@ -363,6 +363,10 @@ class FixIt {
}
initHighlight() {
if (!this.config.code) {
return
}
// if markup.highlight.lineNumbersInTable set to false
this.util.forEach(document.querySelectorAll('.highlight > pre.chroma'), ($preChroma) => {
const $chroma = document.createElement('div');
$chroma.className = $preChroma.className;
+5 -3
View File
@@ -918,11 +918,13 @@ enableEmoji = true
copyTex = true
# KaTeX extension mhchem
mhchem = true
# Code config
# Code wrapper config
[params.page.code]
# whether to show the copy button of the code block
# FixIt 0.3.9 | NEW whether to enable the code wrapper
enable = true
# whether to show the copy button of the code wrapper
copy = true
# FixIt 0.2.13 | NEW whether to show the edit button of the code block
# FixIt 0.2.13 | NEW whether to show the edit button of the code wrapper
edit = true
# the maximum number of lines of displayed code by default
maxShownLines = 10
+9 -10
View File
@@ -51,17 +51,16 @@
{{- $config = dict "lightgallery" true | merge $config -}}
{{- end -}}
{{- /* Code wrapper */ -}}
{{- $code := $params.code | default dict -}}
{{- $config = cond (ne $code.maxShownLines nil) $code.maxShownLines 10 | dict "maxShownLines" | dict "code" | merge $config -}}
{{- /* edit code */ -}}
{{- if ne $code.edit false -}}
{{- $config = dict "editable" true "editLockTitle" (T "assets.editLockTitle") "editUnLockTitle" (T "assets.editUnLockTitle") | dict "code" | merge $config -}}
{{- end -}}
{{- /* copy code */ -}}
{{- if ne $code.copy false -}}
{{- $config = T "assets.copyToClipboard" | dict "copyTitle" | dict "code" | merge $config -}}
{{- if $code.enable -}}
{{- $config = $code.maxShownLines | dict "maxShownLines" | dict "code" | merge $config -}}
{{- if ne $code.edit false -}}
{{- $config = dict "editable" true "editLockTitle" (T "assets.editLockTitle") "editUnLockTitle" (T "assets.editUnLockTitle") | dict "code" | merge $config -}}
{{- end -}}
{{- if ne $code.copy false -}}
{{- $config = T "assets.copyToClipboard" | dict "copyTitle" | dict "code" | merge $config -}}
{{- end -}}
{{- end -}}
{{- /* Sharer.js */ -}}
@@ -15,6 +15,7 @@
{{- dict "Collections" $termLink | T "single.includedIn.collections" | strings.FirstUpper | safeHTML }} {{ .Pages.Len -}}
</div>
<div class="collection-nav">
{{/* TODO JS 实现 reverse 翻转顺序 */}}
{{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}}
{{- with $pages.Next $ -}}
<a href="{{ .RelPermalink }}" class="collection-nav-item" rel="prev" title="{{ title .LinkTitle }}">