@nextclaw/ui 0.3.17 → 0.5.0
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/CHANGELOG.md +19 -0
- package/dist/assets/index-1h_LfFkZ.js +337 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/doc-browser/DocBrowser.tsx +12 -0
- package/src/components/doc-browser/DocBrowserContext.tsx +14 -6
- package/src/components/doc-browser/useDocLinkInterceptor.ts +3 -0
- package/src/lib/i18n.ts +1 -0
- package/dist/assets/index-CPXV1dWr.js +0 -337
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>NextClaw - 系统配置</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-1h_LfFkZ.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-Wn63frSd.css">
|
|
11
11
|
</head>
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -48,6 +48,17 @@ export function DocBrowser() {
|
|
|
48
48
|
}
|
|
49
49
|
}, [currentUrl]);
|
|
50
50
|
|
|
51
|
+
// Listen for route changes from the iframe via postMessage
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const handler = (e: MessageEvent) => {
|
|
54
|
+
if (e.data?.type === 'docs-route-change' && typeof e.data.url === 'string') {
|
|
55
|
+
navigate(e.data.url);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener('message', handler);
|
|
59
|
+
return () => window.removeEventListener('message', handler);
|
|
60
|
+
}, [navigate]);
|
|
61
|
+
|
|
51
62
|
const handleUrlSubmit = useCallback((e: React.FormEvent) => {
|
|
52
63
|
e.preventDefault();
|
|
53
64
|
const input = urlInput.trim();
|
|
@@ -235,6 +246,7 @@ export function DocBrowser() {
|
|
|
235
246
|
{/* Iframe Content */}
|
|
236
247
|
<div className="flex-1 relative overflow-hidden">
|
|
237
248
|
<iframe
|
|
249
|
+
key={currentUrl}
|
|
238
250
|
src={currentUrl}
|
|
239
251
|
className="absolute inset-0 w-full h-full border-0"
|
|
240
252
|
title="NextClaw Documentation"
|
|
@@ -86,12 +86,20 @@ export function DocBrowserProvider({ children }: { children: ReactNode }) {
|
|
|
86
86
|
}, []);
|
|
87
87
|
|
|
88
88
|
const navigate = useCallback((url: string) => {
|
|
89
|
-
setState(prev =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
setState(prev => {
|
|
90
|
+
// Normalize URLs for comparison (strip trailing slash, .html suffix)
|
|
91
|
+
const normalize = (u: string) => {
|
|
92
|
+
try { return new URL(u).pathname.replace(/\.html$/, '').replace(/\/$/, ''); } catch { return u; }
|
|
93
|
+
};
|
|
94
|
+
// Skip if same as current URL (prevents loop from postMessage echo)
|
|
95
|
+
if (normalize(url) === normalize(prev.currentUrl)) return prev;
|
|
96
|
+
return {
|
|
97
|
+
...prev,
|
|
98
|
+
currentUrl: url,
|
|
99
|
+
history: [...prev.history.slice(0, prev.historyIndex + 1), url],
|
|
100
|
+
historyIndex: prev.historyIndex + 1,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
95
103
|
}, []);
|
|
96
104
|
|
|
97
105
|
const goBack = useCallback(() => {
|
|
@@ -18,6 +18,9 @@ export function useDocLinkInterceptor() {
|
|
|
18
18
|
const href = anchor.getAttribute('href') || '';
|
|
19
19
|
if (!isDocsUrl(href)) return;
|
|
20
20
|
|
|
21
|
+
// Don't intercept links explicitly marked for external opening
|
|
22
|
+
if (anchor.hasAttribute('data-doc-external')) return;
|
|
23
|
+
|
|
21
24
|
// Don't intercept if modifier keys are held (user wants new tab behavior)
|
|
22
25
|
if (e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
23
26
|
|
package/src/lib/i18n.ts
CHANGED
|
@@ -164,6 +164,7 @@ export const LABELS: Record<string, { zh: string; en: string }> = {
|
|
|
164
164
|
// Doc Browser
|
|
165
165
|
docBrowserTitle: { zh: '帮助文档', en: 'Help Docs' },
|
|
166
166
|
docBrowserSearchPlaceholder: { zh: '搜索,也可以输入文档地址直接打开', en: 'Search, or enter a doc URL to open' },
|
|
167
|
+
docBrowserUrlPlaceholder: { zh: '输入文档路径,如 /guide/channels', en: 'Enter a doc path, e.g. /guide/channels' },
|
|
167
168
|
docBrowserOpenExternal: { zh: '文档中心打开', en: 'Open in Docs' },
|
|
168
169
|
docBrowserFloatMode: { zh: '悬浮窗口', en: 'Float Window' },
|
|
169
170
|
docBrowserDockMode: { zh: '固定到侧栏', en: 'Dock to Sidebar' },
|