Enhance reader styles exports and settings
This commit is contained in:
+200
-16
@@ -325,44 +325,224 @@ html[data-theme="dark"] td code {
|
||||
.code-block {
|
||||
position: relative;
|
||||
margin: 1.2em 0;
|
||||
border: 1px solid #d8dee8;
|
||||
border: 1px solid #d4d4d4;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #f7f9fc;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .code-block {
|
||||
border-color: #384252;
|
||||
background: #171b22;
|
||||
border-color: #3c3c3c;
|
||||
background: #1e1e1e;
|
||||
}
|
||||
|
||||
.code-title {
|
||||
padding: 0.42em 0.76em;
|
||||
border-bottom: 1px solid #d8dee8;
|
||||
background: #edf1f6;
|
||||
color: #53606f;
|
||||
border-bottom: 1px solid #d4d4d4;
|
||||
background: #f3f3f3;
|
||||
color: #616161;
|
||||
font-size: 0.82em;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .code-title {
|
||||
border-bottom-color: #384252;
|
||||
background: #242b36;
|
||||
color: #b7c0cc;
|
||||
border-bottom-color: #3c3c3c;
|
||||
background: #252526;
|
||||
color: #cccccc;
|
||||
}
|
||||
|
||||
pre.highlight {
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
overflow-x: auto;
|
||||
background: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] pre.highlight {
|
||||
background: #1e1e1e;
|
||||
color: #d4d4d4;
|
||||
}
|
||||
|
||||
pre.highlight code {
|
||||
display: block;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.highlight .c,
|
||||
.highlight .cm,
|
||||
.highlight .c1,
|
||||
.highlight .cs {
|
||||
color: #008000;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.highlight .k,
|
||||
.highlight .kc,
|
||||
.highlight .kd,
|
||||
.highlight .kn,
|
||||
.highlight .kp,
|
||||
.highlight .kr,
|
||||
.highlight .ow {
|
||||
color: #0000ff;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.highlight .kt,
|
||||
.highlight .nc,
|
||||
.highlight .nn {
|
||||
color: #267f99;
|
||||
}
|
||||
|
||||
.highlight .s,
|
||||
.highlight .sa,
|
||||
.highlight .sb,
|
||||
.highlight .sc,
|
||||
.highlight .dl,
|
||||
.highlight .sd,
|
||||
.highlight .s1,
|
||||
.highlight .s2,
|
||||
.highlight .se,
|
||||
.highlight .sh,
|
||||
.highlight .si,
|
||||
.highlight .sx,
|
||||
.highlight .sr,
|
||||
.highlight .ss {
|
||||
color: #a31515;
|
||||
}
|
||||
|
||||
.highlight .m,
|
||||
.highlight .mb,
|
||||
.highlight .mf,
|
||||
.highlight .mh,
|
||||
.highlight .mi,
|
||||
.highlight .mo,
|
||||
.highlight .il {
|
||||
color: #098658;
|
||||
}
|
||||
|
||||
.highlight .nf,
|
||||
.highlight .fm,
|
||||
.highlight .nb,
|
||||
.highlight .bp {
|
||||
color: #795e26;
|
||||
}
|
||||
|
||||
.highlight .na,
|
||||
.highlight .nv,
|
||||
.highlight .vc,
|
||||
.highlight .vg,
|
||||
.highlight .vi,
|
||||
.highlight .vm {
|
||||
color: #001080;
|
||||
}
|
||||
|
||||
.highlight .nd,
|
||||
.highlight .ne,
|
||||
.highlight .nl {
|
||||
color: #af00db;
|
||||
}
|
||||
|
||||
.highlight .o,
|
||||
.highlight .p {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.highlight .err {
|
||||
background: transparent;
|
||||
color: #a31515;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .c,
|
||||
html[data-theme="dark"] .highlight .cm,
|
||||
html[data-theme="dark"] .highlight .c1,
|
||||
html[data-theme="dark"] .highlight .cs {
|
||||
color: #6a9955;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .k,
|
||||
html[data-theme="dark"] .highlight .kc,
|
||||
html[data-theme="dark"] .highlight .kd,
|
||||
html[data-theme="dark"] .highlight .kn,
|
||||
html[data-theme="dark"] .highlight .kp,
|
||||
html[data-theme="dark"] .highlight .kr,
|
||||
html[data-theme="dark"] .highlight .ow {
|
||||
color: #569cd6;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .kt,
|
||||
html[data-theme="dark"] .highlight .nc,
|
||||
html[data-theme="dark"] .highlight .nn {
|
||||
color: #4ec9b0;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .s,
|
||||
html[data-theme="dark"] .highlight .sa,
|
||||
html[data-theme="dark"] .highlight .sb,
|
||||
html[data-theme="dark"] .highlight .sc,
|
||||
html[data-theme="dark"] .highlight .dl,
|
||||
html[data-theme="dark"] .highlight .sd,
|
||||
html[data-theme="dark"] .highlight .s1,
|
||||
html[data-theme="dark"] .highlight .s2,
|
||||
html[data-theme="dark"] .highlight .se,
|
||||
html[data-theme="dark"] .highlight .sh,
|
||||
html[data-theme="dark"] .highlight .si,
|
||||
html[data-theme="dark"] .highlight .sx,
|
||||
html[data-theme="dark"] .highlight .sr,
|
||||
html[data-theme="dark"] .highlight .ss {
|
||||
color: #ce9178;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .m,
|
||||
html[data-theme="dark"] .highlight .mb,
|
||||
html[data-theme="dark"] .highlight .mf,
|
||||
html[data-theme="dark"] .highlight .mh,
|
||||
html[data-theme="dark"] .highlight .mi,
|
||||
html[data-theme="dark"] .highlight .mo,
|
||||
html[data-theme="dark"] .highlight .il {
|
||||
color: #b5cea8;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .nf,
|
||||
html[data-theme="dark"] .highlight .fm,
|
||||
html[data-theme="dark"] .highlight .nb,
|
||||
html[data-theme="dark"] .highlight .bp {
|
||||
color: #dcdcaa;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .na,
|
||||
html[data-theme="dark"] .highlight .nv,
|
||||
html[data-theme="dark"] .highlight .vc,
|
||||
html[data-theme="dark"] .highlight .vg,
|
||||
html[data-theme="dark"] .highlight .vi,
|
||||
html[data-theme="dark"] .highlight .vm {
|
||||
color: #9cdcfe;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .nd,
|
||||
html[data-theme="dark"] .highlight .ne,
|
||||
html[data-theme="dark"] .highlight .nl {
|
||||
color: #c586c0;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .o,
|
||||
html[data-theme="dark"] .highlight .p {
|
||||
color: #d4d4d4;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .highlight .err {
|
||||
color: #f48771;
|
||||
}
|
||||
|
||||
.code-line {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
min-width: 100%;
|
||||
width: max-content;
|
||||
min-height: 1.5em;
|
||||
padding-left: 3.4em;
|
||||
position: relative;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.code-line::before {
|
||||
@@ -370,13 +550,13 @@ pre.highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 2.5em;
|
||||
color: #8a95a5;
|
||||
color: #858585;
|
||||
text-align: right;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .code-line::before {
|
||||
color: #748094;
|
||||
color: #858585;
|
||||
}
|
||||
|
||||
.code-block.is-collapsible.is-collapsed pre.highlight {
|
||||
@@ -392,11 +572,11 @@ html[data-theme="dark"] .code-line::before {
|
||||
bottom: 0;
|
||||
height: 3.2em;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(rgb(247 249 252 / 0), #f7f9fc);
|
||||
background: linear-gradient(rgb(255 255 255 / 0), #ffffff);
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .code-block.is-collapsible.is-collapsed::after {
|
||||
background: linear-gradient(rgb(23 27 34 / 0), #171b22);
|
||||
background: linear-gradient(rgb(30 30 30 / 0), #1e1e1e);
|
||||
}
|
||||
|
||||
.plain-file-view {
|
||||
@@ -526,10 +706,14 @@ html[data-theme="dark"] .copy-code-button:hover {
|
||||
}
|
||||
|
||||
.pseudo-keyword {
|
||||
color: #7b3ff2;
|
||||
color: #0000ff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .pseudo-keyword {
|
||||
color: #569cd6;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
|
||||
@@ -71,16 +71,16 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
code.dataset.lineNumbered = "true";
|
||||
const htmlLines = code.innerHTML.replace(/\n$/, "").split("\n");
|
||||
code.innerHTML = htmlLines
|
||||
.map((line, index) => `<span class="code-line" data-line="${index + 1}">${line || " "}</span>`)
|
||||
.join("\n");
|
||||
.map((line, index) => `<span class="code-line" data-line="${index + 1}">${line || " "}</span>`)
|
||||
.join("");
|
||||
}
|
||||
|
||||
if (lines.length > 18) {
|
||||
block.classList.add("is-collapsible", "is-collapsed");
|
||||
block.classList.add("is-collapsible");
|
||||
const toggle = document.createElement("button");
|
||||
toggle.type = "button";
|
||||
toggle.className = "toggle-code-button";
|
||||
toggle.textContent = "展开";
|
||||
toggle.textContent = "收起";
|
||||
toggle.addEventListener("click", () => {
|
||||
const collapsed = block.classList.toggle("is-collapsed");
|
||||
toggle.textContent = collapsed ? "展开" : "收起";
|
||||
@@ -358,6 +358,88 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
};
|
||||
|
||||
const configuredWheelSpeed = () => {
|
||||
const speed = Number(document.documentElement.dataset.wheelScrollSpeed || "1");
|
||||
if (!Number.isFinite(speed)) {
|
||||
return 1;
|
||||
}
|
||||
return Math.max(0.5, Math.min(3, speed));
|
||||
};
|
||||
|
||||
const normalizedWheelDelta = (event) => {
|
||||
const unit = event.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 : window.innerHeight;
|
||||
if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
||||
return { x: event.deltaX, y: event.deltaY };
|
||||
}
|
||||
return { x: event.deltaX * unit, y: event.deltaY * unit };
|
||||
};
|
||||
|
||||
const canScrollFurther = (element, deltaX, deltaY) => {
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
const vertical = Math.abs(deltaY) >= Math.abs(deltaX);
|
||||
if (vertical) {
|
||||
if (deltaY < 0) {
|
||||
return element.scrollTop > 0;
|
||||
}
|
||||
return element.scrollTop + element.clientHeight < element.scrollHeight - 1;
|
||||
}
|
||||
if (deltaX < 0) {
|
||||
return element.scrollLeft > 0;
|
||||
}
|
||||
return element.scrollLeft + element.clientWidth < element.scrollWidth - 1;
|
||||
};
|
||||
|
||||
const nearestWheelScroller = (target, deltaX, deltaY) => {
|
||||
let node = target instanceof Element ? target : target?.parentElement;
|
||||
const vertical = Math.abs(deltaY) >= Math.abs(deltaX);
|
||||
while (node && node !== document.body && node !== document.documentElement) {
|
||||
const style = window.getComputedStyle(node);
|
||||
const canScrollY =
|
||||
vertical &&
|
||||
/(auto|scroll)/.test(style.overflowY) &&
|
||||
node.scrollHeight > node.clientHeight + 1;
|
||||
const canScrollX =
|
||||
!vertical &&
|
||||
/(auto|scroll)/.test(style.overflowX) &&
|
||||
node.scrollWidth > node.clientWidth + 1;
|
||||
if ((canScrollY || canScrollX) && canScrollFurther(node, deltaX, deltaY)) {
|
||||
return node;
|
||||
}
|
||||
node = node.parentElement;
|
||||
}
|
||||
return document.scrollingElement || document.documentElement;
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
"wheel",
|
||||
(event) => {
|
||||
const speed = configuredWheelSpeed();
|
||||
if (Math.abs(speed - 1) < 0.01 || event.ctrlKey || event.metaKey || event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
const delta = normalizedWheelDelta(event);
|
||||
const scroller = nearestWheelScroller(event.target, delta.x, delta.y);
|
||||
if (!scroller) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
scroller.scrollBy({
|
||||
left: delta.x * speed,
|
||||
top: delta.y * speed,
|
||||
behavior: "auto",
|
||||
});
|
||||
if (
|
||||
scroller === document.scrollingElement ||
|
||||
scroller === document.documentElement ||
|
||||
scroller === document.body
|
||||
) {
|
||||
scheduleReport();
|
||||
}
|
||||
},
|
||||
{ passive: false }
|
||||
);
|
||||
if (window.qt && window.qt.webChannelTransport) {
|
||||
new QWebChannel(window.qt.webChannelTransport, (channel) => {
|
||||
bridge = channel.objects.mdhelperBridge;
|
||||
|
||||
Reference in New Issue
Block a user