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,13 @@
|
|
|
1
|
+
import { cn } from "@/lib/utils"
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton }
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { PlateEditor, PlateElementProps } from 'platejs/react';
|
|
2
|
+
import {
|
|
3
|
+
CalendarIcon,
|
|
4
|
+
ChevronRightIcon,
|
|
5
|
+
Code2,
|
|
6
|
+
Columns3Icon,
|
|
7
|
+
Heading1Icon,
|
|
8
|
+
Heading2Icon,
|
|
9
|
+
Heading3Icon,
|
|
10
|
+
LightbulbIcon,
|
|
11
|
+
ListIcon,
|
|
12
|
+
ListOrdered,
|
|
13
|
+
PilcrowIcon,
|
|
14
|
+
Quote,
|
|
15
|
+
RadicalIcon,
|
|
16
|
+
Square,
|
|
17
|
+
Table,
|
|
18
|
+
TableOfContentsIcon,
|
|
19
|
+
} from 'lucide-react';
|
|
20
|
+
import { type TComboboxInputElement, KEYS } from 'platejs';
|
|
21
|
+
import { PlateElement } from 'platejs/react';
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
insertBlock,
|
|
25
|
+
insertInlineElement,
|
|
26
|
+
} from '@/components/editor/transforms';
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
InlineCombobox,
|
|
30
|
+
InlineComboboxContent,
|
|
31
|
+
InlineComboboxEmpty,
|
|
32
|
+
InlineComboboxGroup,
|
|
33
|
+
InlineComboboxGroupLabel,
|
|
34
|
+
InlineComboboxInput,
|
|
35
|
+
InlineComboboxItem,
|
|
36
|
+
} from './inline-combobox';
|
|
37
|
+
import { CodebaseSnippetType } from '../editor/plugins/codebase-kit';
|
|
38
|
+
|
|
39
|
+
type Group = {
|
|
40
|
+
group: string;
|
|
41
|
+
items: {
|
|
42
|
+
icon: React.ReactNode;
|
|
43
|
+
value: string;
|
|
44
|
+
onSelect: (editor: PlateEditor, value: string) => void;
|
|
45
|
+
className?: string;
|
|
46
|
+
focusEditor?: boolean;
|
|
47
|
+
keywords?: string[];
|
|
48
|
+
label?: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const groups: Group[] = [
|
|
53
|
+
{
|
|
54
|
+
group: 'Basic blocks',
|
|
55
|
+
items: [
|
|
56
|
+
{
|
|
57
|
+
icon: <PilcrowIcon />,
|
|
58
|
+
keywords: ['paragraph'],
|
|
59
|
+
label: 'Text',
|
|
60
|
+
value: KEYS.p,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
icon: <Heading1Icon />,
|
|
64
|
+
keywords: ['title', 'h1'],
|
|
65
|
+
label: 'Heading 1',
|
|
66
|
+
value: KEYS.h1,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
icon: <Heading2Icon />,
|
|
70
|
+
keywords: ['subtitle', 'h2'],
|
|
71
|
+
label: 'Heading 2',
|
|
72
|
+
value: KEYS.h2,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
icon: <Heading3Icon />,
|
|
76
|
+
keywords: ['subtitle', 'h3'],
|
|
77
|
+
label: 'Heading 3',
|
|
78
|
+
value: KEYS.h3,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
icon: <ListIcon />,
|
|
82
|
+
keywords: ['unordered', 'ul', '-'],
|
|
83
|
+
label: 'Bulleted list',
|
|
84
|
+
value: KEYS.ul,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
icon: <ListOrdered />,
|
|
88
|
+
keywords: ['ordered', 'ol', '1'],
|
|
89
|
+
label: 'Numbered list',
|
|
90
|
+
value: KEYS.ol,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: <Square />,
|
|
94
|
+
keywords: ['checklist', 'task', 'checkbox', '[]'],
|
|
95
|
+
label: 'To-do list',
|
|
96
|
+
value: KEYS.listTodo,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
icon: <ChevronRightIcon />,
|
|
100
|
+
keywords: ['collapsible', 'expandable'],
|
|
101
|
+
label: 'Toggle',
|
|
102
|
+
value: KEYS.toggle,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
icon: <Code2 />,
|
|
106
|
+
keywords: ['```'],
|
|
107
|
+
label: 'Code Block',
|
|
108
|
+
value: KEYS.codeBlock,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
icon: <Table />,
|
|
112
|
+
label: 'Table',
|
|
113
|
+
value: KEYS.table,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
icon: <Quote />,
|
|
117
|
+
keywords: ['citation', 'blockquote', 'quote', '>'],
|
|
118
|
+
label: 'Blockquote',
|
|
119
|
+
value: KEYS.blockquote,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: 'Insert a highlighted block.',
|
|
123
|
+
icon: <LightbulbIcon />,
|
|
124
|
+
keywords: ['note'],
|
|
125
|
+
label: 'Callout',
|
|
126
|
+
value: KEYS.callout,
|
|
127
|
+
},
|
|
128
|
+
].map((item) => ({
|
|
129
|
+
...item,
|
|
130
|
+
onSelect: (editor, value) => {
|
|
131
|
+
insertBlock(editor, value, { upsert: true });
|
|
132
|
+
},
|
|
133
|
+
})),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
group: 'Advanced blocks',
|
|
137
|
+
items: [
|
|
138
|
+
{
|
|
139
|
+
icon: <TableOfContentsIcon />,
|
|
140
|
+
keywords: ['toc'],
|
|
141
|
+
label: 'Table of contents',
|
|
142
|
+
value: KEYS.toc,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
icon: <Columns3Icon />,
|
|
146
|
+
label: '3 columns',
|
|
147
|
+
value: 'action_three_columns',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
focusEditor: false,
|
|
151
|
+
icon: <RadicalIcon />,
|
|
152
|
+
label: 'Equation',
|
|
153
|
+
value: KEYS.equation,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
icon: <Code2 />,
|
|
157
|
+
label: 'Codebase Snippet',
|
|
158
|
+
value: CodebaseSnippetType,
|
|
159
|
+
},
|
|
160
|
+
].map((item) => ({
|
|
161
|
+
...item,
|
|
162
|
+
onSelect: (editor, value) => {
|
|
163
|
+
insertBlock(editor, value, { upsert: true });
|
|
164
|
+
},
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
group: 'Inline',
|
|
169
|
+
items: [
|
|
170
|
+
{
|
|
171
|
+
focusEditor: true,
|
|
172
|
+
icon: <CalendarIcon />,
|
|
173
|
+
keywords: ['time'],
|
|
174
|
+
label: 'Date',
|
|
175
|
+
value: KEYS.date,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
focusEditor: false,
|
|
179
|
+
icon: <RadicalIcon />,
|
|
180
|
+
label: 'Inline Equation',
|
|
181
|
+
value: KEYS.inlineEquation,
|
|
182
|
+
},
|
|
183
|
+
].map((item) => ({
|
|
184
|
+
...item,
|
|
185
|
+
onSelect: (editor, value) => {
|
|
186
|
+
insertInlineElement(editor, value);
|
|
187
|
+
},
|
|
188
|
+
})),
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
export function SlashInputElement(
|
|
193
|
+
props: PlateElementProps<TComboboxInputElement>
|
|
194
|
+
) {
|
|
195
|
+
const { editor, element } = props;
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<PlateElement {...props} as="span">
|
|
199
|
+
<InlineCombobox element={element} trigger="/">
|
|
200
|
+
<InlineComboboxInput />
|
|
201
|
+
|
|
202
|
+
<InlineComboboxContent>
|
|
203
|
+
<InlineComboboxEmpty>No results</InlineComboboxEmpty>
|
|
204
|
+
|
|
205
|
+
{groups.map(({ group, items }) => (
|
|
206
|
+
<InlineComboboxGroup key={group}>
|
|
207
|
+
<InlineComboboxGroupLabel>{group}</InlineComboboxGroupLabel>
|
|
208
|
+
|
|
209
|
+
{items.map(
|
|
210
|
+
({ focusEditor, icon, keywords, label, value, onSelect }) => (
|
|
211
|
+
<InlineComboboxItem
|
|
212
|
+
key={value}
|
|
213
|
+
value={value}
|
|
214
|
+
onClick={() => onSelect(editor, value)}
|
|
215
|
+
label={label}
|
|
216
|
+
focusEditor={focusEditor}
|
|
217
|
+
group={group}
|
|
218
|
+
keywords={keywords}
|
|
219
|
+
>
|
|
220
|
+
<div className="mr-2 text-muted-foreground">{icon}</div>
|
|
221
|
+
{label ?? value}
|
|
222
|
+
</InlineComboboxItem>
|
|
223
|
+
)
|
|
224
|
+
)}
|
|
225
|
+
</InlineComboboxGroup>
|
|
226
|
+
))}
|
|
227
|
+
</InlineComboboxContent>
|
|
228
|
+
</InlineCombobox>
|
|
229
|
+
|
|
230
|
+
{props.children}
|
|
231
|
+
</PlateElement>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CircleCheckIcon,
|
|
3
|
+
InfoIcon,
|
|
4
|
+
Loader2Icon,
|
|
5
|
+
OctagonXIcon,
|
|
6
|
+
TriangleAlertIcon,
|
|
7
|
+
} from "lucide-react"
|
|
8
|
+
import { useTheme } from "next-themes"
|
|
9
|
+
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
|
10
|
+
|
|
11
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
12
|
+
const { theme = "system" } = useTheme()
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Sonner
|
|
16
|
+
theme={theme as ToasterProps["theme"]}
|
|
17
|
+
className="toaster group"
|
|
18
|
+
icons={{
|
|
19
|
+
success: <CircleCheckIcon className="size-4" />,
|
|
20
|
+
info: <InfoIcon className="size-4" />,
|
|
21
|
+
warning: <TriangleAlertIcon className="size-4" />,
|
|
22
|
+
error: <OctagonXIcon className="size-4" />,
|
|
23
|
+
loading: <Loader2Icon className="size-4 animate-spin" />,
|
|
24
|
+
}}
|
|
25
|
+
style={
|
|
26
|
+
{
|
|
27
|
+
"--normal-bg": "var(--popover)",
|
|
28
|
+
"--normal-text": "var(--popover-foreground)",
|
|
29
|
+
"--normal-border": "var(--border)",
|
|
30
|
+
"--border-radius": "var(--radius)",
|
|
31
|
+
} as React.CSSProperties
|
|
32
|
+
}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { Toaster }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TSuggestionText } from 'platejs';
|
|
2
|
+
import type { SlateLeafProps } from 'platejs/static';
|
|
3
|
+
|
|
4
|
+
import { BaseSuggestionPlugin } from '@platejs/suggestion';
|
|
5
|
+
import { SlateLeaf } from 'platejs/static';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
export function SuggestionLeafStatic(props: SlateLeafProps<TSuggestionText>) {
|
|
10
|
+
const { editor, leaf } = props;
|
|
11
|
+
|
|
12
|
+
const dataList = editor
|
|
13
|
+
.getApi(BaseSuggestionPlugin)
|
|
14
|
+
.suggestion.dataList(leaf);
|
|
15
|
+
const hasRemove = dataList.some((data) => data.type === 'remove');
|
|
16
|
+
const diffOperation = { type: hasRemove ? 'delete' : 'insert' } as const;
|
|
17
|
+
|
|
18
|
+
const Component = ({ delete: 'del', insert: 'ins', update: 'span' } as const)[
|
|
19
|
+
diffOperation.type
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<SlateLeaf
|
|
24
|
+
{...props}
|
|
25
|
+
as={Component}
|
|
26
|
+
className={cn(
|
|
27
|
+
'border-b-2 border-b-brand/[.24] bg-brand/[.08] text-brand/80 no-underline transition-colors duration-200',
|
|
28
|
+
hasRemove &&
|
|
29
|
+
'border-b-gray-300 bg-gray-300/25 text-gray-400 line-through'
|
|
30
|
+
)}
|
|
31
|
+
>
|
|
32
|
+
{props.children}
|
|
33
|
+
</SlateLeaf>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { TSuggestionData, TSuggestionText } from 'platejs';
|
|
4
|
+
import type { PlateLeafProps, RenderNodeWrapper } from 'platejs/react';
|
|
5
|
+
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import { CornerDownLeftIcon } from 'lucide-react';
|
|
8
|
+
import { PlateLeaf, useEditorPlugin, usePluginOption } from 'platejs/react';
|
|
9
|
+
|
|
10
|
+
import { cn } from '@/lib/utils';
|
|
11
|
+
import {
|
|
12
|
+
type SuggestionConfig,
|
|
13
|
+
suggestionPlugin,
|
|
14
|
+
} from '@/components/editor/plugins/suggestion-kit';
|
|
15
|
+
|
|
16
|
+
const suggestionVariants = cva(
|
|
17
|
+
cn(
|
|
18
|
+
'bg-emerald-100 text-emerald-700 no-underline transition-colors duration-200'
|
|
19
|
+
),
|
|
20
|
+
{
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
insertActive: false,
|
|
23
|
+
remove: false,
|
|
24
|
+
removeActive: false,
|
|
25
|
+
},
|
|
26
|
+
variants: {
|
|
27
|
+
insertActive: {
|
|
28
|
+
false: '',
|
|
29
|
+
true: 'bg-emerald-200/80',
|
|
30
|
+
},
|
|
31
|
+
remove: {
|
|
32
|
+
false: '',
|
|
33
|
+
true: 'bg-red-100 text-red-700',
|
|
34
|
+
},
|
|
35
|
+
removeActive: {
|
|
36
|
+
false: '',
|
|
37
|
+
true: 'bg-red-200/80 no-underline',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export function SuggestionLeaf(props: PlateLeafProps<TSuggestionText>) {
|
|
44
|
+
const { api, setOption } = useEditorPlugin(suggestionPlugin);
|
|
45
|
+
const leaf = props.leaf;
|
|
46
|
+
|
|
47
|
+
const leafId: string = api.suggestion.nodeId(leaf) ?? '';
|
|
48
|
+
const activeSuggestionId = usePluginOption(suggestionPlugin, 'activeId');
|
|
49
|
+
const hoverSuggestionId = usePluginOption(suggestionPlugin, 'hoverId');
|
|
50
|
+
const dataList = api.suggestion.dataList(leaf);
|
|
51
|
+
|
|
52
|
+
const hasRemove = dataList.some((data) => data.type === 'remove');
|
|
53
|
+
const hasActive = dataList.some((data) => data.id === activeSuggestionId);
|
|
54
|
+
const hasHover = dataList.some((data) => data.id === hoverSuggestionId);
|
|
55
|
+
|
|
56
|
+
const diffOperation = { type: hasRemove ? 'delete' : 'insert' } as const;
|
|
57
|
+
|
|
58
|
+
const Component = ({ delete: 'del', insert: 'ins', update: 'span' } as const)[
|
|
59
|
+
diffOperation.type
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<PlateLeaf
|
|
64
|
+
{...props}
|
|
65
|
+
as={Component}
|
|
66
|
+
className={cn(
|
|
67
|
+
suggestionVariants({
|
|
68
|
+
insertActive: hasActive || hasHover,
|
|
69
|
+
remove: hasRemove,
|
|
70
|
+
removeActive: (hasActive || hasHover) && hasRemove,
|
|
71
|
+
})
|
|
72
|
+
)}
|
|
73
|
+
attributes={{
|
|
74
|
+
...props.attributes,
|
|
75
|
+
onMouseEnter: () => setOption('hoverId', leafId),
|
|
76
|
+
onMouseLeave: () => setOption('hoverId', null),
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{props.children}
|
|
80
|
+
</PlateLeaf>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
export const SuggestionLineBreak: RenderNodeWrapper<SuggestionConfig> = ({
|
|
84
|
+
api,
|
|
85
|
+
element,
|
|
86
|
+
}) => {
|
|
87
|
+
if (!api.suggestion.isBlockSuggestion(element)) return;
|
|
88
|
+
|
|
89
|
+
const suggestionData = element.suggestion;
|
|
90
|
+
|
|
91
|
+
return function Component({ children }) {
|
|
92
|
+
return (
|
|
93
|
+
<SuggestionLineBreakContent suggestionData={suggestionData}>
|
|
94
|
+
{children}
|
|
95
|
+
</SuggestionLineBreakContent>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function SuggestionLineBreakContent({
|
|
101
|
+
children,
|
|
102
|
+
suggestionData,
|
|
103
|
+
}: {
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
suggestionData: TSuggestionData;
|
|
106
|
+
}) {
|
|
107
|
+
const { isLineBreak, type } = suggestionData;
|
|
108
|
+
const isRemove = type === 'remove';
|
|
109
|
+
const isInsert = type === 'insert';
|
|
110
|
+
|
|
111
|
+
const activeSuggestionId = usePluginOption(suggestionPlugin, 'activeId');
|
|
112
|
+
const hoverSuggestionId = usePluginOption(suggestionPlugin, 'hoverId');
|
|
113
|
+
|
|
114
|
+
const isActive = activeSuggestionId === suggestionData.id;
|
|
115
|
+
const isHover = hoverSuggestionId === suggestionData.id;
|
|
116
|
+
|
|
117
|
+
const spanRef = React.useRef<HTMLSpanElement>(null);
|
|
118
|
+
const { setOption } = useEditorPlugin(suggestionPlugin);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
{isLineBreak ? (
|
|
123
|
+
<>
|
|
124
|
+
{children}
|
|
125
|
+
<span
|
|
126
|
+
ref={spanRef}
|
|
127
|
+
className={cn(
|
|
128
|
+
'absolute text-justify',
|
|
129
|
+
suggestionVariants({
|
|
130
|
+
insertActive: isInsert && (isActive || isHover),
|
|
131
|
+
remove: isRemove,
|
|
132
|
+
removeActive: (isActive || isHover) && isRemove,
|
|
133
|
+
})
|
|
134
|
+
)}
|
|
135
|
+
style={{
|
|
136
|
+
bottom: 3.5,
|
|
137
|
+
height: 21,
|
|
138
|
+
}}
|
|
139
|
+
contentEditable={false}
|
|
140
|
+
>
|
|
141
|
+
<CornerDownLeftIcon className="mt-0.5 size-4" />
|
|
142
|
+
</span>
|
|
143
|
+
</>
|
|
144
|
+
) : (
|
|
145
|
+
<div
|
|
146
|
+
className={cn(
|
|
147
|
+
suggestionVariants({
|
|
148
|
+
insertActive: isInsert && (isActive || isHover),
|
|
149
|
+
remove: isRemove,
|
|
150
|
+
removeActive: (isActive || isHover) && isRemove,
|
|
151
|
+
})
|
|
152
|
+
)}
|
|
153
|
+
onMouseEnter={() => setOption('hoverId', suggestionData.id)}
|
|
154
|
+
onMouseLeave={() => setOption('hoverId', null)}
|
|
155
|
+
data-block-suggestion="true"
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</div>
|
|
159
|
+
)}
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { SuggestionPlugin } from '@platejs/suggestion/react';
|
|
4
|
+
import { PencilLineIcon } from 'lucide-react';
|
|
5
|
+
import { useEditorPlugin, usePluginOption } from 'platejs/react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
import { ToolbarButton } from './toolbar';
|
|
10
|
+
|
|
11
|
+
export function SuggestionToolbarButton() {
|
|
12
|
+
const { setOption } = useEditorPlugin(SuggestionPlugin);
|
|
13
|
+
const isSuggesting = usePluginOption(SuggestionPlugin, 'isSuggesting');
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<ToolbarButton
|
|
17
|
+
className={cn(isSuggesting && 'text-brand/80 hover:text-brand/80')}
|
|
18
|
+
onClick={() => setOption('isSuggesting', !isSuggesting)}
|
|
19
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
20
|
+
tooltip={isSuggesting ? 'Turn off suggesting' : 'Suggestion edits'}
|
|
21
|
+
>
|
|
22
|
+
<PencilLineIcon />
|
|
23
|
+
</ToolbarButton>
|
|
24
|
+
);
|
|
25
|
+
}
|