docnest 0.1.21 → 0.1.23

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/README.md CHANGED
@@ -84,6 +84,8 @@ export default defineConfig({
84
84
 
85
85
  受限模式只移除 DocNest 提供的页面入口和脚本,不承诺对浏览器开发者工具或系统级截图提供绝对防护。
86
86
 
87
+ 页面水印使用 4% 透明度,保持可辨识而不遮挡正文和图表。Mermaid 代码围栏按独立图表渲染,不继承普通代码块的等宽字体;节点内的 HTML 换行与图表字体测量保持一致。
88
+
87
89
  ### 极简单口令授权
88
90
 
89
91
  需要让文档中心只对知道口令的人开放时,可以启用单口令授权:
package/dist/server.js CHANGED
@@ -188,10 +188,6 @@ const md = new MarkdownIt({
188
188
  linkify: true,
189
189
  typographer: true,
190
190
  highlight: function (str, lang) {
191
- // 特殊处理 Mermaid 图表
192
- if (lang === 'mermaid') {
193
- return `<div class="mermaid">${str}</div>`;
194
- }
195
191
  // 其他代码块使用 highlight.js
196
192
  if (lang && hljs.getLanguage(lang)) {
197
193
  try {
@@ -202,6 +198,16 @@ const md = new MarkdownIt({
202
198
  return `<pre class="hljs"><code>${md.utils.escapeHtml(str)}</code></pre>`;
203
199
  },
204
200
  });
201
+ // Mermaid is a diagram, not highlighted code. A code/pre ancestor changes
202
+ // the inherited font after Mermaid measures HTML labels, clipping their text.
203
+ const renderCodeFence = md.renderer.rules.fence;
204
+ md.renderer.rules.fence = function (tokens, index, options, env, renderer) {
205
+ const token = tokens[index];
206
+ if (token.info.trim().split(/\s+/)[0] === 'mermaid') {
207
+ return `<div class="mermaid">${md.utils.escapeHtml(token.content)}</div>\n`;
208
+ }
209
+ return renderCodeFence(tokens, index, options, env, renderer);
210
+ };
205
211
  function slugifyHeading(text) {
206
212
  return (text || '')
207
213
  .replace(/`([^`]+)`/g, '$1')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docnest",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "可复用的本地 Markdown 文档中心",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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;
@@ -1303,6 +1339,9 @@ body[data-theme="dark"] .not-found-path {
1303
1339
 
1304
1340
  /* Mermaid 图表样式 */
1305
1341
  .markdown-body .mermaid {
1342
+ /* Match Mermaid's measurement fallback when a diagram font is omitted or
1343
+ rejected by its directive sanitizer. Explicit SVG fonts still take priority. */
1344
+ font-family: "trebuchet ms", verdana, arial, sans-serif;
1306
1345
  margin: 24px 0;
1307
1346
  text-align: center;
1308
1347
  background: var(--linear-bg-subtle);
@@ -1918,6 +1957,21 @@ body[data-theme="dark"] .diagram-viewer-content {
1918
1957
  gap: 0.5rem;
1919
1958
  }
1920
1959
 
1960
+ .header-content-with-search {
1961
+ grid-template-columns: minmax(0, 1fr);
1962
+ }
1963
+
1964
+ .header-content-with-search > .header-title-group,
1965
+ .header-content-with-search > .header-meta,
1966
+ .header-content-with-search > .doc-search-trigger {
1967
+ grid-column: 1;
1968
+ grid-row: auto;
1969
+ }
1970
+
1971
+ .header-content-with-search > .doc-search-trigger .header-action-text {
1972
+ display: inline;
1973
+ }
1974
+
1921
1975
  .header-meta {
1922
1976
  width: 100%;
1923
1977
  align-items: flex-start;
@@ -89,7 +89,7 @@ html.docnest-restricted .markdown-body .mermaid-download-btn {
89
89
  color: var(--linear-text, rgba(15, 23, 42, 0.42));
90
90
  font: 700 clamp(0.75rem, 1.5vw, 1.5rem)/1 var(--doc-font-mono);
91
91
  letter-spacing: 0.08em;
92
- opacity: 0.12;
92
+ opacity: 0.04;
93
93
  transform: rotate(-24deg);
94
94
  white-space: nowrap;
95
95
  }
@@ -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>