docnest 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.doc-reading-toggle {
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 4px;
|
|
4
|
+
right: var(--doc-reading-button-right, 40px);
|
|
5
|
+
z-index: 2;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
width: 36px;
|
|
10
|
+
height: 36px;
|
|
11
|
+
padding: 8px;
|
|
12
|
+
border: 1px solid var(--linear-border);
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
background: var(--linear-bg);
|
|
15
|
+
color: var(--linear-text);
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
.doc-reading-toggle:hover { color: var(--linear-accent); }
|
|
19
|
+
.doc-reading-toggle:focus-visible { outline: 2px solid var(--linear-accent); outline-offset: 2px; }
|
|
20
|
+
.doc-reading-toggle svg { width: 20px; height: 20px; }
|
|
21
|
+
body.doc-reading-expanded .sidebar,
|
|
22
|
+
body.doc-reading-expanded .sidebar-chrome,
|
|
23
|
+
body.doc-reading-expanded .doc-toc { display: none !important; }
|
|
24
|
+
body.doc-reading-expanded .main-content {
|
|
25
|
+
padding-left: var(--doc-reading-left-margin) !important;
|
|
26
|
+
padding-right: var(--doc-reading-right-margin) !important;
|
|
27
|
+
}
|
|
28
|
+
body.doc-reading-expanded .doc-layout { width: 100% !important; max-width: none; }
|
|
29
|
+
@media print { .doc-reading-toggle { display: none; } }
|
|
@@ -51,6 +51,42 @@ body {
|
|
|
51
51
|
gap: 1rem;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/* Equal side columns keep search centered in the entire header. */
|
|
55
|
+
.header-content-with-search {
|
|
56
|
+
display: grid;
|
|
57
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.header-content-with-search > .doc-search-trigger {
|
|
61
|
+
justify-self: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.header-content-with-search > .header-meta {
|
|
65
|
+
justify-self: end;
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@media (max-width: 1200px) {
|
|
70
|
+
.header-content-with-search {
|
|
71
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.header-content-with-search > .header-title-group {
|
|
75
|
+
grid-column: 1;
|
|
76
|
+
grid-row: 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.header-content-with-search > .header-meta {
|
|
80
|
+
grid-column: 2;
|
|
81
|
+
grid-row: 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.header-content-with-search > .doc-search-trigger {
|
|
85
|
+
grid-column: 1 / -1;
|
|
86
|
+
grid-row: 2;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
54
90
|
.header h1 {
|
|
55
91
|
font-size: 1.25rem;
|
|
56
92
|
font-weight: 600;
|
|
@@ -1918,6 +1954,21 @@ body[data-theme="dark"] .diagram-viewer-content {
|
|
|
1918
1954
|
gap: 0.5rem;
|
|
1919
1955
|
}
|
|
1920
1956
|
|
|
1957
|
+
.header-content-with-search {
|
|
1958
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
.header-content-with-search > .header-title-group,
|
|
1962
|
+
.header-content-with-search > .header-meta,
|
|
1963
|
+
.header-content-with-search > .doc-search-trigger {
|
|
1964
|
+
grid-column: 1;
|
|
1965
|
+
grid-row: auto;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
.header-content-with-search > .doc-search-trigger .header-action-text {
|
|
1969
|
+
display: inline;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1921
1972
|
.header-meta {
|
|
1922
1973
|
width: 100%;
|
|
1923
1974
|
align-items: flex-start;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
const layout = document.querySelector('.doc-layout');
|
|
3
|
+
const main = document.querySelector('.main-content');
|
|
4
|
+
const article = layout?.querySelector('.markdown-body');
|
|
5
|
+
if (!layout || !main || !article) return;
|
|
6
|
+
|
|
7
|
+
const button = document.createElement('button');
|
|
8
|
+
button.type = 'button';
|
|
9
|
+
button.className = 'doc-reading-toggle';
|
|
10
|
+
button.setAttribute('aria-controls', 'sidebar doc-toc');
|
|
11
|
+
function updateButton() {
|
|
12
|
+
const expanded = document.body.classList.contains('doc-reading-expanded');
|
|
13
|
+
const iconPath = expanded
|
|
14
|
+
? 'M3 8h5V3M8 8 2 2M21 8h-5V3M16 8l6-6M3 16h5v5M8 16l-6 6M21 16h-5v5M16 16l6 6'
|
|
15
|
+
: 'M8 3H3v5M3 3l6 6M16 3h5v5M21 3l-6 6M3 16v5h5M3 21l6-6M21 16v5h-5M21 21l-6-6';
|
|
16
|
+
button.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${iconPath}"/></svg>`;
|
|
17
|
+
button.setAttribute('aria-label', expanded ? '缩小正文,恢复目录' : '放大正文,隐藏目录');
|
|
18
|
+
button.setAttribute('aria-pressed', String(expanded));
|
|
19
|
+
button.title = expanded ? '恢复默认阅读布局' : '扩大正文阅读区域';
|
|
20
|
+
}
|
|
21
|
+
function positionButton() {
|
|
22
|
+
const right = main.getBoundingClientRect().left + main.clientWidth - article.getBoundingClientRect().right;
|
|
23
|
+
main.style.setProperty('--doc-reading-button-right', `${Math.max(0, right)}px`);
|
|
24
|
+
}
|
|
25
|
+
window.addEventListener('resize', positionButton);
|
|
26
|
+
button.addEventListener('click', function () {
|
|
27
|
+
if (!document.body.classList.contains('doc-reading-expanded')) {
|
|
28
|
+
const mainBounds = main.getBoundingClientRect();
|
|
29
|
+
const articleRight = article.getBoundingClientRect().right;
|
|
30
|
+
const rightPadding = mainBounds.left + main.clientWidth - articleRight;
|
|
31
|
+
const outerMargin = document.documentElement.clientWidth - articleRight;
|
|
32
|
+
main.style.setProperty('--doc-reading-left-margin', `${Math.max(0, outerMargin)}px`);
|
|
33
|
+
main.style.setProperty('--doc-reading-right-margin', `${Math.max(0, rightPadding)}px`);
|
|
34
|
+
}
|
|
35
|
+
document.body.classList.toggle('doc-reading-expanded');
|
|
36
|
+
updateButton();
|
|
37
|
+
positionButton();
|
|
38
|
+
});
|
|
39
|
+
updateButton();
|
|
40
|
+
main.appendChild(button);
|
|
41
|
+
positionButton();
|
|
42
|
+
})();
|
package/server/views/doc.ejs
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
<link rel="stylesheet" href="/static/css/styles.css?v=<%= assetVersion %>">
|
|
10
10
|
<link rel="stylesheet" href="/static/css/highlight.css?v=<%= assetVersion %>">
|
|
11
11
|
<link rel="stylesheet" href="/static/css/themes.css?v=<%= assetVersion %>">
|
|
12
|
+
<link rel="stylesheet" href="/static/css/doc-reading-view.css?v=<%= assetVersion %>">
|
|
13
|
+
<script defer src="/static/js/core/doc-reading-view.js?v=<%= assetVersion %>"></script>
|
|
12
14
|
<script src="/mermaid/mermaid.min.js?v=<%= assetVersion %>"></script>
|
|
13
15
|
<%- include('partials/appearance-head') %>
|
|
14
16
|
<!-- 基础功能模块 -->
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<header class="header">
|
|
2
|
-
<div class="header-content">
|
|
2
|
+
<div class="header-content<%= !docsRestrictedMode ? ' header-content-with-search' : '' %>">
|
|
3
3
|
<div class="header-title-group">
|
|
4
4
|
<h1>
|
|
5
5
|
<% if (docsLogo) { %><img class="brand-logo" src="<%= docsLogo %>" alt=""><% } else { %><span class="brand-fallback" aria-hidden="true"><span class="brand-fallback-emoji">📚</span><span class="brand-fallback-shape"></span></span><% } %>
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
<p class="subtitle"><%= docsSubtitle %></p>
|
|
12
12
|
<% } %>
|
|
13
13
|
</div>
|
|
14
|
-
<div class="header-meta">
|
|
15
|
-
<div class="header-actions">
|
|
16
14
|
<% if (!docsRestrictedMode) { %>
|
|
17
15
|
<button type="button" id="doc-search-trigger" class="header-action-btn doc-search-trigger" aria-haspopup="dialog" aria-controls="doc-search-modal" title="搜索文档(⌘K / Ctrl K)">
|
|
18
16
|
<span class="doc-search-icon" aria-hidden="true">⌕</span>
|
|
@@ -20,6 +18,8 @@
|
|
|
20
18
|
<kbd class="doc-search-shortcut" aria-label="打开搜索快捷键">⌘ K</kbd>
|
|
21
19
|
</button>
|
|
22
20
|
<% } %>
|
|
21
|
+
<div class="header-meta">
|
|
22
|
+
<div class="header-actions">
|
|
23
23
|
<% if (typeof showPrintButton !== 'undefined' && showPrintButton && !docsRestrictedMode) { %>
|
|
24
24
|
<button type="button" id="print-doc-btn" class="header-action-btn print-btn" title="打印当前文章">
|
|
25
25
|
<span class="print-icon">🖨️</span>
|