From 54197ec79418eaa644657e7483cf6cdefe7edbd0 Mon Sep 17 00:00:00 2001 From: aubreyli Date: Wed, 28 May 2025 06:09:07 +0000 Subject: [PATCH] deploy: ce75fcd7ddbeb7b2d77a7fc0674e7848b5bf9dbd --- 404.html | 15 ++++++-- book.js | 51 +++++++++++++++++++++++++++- css/chrome.css | 62 ++++++++++++++++++++++++++++++++-- css/variables.css | 10 ++++++ en/DeepseekR1_V3_tutorial.html | 15 ++++++-- en/FAQ.html | 15 ++++++-- en/ROCm.html | 15 ++++++-- en/V3-success.html | 15 ++++++-- en/api/server/server.html | 15 ++++++-- en/api/server/tabby.html | 15 ++++++-- en/api/server/website.html | 15 ++++++-- en/benchmark.html | 15 ++++++-- en/deepseek-v2-injection.html | 15 ++++++-- en/fp8_kernel.html | 15 ++++++-- en/injection_tutorial.html | 15 ++++++-- en/install.html | 15 ++++++-- en/makefile_usage.html | 15 ++++++-- en/multi-gpu-tutorial.html | 15 ++++++-- index.html | 15 ++++++-- print.html | 15 ++++++-- searcher.js | 37 ++++++++++---------- 21 files changed, 360 insertions(+), 55 deletions(-) diff --git a/404.html b/404.html index ecff5c82..37dc17e8 100644 --- a/404.html +++ b/404.html @@ -42,6 +42,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/book.js b/book.js index e54da6a0..5df2096f 100644 --- a/book.js +++ b/book.js @@ -623,7 +623,7 @@ aria-label="Show hidden lines">'; (function chapterNavigation() { document.addEventListener('keydown', function(e) { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { + if (e.altKey || e.ctrlKey || e.metaKey) { return; } if (window.search && window.search.hasFocus()) { @@ -643,6 +643,55 @@ aria-label="Show hidden lines">'; window.location.href = previousButton.href; } } + function showHelp() { + const container = document.getElementById('mdbook-help-container'); + const overlay = document.getElementById('mdbook-help-popup'); + container.style.display = 'flex'; + + // Clicking outside the popup will dismiss it. + const mouseHandler = event => { + if (overlay.contains(event.target)) { + return; + } + if (event.button !== 0) { + return; + } + event.preventDefault(); + event.stopPropagation(); + document.removeEventListener('mousedown', mouseHandler); + hideHelp(); + }; + + // Pressing esc will dismiss the popup. + const escapeKeyHandler = event => { + if (event.key === 'Escape') { + event.preventDefault(); + event.stopPropagation(); + document.removeEventListener('keydown', escapeKeyHandler, true); + hideHelp(); + } + }; + document.addEventListener('keydown', escapeKeyHandler, true); + document.getElementById('mdbook-help-container') + .addEventListener('mousedown', mouseHandler); + } + function hideHelp() { + document.getElementById('mdbook-help-container').style.display = 'none'; + } + + // Usually needs the Shift key to be pressed + switch (e.key) { + case '?': + e.preventDefault(); + showHelp(); + break; + } + + // Rest of the keys are only active when the Shift key is not pressed + if (e.shiftKey) { + return; + } + switch (e.key) { case 'ArrowRight': e.preventDefault(); diff --git a/css/chrome.css b/css/chrome.css index 7a95c244..360a6537 100644 --- a/css/chrome.css +++ b/css/chrome.css @@ -474,9 +474,24 @@ html:not(.sidebar-resizing) .sidebar { .sidebar-resize-handle .sidebar-resize-indicator { width: 100%; - height: 12px; - background-color: var(--icons); + height: 16px; + color: var(--icons); margin-inline-start: var(--sidebar-resize-indicator-space); + display: flex; + align-items: center; + justify-content: flex-start; +} +.sidebar-resize-handle .sidebar-resize-indicator::before { + content: ""; + width: 2px; + height: 12px; + border-left: dotted 2px currentColor; +} +.sidebar-resize-handle .sidebar-resize-indicator::after { + content: ""; + width: 2px; + height: 16px; + border-left: dotted 2px currentColor; } [dir=rtl] .sidebar .sidebar-resize-handle { @@ -641,3 +656,46 @@ html:not(.sidebar-resizing) .sidebar { margin-inline-start: -14px; width: 14px; } + +/* The container for the help popup that covers the whole window. */ +#mdbook-help-container { + /* Position and size for the whole window. */ + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + /* This uses flex layout (which is set in book.js), and centers the popup + in the window.*/ + display: none; + align-items: center; + justify-content: center; + z-index: 1000; + /* Dim out the book while the popup is visible. */ + background: var(--overlay-bg); +} + +/* The popup help box. */ +#mdbook-help-popup { + box-shadow: 0 4px 24px rgba(0,0,0,0.15); + min-width: 300px; + max-width: 500px; + width: 100%; + box-sizing: border-box; + display: flex; + flex-direction: column; + align-items: center; + background-color: var(--bg); + color: var(--fg); + border-width: 1px; + border-color: var(--theme-popup-border); + border-style: solid; + border-radius: 8px; + padding: 10px; +} + +.mdbook-help-title { + text-align: center; + /* mdbook's margin for h2 is way too large. */ + margin: 10px; +} diff --git a/css/variables.css b/css/variables.css index 43eb9e0c..5742d241 100644 --- a/css/variables.css +++ b/css/variables.css @@ -64,6 +64,8 @@ --copy-button-filter-hover: invert(68%) sepia(55%) saturate(531%) hue-rotate(341deg) brightness(104%) contrast(101%); --footnote-highlight: #2668a6; + + --overlay-bg: rgba(33, 40, 48, 0.4); } .coal { @@ -115,6 +117,8 @@ --copy-button-filter-hover: invert(36%) sepia(70%) saturate(503%) hue-rotate(167deg) brightness(98%) contrast(89%); --footnote-highlight: #4079ae; + + --overlay-bg: rgba(33, 40, 48, 0.4); } .light, html:not(.js) { @@ -166,6 +170,8 @@ --copy-button-filter-hover: invert(14%) sepia(93%) saturate(4250%) hue-rotate(243deg) brightness(99%) contrast(130%); --footnote-highlight: #7e7eff; + + --overlay-bg: rgba(200, 200, 205, 0.4); } .navy { @@ -217,6 +223,8 @@ --copy-button-filter-hover: invert(46%) sepia(20%) saturate(1537%) hue-rotate(156deg) brightness(85%) contrast(90%); --footnote-highlight: #4079ae; + + --overlay-bg: rgba(33, 40, 48, 0.4); } .rust { @@ -266,6 +274,8 @@ --copy-button-filter-hover: invert(77%) sepia(16%) saturate(1798%) hue-rotate(328deg) brightness(98%) contrast(83%); --footnote-highlight: #d3a17a; + + --overlay-bg: rgba(150, 150, 150, 0.25); } @media (prefers-color-scheme: dark) { diff --git a/en/DeepseekR1_V3_tutorial.html b/en/DeepseekR1_V3_tutorial.html index 33743642..449f0492 100644 --- a/en/DeepseekR1_V3_tutorial.html +++ b/en/DeepseekR1_V3_tutorial.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/FAQ.html b/en/FAQ.html index a56ee950..0fea5cc5 100644 --- a/en/FAQ.html +++ b/en/FAQ.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/ROCm.html b/en/ROCm.html index 8e0ce438..7781ee1d 100644 --- a/en/ROCm.html +++ b/en/ROCm.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/V3-success.html b/en/V3-success.html index a7a065ea..a71ffdcb 100644 --- a/en/V3-success.html +++ b/en/V3-success.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/api/server/server.html b/en/api/server/server.html index 01d6da1e..1ffd5df6 100644 --- a/en/api/server/server.html +++ b/en/api/server/server.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/api/server/tabby.html b/en/api/server/tabby.html index 99991016..5bda40d2 100644 --- a/en/api/server/tabby.html +++ b/en/api/server/tabby.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/api/server/website.html b/en/api/server/website.html index 2caf3b10..fb466fc5 100644 --- a/en/api/server/website.html +++ b/en/api/server/website.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/benchmark.html b/en/benchmark.html index 8069e7d0..02dae0d6 100644 --- a/en/benchmark.html +++ b/en/benchmark.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/deepseek-v2-injection.html b/en/deepseek-v2-injection.html index 8cb6b8b7..b66cee3c 100644 --- a/en/deepseek-v2-injection.html +++ b/en/deepseek-v2-injection.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/fp8_kernel.html b/en/fp8_kernel.html index 5aab9a13..a58ba6e6 100644 --- a/en/fp8_kernel.html +++ b/en/fp8_kernel.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/injection_tutorial.html b/en/injection_tutorial.html index 94dc4f05..6c3729ac 100644 --- a/en/injection_tutorial.html +++ b/en/injection_tutorial.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/install.html b/en/install.html index 78496428..48ef50ec 100644 --- a/en/install.html +++ b/en/install.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/makefile_usage.html b/en/makefile_usage.html index 5248b57a..5d5756b1 100644 --- a/en/makefile_usage.html +++ b/en/makefile_usage.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/en/multi-gpu-tutorial.html b/en/multi-gpu-tutorial.html index 91041296..6c7112d4 100644 --- a/en/multi-gpu-tutorial.html +++ b/en/multi-gpu-tutorial.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/index.html b/index.html index f14b374b..0ed0a72b 100644 --- a/index.html +++ b/index.html @@ -41,6 +41,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/print.html b/print.html index 51f5af6f..5486abef 100644 --- a/print.html +++ b/print.html @@ -42,6 +42,17 @@ +
+
+

Keyboard shortcuts

+
+

Press ← or → to navigate between chapters

+

Press S or / to search in the book

+

Press ? to show this help

+

Press Esc to hide this help

+
+
+
- + diff --git a/searcher.js b/searcher.js index 201aa5d7..fc65604e 100644 --- a/searcher.js +++ b/searcher.js @@ -33,13 +33,7 @@ window.search = window.search || {}; mark_exclude = ['text'], marker = new Mark(content), URL_SEARCH_PARAM = 'search', - URL_MARK_PARAM = 'highlight', - - SEARCH_HOTKEY_KEYCODE = 83, - ESCAPE_KEYCODE = 27, - DOWN_KEYCODE = 40, - UP_KEYCODE = 38, - SELECT_KEYCODE = 13; + URL_MARK_PARAM = 'highlight'; let current_searchterm = '', doc_urls = [], @@ -352,7 +346,7 @@ window.search = window.search || {}; return; } - if (e.keyCode === ESCAPE_KEYCODE) { + if (e.key === 'Escape') { e.preventDefault(); searchbar.classList.remove('active'); setSearchUrlParameters('', @@ -362,31 +356,38 @@ window.search = window.search || {}; } showSearch(false); marker.unmark(); - } else if (!hasFocus() && e.keyCode === SEARCH_HOTKEY_KEYCODE) { + } else if (!hasFocus() && (e.key === 's' || e.key === '/')) { e.preventDefault(); showSearch(true); window.scrollTo(0, 0); searchbar.select(); - } else if (hasFocus() && e.keyCode === DOWN_KEYCODE) { + } else if (hasFocus() && (e.key === 'ArrowDown' + || e.key === 'Enter')) { e.preventDefault(); - unfocusSearchbar(); - searchresults.firstElementChild.classList.add('focus'); - } else if (!hasFocus() && (e.keyCode === DOWN_KEYCODE - || e.keyCode === UP_KEYCODE - || e.keyCode === SELECT_KEYCODE)) { + const first = searchresults.firstElementChild; + if (first !== null) { + unfocusSearchbar(); + first.classList.add('focus'); + if (e.key === 'Enter') { + window.location.assign(first.querySelector('a')); + } + } + } else if (!hasFocus() && (e.key === 'ArrowDown' + || e.key === 'ArrowUp' + || e.key === 'Enter')) { // not `:focus` because browser does annoying scrolling const focused = searchresults.querySelector('li.focus'); if (!focused) { return; } e.preventDefault(); - if (e.keyCode === DOWN_KEYCODE) { + if (e.key === 'ArrowDown') { const next = focused.nextElementSibling; if (next) { focused.classList.remove('focus'); next.classList.add('focus'); } - } else if (e.keyCode === UP_KEYCODE) { + } else if (e.key === 'ArrowUp') { focused.classList.remove('focus'); const prev = focused.previousElementSibling; if (prev) { @@ -394,7 +395,7 @@ window.search = window.search || {}; } else { searchbar.select(); } - } else { // SELECT_KEYCODE + } else { // Enter window.location.assign(focused.querySelector('a')); } }