doclific 0.1.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/.gitattributes +2 -0
- package/.prettierignore +5 -0
- package/.prettierrc +9 -0
- package/.vscode/settings.json +13 -0
- package/dist/bin/doclific.d.ts +3 -0
- package/dist/bin/doclific.d.ts.map +1 -0
- package/dist/bin/doclific.js +11 -0
- package/dist/core/codebase.js +31 -0
- package/dist/core/docs.js +75 -0
- package/dist/core/git.js +47 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +46 -0
- package/dist/server/router.d.ts +9 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/router.js +55 -0
- package/frontend/README.md +73 -0
- package/frontend/components.json +24 -0
- package/frontend/eslint.config.js +23 -0
- package/frontend/index.html +25 -0
- package/frontend/package-lock.json +15754 -0
- package/frontend/package.json +122 -0
- package/frontend/public/logo.svg +1 -0
- package/frontend/src/App.tsx +21 -0
- package/frontend/src/components/app-sidebar.tsx +393 -0
- package/frontend/src/components/editor/editor-base-kit.tsx +43 -0
- package/frontend/src/components/editor/editor-kit.tsx +93 -0
- package/frontend/src/components/editor/plugins/align-base-kit.tsx +16 -0
- package/frontend/src/components/editor/plugins/align-kit.tsx +18 -0
- package/frontend/src/components/editor/plugins/autoformat-kit.tsx +236 -0
- package/frontend/src/components/editor/plugins/basic-blocks-base-kit.tsx +35 -0
- package/frontend/src/components/editor/plugins/basic-blocks-kit.tsx +88 -0
- package/frontend/src/components/editor/plugins/basic-marks-base-kit.tsx +27 -0
- package/frontend/src/components/editor/plugins/basic-marks-kit.tsx +41 -0
- package/frontend/src/components/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/frontend/src/components/editor/plugins/block-menu-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/frontend/src/components/editor/plugins/block-selection-kit.tsx +32 -0
- package/frontend/src/components/editor/plugins/callout-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/callout-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/code-block-base-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/code-block-kit.tsx +26 -0
- package/frontend/src/components/editor/plugins/codebase-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/column-base-kit.tsx +11 -0
- package/frontend/src/components/editor/plugins/column-kit.tsx +10 -0
- package/frontend/src/components/editor/plugins/comment-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/comment-kit.tsx +97 -0
- package/frontend/src/components/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/date-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/date-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/discussion-kit.tsx +148 -0
- package/frontend/src/components/editor/plugins/dnd-kit.tsx +28 -0
- package/frontend/src/components/editor/plugins/docx-kit.tsx +6 -0
- package/frontend/src/components/editor/plugins/emoji-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/excalidraw-kit.tsx +9 -0
- package/frontend/src/components/editor/plugins/exit-break-kit.tsx +12 -0
- package/frontend/src/components/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/frontend/src/components/editor/plugins/font-base-kit.tsx +20 -0
- package/frontend/src/components/editor/plugins/font-kit.tsx +29 -0
- package/frontend/src/components/editor/plugins/indent-base-kit.tsx +19 -0
- package/frontend/src/components/editor/plugins/indent-kit.tsx +22 -0
- package/frontend/src/components/editor/plugins/line-height-base-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/line-height-kit.tsx +16 -0
- package/frontend/src/components/editor/plugins/link-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/link-kit.tsx +15 -0
- package/frontend/src/components/editor/plugins/list-base-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/list-kit.tsx +26 -0
- package/frontend/src/components/editor/plugins/markdown-kit.tsx +46 -0
- package/frontend/src/components/editor/plugins/math-base-kit.tsx +11 -0
- package/frontend/src/components/editor/plugins/math-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/media-base-kit.tsx +31 -0
- package/frontend/src/components/editor/plugins/media-kit.tsx +43 -0
- package/frontend/src/components/editor/plugins/mention-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/mention-kit.tsx +15 -0
- package/frontend/src/components/editor/plugins/slash-kit.tsx +18 -0
- package/frontend/src/components/editor/plugins/suggestion-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/suggestion-kit.tsx +90 -0
- package/frontend/src/components/editor/plugins/table-base-kit.tsx +20 -0
- package/frontend/src/components/editor/plugins/table-kit.tsx +22 -0
- package/frontend/src/components/editor/plugins/toc-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/toc-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/toggle-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/toggle-kit.tsx +11 -0
- package/frontend/src/components/editor/transforms.ts +194 -0
- package/frontend/src/components/markdown-to-slate-demo.tsx +50 -0
- package/frontend/src/components/mode-toggle.tsx +15 -0
- package/frontend/src/components/theme-provider.tsx +73 -0
- package/frontend/src/components/ui/alert-dialog.tsx +155 -0
- package/frontend/src/components/ui/align-toolbar-button.tsx +84 -0
- package/frontend/src/components/ui/avatar.tsx +51 -0
- package/frontend/src/components/ui/block-context-menu.tsx +199 -0
- package/frontend/src/components/ui/block-discussion.tsx +365 -0
- package/frontend/src/components/ui/block-draggable.tsx +512 -0
- package/frontend/src/components/ui/block-list-static.tsx +80 -0
- package/frontend/src/components/ui/block-list.tsx +87 -0
- package/frontend/src/components/ui/block-selection.tsx +42 -0
- package/frontend/src/components/ui/block-suggestion.tsx +473 -0
- package/frontend/src/components/ui/blockquote-node-static.tsx +11 -0
- package/frontend/src/components/ui/blockquote-node.tsx +13 -0
- package/frontend/src/components/ui/button.tsx +62 -0
- package/frontend/src/components/ui/calendar.tsx +218 -0
- package/frontend/src/components/ui/callout-node-static.tsx +36 -0
- package/frontend/src/components/ui/callout-node.tsx +63 -0
- package/frontend/src/components/ui/caption.tsx +63 -0
- package/frontend/src/components/ui/checkbox.tsx +30 -0
- package/frontend/src/components/ui/code-block-node-static.tsx +35 -0
- package/frontend/src/components/ui/code-block-node.tsx +287 -0
- package/frontend/src/components/ui/code-node-static.tsx +15 -0
- package/frontend/src/components/ui/code-node.tsx +17 -0
- package/frontend/src/components/ui/codebase-snippet-node.tsx +237 -0
- package/frontend/src/components/ui/column-node-static.tsx +29 -0
- package/frontend/src/components/ui/column-node.tsx +317 -0
- package/frontend/src/components/ui/command.tsx +182 -0
- package/frontend/src/components/ui/comment-node-static.tsx +15 -0
- package/frontend/src/components/ui/comment-node.tsx +45 -0
- package/frontend/src/components/ui/comment-toolbar-button.tsx +24 -0
- package/frontend/src/components/ui/comment.tsx +618 -0
- package/frontend/src/components/ui/context-menu.tsx +250 -0
- package/frontend/src/components/ui/cursor-overlay.tsx +66 -0
- package/frontend/src/components/ui/date-node-static.tsx +45 -0
- package/frontend/src/components/ui/date-node.tsx +93 -0
- package/frontend/src/components/ui/dialog.tsx +143 -0
- package/frontend/src/components/ui/dropdown-menu.tsx +255 -0
- package/frontend/src/components/ui/dynamic-icon.tsx +12 -0
- package/frontend/src/components/ui/editor-static.tsx +53 -0
- package/frontend/src/components/ui/editor.tsx +130 -0
- package/frontend/src/components/ui/emoji-node.tsx +69 -0
- package/frontend/src/components/ui/emoji-toolbar-button.tsx +628 -0
- package/frontend/src/components/ui/equation-node-static.tsx +98 -0
- package/frontend/src/components/ui/equation-node.tsx +235 -0
- package/frontend/src/components/ui/equation-toolbar-button.tsx +25 -0
- package/frontend/src/components/ui/excalidraw-node.tsx +36 -0
- package/frontend/src/components/ui/export-toolbar-button.tsx +174 -0
- package/frontend/src/components/ui/file-selector.tsx +339 -0
- package/frontend/src/components/ui/floating-toolbar-buttons.tsx +73 -0
- package/frontend/src/components/ui/floating-toolbar.tsx +85 -0
- package/frontend/src/components/ui/font-color-toolbar-button.tsx +831 -0
- package/frontend/src/components/ui/font-size-toolbar-button.tsx +152 -0
- package/frontend/src/components/ui/heading-node-static.tsx +68 -0
- package/frontend/src/components/ui/heading-node.tsx +58 -0
- package/frontend/src/components/ui/highlight-node-static.tsx +11 -0
- package/frontend/src/components/ui/highlight-node.tsx +13 -0
- package/frontend/src/components/ui/history-toolbar-button.tsx +50 -0
- package/frontend/src/components/ui/hr-node-static.tsx +20 -0
- package/frontend/src/components/ui/hr-node.tsx +33 -0
- package/frontend/src/components/ui/import-toolbar-button.tsx +97 -0
- package/frontend/src/components/ui/indent-toolbar-button.tsx +30 -0
- package/frontend/src/components/ui/inline-combobox.tsx +414 -0
- package/frontend/src/components/ui/input.tsx +21 -0
- package/frontend/src/components/ui/insert-toolbar-button.tsx +254 -0
- package/frontend/src/components/ui/kbd-node-static.tsx +15 -0
- package/frontend/src/components/ui/kbd-node.tsx +17 -0
- package/frontend/src/components/ui/layout-header.tsx +35 -0
- package/frontend/src/components/ui/line-height-toolbar-button.tsx +68 -0
- package/frontend/src/components/ui/link-node-static.tsx +21 -0
- package/frontend/src/components/ui/link-node.tsx +39 -0
- package/frontend/src/components/ui/link-toolbar-button.tsx +22 -0
- package/frontend/src/components/ui/link-toolbar.tsx +206 -0
- package/frontend/src/components/ui/list-toolbar-button.tsx +204 -0
- package/frontend/src/components/ui/mark-toolbar-button.tsx +19 -0
- package/frontend/src/components/ui/media-audio-node-static.tsx +17 -0
- package/frontend/src/components/ui/media-audio-node.tsx +39 -0
- package/frontend/src/components/ui/media-embed-node.tsx +136 -0
- package/frontend/src/components/ui/media-file-node-static.tsx +29 -0
- package/frontend/src/components/ui/media-file-node.tsx +47 -0
- package/frontend/src/components/ui/media-image-node-static.tsx +39 -0
- package/frontend/src/components/ui/media-image-node.tsx +80 -0
- package/frontend/src/components/ui/media-placeholder-node.tsx +249 -0
- package/frontend/src/components/ui/media-preview-dialog.tsx +152 -0
- package/frontend/src/components/ui/media-toolbar-button.tsx +225 -0
- package/frontend/src/components/ui/media-toolbar.tsx +115 -0
- package/frontend/src/components/ui/media-upload-toast.tsx +66 -0
- package/frontend/src/components/ui/media-video-node-static.tsx +30 -0
- package/frontend/src/components/ui/media-video-node.tsx +121 -0
- package/frontend/src/components/ui/mention-node-static.tsx +36 -0
- package/frontend/src/components/ui/mention-node.tsx +194 -0
- package/frontend/src/components/ui/mode-toolbar-button.tsx +123 -0
- package/frontend/src/components/ui/more-toolbar-button.tsx +80 -0
- package/frontend/src/components/ui/paragraph-node-static.tsx +13 -0
- package/frontend/src/components/ui/paragraph-node.tsx +15 -0
- package/frontend/src/components/ui/popover.tsx +46 -0
- package/frontend/src/components/ui/resize-handle.tsx +87 -0
- package/frontend/src/components/ui/separator.tsx +28 -0
- package/frontend/src/components/ui/sheet.tsx +139 -0
- package/frontend/src/components/ui/sidebar.tsx +726 -0
- package/frontend/src/components/ui/skeleton.tsx +13 -0
- package/frontend/src/components/ui/slash-node.tsx +233 -0
- package/frontend/src/components/ui/sonner.tsx +38 -0
- package/frontend/src/components/ui/suggestion-node-static.tsx +35 -0
- package/frontend/src/components/ui/suggestion-node.tsx +162 -0
- package/frontend/src/components/ui/suggestion-toolbar-button.tsx +25 -0
- package/frontend/src/components/ui/table-icons.tsx +862 -0
- package/frontend/src/components/ui/table-node-static.tsx +98 -0
- package/frontend/src/components/ui/table-node.tsx +656 -0
- package/frontend/src/components/ui/table-toolbar-button.tsx +264 -0
- package/frontend/src/components/ui/toc-node-static.tsx +92 -0
- package/frontend/src/components/ui/toc-node.tsx +55 -0
- package/frontend/src/components/ui/toggle-node-static.tsx +18 -0
- package/frontend/src/components/ui/toggle-node.tsx +36 -0
- package/frontend/src/components/ui/toggle-toolbar-button.tsx +22 -0
- package/frontend/src/components/ui/toolbar.tsx +387 -0
- package/frontend/src/components/ui/tooltip.tsx +59 -0
- package/frontend/src/components/ui/turn-into-toolbar-button.tsx +188 -0
- package/frontend/src/hooks/use-debounce.ts +18 -0
- package/frontend/src/hooks/use-is-touch-device.ts +24 -0
- package/frontend/src/hooks/use-mobile.ts +19 -0
- package/frontend/src/hooks/use-mounted.ts +11 -0
- package/frontend/src/hooks/use-upload-file.ts +128 -0
- package/frontend/src/index.css +128 -0
- package/frontend/src/layout.tsx +42 -0
- package/frontend/src/lib/markdown-joiner-transform.ts +239 -0
- package/frontend/src/lib/orpc.ts +13 -0
- package/frontend/src/lib/uploadthing.ts +19 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/main.tsx +13 -0
- package/frontend/src/pages/editor.tsx +44 -0
- package/frontend/src/types/docs.d.ts +6 -0
- package/frontend/src/types/global.d.ts +9 -0
- package/frontend/src/types/router.d.ts +4 -0
- package/frontend/tsconfig.app.json +33 -0
- package/frontend/tsconfig.json +10 -0
- package/frontend/tsconfig.node.json +26 -0
- package/frontend/vite.config.ts +14 -0
- package/package.json +30 -0
- package/src/bin/doclific.ts +17 -0
- package/src/core/codebase.ts +39 -0
- package/src/core/docs.ts +90 -0
- package/src/core/git.ts +48 -0
- package/src/server/index.ts +55 -0
- package/src/server/router.ts +65 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { ChevronRight, EllipsisVertical, FileIcon, Plus, UserCircle, Search, X } from "lucide-react";
|
|
2
|
+
import * as Icons from "lucide-react";
|
|
3
|
+
import {
|
|
4
|
+
Sidebar,
|
|
5
|
+
SidebarContent,
|
|
6
|
+
SidebarFooter,
|
|
7
|
+
SidebarGroup,
|
|
8
|
+
SidebarGroupContent,
|
|
9
|
+
SidebarGroupLabel,
|
|
10
|
+
SidebarMenu,
|
|
11
|
+
SidebarMenuButton,
|
|
12
|
+
SidebarMenuItem,
|
|
13
|
+
SidebarHeader,
|
|
14
|
+
SidebarMenuSub,
|
|
15
|
+
SidebarMenuSubItem,
|
|
16
|
+
SidebarMenuSubButton,
|
|
17
|
+
} from "@/components/ui/sidebar"
|
|
18
|
+
import { orpcTs } from "@/lib/orpc"
|
|
19
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
|
20
|
+
import { useState, useRef, useEffect } from "react"
|
|
21
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, DropdownMenuGroup } from "@/components/ui/dropdown-menu"
|
|
22
|
+
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
|
|
23
|
+
import { useSidebar } from "@/components/ui/sidebar"
|
|
24
|
+
import type { FolderStructure } from "@/types/docs"
|
|
25
|
+
import { DynamicIcon, type LucideIconName } from "./ui/dynamic-icon"
|
|
26
|
+
import { useNavigate } from "react-router"
|
|
27
|
+
import {
|
|
28
|
+
Dialog,
|
|
29
|
+
DialogContent,
|
|
30
|
+
DialogFooter,
|
|
31
|
+
DialogHeader,
|
|
32
|
+
DialogTitle,
|
|
33
|
+
DialogTrigger,
|
|
34
|
+
} from "@/components/ui/dialog"
|
|
35
|
+
import { Button } from "@/components/ui/button"
|
|
36
|
+
import { Input } from "@/components/ui/input"
|
|
37
|
+
import React from "react"
|
|
38
|
+
|
|
39
|
+
function CreateDocDialog({
|
|
40
|
+
parentPath,
|
|
41
|
+
isNested,
|
|
42
|
+
}: {
|
|
43
|
+
parentPath: string
|
|
44
|
+
isNested: boolean
|
|
45
|
+
}) {
|
|
46
|
+
const [open, setOpen] = useState(false)
|
|
47
|
+
const [title, setTitle] = useState("")
|
|
48
|
+
const [selectedIcon, setSelectedIcon] = useState<string>("")
|
|
49
|
+
const [iconSearch, setIconSearch] = useState("")
|
|
50
|
+
const [showIconPicker, setShowIconPicker] = useState(false)
|
|
51
|
+
const iconPickerRef = useRef<HTMLDivElement>(null)
|
|
52
|
+
const queryClient = useQueryClient()
|
|
53
|
+
|
|
54
|
+
// Close icon picker when clicking outside
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
57
|
+
if (iconPickerRef.current && !iconPickerRef.current.contains(event.target as Node)) {
|
|
58
|
+
setShowIconPicker(false)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (showIconPicker) {
|
|
62
|
+
document.addEventListener("mousedown", handleClickOutside)
|
|
63
|
+
return () => document.removeEventListener("mousedown", handleClickOutside)
|
|
64
|
+
}
|
|
65
|
+
}, [showIconPicker])
|
|
66
|
+
const createDocMutation = useMutation({
|
|
67
|
+
...orpcTs.docs.createDoc.mutationOptions(),
|
|
68
|
+
onSuccess: () => {
|
|
69
|
+
queryClient.invalidateQueries({ queryKey: orpcTs.docs.getDocs.queryKey() })
|
|
70
|
+
setOpen(false)
|
|
71
|
+
setTitle("")
|
|
72
|
+
setSelectedIcon("")
|
|
73
|
+
setIconSearch("")
|
|
74
|
+
setShowIconPicker(false)
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
79
|
+
e.preventDefault()
|
|
80
|
+
createDocMutation.mutate({
|
|
81
|
+
filePath: parentPath,
|
|
82
|
+
title,
|
|
83
|
+
icon: selectedIcon || undefined,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const iconNames = Object.keys(Icons).filter((iconName) => iconName.endsWith("Icon") && iconName !== "createLucideIcon").map((iconName) => iconName.replace("Icon", ""))
|
|
88
|
+
|
|
89
|
+
const IconComponent = selectedIcon ? <DynamicIcon name={selectedIcon as LucideIconName} /> : null
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
93
|
+
<DialogTrigger asChild>
|
|
94
|
+
{isNested ? (
|
|
95
|
+
<SidebarMenuSubButton className="text-muted-foreground hover:text-foreground">
|
|
96
|
+
<Plus className="size-4 !stroke-current" />
|
|
97
|
+
<span className="truncate">New doc</span>
|
|
98
|
+
</SidebarMenuSubButton>
|
|
99
|
+
) : (
|
|
100
|
+
<SidebarMenuButton className="text-muted-foreground stroke-muted-foreground hover:text-foreground hover:stroke-foreground">
|
|
101
|
+
<Plus className="size-4 !stroke-current" />
|
|
102
|
+
<span className="truncate">New doc</span>
|
|
103
|
+
</SidebarMenuButton>
|
|
104
|
+
)}
|
|
105
|
+
</DialogTrigger>
|
|
106
|
+
<DialogContent className="max-w-md">
|
|
107
|
+
<DialogHeader>
|
|
108
|
+
<DialogTitle>Create New Document</DialogTitle>
|
|
109
|
+
</DialogHeader>
|
|
110
|
+
<form onSubmit={handleSubmit}>
|
|
111
|
+
<div className="grid gap-4 py-4">
|
|
112
|
+
<div className="grid gap-2">
|
|
113
|
+
<label htmlFor="title" className="text-sm font-medium">
|
|
114
|
+
Title
|
|
115
|
+
</label>
|
|
116
|
+
<Input
|
|
117
|
+
id="title"
|
|
118
|
+
value={title}
|
|
119
|
+
onChange={(e) => setTitle(e.target.value)}
|
|
120
|
+
placeholder="Document title"
|
|
121
|
+
required
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
<div className="grid gap-2">
|
|
125
|
+
<label className="text-sm font-medium">Icon (optional)</label>
|
|
126
|
+
<div className="relative">
|
|
127
|
+
<Button
|
|
128
|
+
type="button"
|
|
129
|
+
variant="outline"
|
|
130
|
+
className="w-full justify-start"
|
|
131
|
+
onClick={() => setShowIconPicker(!showIconPicker)}
|
|
132
|
+
>
|
|
133
|
+
{IconComponent ? (
|
|
134
|
+
<>
|
|
135
|
+
<DynamicIcon name={selectedIcon as LucideIconName} className="size-4 mr-2" />
|
|
136
|
+
<span>{selectedIcon}</span>
|
|
137
|
+
</>
|
|
138
|
+
) : (
|
|
139
|
+
<>
|
|
140
|
+
<FileIcon className="size-4 mr-2" />
|
|
141
|
+
<span>Select icon</span>
|
|
142
|
+
</>
|
|
143
|
+
)}
|
|
144
|
+
</Button>
|
|
145
|
+
{selectedIcon && (
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
onClick={(e) => {
|
|
149
|
+
e.stopPropagation()
|
|
150
|
+
setSelectedIcon("")
|
|
151
|
+
}}
|
|
152
|
+
className="absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-muted rounded"
|
|
153
|
+
>
|
|
154
|
+
<X className="size-3" />
|
|
155
|
+
</button>
|
|
156
|
+
)}
|
|
157
|
+
{showIconPicker && (
|
|
158
|
+
<div ref={iconPickerRef} className="absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg p-2 overflow-hidden">
|
|
159
|
+
<div className="relative mb-2">
|
|
160
|
+
<Search className="absolute left-2 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" />
|
|
161
|
+
<Input
|
|
162
|
+
placeholder="Search icons..."
|
|
163
|
+
value={iconSearch}
|
|
164
|
+
onChange={(e) => setIconSearch(e.target.value)}
|
|
165
|
+
className="pl-8"
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
<div className="grid grid-cols-6 gap-2 max-h-64 h-full overflow-y-auto">
|
|
169
|
+
{iconNames.filter((iconName) => iconSearch === "" || iconName.toLowerCase().includes(iconSearch.toLowerCase())).map((iconName) => {
|
|
170
|
+
try {
|
|
171
|
+
return (
|
|
172
|
+
<button
|
|
173
|
+
key={iconName}
|
|
174
|
+
type="button"
|
|
175
|
+
onClick={() => {
|
|
176
|
+
setSelectedIcon(iconName)
|
|
177
|
+
setShowIconPicker(false)
|
|
178
|
+
setIconSearch("")
|
|
179
|
+
}}
|
|
180
|
+
className={`p-2 rounded hover:bg-muted transition-colors ${selectedIcon === iconName ? "bg-primary/10 border border-primary" : ""
|
|
181
|
+
}`}
|
|
182
|
+
title={iconName}
|
|
183
|
+
>
|
|
184
|
+
<DynamicIcon name={iconName as LucideIconName} className="size-4 mx-auto" />
|
|
185
|
+
</button>
|
|
186
|
+
)
|
|
187
|
+
} catch {
|
|
188
|
+
return <></>
|
|
189
|
+
}
|
|
190
|
+
})}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
)}
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
<DialogFooter>
|
|
198
|
+
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
|
|
199
|
+
Cancel
|
|
200
|
+
</Button>
|
|
201
|
+
<Button type="submit" disabled={createDocMutation.isPending}>
|
|
202
|
+
{createDocMutation.isPending ? "Creating..." : "Create"}
|
|
203
|
+
</Button>
|
|
204
|
+
</DialogFooter>
|
|
205
|
+
</form>
|
|
206
|
+
</DialogContent>
|
|
207
|
+
</Dialog>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function AppSidebar() {
|
|
212
|
+
const navigate = useNavigate()
|
|
213
|
+
const sidebarData = useQuery({
|
|
214
|
+
...orpcTs.git.getRepoInfo.queryOptions(),
|
|
215
|
+
enabled: true,
|
|
216
|
+
})
|
|
217
|
+
const { isMobile } = useSidebar()
|
|
218
|
+
const docsQuery = useQuery({
|
|
219
|
+
...orpcTs.docs.getDocs.queryOptions(),
|
|
220
|
+
enabled: true,
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
const [expandedItems, setExpandedItems] = useState<Set<string>>(new Set())
|
|
224
|
+
|
|
225
|
+
const toggleExpanded = (name: string) => {
|
|
226
|
+
setExpandedItems((prev) => {
|
|
227
|
+
const next = new Set(prev)
|
|
228
|
+
if (next.has(name)) {
|
|
229
|
+
next.delete(name)
|
|
230
|
+
} else {
|
|
231
|
+
next.add(name)
|
|
232
|
+
}
|
|
233
|
+
return next
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const renderDocItem = (
|
|
238
|
+
doc: FolderStructure,
|
|
239
|
+
fullPath: string,
|
|
240
|
+
isNested: boolean = false,
|
|
241
|
+
index: number = 0,
|
|
242
|
+
totalSiblings: number = 0
|
|
243
|
+
) => {
|
|
244
|
+
const isExpanded = expandedItems.has(fullPath)
|
|
245
|
+
const isLast = index === totalSiblings - 1
|
|
246
|
+
|
|
247
|
+
if (isNested) {
|
|
248
|
+
return (
|
|
249
|
+
<>
|
|
250
|
+
<SidebarMenuSubItem key={fullPath}>
|
|
251
|
+
<SidebarMenuSubButton
|
|
252
|
+
className="group cursor-pointer"
|
|
253
|
+
onClick={() => navigate(`/${fullPath}`)}
|
|
254
|
+
>
|
|
255
|
+
<ChevronRight
|
|
256
|
+
onClick={(e) => {
|
|
257
|
+
e.stopPropagation()
|
|
258
|
+
toggleExpanded(fullPath)
|
|
259
|
+
}}
|
|
260
|
+
className={`size-4 transition-transform ${isExpanded ? "rotate-90" : ""}`}
|
|
261
|
+
/>
|
|
262
|
+
{doc.icon ? <DynamicIcon name={doc.icon as LucideIconName} /> : <FileIcon />}
|
|
263
|
+
<span className="truncate">{doc.title}</span>
|
|
264
|
+
</SidebarMenuSubButton>
|
|
265
|
+
{isExpanded && (
|
|
266
|
+
<SidebarMenuSub>
|
|
267
|
+
{doc.children.map((child, childIndex) => {
|
|
268
|
+
const childPath = `${fullPath}/${child.name}`
|
|
269
|
+
return renderDocItem(child, childPath, true, childIndex, doc.children.length)
|
|
270
|
+
})}
|
|
271
|
+
<SidebarMenuSubItem>
|
|
272
|
+
<CreateDocDialog parentPath={fullPath} isNested={true} />
|
|
273
|
+
</SidebarMenuSubItem>
|
|
274
|
+
</SidebarMenuSub>
|
|
275
|
+
)}
|
|
276
|
+
</SidebarMenuSubItem>
|
|
277
|
+
</>
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<React.Fragment key={fullPath}>
|
|
283
|
+
<SidebarMenuItem key={fullPath}>
|
|
284
|
+
<SidebarMenuButton
|
|
285
|
+
className="group cursor-pointer"
|
|
286
|
+
onClick={() => navigate(`/${fullPath}`)}
|
|
287
|
+
>
|
|
288
|
+
<ChevronRight
|
|
289
|
+
onClick={(e) => {
|
|
290
|
+
e.stopPropagation()
|
|
291
|
+
toggleExpanded(fullPath)
|
|
292
|
+
}}
|
|
293
|
+
className={`size-4 transition-transform ${isExpanded ? "rotate-90" : ""}`}
|
|
294
|
+
/>
|
|
295
|
+
{doc.icon ? <DynamicIcon name={doc.icon as LucideIconName} /> : <FileIcon />}
|
|
296
|
+
<span className="truncate font-medium">{doc.title}</span>
|
|
297
|
+
</SidebarMenuButton>
|
|
298
|
+
{isExpanded && (
|
|
299
|
+
<SidebarMenuSub>
|
|
300
|
+
{doc.children.map((child, childIndex) => {
|
|
301
|
+
const childPath = `${fullPath}/${child.name}`
|
|
302
|
+
return renderDocItem(child, childPath, true, childIndex, doc.children.length)
|
|
303
|
+
})}
|
|
304
|
+
<SidebarMenuSubItem>
|
|
305
|
+
<CreateDocDialog parentPath={fullPath} isNested={true} />
|
|
306
|
+
</SidebarMenuSubItem>
|
|
307
|
+
</SidebarMenuSub>
|
|
308
|
+
)}
|
|
309
|
+
</SidebarMenuItem>
|
|
310
|
+
{isLast && (
|
|
311
|
+
<SidebarMenuItem>
|
|
312
|
+
<CreateDocDialog parentPath="" isNested={false} />
|
|
313
|
+
</SidebarMenuItem>
|
|
314
|
+
)}
|
|
315
|
+
</React.Fragment>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const docsMenu = (docs: FolderStructure[]): React.ReactNode[] => {
|
|
320
|
+
return docs.map((doc, index) => renderDocItem(doc, doc.name, false, index, docs.length))
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<Sidebar variant="inset">
|
|
326
|
+
<SidebarHeader>
|
|
327
|
+
<span className="text-2xl font-extrabold italic" style={{ fontFamily: 'Google Sans Code' }}>Doclific</span>
|
|
328
|
+
</SidebarHeader>
|
|
329
|
+
<SidebarContent>
|
|
330
|
+
<SidebarGroup>
|
|
331
|
+
<SidebarGroupLabel>{sidebarData.data?.repositoryName} ({sidebarData.data?.repositoryBranch})</SidebarGroupLabel>
|
|
332
|
+
<SidebarGroupContent>
|
|
333
|
+
<SidebarMenu>
|
|
334
|
+
{docsMenu(docsQuery.data ?? [])}
|
|
335
|
+
</SidebarMenu>
|
|
336
|
+
</SidebarGroupContent>
|
|
337
|
+
</SidebarGroup>
|
|
338
|
+
</SidebarContent>
|
|
339
|
+
<SidebarFooter>
|
|
340
|
+
<SidebarMenu>
|
|
341
|
+
<SidebarMenuItem>
|
|
342
|
+
<DropdownMenu>
|
|
343
|
+
<DropdownMenuTrigger asChild>
|
|
344
|
+
<SidebarMenuButton
|
|
345
|
+
size="lg"
|
|
346
|
+
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
|
347
|
+
>
|
|
348
|
+
<Avatar className="h-8 w-8 rounded-lg grayscale">
|
|
349
|
+
<AvatarFallback className="rounded-lg">{sidebarData.data?.user?.charAt(0).toUpperCase()}</AvatarFallback>
|
|
350
|
+
</Avatar>
|
|
351
|
+
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
352
|
+
<span className="truncate font-medium">{sidebarData.data?.user}</span>
|
|
353
|
+
<span className="text-muted-foreground truncate text-xs">
|
|
354
|
+
{sidebarData.data?.userEmail ?? sidebarData.data?.user}
|
|
355
|
+
</span>
|
|
356
|
+
</div>
|
|
357
|
+
<EllipsisVertical className="ml-auto size-4" />
|
|
358
|
+
</SidebarMenuButton>
|
|
359
|
+
</DropdownMenuTrigger>
|
|
360
|
+
<DropdownMenuContent
|
|
361
|
+
className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
|
362
|
+
side={isMobile ? "bottom" : "right"}
|
|
363
|
+
align="end"
|
|
364
|
+
sideOffset={4}
|
|
365
|
+
>
|
|
366
|
+
<DropdownMenuLabel className="p-0 font-normal">
|
|
367
|
+
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
|
368
|
+
<Avatar className="h-8 w-8 rounded-lg">
|
|
369
|
+
<AvatarFallback className="rounded-lg">{sidebarData.data?.user?.charAt(0).toUpperCase()}</AvatarFallback>
|
|
370
|
+
</Avatar>
|
|
371
|
+
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
372
|
+
<span className="truncate font-medium">{sidebarData.data?.user}</span>
|
|
373
|
+
<span className="text-muted-foreground truncate text-xs">
|
|
374
|
+
{sidebarData.data?.userEmail ?? sidebarData.data?.user}
|
|
375
|
+
</span>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</DropdownMenuLabel>
|
|
379
|
+
<DropdownMenuSeparator />
|
|
380
|
+
<DropdownMenuGroup>
|
|
381
|
+
<DropdownMenuItem>
|
|
382
|
+
<UserCircle className="mr-2 size-4" />
|
|
383
|
+
Account
|
|
384
|
+
</DropdownMenuItem>
|
|
385
|
+
</DropdownMenuGroup>
|
|
386
|
+
</DropdownMenuContent>
|
|
387
|
+
</DropdownMenu>
|
|
388
|
+
</SidebarMenuItem>
|
|
389
|
+
</SidebarMenu>
|
|
390
|
+
</SidebarFooter>
|
|
391
|
+
</Sidebar>
|
|
392
|
+
)
|
|
393
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseAlignKit } from './plugins/align-base-kit';
|
|
2
|
+
import { BaseBasicBlocksKit } from './plugins/basic-blocks-base-kit';
|
|
3
|
+
import { BaseBasicMarksKit } from './plugins/basic-marks-base-kit';
|
|
4
|
+
import { BaseCalloutKit } from './plugins/callout-base-kit';
|
|
5
|
+
import { BaseCodeBlockKit } from './plugins/code-block-base-kit';
|
|
6
|
+
import { BaseColumnKit } from './plugins/column-base-kit';
|
|
7
|
+
import { BaseCommentKit } from './plugins/comment-base-kit';
|
|
8
|
+
import { BaseDateKit } from './plugins/date-base-kit';
|
|
9
|
+
import { BaseFontKit } from './plugins/font-base-kit';
|
|
10
|
+
import { BaseLineHeightKit } from './plugins/line-height-base-kit';
|
|
11
|
+
import { BaseLinkKit } from './plugins/link-base-kit';
|
|
12
|
+
import { BaseListKit } from './plugins/list-base-kit';
|
|
13
|
+
import { MarkdownKit } from './plugins/markdown-kit';
|
|
14
|
+
import { BaseMathKit } from './plugins/math-base-kit';
|
|
15
|
+
import { BaseMediaKit } from './plugins/media-base-kit';
|
|
16
|
+
import { BaseMentionKit } from './plugins/mention-base-kit';
|
|
17
|
+
import { BaseSuggestionKit } from './plugins/suggestion-base-kit';
|
|
18
|
+
import { BaseTableKit } from './plugins/table-base-kit';
|
|
19
|
+
import { BaseTocKit } from './plugins/toc-base-kit';
|
|
20
|
+
import { BaseToggleKit } from './plugins/toggle-base-kit';
|
|
21
|
+
|
|
22
|
+
export const BaseEditorKit = [
|
|
23
|
+
...BaseBasicBlocksKit,
|
|
24
|
+
...BaseCodeBlockKit,
|
|
25
|
+
...BaseTableKit,
|
|
26
|
+
...BaseToggleKit,
|
|
27
|
+
...BaseTocKit,
|
|
28
|
+
...BaseMediaKit,
|
|
29
|
+
...BaseCalloutKit,
|
|
30
|
+
...BaseColumnKit,
|
|
31
|
+
...BaseMathKit,
|
|
32
|
+
...BaseDateKit,
|
|
33
|
+
...BaseLinkKit,
|
|
34
|
+
...BaseMentionKit,
|
|
35
|
+
...BaseBasicMarksKit,
|
|
36
|
+
...BaseFontKit,
|
|
37
|
+
...BaseListKit,
|
|
38
|
+
...BaseAlignKit,
|
|
39
|
+
...BaseLineHeightKit,
|
|
40
|
+
...BaseCommentKit,
|
|
41
|
+
...BaseSuggestionKit,
|
|
42
|
+
...MarkdownKit,
|
|
43
|
+
];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { type Value, TrailingBlockPlugin } from 'platejs';
|
|
4
|
+
import { type TPlateEditor, useEditorRef } from 'platejs/react';
|
|
5
|
+
|
|
6
|
+
import { AlignKit } from './plugins/align-kit';
|
|
7
|
+
import { AutoformatKit } from './plugins/autoformat-kit';
|
|
8
|
+
import { BasicBlocksKit } from './plugins/basic-blocks-kit';
|
|
9
|
+
import { BasicMarksKit } from './plugins/basic-marks-kit';
|
|
10
|
+
import { BlockMenuKit } from './plugins/block-menu-kit';
|
|
11
|
+
import { BlockPlaceholderKit } from './plugins/block-placeholder-kit';
|
|
12
|
+
import { CalloutKit } from './plugins/callout-kit';
|
|
13
|
+
import { CodeBlockKit } from './plugins/code-block-kit';
|
|
14
|
+
import { ColumnKit } from './plugins/column-kit';
|
|
15
|
+
import { CommentKit } from './plugins/comment-kit';
|
|
16
|
+
import { CursorOverlayKit } from './plugins/cursor-overlay-kit';
|
|
17
|
+
import { DateKit } from './plugins/date-kit';
|
|
18
|
+
import { DiscussionKit } from './plugins/discussion-kit';
|
|
19
|
+
import { DndKit } from './plugins/dnd-kit';
|
|
20
|
+
import { DocxKit } from './plugins/docx-kit';
|
|
21
|
+
import { EmojiKit } from './plugins/emoji-kit';
|
|
22
|
+
import { ExitBreakKit } from './plugins/exit-break-kit';
|
|
23
|
+
import { FloatingToolbarKit } from './plugins/floating-toolbar-kit';
|
|
24
|
+
import { FontKit } from './plugins/font-kit';
|
|
25
|
+
import { LineHeightKit } from './plugins/line-height-kit';
|
|
26
|
+
import { LinkKit } from './plugins/link-kit';
|
|
27
|
+
import { ListKit } from './plugins/list-kit';
|
|
28
|
+
import { MarkdownKit } from './plugins/markdown-kit';
|
|
29
|
+
import { MathKit } from './plugins/math-kit';
|
|
30
|
+
import { MediaKit } from './plugins/media-kit';
|
|
31
|
+
import { MentionKit } from './plugins/mention-kit';
|
|
32
|
+
import { SlashKit } from './plugins/slash-kit';
|
|
33
|
+
import { SuggestionKit } from './plugins/suggestion-kit';
|
|
34
|
+
import { TableKit } from './plugins/table-kit';
|
|
35
|
+
import { TocKit } from './plugins/toc-kit';
|
|
36
|
+
import { ToggleKit } from './plugins/toggle-kit';
|
|
37
|
+
import { CodebaseSnippetPlugin } from './plugins/codebase-kit';
|
|
38
|
+
|
|
39
|
+
export const EditorKit = [
|
|
40
|
+
...BlockMenuKit,
|
|
41
|
+
|
|
42
|
+
// Elements
|
|
43
|
+
...BasicBlocksKit,
|
|
44
|
+
...CodeBlockKit,
|
|
45
|
+
...TableKit,
|
|
46
|
+
...ToggleKit,
|
|
47
|
+
...TocKit,
|
|
48
|
+
...MediaKit,
|
|
49
|
+
...CalloutKit,
|
|
50
|
+
...ColumnKit,
|
|
51
|
+
...MathKit,
|
|
52
|
+
...DateKit,
|
|
53
|
+
...LinkKit,
|
|
54
|
+
...MentionKit,
|
|
55
|
+
|
|
56
|
+
// Marks
|
|
57
|
+
...BasicMarksKit,
|
|
58
|
+
...FontKit,
|
|
59
|
+
|
|
60
|
+
// Block Style
|
|
61
|
+
...ListKit,
|
|
62
|
+
...AlignKit,
|
|
63
|
+
...LineHeightKit,
|
|
64
|
+
|
|
65
|
+
// Collaboration
|
|
66
|
+
...DiscussionKit,
|
|
67
|
+
...CommentKit,
|
|
68
|
+
...SuggestionKit,
|
|
69
|
+
|
|
70
|
+
// Editing
|
|
71
|
+
...SlashKit,
|
|
72
|
+
...AutoformatKit,
|
|
73
|
+
...CursorOverlayKit,
|
|
74
|
+
...DndKit,
|
|
75
|
+
...EmojiKit,
|
|
76
|
+
...ExitBreakKit,
|
|
77
|
+
TrailingBlockPlugin,
|
|
78
|
+
|
|
79
|
+
// Parsers
|
|
80
|
+
...DocxKit,
|
|
81
|
+
...MarkdownKit,
|
|
82
|
+
|
|
83
|
+
// UI
|
|
84
|
+
...BlockPlaceholderKit,
|
|
85
|
+
...FloatingToolbarKit,
|
|
86
|
+
|
|
87
|
+
// Custom
|
|
88
|
+
CodebaseSnippetPlugin,
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
export type MyEditor = TPlateEditor<Value, (typeof EditorKit)[number]>;
|
|
92
|
+
|
|
93
|
+
export const useEditor = () => useEditorRef<MyEditor>();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseTextAlignPlugin } from '@platejs/basic-styles';
|
|
2
|
+
import { KEYS } from 'platejs';
|
|
3
|
+
|
|
4
|
+
export const BaseAlignKit = [
|
|
5
|
+
BaseTextAlignPlugin.configure({
|
|
6
|
+
inject: {
|
|
7
|
+
nodeProps: {
|
|
8
|
+
defaultNodeValue: 'start',
|
|
9
|
+
nodeKey: 'align',
|
|
10
|
+
styleKey: 'textAlign',
|
|
11
|
+
validNodeValues: ['start', 'left', 'center', 'right', 'end', 'justify'],
|
|
12
|
+
},
|
|
13
|
+
targetPlugins: [...KEYS.heading, KEYS.p, KEYS.img, KEYS.mediaEmbed],
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { TextAlignPlugin } from '@platejs/basic-styles/react';
|
|
4
|
+
import { KEYS } from 'platejs';
|
|
5
|
+
|
|
6
|
+
export const AlignKit = [
|
|
7
|
+
TextAlignPlugin.configure({
|
|
8
|
+
inject: {
|
|
9
|
+
nodeProps: {
|
|
10
|
+
defaultNodeValue: 'start',
|
|
11
|
+
nodeKey: 'align',
|
|
12
|
+
styleKey: 'textAlign',
|
|
13
|
+
validNodeValues: ['start', 'left', 'center', 'right', 'end', 'justify'],
|
|
14
|
+
},
|
|
15
|
+
targetPlugins: [...KEYS.heading, KEYS.p, KEYS.img, KEYS.mediaEmbed],
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
];
|