kumidocs 0.20260313.3

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/bunfig.toml +3 -0
  4. package/package.json +84 -0
  5. package/src/App.tsx +97 -0
  6. package/src/components/dialogs/NewPageDialog.tsx +199 -0
  7. package/src/components/editor/CodeEditor.tsx +90 -0
  8. package/src/components/editor/MarkdownEditor.tsx +639 -0
  9. package/src/components/editor/MarkdownViewer.tsx +99 -0
  10. package/src/components/editor/SlideViewer.tsx +432 -0
  11. package/src/components/editor/rehypeEmojiPlugin.ts +76 -0
  12. package/src/components/editor/rehypeHeadingIdsPlugin.ts +34 -0
  13. package/src/components/editor/rehypeImageAttrsPlugin.ts +140 -0
  14. package/src/components/layout/AppShell.tsx +210 -0
  15. package/src/components/layout/PageInfoPanel.tsx +322 -0
  16. package/src/components/layout/Sidebar.tsx +443 -0
  17. package/src/components/layout/TopBar.tsx +98 -0
  18. package/src/components/search/SearchPalette.tsx +126 -0
  19. package/src/components/ui/EmojiIcon.tsx +151 -0
  20. package/src/components/ui/EmojiPicker.tsx +203 -0
  21. package/src/components/ui/EmojiPickerPopover.tsx +73 -0
  22. package/src/components/ui/PageMenuItems.tsx +151 -0
  23. package/src/components/ui/avatar.tsx +77 -0
  24. package/src/components/ui/badge.tsx +46 -0
  25. package/src/components/ui/button.tsx +58 -0
  26. package/src/components/ui/card.tsx +78 -0
  27. package/src/components/ui/checkbox.tsx +27 -0
  28. package/src/components/ui/command.tsx +167 -0
  29. package/src/components/ui/context-menu.tsx +225 -0
  30. package/src/components/ui/dialog.tsx +142 -0
  31. package/src/components/ui/dropdown-menu.tsx +226 -0
  32. package/src/components/ui/emoji/emojimart-data-all-15.json +18960 -0
  33. package/src/components/ui/emoji/emojis.ts +1541 -0
  34. package/src/components/ui/input.tsx +21 -0
  35. package/src/components/ui/kbd.tsx +28 -0
  36. package/src/components/ui/label.tsx +21 -0
  37. package/src/components/ui/scroll-area.tsx +54 -0
  38. package/src/components/ui/select.tsx +172 -0
  39. package/src/components/ui/separator.tsx +28 -0
  40. package/src/components/ui/sonner.tsx +40 -0
  41. package/src/components/ui/textarea.tsx +18 -0
  42. package/src/components/ui/tooltip.tsx +53 -0
  43. package/src/frontend.tsx +28 -0
  44. package/src/hooks/usePageActions.tsx +333 -0
  45. package/src/index.css +13 -0
  46. package/src/index.html +13 -0
  47. package/src/index.ts +291 -0
  48. package/src/lib/avatar.ts +43 -0
  49. package/src/lib/filetypes.ts +93 -0
  50. package/src/lib/types.ts +94 -0
  51. package/src/lib/utils.ts +18 -0
  52. package/src/logo.png +0 -0
  53. package/src/pages/FilePage.tsx +709 -0
  54. package/src/pages/ImageLibraryPage.tsx +287 -0
  55. package/src/pages/NotFound.tsx +30 -0
  56. package/src/pages/WelcomePage.tsx +15 -0
  57. package/src/server/api.ts +457 -0
  58. package/src/server/auth.ts +66 -0
  59. package/src/server/config.ts +25 -0
  60. package/src/server/filestore.ts +190 -0
  61. package/src/server/git.ts +258 -0
  62. package/src/server/search.ts +121 -0
  63. package/src/server/websocket.ts +207 -0
  64. package/src/store/theme.tsx +45 -0
  65. package/src/store/user.tsx +58 -0
  66. package/src/store/ws.ts +133 -0
  67. package/styles/globals.css +160 -0
  68. package/tsconfig.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Foorack / Max Faxälv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # bun-react-tailwind-shadcn-template
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To start a development server:
10
+
11
+ ```bash
12
+ bun dev
13
+ ```
14
+
15
+ To run for production:
16
+
17
+ ```bash
18
+ bun start
19
+ ```
20
+
21
+ This project was created using `bun init` in bun v1.3.9. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/bunfig.toml ADDED
@@ -0,0 +1,3 @@
1
+ [serve.static]
2
+ plugins = ["bun-plugin-tailwind"]
3
+ env = "BUN_PUBLIC_*"
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "kumidocs",
3
+ "version": "0.20260313.3",
4
+ "description": "A developer-focused wiki/docs platform with zero database — all content stored in Git.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Foorack/kumidocs.git"
9
+ },
10
+ "keywords": [
11
+ "wiki",
12
+ "docs",
13
+ "markdown",
14
+ "git",
15
+ "bun",
16
+ "self-hosted"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "files": [
22
+ "src",
23
+ "styles",
24
+ "bunfig.toml",
25
+ "tsconfig.json"
26
+ ],
27
+ "type": "module",
28
+ "scripts": {
29
+ "dev": "bun --hot src/index.ts",
30
+ "start": "NODE_ENV=production bun src/index.ts",
31
+ "lint": "bunx prettier --check . && bunx eslint .",
32
+ "format": "bunx prettier --write .",
33
+ "ts": "bunx tsc --noEmit"
34
+ },
35
+ "dependencies": {
36
+ "@fluentui/react-icons": "2.0.320",
37
+ "@noble/hashes": "^2.0.1",
38
+ "@radix-ui/react-label": "2.1.8",
39
+ "@radix-ui/react-select": "2.2.6",
40
+ "@radix-ui/react-slot": "1.2.4",
41
+ "@streamdown/cjk": "^1.0.2",
42
+ "@streamdown/code": "^1.1.0",
43
+ "@streamdown/math": "^1.0.2",
44
+ "@tailwindcss/typography": "^0.5.19",
45
+ "@uiw/codemirror-extensions-langs": "^4.25.8",
46
+ "@uiw/codemirror-theme-github": "^4.25.8",
47
+ "@uiw/react-codemirror": "^4.25.8",
48
+ "class-variance-authority": "0.7.1",
49
+ "clsx": "2.1.1",
50
+ "cmdk": "1.1.1",
51
+ "diff": "^8.0.3",
52
+ "gray-matter": "4.0.3",
53
+ "html2canvas-pro": "^2.0.2",
54
+ "isomorphic-git": "1.37.3",
55
+ "jspdf": "^4.2.0",
56
+ "lucide-react": "0.577.0",
57
+ "minisearch": "7.2.0",
58
+ "next-themes": "0.4.6",
59
+ "radix-ui": "1.4.3",
60
+ "react": "19.2.4",
61
+ "react-diff-view": "^3.3.2",
62
+ "react-dom": "19.2.4",
63
+ "react-router-dom": "7.13.1",
64
+ "rehype-harden": "^1.1.8",
65
+ "sonner": "2.0.7",
66
+ "streamdown": "^2.4.0",
67
+ "tailwind-merge": "3.5.0"
68
+ },
69
+ "devDependencies": {
70
+ "@eslint/js": "10.0.1",
71
+ "@types/bun": "1.3.10",
72
+ "@types/react": "19.2.14",
73
+ "@types/react-dom": "19.2.3",
74
+ "country-flag-icons": "^1.6.15",
75
+ "eslint-plugin-erasable-syntax-only": "0.4.0",
76
+ "eslint-plugin-react": "^7.37.5",
77
+ "eslint-plugin-react-hooks": "^7.0.1",
78
+ "globals": "^17.4.0",
79
+ "prettier": "3.8.1",
80
+ "tailwindcss": "4.2.1",
81
+ "tw-animate-css": "1.4.0",
82
+ "typescript-eslint": "8.57.0"
83
+ }
84
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,97 @@
1
+ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
2
+ import { useState } from 'react';
3
+ import { TooltipProvider } from '@/components/ui/tooltip';
4
+ import { ThemeProvider } from './store/theme';
5
+ import { UserProvider, useUser } from './store/user';
6
+ import { AppShell } from './components/layout/AppShell';
7
+ import FilePage from './pages/FilePage';
8
+ import NotFound from './pages/NotFound';
9
+ import './index.css';
10
+ import WelcomePage from './pages/WelcomePage';
11
+ import ImageLibraryPage from './pages/ImageLibraryPage';
12
+ import {
13
+ Dialog,
14
+ DialogContent,
15
+ DialogHeader,
16
+ DialogTitle,
17
+ DialogFooter,
18
+ } from '@/components/ui/dialog';
19
+ import { Input } from '@/components/ui/input';
20
+ import { Button } from '@/components/ui/button';
21
+ import { Label } from '@/components/ui/label';
22
+
23
+ function EmailSetupDialog() {
24
+ const { needsEmailSetup, setEmailAndRefetch } = useUser();
25
+ const [email, setEmail] = useState('');
26
+
27
+ function handleSubmit(e: React.SubmitEvent) {
28
+ e.preventDefault();
29
+ if (!email.includes('@')) return;
30
+ setEmailAndRefetch(email);
31
+ }
32
+
33
+ return (
34
+ <Dialog open={needsEmailSetup}>
35
+ <DialogContent className="sm:max-w-sm" showCloseButton={false}>
36
+ <DialogHeader>
37
+ <DialogTitle>Enter your email</DialogTitle>
38
+ <p className="text-sm text-muted-foreground">
39
+ No identity provider was detected. Enter your email to continue — it will be
40
+ stored as a local cookie.
41
+ </p>
42
+ </DialogHeader>
43
+ <form
44
+ onSubmit={(e) => {
45
+ handleSubmit(e);
46
+ }}
47
+ >
48
+ <div className="grid gap-3 py-2">
49
+ <Label htmlFor="email-input">Email</Label>
50
+ <Input
51
+ id="email-input"
52
+ type="email"
53
+ placeholder="you@example.com"
54
+ value={email}
55
+ onChange={(e) => {
56
+ setEmail(e.target.value);
57
+ }}
58
+ autoFocus
59
+ required
60
+ />
61
+ </div>
62
+ <DialogFooter className="mt-2">
63
+ <Button type="submit" disabled={!email.includes('@')}>
64
+ Continue
65
+ </Button>
66
+ </DialogFooter>
67
+ </form>
68
+ </DialogContent>
69
+ </Dialog>
70
+ );
71
+ }
72
+
73
+ export function App() {
74
+ return (
75
+ <BrowserRouter>
76
+ <ThemeProvider>
77
+ <UserProvider>
78
+ <TooltipProvider delayDuration={300}>
79
+ <EmailSetupDialog />
80
+ <Routes>
81
+ <Route path="/" element={<Navigate to="/p/README.md" replace />} />{' '}
82
+ <Route element={<AppShell />}>
83
+ <Route path="/p/*" element={<FilePage />} />
84
+ <Route path="/i" element={<ImageLibraryPage />} />
85
+ <Route path="/i/:filename" element={<ImageLibraryPage />} />
86
+ <Route path="/welcome" element={<WelcomePage />} />
87
+ <Route path="*" element={<NotFound />} />
88
+ </Route>
89
+ </Routes>
90
+ </TooltipProvider>
91
+ </UserProvider>
92
+ </ThemeProvider>
93
+ </BrowserRouter>
94
+ );
95
+ }
96
+
97
+ export default App;
@@ -0,0 +1,199 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ import { toast } from 'sonner';
4
+ import {
5
+ Dialog,
6
+ DialogContent,
7
+ DialogHeader,
8
+ DialogTitle,
9
+ DialogDescription,
10
+ DialogFooter,
11
+ } from '../ui/dialog';
12
+ import { Input } from '../ui/input';
13
+ import { Label } from '../ui/label';
14
+ import { Button } from '../ui/button';
15
+ import { EmojiIcon } from '../ui/EmojiIcon';
16
+ import type { MarkdownType } from '@/lib/types';
17
+
18
+ interface NewPageDialogProps {
19
+ open: boolean;
20
+ onClose: () => void;
21
+ /** When set, the new page is placed under this directory (e.g. "docs/api"). */
22
+ parentDir?: string;
23
+ onCreated?: () => void;
24
+ }
25
+
26
+ function slugify(title: string): string {
27
+ return title
28
+ .toLowerCase()
29
+ .trim()
30
+ .replace(/\s+/g, '-')
31
+ .replace(/[^a-z0-9-_]/g, '')
32
+ .replace(/--+/g, '-')
33
+ .replace(/^-+|-+$/g, '');
34
+ }
35
+
36
+ export function NewPageDialog({ open, onClose, parentDir, onCreated }: NewPageDialogProps) {
37
+ const navigate = useNavigate();
38
+
39
+ const [title, setTitle] = useState('');
40
+ const [slug, setSlug] = useState('');
41
+ const [slugEdited, setSlugEdited] = useState(false);
42
+ const [pageType, setPageType] = useState<MarkdownType>('doc');
43
+ const [creating, setCreating] = useState(false);
44
+
45
+ // Auto-derive slug from title unless user has manually edited it (derived state, no effect needed)
46
+ const effectiveSlug = slugEdited ? slug : slugify(title);
47
+
48
+ const finalPath = effectiveSlug ? `${parentDir ? parentDir + '/' : ''}${effectiveSlug}.md` : '';
49
+
50
+ const handleCreate = useCallback(async () => {
51
+ const resolvedSlug = slugEdited ? slug : slugify(title);
52
+ if (!title.trim() || !resolvedSlug) return;
53
+ setCreating(true);
54
+
55
+ const slidesHeader = pageType === 'slide' ? '---\nslides: true\n---\n\n' : '';
56
+ const stub = `${slidesHeader}# ${title.trim()}\n`;
57
+
58
+ const res = await fetch('/api/file', {
59
+ method: 'POST',
60
+ headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify({ path: finalPath, content: stub }),
62
+ });
63
+
64
+ setCreating(false);
65
+
66
+ if (res.ok) {
67
+ toast.success('Page created');
68
+ onCreated?.();
69
+ onClose();
70
+ navigate(`/p/${finalPath}`)?.catch((err: unknown) => {
71
+ console.error('Navigation failed:', err);
72
+ });
73
+ } else if (res.status === 409) {
74
+ toast.error('A page at that path already exists.');
75
+ } else {
76
+ toast.error('Failed to create page');
77
+ }
78
+ }, [title, slug, slugEdited, pageType, finalPath, navigate, onCreated, onClose]);
79
+
80
+ const handleKeyDown = (e: React.KeyboardEvent) => {
81
+ if (e.key === 'Enter' && !creating && title.trim() && effectiveSlug) {
82
+ handleCreate().catch((err: unknown) => {
83
+ console.error('Failed to create page:', err);
84
+ });
85
+ }
86
+ };
87
+
88
+ return (
89
+ <Dialog
90
+ open={open}
91
+ onOpenChange={(v) => {
92
+ if (v) {
93
+ setTitle('');
94
+ setSlug('');
95
+ setSlugEdited(false);
96
+ setPageType('doc');
97
+ setCreating(false);
98
+ } else {
99
+ onClose();
100
+ }
101
+ }}
102
+ >
103
+ <DialogContent className="sm:max-w-md" onKeyDown={handleKeyDown}>
104
+ <DialogHeader>
105
+ <DialogTitle>New page</DialogTitle>
106
+ <DialogDescription>
107
+ {parentDir
108
+ ? `Create a sub-page under "${parentDir}"`
109
+ : 'Create a new page at the root of the repository'}
110
+ </DialogDescription>
111
+ </DialogHeader>
112
+
113
+ <div className="grid gap-4 py-1">
114
+ {/* Page type selector */}
115
+ <div className="grid gap-1.5">
116
+ <Label>Type</Label>
117
+ <div className="flex gap-2">
118
+ <Button
119
+ type="button"
120
+ size="sm"
121
+ variant={pageType === 'doc' ? 'default' : 'outline'}
122
+ className="flex-1 h-8 text-xs gap-1.5"
123
+ onClick={() => {
124
+ setPageType('doc');
125
+ }}
126
+ >
127
+ <EmojiIcon fileType="doc" size={14} />
128
+ Markdown
129
+ </Button>
130
+ <Button
131
+ type="button"
132
+ size="sm"
133
+ variant={pageType === 'slide' ? 'default' : 'outline'}
134
+ className="flex-1 h-8 text-xs gap-1.5"
135
+ onClick={() => {
136
+ setPageType('slide');
137
+ }}
138
+ >
139
+ <EmojiIcon fileType="slide" size={14} />
140
+ Slides
141
+ </Button>
142
+ </div>
143
+ </div>
144
+
145
+ {/* Title */}
146
+ <div className="grid gap-1.5">
147
+ <Label htmlFor="np-title">Title</Label>
148
+ <Input
149
+ id="np-title"
150
+ autoFocus
151
+ value={title}
152
+ onChange={(e) => {
153
+ setTitle(e.target.value);
154
+ }}
155
+ placeholder="My new page"
156
+ />
157
+ </div>
158
+
159
+ {/* Slug (editable) */}
160
+ <div className="grid gap-1.5">
161
+ <Label htmlFor="np-slug">Filename slug</Label>
162
+ <Input
163
+ id="np-slug"
164
+ value={effectiveSlug}
165
+ onChange={(e) => {
166
+ setSlug(e.target.value);
167
+ setSlugEdited(e.target.value !== '');
168
+ }}
169
+ placeholder="my-new-page"
170
+ />
171
+ </div>
172
+
173
+ {/* Path preview */}
174
+ {finalPath && (
175
+ <p className="text-xs text-muted-foreground font-mono bg-muted rounded px-2 py-1.5 truncate">
176
+ {finalPath}
177
+ </p>
178
+ )}
179
+ </div>
180
+
181
+ <DialogFooter>
182
+ <Button variant="outline" onClick={onClose} disabled={creating}>
183
+ Cancel
184
+ </Button>
185
+ <Button
186
+ onClick={() => {
187
+ handleCreate().catch((err: unknown) => {
188
+ console.error('Failed to create page:', err);
189
+ });
190
+ }}
191
+ disabled={creating || !title.trim() || !effectiveSlug}
192
+ >
193
+ {creating ? 'Creating…' : 'Create'}
194
+ </Button>
195
+ </DialogFooter>
196
+ </DialogContent>
197
+ </Dialog>
198
+ );
199
+ }
@@ -0,0 +1,90 @@
1
+ import CodeMirror, { EditorView } from '@uiw/react-codemirror';
2
+ import { loadLanguage, type LanguageName } from '@uiw/codemirror-extensions-langs';
3
+ import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
4
+ import { useTheme } from '../../store/theme';
5
+
6
+ interface CodeEditorProps {
7
+ value: string;
8
+ language: string; // raw file extension, e.g. "ts", "py", "json"
9
+ readOnly?: boolean;
10
+ onChange?: (value: string) => void;
11
+ onSave?: () => void;
12
+ }
13
+
14
+ // Map raw file extensions to @uiw/codemirror-extensions-langs language names.
15
+ // Many extensions match directly (ts, js, py, rs, etc.), so only exceptions are listed.
16
+ const EXT_TO_LANG: Record<string, string> = {
17
+ mjs: 'js',
18
+ cjs: 'js',
19
+ bash: 'sh',
20
+ zsh: 'sh',
21
+ fish: 'sh',
22
+ htm: 'html',
23
+ scss: 'sass',
24
+ yml: 'yaml',
25
+ jsonc: 'json',
26
+ gql: 'graphql',
27
+ kt: 'kotlin',
28
+ kts: 'kotlin',
29
+ tf: 'hcl',
30
+ tfvars: 'hcl',
31
+ };
32
+
33
+ function resolveLanguage(ext: string) {
34
+ const name = (EXT_TO_LANG[ext] ?? ext) as LanguageName;
35
+ try {
36
+ const lang = loadLanguage(name);
37
+ return lang ? [lang] : [];
38
+ } catch {
39
+ return [];
40
+ }
41
+ }
42
+
43
+ export function CodeEditor({
44
+ value,
45
+ language,
46
+ readOnly = false,
47
+ onChange,
48
+ onSave,
49
+ }: CodeEditorProps) {
50
+ const { theme } = useTheme();
51
+
52
+ const extensions = [
53
+ ...resolveLanguage(language),
54
+ EditorView.lineWrapping,
55
+ // Ctrl+S / Cmd+S save shortcut
56
+ ...(onSave
57
+ ? [
58
+ EditorView.domEventHandlers({
59
+ keydown(e) {
60
+ if ((e.ctrlKey || e.metaKey) && e.key === 's') {
61
+ e.preventDefault();
62
+ onSave();
63
+ }
64
+ },
65
+ }),
66
+ ]
67
+ : []),
68
+ ];
69
+
70
+ return (
71
+ <div className="h-full overflow-auto text-sm [&_.cm-editor]:h-full [&_.cm-scroller]:min-h-full [&_.cm-editor.cm-focused]:outline-none">
72
+ <CodeMirror
73
+ value={value}
74
+ height="100%"
75
+ theme={theme === 'dark' ? githubDark : githubLight}
76
+ extensions={extensions}
77
+ readOnly={readOnly}
78
+ basicSetup={{
79
+ lineNumbers: true,
80
+ foldGutter: true,
81
+ highlightActiveLine: !readOnly,
82
+ highlightSelectionMatches: true,
83
+ autocompletion: false,
84
+ closeBrackets: false,
85
+ }}
86
+ onChange={onChange}
87
+ />
88
+ </div>
89
+ );
90
+ }