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,255 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
|
3
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function DropdownMenu({
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
10
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function DropdownMenuPortal({
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
16
|
+
return (
|
|
17
|
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DropdownMenuTrigger({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
24
|
+
return (
|
|
25
|
+
<DropdownMenuPrimitive.Trigger
|
|
26
|
+
data-slot="dropdown-menu-trigger"
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function DropdownMenuContent({
|
|
33
|
+
className,
|
|
34
|
+
sideOffset = 4,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
37
|
+
return (
|
|
38
|
+
<DropdownMenuPrimitive.Portal>
|
|
39
|
+
<DropdownMenuPrimitive.Content
|
|
40
|
+
data-slot="dropdown-menu-content"
|
|
41
|
+
sideOffset={sideOffset}
|
|
42
|
+
className={cn(
|
|
43
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
</DropdownMenuPrimitive.Portal>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DropdownMenuGroup({
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
55
|
+
return (
|
|
56
|
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function DropdownMenuItem({
|
|
61
|
+
className,
|
|
62
|
+
inset,
|
|
63
|
+
variant = "default",
|
|
64
|
+
...props
|
|
65
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
66
|
+
inset?: boolean
|
|
67
|
+
variant?: "default" | "destructive"
|
|
68
|
+
}) {
|
|
69
|
+
return (
|
|
70
|
+
<DropdownMenuPrimitive.Item
|
|
71
|
+
data-slot="dropdown-menu-item"
|
|
72
|
+
data-inset={inset}
|
|
73
|
+
data-variant={variant}
|
|
74
|
+
className={cn(
|
|
75
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
76
|
+
className
|
|
77
|
+
)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DropdownMenuCheckboxItem({
|
|
84
|
+
className,
|
|
85
|
+
children,
|
|
86
|
+
checked,
|
|
87
|
+
...props
|
|
88
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
|
89
|
+
return (
|
|
90
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
91
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
92
|
+
className={cn(
|
|
93
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
94
|
+
className
|
|
95
|
+
)}
|
|
96
|
+
checked={checked}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
100
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
101
|
+
<CheckIcon className="size-4" />
|
|
102
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
103
|
+
</span>
|
|
104
|
+
{children}
|
|
105
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function DropdownMenuRadioGroup({
|
|
110
|
+
...props
|
|
111
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
112
|
+
return (
|
|
113
|
+
<DropdownMenuPrimitive.RadioGroup
|
|
114
|
+
data-slot="dropdown-menu-radio-group"
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function DropdownMenuRadioItem({
|
|
121
|
+
className,
|
|
122
|
+
children,
|
|
123
|
+
...props
|
|
124
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
|
125
|
+
return (
|
|
126
|
+
<DropdownMenuPrimitive.RadioItem
|
|
127
|
+
data-slot="dropdown-menu-radio-item"
|
|
128
|
+
className={cn(
|
|
129
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
130
|
+
className
|
|
131
|
+
)}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
135
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
136
|
+
<CircleIcon className="size-2 fill-current" />
|
|
137
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
138
|
+
</span>
|
|
139
|
+
{children}
|
|
140
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function DropdownMenuLabel({
|
|
145
|
+
className,
|
|
146
|
+
inset,
|
|
147
|
+
...props
|
|
148
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
149
|
+
inset?: boolean
|
|
150
|
+
}) {
|
|
151
|
+
return (
|
|
152
|
+
<DropdownMenuPrimitive.Label
|
|
153
|
+
data-slot="dropdown-menu-label"
|
|
154
|
+
data-inset={inset}
|
|
155
|
+
className={cn(
|
|
156
|
+
"px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
|
|
157
|
+
className
|
|
158
|
+
)}
|
|
159
|
+
{...props}
|
|
160
|
+
/>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function DropdownMenuSeparator({
|
|
165
|
+
className,
|
|
166
|
+
...props
|
|
167
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
168
|
+
return (
|
|
169
|
+
<DropdownMenuPrimitive.Separator
|
|
170
|
+
data-slot="dropdown-menu-separator"
|
|
171
|
+
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
|
172
|
+
{...props}
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function DropdownMenuShortcut({
|
|
178
|
+
className,
|
|
179
|
+
...props
|
|
180
|
+
}: React.ComponentProps<"span">) {
|
|
181
|
+
return (
|
|
182
|
+
<span
|
|
183
|
+
data-slot="dropdown-menu-shortcut"
|
|
184
|
+
className={cn(
|
|
185
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
186
|
+
className
|
|
187
|
+
)}
|
|
188
|
+
{...props}
|
|
189
|
+
/>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function DropdownMenuSub({
|
|
194
|
+
...props
|
|
195
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
196
|
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function DropdownMenuSubTrigger({
|
|
200
|
+
className,
|
|
201
|
+
inset,
|
|
202
|
+
children,
|
|
203
|
+
...props
|
|
204
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
205
|
+
inset?: boolean
|
|
206
|
+
}) {
|
|
207
|
+
return (
|
|
208
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
209
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
210
|
+
data-inset={inset}
|
|
211
|
+
className={cn(
|
|
212
|
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
213
|
+
className
|
|
214
|
+
)}
|
|
215
|
+
{...props}
|
|
216
|
+
>
|
|
217
|
+
{children}
|
|
218
|
+
<ChevronRightIcon className="ml-auto size-4" />
|
|
219
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function DropdownMenuSubContent({
|
|
224
|
+
className,
|
|
225
|
+
...props
|
|
226
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
227
|
+
return (
|
|
228
|
+
<DropdownMenuPrimitive.SubContent
|
|
229
|
+
data-slot="dropdown-menu-sub-content"
|
|
230
|
+
className={cn(
|
|
231
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
|
232
|
+
className
|
|
233
|
+
)}
|
|
234
|
+
{...props}
|
|
235
|
+
/>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export {
|
|
240
|
+
DropdownMenu,
|
|
241
|
+
DropdownMenuPortal,
|
|
242
|
+
DropdownMenuTrigger,
|
|
243
|
+
DropdownMenuContent,
|
|
244
|
+
DropdownMenuGroup,
|
|
245
|
+
DropdownMenuLabel,
|
|
246
|
+
DropdownMenuItem,
|
|
247
|
+
DropdownMenuCheckboxItem,
|
|
248
|
+
DropdownMenuRadioGroup,
|
|
249
|
+
DropdownMenuRadioItem,
|
|
250
|
+
DropdownMenuSeparator,
|
|
251
|
+
DropdownMenuShortcut,
|
|
252
|
+
DropdownMenuSub,
|
|
253
|
+
DropdownMenuSubTrigger,
|
|
254
|
+
DropdownMenuSubContent,
|
|
255
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Icons from 'lucide-react';
|
|
2
|
+
import type { LucideProps } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
export type LucideIconName = keyof typeof Icons;
|
|
5
|
+
|
|
6
|
+
export function DynamicIcon({
|
|
7
|
+
name,
|
|
8
|
+
...props
|
|
9
|
+
}: { name: LucideIconName } & LucideProps) {
|
|
10
|
+
const Icon = (Icons[name] as React.ComponentType<LucideProps>) || Icons.FileIcon;
|
|
11
|
+
return <Icon {...props} />;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { type PlateStaticProps, PlateStatic } from 'platejs/static';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
export const editorVariants = cva(
|
|
9
|
+
cn(
|
|
10
|
+
'group/editor',
|
|
11
|
+
'relative w-full cursor-text select-text overflow-x-hidden whitespace-pre-wrap break-words',
|
|
12
|
+
'rounded-md ring-offset-background focus-visible:outline-none',
|
|
13
|
+
'placeholder:text-muted-foreground/80 **:data-slate-placeholder:top-[auto_!important] **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!',
|
|
14
|
+
'[&_strong]:font-bold'
|
|
15
|
+
),
|
|
16
|
+
{
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
variant: 'none',
|
|
19
|
+
},
|
|
20
|
+
variants: {
|
|
21
|
+
disabled: {
|
|
22
|
+
true: 'cursor-not-allowed opacity-50',
|
|
23
|
+
},
|
|
24
|
+
focused: {
|
|
25
|
+
true: 'ring-2 ring-ring ring-offset-2',
|
|
26
|
+
},
|
|
27
|
+
variant: {
|
|
28
|
+
ai: 'w-full px-0 text-base md:text-sm',
|
|
29
|
+
aiChat:
|
|
30
|
+
'max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-5 py-3 text-base md:text-sm',
|
|
31
|
+
default:
|
|
32
|
+
'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
|
|
33
|
+
demo: 'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
|
|
34
|
+
fullWidth: 'size-full px-16 pt-4 pb-72 text-base sm:px-24',
|
|
35
|
+
none: '',
|
|
36
|
+
select: 'px-3 py-2 text-base data-readonly:w-fit',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export function EditorStatic({
|
|
43
|
+
className,
|
|
44
|
+
variant,
|
|
45
|
+
...props
|
|
46
|
+
}: PlateStaticProps & VariantProps<typeof editorVariants>) {
|
|
47
|
+
return (
|
|
48
|
+
<PlateStatic
|
|
49
|
+
className={cn(editorVariants({ variant }), className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
4
|
+
import type { PlateContentProps, PlateViewProps } from 'platejs/react';
|
|
5
|
+
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import { PlateContainer, PlateContent, PlateView } from 'platejs/react';
|
|
8
|
+
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
const editorContainerVariants = cva(
|
|
12
|
+
'relative w-full cursor-text select-text overflow-y-auto caret-primary selection:bg-brand/25 focus-visible:outline-none [&_.slate-selection-area]:z-50 [&_.slate-selection-area]:border [&_.slate-selection-area]:border-brand/25 [&_.slate-selection-area]:bg-brand/15',
|
|
13
|
+
{
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: 'default',
|
|
16
|
+
},
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
comment: cn(
|
|
20
|
+
'flex flex-wrap justify-between gap-1 px-2 py-0.5 text-sm',
|
|
21
|
+
'rounded-md border-[1.5px] border-transparent bg-transparent',
|
|
22
|
+
'has-[[data-slate-editor]:focus]:border-brand/50 has-[[data-slate-editor]:focus]:ring-2 has-[[data-slate-editor]:focus]:ring-brand/30',
|
|
23
|
+
'has-aria-disabled:border-input has-aria-disabled:bg-muted'
|
|
24
|
+
),
|
|
25
|
+
default: 'h-full',
|
|
26
|
+
demo: 'h-[650px]',
|
|
27
|
+
select: cn(
|
|
28
|
+
'group rounded-md border border-input ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2',
|
|
29
|
+
'has-data-readonly:w-fit has-data-readonly:cursor-default has-data-readonly:border-transparent has-data-readonly:focus-within:[box-shadow:none]'
|
|
30
|
+
),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export function EditorContainer({
|
|
37
|
+
className,
|
|
38
|
+
variant,
|
|
39
|
+
...props
|
|
40
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof editorContainerVariants>) {
|
|
41
|
+
return (
|
|
42
|
+
<PlateContainer
|
|
43
|
+
className={cn(
|
|
44
|
+
'ignore-click-outside/toolbar',
|
|
45
|
+
editorContainerVariants({ variant }),
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const editorVariants = cva(
|
|
54
|
+
cn(
|
|
55
|
+
'group/editor',
|
|
56
|
+
'relative w-full cursor-text select-text overflow-x-hidden whitespace-pre-wrap break-words',
|
|
57
|
+
'rounded-md ring-offset-background focus-visible:outline-none',
|
|
58
|
+
'**:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 placeholder:text-muted-foreground/80 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!',
|
|
59
|
+
'[&_strong]:font-bold'
|
|
60
|
+
),
|
|
61
|
+
{
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
variant: 'default',
|
|
64
|
+
},
|
|
65
|
+
variants: {
|
|
66
|
+
disabled: {
|
|
67
|
+
true: 'cursor-not-allowed opacity-50',
|
|
68
|
+
},
|
|
69
|
+
focused: {
|
|
70
|
+
true: 'ring-2 ring-ring ring-offset-2',
|
|
71
|
+
},
|
|
72
|
+
variant: {
|
|
73
|
+
ai: 'w-full px-0 text-base md:text-sm',
|
|
74
|
+
aiChat:
|
|
75
|
+
'max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-3 py-2 text-base md:text-sm',
|
|
76
|
+
comment: cn('rounded-none border-none bg-transparent text-sm'),
|
|
77
|
+
default:
|
|
78
|
+
'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
|
|
79
|
+
demo: 'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
|
|
80
|
+
fullWidth: 'size-full px-16 pt-4 pb-72 text-base sm:px-24',
|
|
81
|
+
none: '',
|
|
82
|
+
select: 'px-3 py-2 text-base data-readonly:w-fit',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export type EditorProps = PlateContentProps &
|
|
89
|
+
VariantProps<typeof editorVariants>;
|
|
90
|
+
|
|
91
|
+
export const Editor = ({
|
|
92
|
+
className,
|
|
93
|
+
disabled,
|
|
94
|
+
focused,
|
|
95
|
+
variant,
|
|
96
|
+
ref,
|
|
97
|
+
...props
|
|
98
|
+
}: EditorProps & { ref?: React.RefObject<HTMLDivElement | null> }) => (
|
|
99
|
+
<PlateContent
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn(
|
|
102
|
+
editorVariants({
|
|
103
|
+
disabled,
|
|
104
|
+
focused,
|
|
105
|
+
variant,
|
|
106
|
+
}),
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
disabled={disabled}
|
|
110
|
+
disableDefaultStyles
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
Editor.displayName = 'Editor';
|
|
116
|
+
|
|
117
|
+
export function EditorView({
|
|
118
|
+
className,
|
|
119
|
+
variant,
|
|
120
|
+
...props
|
|
121
|
+
}: PlateViewProps & VariantProps<typeof editorVariants>) {
|
|
122
|
+
return (
|
|
123
|
+
<PlateView
|
|
124
|
+
{...props}
|
|
125
|
+
className={cn(editorVariants({ variant }), className)}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
EditorView.displayName = 'EditorView';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { PlateElementProps } from 'platejs/react';
|
|
4
|
+
|
|
5
|
+
import { EmojiInlineIndexSearch, insertEmoji } from '@platejs/emoji';
|
|
6
|
+
import { EmojiPlugin } from '@platejs/emoji/react';
|
|
7
|
+
import { PlateElement, usePluginOption } from 'platejs/react';
|
|
8
|
+
|
|
9
|
+
import { useDebounce } from '@/hooks/use-debounce';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
InlineCombobox,
|
|
13
|
+
InlineComboboxContent,
|
|
14
|
+
InlineComboboxEmpty,
|
|
15
|
+
InlineComboboxGroup,
|
|
16
|
+
InlineComboboxInput,
|
|
17
|
+
InlineComboboxItem,
|
|
18
|
+
} from './inline-combobox';
|
|
19
|
+
|
|
20
|
+
const TRAILING_COLON_REGEX = /:$/;
|
|
21
|
+
|
|
22
|
+
export function EmojiInputElement(props: PlateElementProps) {
|
|
23
|
+
const { children, editor, element } = props;
|
|
24
|
+
const data = usePluginOption(EmojiPlugin, 'data')!;
|
|
25
|
+
const [value, setValue] = React.useState('');
|
|
26
|
+
const debouncedValue = useDebounce(value, 100);
|
|
27
|
+
const isPending = value !== debouncedValue;
|
|
28
|
+
|
|
29
|
+
const filteredEmojis = React.useMemo(() => {
|
|
30
|
+
if (debouncedValue.trim().length === 0) return [];
|
|
31
|
+
|
|
32
|
+
return EmojiInlineIndexSearch.getInstance(data)
|
|
33
|
+
.search(debouncedValue.replace(TRAILING_COLON_REGEX, ''))
|
|
34
|
+
.get();
|
|
35
|
+
}, [data, debouncedValue]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<PlateElement as="span" {...props}>
|
|
39
|
+
<InlineCombobox
|
|
40
|
+
value={value}
|
|
41
|
+
element={element}
|
|
42
|
+
filter={false}
|
|
43
|
+
setValue={setValue}
|
|
44
|
+
trigger=":"
|
|
45
|
+
hideWhenNoValue
|
|
46
|
+
>
|
|
47
|
+
<InlineComboboxInput />
|
|
48
|
+
|
|
49
|
+
<InlineComboboxContent>
|
|
50
|
+
{!isPending && <InlineComboboxEmpty>No results</InlineComboboxEmpty>}
|
|
51
|
+
|
|
52
|
+
<InlineComboboxGroup>
|
|
53
|
+
{filteredEmojis.map((emoji) => (
|
|
54
|
+
<InlineComboboxItem
|
|
55
|
+
key={emoji.id}
|
|
56
|
+
value={emoji.name}
|
|
57
|
+
onClick={() => insertEmoji(editor, emoji)}
|
|
58
|
+
>
|
|
59
|
+
{emoji.skins[0].native} {emoji.name}
|
|
60
|
+
</InlineComboboxItem>
|
|
61
|
+
))}
|
|
62
|
+
</InlineComboboxGroup>
|
|
63
|
+
</InlineComboboxContent>
|
|
64
|
+
</InlineCombobox>
|
|
65
|
+
|
|
66
|
+
{children}
|
|
67
|
+
</PlateElement>
|
|
68
|
+
);
|
|
69
|
+
}
|