doclific 0.2.0 → 0.2.2
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/LICENSE +17 -0
- package/dist/bin/doclific.js +36 -8
- package/package.json +11 -4
- package/readme.md +77 -0
- package/.gitattributes +0 -2
- package/.prettierignore +0 -5
- package/.prettierrc +0 -9
- package/.vscode/settings.json +0 -13
- package/frontend/components.json +0 -24
- package/frontend/eslint.config.js +0 -23
- package/frontend/index.html +0 -25
- package/frontend/package-lock.json +0 -15754
- package/frontend/public/logo.svg +0 -1
- package/frontend/src/App.tsx +0 -21
- package/frontend/src/components/app-sidebar.tsx +0 -393
- package/frontend/src/components/editor/editor-base-kit.tsx +0 -43
- package/frontend/src/components/editor/editor-kit.tsx +0 -93
- package/frontend/src/components/editor/plugins/align-base-kit.tsx +0 -16
- package/frontend/src/components/editor/plugins/align-kit.tsx +0 -18
- package/frontend/src/components/editor/plugins/autoformat-kit.tsx +0 -236
- package/frontend/src/components/editor/plugins/basic-blocks-base-kit.tsx +0 -35
- package/frontend/src/components/editor/plugins/basic-blocks-kit.tsx +0 -88
- package/frontend/src/components/editor/plugins/basic-marks-base-kit.tsx +0 -27
- package/frontend/src/components/editor/plugins/basic-marks-kit.tsx +0 -41
- package/frontend/src/components/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/frontend/src/components/editor/plugins/block-menu-kit.tsx +0 -14
- package/frontend/src/components/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/frontend/src/components/editor/plugins/block-selection-kit.tsx +0 -32
- package/frontend/src/components/editor/plugins/callout-base-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/callout-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/code-block-base-kit.tsx +0 -23
- package/frontend/src/components/editor/plugins/code-block-kit.tsx +0 -26
- package/frontend/src/components/editor/plugins/codebase-kit.tsx +0 -23
- package/frontend/src/components/editor/plugins/column-base-kit.tsx +0 -11
- package/frontend/src/components/editor/plugins/column-kit.tsx +0 -10
- package/frontend/src/components/editor/plugins/comment-base-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/comment-kit.tsx +0 -97
- package/frontend/src/components/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/frontend/src/components/editor/plugins/date-base-kit.tsx +0 -5
- package/frontend/src/components/editor/plugins/date-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/discussion-kit.tsx +0 -148
- package/frontend/src/components/editor/plugins/dnd-kit.tsx +0 -28
- package/frontend/src/components/editor/plugins/docx-kit.tsx +0 -6
- package/frontend/src/components/editor/plugins/emoji-kit.tsx +0 -13
- package/frontend/src/components/editor/plugins/excalidraw-kit.tsx +0 -9
- package/frontend/src/components/editor/plugins/exit-break-kit.tsx +0 -12
- package/frontend/src/components/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/frontend/src/components/editor/plugins/font-base-kit.tsx +0 -20
- package/frontend/src/components/editor/plugins/font-kit.tsx +0 -29
- package/frontend/src/components/editor/plugins/indent-base-kit.tsx +0 -19
- package/frontend/src/components/editor/plugins/indent-kit.tsx +0 -22
- package/frontend/src/components/editor/plugins/line-height-base-kit.tsx +0 -14
- package/frontend/src/components/editor/plugins/line-height-kit.tsx +0 -16
- package/frontend/src/components/editor/plugins/link-base-kit.tsx +0 -5
- package/frontend/src/components/editor/plugins/link-kit.tsx +0 -15
- package/frontend/src/components/editor/plugins/list-base-kit.tsx +0 -23
- package/frontend/src/components/editor/plugins/list-kit.tsx +0 -26
- package/frontend/src/components/editor/plugins/markdown-kit.tsx +0 -46
- package/frontend/src/components/editor/plugins/math-base-kit.tsx +0 -11
- package/frontend/src/components/editor/plugins/math-kit.tsx +0 -13
- package/frontend/src/components/editor/plugins/media-base-kit.tsx +0 -31
- package/frontend/src/components/editor/plugins/media-kit.tsx +0 -43
- package/frontend/src/components/editor/plugins/mention-base-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/mention-kit.tsx +0 -15
- package/frontend/src/components/editor/plugins/slash-kit.tsx +0 -18
- package/frontend/src/components/editor/plugins/suggestion-base-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/suggestion-kit.tsx +0 -90
- package/frontend/src/components/editor/plugins/table-base-kit.tsx +0 -20
- package/frontend/src/components/editor/plugins/table-kit.tsx +0 -22
- package/frontend/src/components/editor/plugins/toc-base-kit.tsx +0 -5
- package/frontend/src/components/editor/plugins/toc-kit.tsx +0 -14
- package/frontend/src/components/editor/plugins/toggle-base-kit.tsx +0 -7
- package/frontend/src/components/editor/plugins/toggle-kit.tsx +0 -11
- package/frontend/src/components/editor/transforms.ts +0 -194
- package/frontend/src/components/markdown-to-slate-demo.tsx +0 -50
- package/frontend/src/components/mode-toggle.tsx +0 -15
- package/frontend/src/components/theme-provider.tsx +0 -73
- package/frontend/src/components/ui/alert-dialog.tsx +0 -155
- package/frontend/src/components/ui/align-toolbar-button.tsx +0 -84
- package/frontend/src/components/ui/avatar.tsx +0 -51
- package/frontend/src/components/ui/block-context-menu.tsx +0 -199
- package/frontend/src/components/ui/block-discussion.tsx +0 -365
- package/frontend/src/components/ui/block-draggable.tsx +0 -512
- package/frontend/src/components/ui/block-list-static.tsx +0 -80
- package/frontend/src/components/ui/block-list.tsx +0 -87
- package/frontend/src/components/ui/block-selection.tsx +0 -42
- package/frontend/src/components/ui/block-suggestion.tsx +0 -473
- package/frontend/src/components/ui/blockquote-node-static.tsx +0 -11
- package/frontend/src/components/ui/blockquote-node.tsx +0 -13
- package/frontend/src/components/ui/button.tsx +0 -62
- package/frontend/src/components/ui/calendar.tsx +0 -218
- package/frontend/src/components/ui/callout-node-static.tsx +0 -36
- package/frontend/src/components/ui/callout-node.tsx +0 -63
- package/frontend/src/components/ui/caption.tsx +0 -63
- package/frontend/src/components/ui/checkbox.tsx +0 -30
- package/frontend/src/components/ui/code-block-node-static.tsx +0 -35
- package/frontend/src/components/ui/code-block-node.tsx +0 -287
- package/frontend/src/components/ui/code-node-static.tsx +0 -15
- package/frontend/src/components/ui/code-node.tsx +0 -17
- package/frontend/src/components/ui/codebase-snippet-node.tsx +0 -237
- package/frontend/src/components/ui/column-node-static.tsx +0 -29
- package/frontend/src/components/ui/column-node.tsx +0 -317
- package/frontend/src/components/ui/command.tsx +0 -182
- package/frontend/src/components/ui/comment-node-static.tsx +0 -15
- package/frontend/src/components/ui/comment-node.tsx +0 -45
- package/frontend/src/components/ui/comment-toolbar-button.tsx +0 -24
- package/frontend/src/components/ui/comment.tsx +0 -618
- package/frontend/src/components/ui/context-menu.tsx +0 -250
- package/frontend/src/components/ui/cursor-overlay.tsx +0 -66
- package/frontend/src/components/ui/date-node-static.tsx +0 -45
- package/frontend/src/components/ui/date-node.tsx +0 -93
- package/frontend/src/components/ui/dialog.tsx +0 -143
- package/frontend/src/components/ui/dropdown-menu.tsx +0 -255
- package/frontend/src/components/ui/dynamic-icon.tsx +0 -12
- package/frontend/src/components/ui/editor-static.tsx +0 -53
- package/frontend/src/components/ui/editor.tsx +0 -130
- package/frontend/src/components/ui/emoji-node.tsx +0 -69
- package/frontend/src/components/ui/emoji-toolbar-button.tsx +0 -628
- package/frontend/src/components/ui/equation-node-static.tsx +0 -98
- package/frontend/src/components/ui/equation-node.tsx +0 -235
- package/frontend/src/components/ui/equation-toolbar-button.tsx +0 -25
- package/frontend/src/components/ui/excalidraw-node.tsx +0 -36
- package/frontend/src/components/ui/export-toolbar-button.tsx +0 -174
- package/frontend/src/components/ui/file-selector.tsx +0 -339
- package/frontend/src/components/ui/floating-toolbar-buttons.tsx +0 -73
- package/frontend/src/components/ui/floating-toolbar.tsx +0 -85
- package/frontend/src/components/ui/font-color-toolbar-button.tsx +0 -831
- package/frontend/src/components/ui/font-size-toolbar-button.tsx +0 -152
- package/frontend/src/components/ui/heading-node-static.tsx +0 -68
- package/frontend/src/components/ui/heading-node.tsx +0 -58
- package/frontend/src/components/ui/highlight-node-static.tsx +0 -11
- package/frontend/src/components/ui/highlight-node.tsx +0 -13
- package/frontend/src/components/ui/history-toolbar-button.tsx +0 -50
- package/frontend/src/components/ui/hr-node-static.tsx +0 -20
- package/frontend/src/components/ui/hr-node.tsx +0 -33
- package/frontend/src/components/ui/import-toolbar-button.tsx +0 -97
- package/frontend/src/components/ui/indent-toolbar-button.tsx +0 -30
- package/frontend/src/components/ui/inline-combobox.tsx +0 -414
- package/frontend/src/components/ui/input.tsx +0 -21
- package/frontend/src/components/ui/insert-toolbar-button.tsx +0 -254
- package/frontend/src/components/ui/kbd-node-static.tsx +0 -15
- package/frontend/src/components/ui/kbd-node.tsx +0 -17
- package/frontend/src/components/ui/layout-header.tsx +0 -35
- package/frontend/src/components/ui/line-height-toolbar-button.tsx +0 -68
- package/frontend/src/components/ui/link-node-static.tsx +0 -21
- package/frontend/src/components/ui/link-node.tsx +0 -39
- package/frontend/src/components/ui/link-toolbar-button.tsx +0 -22
- package/frontend/src/components/ui/link-toolbar.tsx +0 -206
- package/frontend/src/components/ui/list-toolbar-button.tsx +0 -204
- package/frontend/src/components/ui/mark-toolbar-button.tsx +0 -19
- package/frontend/src/components/ui/media-audio-node-static.tsx +0 -17
- package/frontend/src/components/ui/media-audio-node.tsx +0 -39
- package/frontend/src/components/ui/media-embed-node.tsx +0 -136
- package/frontend/src/components/ui/media-file-node-static.tsx +0 -29
- package/frontend/src/components/ui/media-file-node.tsx +0 -47
- package/frontend/src/components/ui/media-image-node-static.tsx +0 -39
- package/frontend/src/components/ui/media-image-node.tsx +0 -80
- package/frontend/src/components/ui/media-placeholder-node.tsx +0 -249
- package/frontend/src/components/ui/media-preview-dialog.tsx +0 -152
- package/frontend/src/components/ui/media-toolbar-button.tsx +0 -225
- package/frontend/src/components/ui/media-toolbar.tsx +0 -115
- package/frontend/src/components/ui/media-upload-toast.tsx +0 -66
- package/frontend/src/components/ui/media-video-node-static.tsx +0 -30
- package/frontend/src/components/ui/media-video-node.tsx +0 -121
- package/frontend/src/components/ui/mention-node-static.tsx +0 -36
- package/frontend/src/components/ui/mention-node.tsx +0 -194
- package/frontend/src/components/ui/mode-toolbar-button.tsx +0 -123
- package/frontend/src/components/ui/more-toolbar-button.tsx +0 -80
- package/frontend/src/components/ui/paragraph-node-static.tsx +0 -13
- package/frontend/src/components/ui/paragraph-node.tsx +0 -15
- package/frontend/src/components/ui/popover.tsx +0 -46
- package/frontend/src/components/ui/resize-handle.tsx +0 -87
- package/frontend/src/components/ui/separator.tsx +0 -28
- package/frontend/src/components/ui/sheet.tsx +0 -139
- package/frontend/src/components/ui/sidebar.tsx +0 -726
- package/frontend/src/components/ui/skeleton.tsx +0 -13
- package/frontend/src/components/ui/slash-node.tsx +0 -233
- package/frontend/src/components/ui/sonner.tsx +0 -38
- package/frontend/src/components/ui/suggestion-node-static.tsx +0 -35
- package/frontend/src/components/ui/suggestion-node.tsx +0 -162
- package/frontend/src/components/ui/suggestion-toolbar-button.tsx +0 -25
- package/frontend/src/components/ui/table-icons.tsx +0 -862
- package/frontend/src/components/ui/table-node-static.tsx +0 -98
- package/frontend/src/components/ui/table-node.tsx +0 -656
- package/frontend/src/components/ui/table-toolbar-button.tsx +0 -264
- package/frontend/src/components/ui/toc-node-static.tsx +0 -92
- package/frontend/src/components/ui/toc-node.tsx +0 -55
- package/frontend/src/components/ui/toggle-node-static.tsx +0 -18
- package/frontend/src/components/ui/toggle-node.tsx +0 -36
- package/frontend/src/components/ui/toggle-toolbar-button.tsx +0 -22
- package/frontend/src/components/ui/toolbar.tsx +0 -387
- package/frontend/src/components/ui/tooltip.tsx +0 -59
- package/frontend/src/components/ui/turn-into-toolbar-button.tsx +0 -188
- package/frontend/src/hooks/use-debounce.ts +0 -18
- package/frontend/src/hooks/use-is-touch-device.ts +0 -24
- package/frontend/src/hooks/use-mobile.ts +0 -19
- package/frontend/src/hooks/use-mounted.ts +0 -11
- package/frontend/src/hooks/use-upload-file.ts +0 -128
- package/frontend/src/index.css +0 -128
- package/frontend/src/layout.tsx +0 -42
- package/frontend/src/lib/markdown-joiner-transform.ts +0 -239
- package/frontend/src/lib/orpc.ts +0 -13
- package/frontend/src/lib/uploadthing.ts +0 -19
- package/frontend/src/lib/utils.ts +0 -6
- package/frontend/src/main.tsx +0 -13
- package/frontend/src/pages/editor.tsx +0 -44
- package/frontend/src/types/docs.d.ts +0 -6
- package/frontend/src/types/global.d.ts +0 -9
- package/frontend/src/types/router.d.ts +0 -4
- package/frontend/tsconfig.app.json +0 -33
- package/frontend/tsconfig.json +0 -10
- package/frontend/tsconfig.node.json +0 -26
- package/frontend/vite.config.ts +0 -14
- package/src/bin/doclific.ts +0 -47
- package/src/core/codebase.ts +0 -39
- package/src/core/docs.ts +0 -90
- package/src/core/git.ts +0 -48
- package/src/server/index.ts +0 -55
- package/src/server/router.ts +0 -65
- package/tsconfig.json +0 -15
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import type { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
|
|
5
|
-
import { TablePlugin, useTableMergeState } from '@platejs/table/react';
|
|
6
|
-
import {
|
|
7
|
-
ArrowDown,
|
|
8
|
-
ArrowLeft,
|
|
9
|
-
ArrowRight,
|
|
10
|
-
ArrowUp,
|
|
11
|
-
Combine,
|
|
12
|
-
Grid3x3Icon,
|
|
13
|
-
Table,
|
|
14
|
-
Trash2Icon,
|
|
15
|
-
Ungroup,
|
|
16
|
-
XIcon,
|
|
17
|
-
} from 'lucide-react';
|
|
18
|
-
import { KEYS } from 'platejs';
|
|
19
|
-
import { useEditorPlugin, useEditorSelector } from 'platejs/react';
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
DropdownMenu,
|
|
23
|
-
DropdownMenuContent,
|
|
24
|
-
DropdownMenuGroup,
|
|
25
|
-
DropdownMenuItem,
|
|
26
|
-
DropdownMenuSub,
|
|
27
|
-
DropdownMenuSubContent,
|
|
28
|
-
DropdownMenuSubTrigger,
|
|
29
|
-
DropdownMenuTrigger,
|
|
30
|
-
} from '@/components/ui/dropdown-menu';
|
|
31
|
-
import { cn } from '@/lib/utils';
|
|
32
|
-
|
|
33
|
-
import { ToolbarButton } from './toolbar';
|
|
34
|
-
|
|
35
|
-
export function TableToolbarButton(props: DropdownMenuProps) {
|
|
36
|
-
const tableSelected = useEditorSelector(
|
|
37
|
-
(editor) => editor.api.some({ match: { type: KEYS.table } }),
|
|
38
|
-
[]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const { editor, tf } = useEditorPlugin(TablePlugin);
|
|
42
|
-
const [open, setOpen] = React.useState(false);
|
|
43
|
-
const mergeState = useTableMergeState();
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<DropdownMenu open={open} onOpenChange={setOpen} modal={false} {...props}>
|
|
47
|
-
<DropdownMenuTrigger asChild>
|
|
48
|
-
<ToolbarButton pressed={open} tooltip="Table" isDropdown>
|
|
49
|
-
<Table />
|
|
50
|
-
</ToolbarButton>
|
|
51
|
-
</DropdownMenuTrigger>
|
|
52
|
-
|
|
53
|
-
<DropdownMenuContent
|
|
54
|
-
className="flex w-[180px] min-w-0 flex-col"
|
|
55
|
-
align="start"
|
|
56
|
-
>
|
|
57
|
-
<DropdownMenuGroup>
|
|
58
|
-
<DropdownMenuSub>
|
|
59
|
-
<DropdownMenuSubTrigger className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50">
|
|
60
|
-
<Grid3x3Icon className="size-4" />
|
|
61
|
-
<span>Table</span>
|
|
62
|
-
</DropdownMenuSubTrigger>
|
|
63
|
-
<DropdownMenuSubContent className="m-0 p-0">
|
|
64
|
-
<TablePicker />
|
|
65
|
-
</DropdownMenuSubContent>
|
|
66
|
-
</DropdownMenuSub>
|
|
67
|
-
|
|
68
|
-
<DropdownMenuSub>
|
|
69
|
-
<DropdownMenuSubTrigger
|
|
70
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
71
|
-
disabled={!tableSelected}
|
|
72
|
-
>
|
|
73
|
-
<div className="size-4" />
|
|
74
|
-
<span>Cell</span>
|
|
75
|
-
</DropdownMenuSubTrigger>
|
|
76
|
-
<DropdownMenuSubContent>
|
|
77
|
-
<DropdownMenuItem
|
|
78
|
-
className="min-w-[180px]"
|
|
79
|
-
disabled={!mergeState.canMerge}
|
|
80
|
-
onSelect={() => {
|
|
81
|
-
tf.table.merge();
|
|
82
|
-
editor.tf.focus();
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<Combine />
|
|
86
|
-
Merge cells
|
|
87
|
-
</DropdownMenuItem>
|
|
88
|
-
<DropdownMenuItem
|
|
89
|
-
className="min-w-[180px]"
|
|
90
|
-
disabled={!mergeState.canSplit}
|
|
91
|
-
onSelect={() => {
|
|
92
|
-
tf.table.split();
|
|
93
|
-
editor.tf.focus();
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
<Ungroup />
|
|
97
|
-
Split cell
|
|
98
|
-
</DropdownMenuItem>
|
|
99
|
-
</DropdownMenuSubContent>
|
|
100
|
-
</DropdownMenuSub>
|
|
101
|
-
|
|
102
|
-
<DropdownMenuSub>
|
|
103
|
-
<DropdownMenuSubTrigger
|
|
104
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
105
|
-
disabled={!tableSelected}
|
|
106
|
-
>
|
|
107
|
-
<div className="size-4" />
|
|
108
|
-
<span>Row</span>
|
|
109
|
-
</DropdownMenuSubTrigger>
|
|
110
|
-
<DropdownMenuSubContent>
|
|
111
|
-
<DropdownMenuItem
|
|
112
|
-
className="min-w-[180px]"
|
|
113
|
-
disabled={!tableSelected}
|
|
114
|
-
onSelect={() => {
|
|
115
|
-
tf.insert.tableRow({ before: true });
|
|
116
|
-
editor.tf.focus();
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
<ArrowUp />
|
|
120
|
-
Insert row before
|
|
121
|
-
</DropdownMenuItem>
|
|
122
|
-
<DropdownMenuItem
|
|
123
|
-
className="min-w-[180px]"
|
|
124
|
-
disabled={!tableSelected}
|
|
125
|
-
onSelect={() => {
|
|
126
|
-
tf.insert.tableRow();
|
|
127
|
-
editor.tf.focus();
|
|
128
|
-
}}
|
|
129
|
-
>
|
|
130
|
-
<ArrowDown />
|
|
131
|
-
Insert row after
|
|
132
|
-
</DropdownMenuItem>
|
|
133
|
-
<DropdownMenuItem
|
|
134
|
-
className="min-w-[180px]"
|
|
135
|
-
disabled={!tableSelected}
|
|
136
|
-
onSelect={() => {
|
|
137
|
-
tf.remove.tableRow();
|
|
138
|
-
editor.tf.focus();
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
<XIcon />
|
|
142
|
-
Delete row
|
|
143
|
-
</DropdownMenuItem>
|
|
144
|
-
</DropdownMenuSubContent>
|
|
145
|
-
</DropdownMenuSub>
|
|
146
|
-
|
|
147
|
-
<DropdownMenuSub>
|
|
148
|
-
<DropdownMenuSubTrigger
|
|
149
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
150
|
-
disabled={!tableSelected}
|
|
151
|
-
>
|
|
152
|
-
<div className="size-4" />
|
|
153
|
-
<span>Column</span>
|
|
154
|
-
</DropdownMenuSubTrigger>
|
|
155
|
-
<DropdownMenuSubContent>
|
|
156
|
-
<DropdownMenuItem
|
|
157
|
-
className="min-w-[180px]"
|
|
158
|
-
disabled={!tableSelected}
|
|
159
|
-
onSelect={() => {
|
|
160
|
-
tf.insert.tableColumn({ before: true });
|
|
161
|
-
editor.tf.focus();
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
164
|
-
<ArrowLeft />
|
|
165
|
-
Insert column before
|
|
166
|
-
</DropdownMenuItem>
|
|
167
|
-
<DropdownMenuItem
|
|
168
|
-
className="min-w-[180px]"
|
|
169
|
-
disabled={!tableSelected}
|
|
170
|
-
onSelect={() => {
|
|
171
|
-
tf.insert.tableColumn();
|
|
172
|
-
editor.tf.focus();
|
|
173
|
-
}}
|
|
174
|
-
>
|
|
175
|
-
<ArrowRight />
|
|
176
|
-
Insert column after
|
|
177
|
-
</DropdownMenuItem>
|
|
178
|
-
<DropdownMenuItem
|
|
179
|
-
className="min-w-[180px]"
|
|
180
|
-
disabled={!tableSelected}
|
|
181
|
-
onSelect={() => {
|
|
182
|
-
tf.remove.tableColumn();
|
|
183
|
-
editor.tf.focus();
|
|
184
|
-
}}
|
|
185
|
-
>
|
|
186
|
-
<XIcon />
|
|
187
|
-
Delete column
|
|
188
|
-
</DropdownMenuItem>
|
|
189
|
-
</DropdownMenuSubContent>
|
|
190
|
-
</DropdownMenuSub>
|
|
191
|
-
|
|
192
|
-
<DropdownMenuItem
|
|
193
|
-
className="min-w-[180px]"
|
|
194
|
-
disabled={!tableSelected}
|
|
195
|
-
onSelect={() => {
|
|
196
|
-
tf.remove.table();
|
|
197
|
-
editor.tf.focus();
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
<Trash2Icon />
|
|
201
|
-
Delete table
|
|
202
|
-
</DropdownMenuItem>
|
|
203
|
-
</DropdownMenuGroup>
|
|
204
|
-
</DropdownMenuContent>
|
|
205
|
-
</DropdownMenu>
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function TablePicker() {
|
|
210
|
-
const { editor, tf } = useEditorPlugin(TablePlugin);
|
|
211
|
-
|
|
212
|
-
const [tablePicker, setTablePicker] = React.useState({
|
|
213
|
-
grid: Array.from({ length: 8 }, () => Array.from({ length: 8 }).fill(0)),
|
|
214
|
-
size: { colCount: 0, rowCount: 0 },
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const onCellMove = (rowIndex: number, colIndex: number) => {
|
|
218
|
-
const newGrid = [...tablePicker.grid];
|
|
219
|
-
|
|
220
|
-
for (let i = 0; i < newGrid.length; i++) {
|
|
221
|
-
for (let j = 0; j < newGrid[i].length; j++) {
|
|
222
|
-
newGrid[i][j] =
|
|
223
|
-
i >= 0 && i <= rowIndex && j >= 0 && j <= colIndex ? 1 : 0;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
setTablePicker({
|
|
228
|
-
grid: newGrid,
|
|
229
|
-
size: { colCount: colIndex + 1, rowCount: rowIndex + 1 },
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<div
|
|
235
|
-
className="flex! m-0 flex-col p-0"
|
|
236
|
-
onClick={() => {
|
|
237
|
-
tf.insert.table(tablePicker.size, { select: true });
|
|
238
|
-
editor.tf.focus();
|
|
239
|
-
}}
|
|
240
|
-
role="button"
|
|
241
|
-
>
|
|
242
|
-
<div className="grid size-[130px] grid-cols-8 gap-0.5 p-1">
|
|
243
|
-
{tablePicker.grid.map((rows, rowIndex) =>
|
|
244
|
-
rows.map((value, columIndex) => (
|
|
245
|
-
<div
|
|
246
|
-
key={`(${rowIndex},${columIndex})`}
|
|
247
|
-
className={cn(
|
|
248
|
-
'col-span-1 size-3 border border-solid bg-secondary',
|
|
249
|
-
!!value && 'border-current'
|
|
250
|
-
)}
|
|
251
|
-
onMouseMove={() => {
|
|
252
|
-
onCellMove(rowIndex, columIndex);
|
|
253
|
-
}}
|
|
254
|
-
/>
|
|
255
|
-
))
|
|
256
|
-
)}
|
|
257
|
-
</div>
|
|
258
|
-
|
|
259
|
-
<div className="text-center text-current text-xs">
|
|
260
|
-
{tablePicker.size.rowCount} x {tablePicker.size.colCount}
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
);
|
|
264
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { SlateElementProps } from 'platejs/static';
|
|
2
|
-
|
|
3
|
-
import { type Heading, BaseTocPlugin, isHeading } from '@platejs/toc';
|
|
4
|
-
import { cva } from 'class-variance-authority';
|
|
5
|
-
import { type SlateEditor, type TElement, NodeApi } from 'platejs';
|
|
6
|
-
import { SlateElement } from 'platejs/static';
|
|
7
|
-
|
|
8
|
-
import { Button } from '@/components/ui/button';
|
|
9
|
-
|
|
10
|
-
const headingItemVariants = cva(
|
|
11
|
-
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
|
12
|
-
{
|
|
13
|
-
variants: {
|
|
14
|
-
depth: {
|
|
15
|
-
1: 'pl-0.5',
|
|
16
|
-
2: 'pl-[26px]',
|
|
17
|
-
3: 'pl-[50px]',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export function TocElementStatic(props: SlateElementProps) {
|
|
24
|
-
const { editor } = props;
|
|
25
|
-
const headingList = getHeadingList(editor);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<SlateElement {...props} className="mb-1 p-0">
|
|
29
|
-
<div>
|
|
30
|
-
{headingList.length > 0 ? (
|
|
31
|
-
headingList.map((item) => (
|
|
32
|
-
<Button
|
|
33
|
-
key={item.title}
|
|
34
|
-
variant="ghost"
|
|
35
|
-
className={headingItemVariants({
|
|
36
|
-
depth: item.depth as 1 | 2 | 3,
|
|
37
|
-
})}
|
|
38
|
-
>
|
|
39
|
-
{item.title}
|
|
40
|
-
</Button>
|
|
41
|
-
))
|
|
42
|
-
) : (
|
|
43
|
-
<div className="text-gray-500 text-sm">
|
|
44
|
-
Create a heading to display the table of contents.
|
|
45
|
-
</div>
|
|
46
|
-
)}
|
|
47
|
-
</div>
|
|
48
|
-
{props.children}
|
|
49
|
-
</SlateElement>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const headingDepth: Record<string, number> = {
|
|
54
|
-
h1: 1,
|
|
55
|
-
h2: 2,
|
|
56
|
-
h3: 3,
|
|
57
|
-
h4: 4,
|
|
58
|
-
h5: 5,
|
|
59
|
-
h6: 6,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const getHeadingList = (editor?: SlateEditor) => {
|
|
63
|
-
if (!editor) return [];
|
|
64
|
-
|
|
65
|
-
const options = editor.getOptions(BaseTocPlugin);
|
|
66
|
-
|
|
67
|
-
if (options.queryHeading) {
|
|
68
|
-
return options.queryHeading(editor);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const headingList: Heading[] = [];
|
|
72
|
-
|
|
73
|
-
const values = editor.api.nodes<TElement>({
|
|
74
|
-
at: [],
|
|
75
|
-
match: (n) => isHeading(n),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
if (!values) return [];
|
|
79
|
-
|
|
80
|
-
Array.from(values).forEach(([node, path]) => {
|
|
81
|
-
const { type } = node;
|
|
82
|
-
const title = NodeApi.string(node);
|
|
83
|
-
const depth = headingDepth[type];
|
|
84
|
-
const id = node.id as string;
|
|
85
|
-
|
|
86
|
-
if (title) {
|
|
87
|
-
headingList.push({ id, depth, path, title, type });
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return headingList;
|
|
92
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { PlateElementProps } from 'platejs/react';
|
|
4
|
-
|
|
5
|
-
import { useTocElement, useTocElementState } from '@platejs/toc/react';
|
|
6
|
-
import { cva } from 'class-variance-authority';
|
|
7
|
-
import { PlateElement } from 'platejs/react';
|
|
8
|
-
|
|
9
|
-
import { Button } from '@/components/ui/button';
|
|
10
|
-
|
|
11
|
-
const headingItemVariants = cva(
|
|
12
|
-
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
|
13
|
-
{
|
|
14
|
-
variants: {
|
|
15
|
-
depth: {
|
|
16
|
-
1: 'pl-0.5',
|
|
17
|
-
2: 'pl-[26px]',
|
|
18
|
-
3: 'pl-[50px]',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export function TocElement(props: PlateElementProps) {
|
|
25
|
-
const state = useTocElementState();
|
|
26
|
-
const { props: btnProps } = useTocElement(state);
|
|
27
|
-
const { headingList } = state;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<PlateElement {...props} className="mb-1 p-0">
|
|
31
|
-
<div contentEditable={false}>
|
|
32
|
-
{headingList.length > 0 ? (
|
|
33
|
-
headingList.map((item) => (
|
|
34
|
-
<Button
|
|
35
|
-
key={item.id}
|
|
36
|
-
variant="ghost"
|
|
37
|
-
className={headingItemVariants({
|
|
38
|
-
depth: item.depth as 1 | 2 | 3,
|
|
39
|
-
})}
|
|
40
|
-
onClick={(e) => btnProps.onClick(e, item, 'smooth')}
|
|
41
|
-
aria-current
|
|
42
|
-
>
|
|
43
|
-
{item.title}
|
|
44
|
-
</Button>
|
|
45
|
-
))
|
|
46
|
-
) : (
|
|
47
|
-
<div className="text-gray-500 text-sm">
|
|
48
|
-
Create a heading to display the table of contents.
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
52
|
-
{props.children}
|
|
53
|
-
</PlateElement>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { SlateElementProps } from 'platejs/static';
|
|
2
|
-
|
|
3
|
-
import { ChevronRight } from 'lucide-react';
|
|
4
|
-
import { SlateElement } from 'platejs/static';
|
|
5
|
-
|
|
6
|
-
export function ToggleElementStatic(props: SlateElementProps) {
|
|
7
|
-
return (
|
|
8
|
-
<SlateElement {...props} className="pl-6">
|
|
9
|
-
<div
|
|
10
|
-
className="-left-0.5 absolute top-0 size-6 cursor-pointer select-none items-center justify-center rounded-md p-px text-muted-foreground transition-colors hover:bg-accent [&_svg]:size-4"
|
|
11
|
-
contentEditable={false}
|
|
12
|
-
>
|
|
13
|
-
<ChevronRight className="rotate-0 transition-transform duration-75" />
|
|
14
|
-
</div>
|
|
15
|
-
{props.children}
|
|
16
|
-
</SlateElement>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { PlateElementProps } from 'platejs/react';
|
|
4
|
-
|
|
5
|
-
import { useToggleButton, useToggleButtonState } from '@platejs/toggle/react';
|
|
6
|
-
import { ChevronRight } from 'lucide-react';
|
|
7
|
-
import { PlateElement } from 'platejs/react';
|
|
8
|
-
|
|
9
|
-
import { Button } from '@/components/ui/button';
|
|
10
|
-
|
|
11
|
-
export function ToggleElement(props: PlateElementProps) {
|
|
12
|
-
const element = props.element;
|
|
13
|
-
const state = useToggleButtonState(element.id as string);
|
|
14
|
-
const { buttonProps, open } = useToggleButton(state);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<PlateElement {...props} className="pl-6">
|
|
18
|
-
<Button
|
|
19
|
-
size="icon"
|
|
20
|
-
variant="ghost"
|
|
21
|
-
className="-left-0.5 absolute top-0 size-6 cursor-pointer select-none items-center justify-center rounded-md p-px text-muted-foreground transition-colors hover:bg-accent [&_svg]:size-4"
|
|
22
|
-
contentEditable={false}
|
|
23
|
-
{...buttonProps}
|
|
24
|
-
>
|
|
25
|
-
<ChevronRight
|
|
26
|
-
className={
|
|
27
|
-
open
|
|
28
|
-
? 'rotate-90 transition-transform duration-75'
|
|
29
|
-
: 'rotate-0 transition-transform duration-75'
|
|
30
|
-
}
|
|
31
|
-
/>
|
|
32
|
-
</Button>
|
|
33
|
-
{props.children}
|
|
34
|
-
</PlateElement>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useToggleToolbarButton,
|
|
5
|
-
useToggleToolbarButtonState,
|
|
6
|
-
} from '@platejs/toggle/react';
|
|
7
|
-
import { ListCollapseIcon } from 'lucide-react';
|
|
8
|
-
|
|
9
|
-
import { ToolbarButton } from './toolbar';
|
|
10
|
-
|
|
11
|
-
export function ToggleToolbarButton(
|
|
12
|
-
props: React.ComponentProps<typeof ToolbarButton>
|
|
13
|
-
) {
|
|
14
|
-
const state = useToggleToolbarButtonState();
|
|
15
|
-
const { props: buttonProps } = useToggleToolbarButton(state);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<ToolbarButton {...props} {...buttonProps} tooltip="Toggle">
|
|
19
|
-
<ListCollapseIcon />
|
|
20
|
-
</ToolbarButton>
|
|
21
|
-
);
|
|
22
|
-
}
|