doclific 0.2.1 → 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 +10 -3
- 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,387 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import * as ToolbarPrimitive from '@radix-ui/react-toolbar';
|
|
4
|
-
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
-
import { type VariantProps, cva } from 'class-variance-authority';
|
|
6
|
-
import { ChevronDown } from 'lucide-react';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
DropdownMenuLabel,
|
|
10
|
-
DropdownMenuRadioGroup,
|
|
11
|
-
DropdownMenuSeparator,
|
|
12
|
-
} from '@/components/ui/dropdown-menu';
|
|
13
|
-
import { Separator } from '@/components/ui/separator';
|
|
14
|
-
import { Tooltip, TooltipTrigger } from '@/components/ui/tooltip';
|
|
15
|
-
import { cn } from '@/lib/utils';
|
|
16
|
-
|
|
17
|
-
export function Toolbar({
|
|
18
|
-
className,
|
|
19
|
-
...props
|
|
20
|
-
}: React.ComponentProps<typeof ToolbarPrimitive.Root>) {
|
|
21
|
-
return (
|
|
22
|
-
<ToolbarPrimitive.Root
|
|
23
|
-
className={cn('relative flex select-none items-center', className)}
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function ToolbarToggleGroup({
|
|
30
|
-
className,
|
|
31
|
-
...props
|
|
32
|
-
}: React.ComponentProps<typeof ToolbarPrimitive.ToolbarToggleGroup>) {
|
|
33
|
-
return (
|
|
34
|
-
<ToolbarPrimitive.ToolbarToggleGroup
|
|
35
|
-
className={cn('flex items-center', className)}
|
|
36
|
-
{...props}
|
|
37
|
-
/>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function ToolbarLink({
|
|
42
|
-
className,
|
|
43
|
-
...props
|
|
44
|
-
}: React.ComponentProps<typeof ToolbarPrimitive.Link>) {
|
|
45
|
-
return (
|
|
46
|
-
<ToolbarPrimitive.Link
|
|
47
|
-
className={cn('font-medium underline underline-offset-4', className)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function ToolbarSeparator({
|
|
54
|
-
className,
|
|
55
|
-
...props
|
|
56
|
-
}: React.ComponentProps<typeof ToolbarPrimitive.Separator>) {
|
|
57
|
-
return (
|
|
58
|
-
<ToolbarPrimitive.Separator
|
|
59
|
-
className={cn('mx-2 my-1 w-px shrink-0 bg-border', className)}
|
|
60
|
-
{...props}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// From toggleVariants
|
|
66
|
-
const toolbarButtonVariants = cva(
|
|
67
|
-
"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm outline-none transition-[color,box-shadow] hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-checked:bg-accent aria-checked:text-accent-foreground aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
68
|
-
{
|
|
69
|
-
defaultVariants: {
|
|
70
|
-
size: 'default',
|
|
71
|
-
variant: 'default',
|
|
72
|
-
},
|
|
73
|
-
variants: {
|
|
74
|
-
size: {
|
|
75
|
-
default: 'h-9 min-w-9 px-2',
|
|
76
|
-
lg: 'h-10 min-w-10 px-2.5',
|
|
77
|
-
sm: 'h-8 min-w-8 px-1.5',
|
|
78
|
-
},
|
|
79
|
-
variant: {
|
|
80
|
-
default: 'bg-transparent',
|
|
81
|
-
outline:
|
|
82
|
-
'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const dropdownArrowVariants = cva(
|
|
89
|
-
cn(
|
|
90
|
-
'inline-flex items-center justify-center rounded-r-md font-medium text-foreground text-sm transition-colors disabled:pointer-events-none disabled:opacity-50'
|
|
91
|
-
),
|
|
92
|
-
{
|
|
93
|
-
defaultVariants: {
|
|
94
|
-
size: 'sm',
|
|
95
|
-
variant: 'default',
|
|
96
|
-
},
|
|
97
|
-
variants: {
|
|
98
|
-
size: {
|
|
99
|
-
default: 'h-9 w-6',
|
|
100
|
-
lg: 'h-10 w-8',
|
|
101
|
-
sm: 'h-8 w-4',
|
|
102
|
-
},
|
|
103
|
-
variant: {
|
|
104
|
-
default:
|
|
105
|
-
'bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground',
|
|
106
|
-
outline:
|
|
107
|
-
'border border-input border-l-0 bg-transparent hover:bg-accent hover:text-accent-foreground',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
type ToolbarButtonProps = {
|
|
114
|
-
isDropdown?: boolean;
|
|
115
|
-
pressed?: boolean;
|
|
116
|
-
} & Omit<
|
|
117
|
-
React.ComponentPropsWithoutRef<typeof ToolbarToggleItem>,
|
|
118
|
-
'asChild' | 'value'
|
|
119
|
-
> &
|
|
120
|
-
VariantProps<typeof toolbarButtonVariants>;
|
|
121
|
-
|
|
122
|
-
export const ToolbarButton = withTooltip(function ToolbarButton({
|
|
123
|
-
children,
|
|
124
|
-
className,
|
|
125
|
-
isDropdown,
|
|
126
|
-
pressed,
|
|
127
|
-
size = 'sm',
|
|
128
|
-
variant,
|
|
129
|
-
...props
|
|
130
|
-
}: ToolbarButtonProps) {
|
|
131
|
-
return typeof pressed === 'boolean' ? (
|
|
132
|
-
<ToolbarToggleGroup disabled={props.disabled} value="single" type="single">
|
|
133
|
-
<ToolbarToggleItem
|
|
134
|
-
className={cn(
|
|
135
|
-
toolbarButtonVariants({
|
|
136
|
-
size,
|
|
137
|
-
variant,
|
|
138
|
-
}),
|
|
139
|
-
isDropdown && 'justify-between gap-1 pr-1',
|
|
140
|
-
className
|
|
141
|
-
)}
|
|
142
|
-
value={pressed ? 'single' : ''}
|
|
143
|
-
{...props}
|
|
144
|
-
>
|
|
145
|
-
{isDropdown ? (
|
|
146
|
-
<>
|
|
147
|
-
<div className="flex flex-1 items-center gap-2 whitespace-nowrap">
|
|
148
|
-
{children}
|
|
149
|
-
</div>
|
|
150
|
-
<div>
|
|
151
|
-
<ChevronDown
|
|
152
|
-
className="size-3.5 text-muted-foreground"
|
|
153
|
-
data-icon
|
|
154
|
-
/>
|
|
155
|
-
</div>
|
|
156
|
-
</>
|
|
157
|
-
) : (
|
|
158
|
-
children
|
|
159
|
-
)}
|
|
160
|
-
</ToolbarToggleItem>
|
|
161
|
-
</ToolbarToggleGroup>
|
|
162
|
-
) : (
|
|
163
|
-
<ToolbarPrimitive.Button
|
|
164
|
-
className={cn(
|
|
165
|
-
toolbarButtonVariants({
|
|
166
|
-
size,
|
|
167
|
-
variant,
|
|
168
|
-
}),
|
|
169
|
-
isDropdown && 'pr-1',
|
|
170
|
-
className
|
|
171
|
-
)}
|
|
172
|
-
{...props}
|
|
173
|
-
>
|
|
174
|
-
{children}
|
|
175
|
-
</ToolbarPrimitive.Button>
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
export function ToolbarSplitButton({
|
|
180
|
-
className,
|
|
181
|
-
...props
|
|
182
|
-
}: React.ComponentPropsWithoutRef<typeof ToolbarButton>) {
|
|
183
|
-
return (
|
|
184
|
-
<ToolbarButton
|
|
185
|
-
className={cn('group flex gap-0 px-0 hover:bg-transparent', className)}
|
|
186
|
-
{...props}
|
|
187
|
-
/>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
type ToolbarSplitButtonPrimaryProps = Omit<
|
|
192
|
-
React.ComponentPropsWithoutRef<typeof ToolbarToggleItem>,
|
|
193
|
-
'value'
|
|
194
|
-
> &
|
|
195
|
-
VariantProps<typeof toolbarButtonVariants>;
|
|
196
|
-
|
|
197
|
-
export function ToolbarSplitButtonPrimary({
|
|
198
|
-
children,
|
|
199
|
-
className,
|
|
200
|
-
size = 'sm',
|
|
201
|
-
variant,
|
|
202
|
-
...props
|
|
203
|
-
}: ToolbarSplitButtonPrimaryProps) {
|
|
204
|
-
return (
|
|
205
|
-
<span
|
|
206
|
-
className={cn(
|
|
207
|
-
toolbarButtonVariants({
|
|
208
|
-
size,
|
|
209
|
-
variant,
|
|
210
|
-
}),
|
|
211
|
-
'rounded-r-none',
|
|
212
|
-
'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',
|
|
213
|
-
className
|
|
214
|
-
)}
|
|
215
|
-
{...props}
|
|
216
|
-
>
|
|
217
|
-
{children}
|
|
218
|
-
</span>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function ToolbarSplitButtonSecondary({
|
|
223
|
-
className,
|
|
224
|
-
size,
|
|
225
|
-
variant,
|
|
226
|
-
...props
|
|
227
|
-
}: React.ComponentPropsWithoutRef<'span'> &
|
|
228
|
-
VariantProps<typeof dropdownArrowVariants>) {
|
|
229
|
-
return (
|
|
230
|
-
<span
|
|
231
|
-
className={cn(
|
|
232
|
-
dropdownArrowVariants({
|
|
233
|
-
size,
|
|
234
|
-
variant,
|
|
235
|
-
}),
|
|
236
|
-
'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',
|
|
237
|
-
className
|
|
238
|
-
)}
|
|
239
|
-
onClick={(e) => e.stopPropagation()}
|
|
240
|
-
role="button"
|
|
241
|
-
{...props}
|
|
242
|
-
>
|
|
243
|
-
<ChevronDown className="size-3.5 text-muted-foreground" data-icon />
|
|
244
|
-
</span>
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export function ToolbarToggleItem({
|
|
249
|
-
className,
|
|
250
|
-
size = 'sm',
|
|
251
|
-
variant,
|
|
252
|
-
...props
|
|
253
|
-
}: React.ComponentProps<typeof ToolbarPrimitive.ToggleItem> &
|
|
254
|
-
VariantProps<typeof toolbarButtonVariants>) {
|
|
255
|
-
return (
|
|
256
|
-
<ToolbarPrimitive.ToggleItem
|
|
257
|
-
className={cn(toolbarButtonVariants({ size, variant }), className)}
|
|
258
|
-
{...props}
|
|
259
|
-
/>
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function ToolbarGroup({
|
|
264
|
-
children,
|
|
265
|
-
className,
|
|
266
|
-
}: React.ComponentProps<'div'>) {
|
|
267
|
-
return (
|
|
268
|
-
<div
|
|
269
|
-
className={cn(
|
|
270
|
-
'group/toolbar-group',
|
|
271
|
-
'relative hidden has-[button]:flex',
|
|
272
|
-
className
|
|
273
|
-
)}
|
|
274
|
-
>
|
|
275
|
-
<div className="flex items-center">{children}</div>
|
|
276
|
-
|
|
277
|
-
<div className="group-last/toolbar-group:hidden! mx-1.5 py-0.5">
|
|
278
|
-
<Separator orientation="vertical" />
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
type TooltipProps<T extends React.ElementType> = {
|
|
285
|
-
tooltip?: React.ReactNode;
|
|
286
|
-
tooltipContentProps?: Omit<
|
|
287
|
-
React.ComponentPropsWithoutRef<typeof TooltipContent>,
|
|
288
|
-
'children'
|
|
289
|
-
>;
|
|
290
|
-
tooltipProps?: Omit<
|
|
291
|
-
React.ComponentPropsWithoutRef<typeof Tooltip>,
|
|
292
|
-
'children'
|
|
293
|
-
>;
|
|
294
|
-
tooltipTriggerProps?: React.ComponentPropsWithoutRef<typeof TooltipTrigger>;
|
|
295
|
-
} & React.ComponentProps<T>;
|
|
296
|
-
|
|
297
|
-
function withTooltip<T extends React.ElementType>(Component: T) {
|
|
298
|
-
return function ExtendComponent({
|
|
299
|
-
tooltip,
|
|
300
|
-
tooltipContentProps,
|
|
301
|
-
tooltipProps,
|
|
302
|
-
tooltipTriggerProps,
|
|
303
|
-
...props
|
|
304
|
-
}: TooltipProps<T>) {
|
|
305
|
-
const [mounted, setMounted] = React.useState(false);
|
|
306
|
-
|
|
307
|
-
React.useEffect(() => {
|
|
308
|
-
setMounted(true);
|
|
309
|
-
}, []);
|
|
310
|
-
|
|
311
|
-
const component = <Component {...(props as React.ComponentProps<T>)} />;
|
|
312
|
-
|
|
313
|
-
if (tooltip && mounted) {
|
|
314
|
-
return (
|
|
315
|
-
<Tooltip {...tooltipProps}>
|
|
316
|
-
<TooltipTrigger asChild {...tooltipTriggerProps}>
|
|
317
|
-
{component}
|
|
318
|
-
</TooltipTrigger>
|
|
319
|
-
|
|
320
|
-
<TooltipContent {...tooltipContentProps}>{tooltip}</TooltipContent>
|
|
321
|
-
</Tooltip>
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return component;
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function TooltipContent({
|
|
330
|
-
children,
|
|
331
|
-
className,
|
|
332
|
-
// CHANGE
|
|
333
|
-
sideOffset = 4,
|
|
334
|
-
...props
|
|
335
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
336
|
-
return (
|
|
337
|
-
<TooltipPrimitive.Portal>
|
|
338
|
-
<TooltipPrimitive.Content
|
|
339
|
-
className={cn(
|
|
340
|
-
'z-50 w-fit origin-(--radix-tooltip-content-transform-origin) text-balance rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs',
|
|
341
|
-
className
|
|
342
|
-
)}
|
|
343
|
-
data-slot="tooltip-content"
|
|
344
|
-
sideOffset={sideOffset}
|
|
345
|
-
{...props}
|
|
346
|
-
>
|
|
347
|
-
{children}
|
|
348
|
-
{/* CHANGE */}
|
|
349
|
-
{/* <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-primary fill-primary" /> */}
|
|
350
|
-
</TooltipPrimitive.Content>
|
|
351
|
-
</TooltipPrimitive.Portal>
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
export function ToolbarMenuGroup({
|
|
356
|
-
children,
|
|
357
|
-
className,
|
|
358
|
-
label,
|
|
359
|
-
...props
|
|
360
|
-
}: React.ComponentProps<typeof DropdownMenuRadioGroup> & { label?: string }) {
|
|
361
|
-
return (
|
|
362
|
-
<>
|
|
363
|
-
<DropdownMenuSeparator
|
|
364
|
-
className={cn(
|
|
365
|
-
'hidden',
|
|
366
|
-
'mb-0 shrink-0 peer-has-[[role=menuitem]]/menu-group:block peer-has-[[role=menuitemradio]]/menu-group:block peer-has-[[role=option]]/menu-group:block'
|
|
367
|
-
)}
|
|
368
|
-
/>
|
|
369
|
-
|
|
370
|
-
<DropdownMenuRadioGroup
|
|
371
|
-
{...props}
|
|
372
|
-
className={cn(
|
|
373
|
-
'hidden',
|
|
374
|
-
'peer/menu-group group/menu-group my-1.5 has-[[role=menuitem]]:block has-[[role=menuitemradio]]:block has-[[role=option]]:block',
|
|
375
|
-
className
|
|
376
|
-
)}
|
|
377
|
-
>
|
|
378
|
-
{label && (
|
|
379
|
-
<DropdownMenuLabel className="select-none font-semibold text-muted-foreground text-xs">
|
|
380
|
-
{label}
|
|
381
|
-
</DropdownMenuLabel>
|
|
382
|
-
)}
|
|
383
|
-
{children}
|
|
384
|
-
</DropdownMenuRadioGroup>
|
|
385
|
-
</>
|
|
386
|
-
);
|
|
387
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
function TooltipProvider({
|
|
7
|
-
delayDuration = 0,
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
10
|
-
return (
|
|
11
|
-
<TooltipPrimitive.Provider
|
|
12
|
-
data-slot="tooltip-provider"
|
|
13
|
-
delayDuration={delayDuration}
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function Tooltip({
|
|
20
|
-
...props
|
|
21
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
22
|
-
return (
|
|
23
|
-
<TooltipProvider>
|
|
24
|
-
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
25
|
-
</TooltipProvider>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function TooltipTrigger({
|
|
30
|
-
...props
|
|
31
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
32
|
-
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function TooltipContent({
|
|
36
|
-
className,
|
|
37
|
-
sideOffset = 0,
|
|
38
|
-
children,
|
|
39
|
-
...props
|
|
40
|
-
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
41
|
-
return (
|
|
42
|
-
<TooltipPrimitive.Portal>
|
|
43
|
-
<TooltipPrimitive.Content
|
|
44
|
-
data-slot="tooltip-content"
|
|
45
|
-
sideOffset={sideOffset}
|
|
46
|
-
className={cn(
|
|
47
|
-
"bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
{...props}
|
|
51
|
-
>
|
|
52
|
-
{children}
|
|
53
|
-
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
|
54
|
-
</TooltipPrimitive.Content>
|
|
55
|
-
</TooltipPrimitive.Portal>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import type { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
import type { TElement } from 'platejs';
|
|
5
|
-
|
|
6
|
-
import { DropdownMenuItemIndicator } from '@radix-ui/react-dropdown-menu';
|
|
7
|
-
import {
|
|
8
|
-
CheckIcon,
|
|
9
|
-
ChevronRightIcon,
|
|
10
|
-
Columns3Icon,
|
|
11
|
-
FileCodeIcon,
|
|
12
|
-
Heading1Icon,
|
|
13
|
-
Heading2Icon,
|
|
14
|
-
Heading3Icon,
|
|
15
|
-
Heading4Icon,
|
|
16
|
-
Heading5Icon,
|
|
17
|
-
Heading6Icon,
|
|
18
|
-
ListIcon,
|
|
19
|
-
ListOrderedIcon,
|
|
20
|
-
PilcrowIcon,
|
|
21
|
-
QuoteIcon,
|
|
22
|
-
SquareIcon,
|
|
23
|
-
} from 'lucide-react';
|
|
24
|
-
import { KEYS } from 'platejs';
|
|
25
|
-
import { useEditorRef, useSelectionFragmentProp } from 'platejs/react';
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
DropdownMenu,
|
|
29
|
-
DropdownMenuContent,
|
|
30
|
-
DropdownMenuRadioItem,
|
|
31
|
-
DropdownMenuTrigger,
|
|
32
|
-
} from '@/components/ui/dropdown-menu';
|
|
33
|
-
import {
|
|
34
|
-
getBlockType,
|
|
35
|
-
setBlockType,
|
|
36
|
-
} from '@/components/editor/transforms';
|
|
37
|
-
|
|
38
|
-
import { ToolbarButton, ToolbarMenuGroup } from './toolbar';
|
|
39
|
-
|
|
40
|
-
export const turnIntoItems = [
|
|
41
|
-
{
|
|
42
|
-
icon: <PilcrowIcon />,
|
|
43
|
-
keywords: ['paragraph'],
|
|
44
|
-
label: 'Text',
|
|
45
|
-
value: KEYS.p,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
icon: <Heading1Icon />,
|
|
49
|
-
keywords: ['title', 'h1'],
|
|
50
|
-
label: 'Heading 1',
|
|
51
|
-
value: 'h1',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
icon: <Heading2Icon />,
|
|
55
|
-
keywords: ['subtitle', 'h2'],
|
|
56
|
-
label: 'Heading 2',
|
|
57
|
-
value: 'h2',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
icon: <Heading3Icon />,
|
|
61
|
-
keywords: ['subtitle', 'h3'],
|
|
62
|
-
label: 'Heading 3',
|
|
63
|
-
value: 'h3',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
icon: <Heading4Icon />,
|
|
67
|
-
keywords: ['subtitle', 'h4'],
|
|
68
|
-
label: 'Heading 4',
|
|
69
|
-
value: 'h4',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
icon: <Heading5Icon />,
|
|
73
|
-
keywords: ['subtitle', 'h5'],
|
|
74
|
-
label: 'Heading 5',
|
|
75
|
-
value: 'h5',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
icon: <Heading6Icon />,
|
|
79
|
-
keywords: ['subtitle', 'h6'],
|
|
80
|
-
label: 'Heading 6',
|
|
81
|
-
value: 'h6',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
icon: <ListIcon />,
|
|
85
|
-
keywords: ['unordered', 'ul', '-'],
|
|
86
|
-
label: 'Bulleted list',
|
|
87
|
-
value: KEYS.ul,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
icon: <ListOrderedIcon />,
|
|
91
|
-
keywords: ['ordered', 'ol', '1'],
|
|
92
|
-
label: 'Numbered list',
|
|
93
|
-
value: KEYS.ol,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
icon: <SquareIcon />,
|
|
97
|
-
keywords: ['checklist', 'task', 'checkbox', '[]'],
|
|
98
|
-
label: 'To-do list',
|
|
99
|
-
value: KEYS.listTodo,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
icon: <ChevronRightIcon />,
|
|
103
|
-
keywords: ['collapsible', 'expandable'],
|
|
104
|
-
label: 'Toggle list',
|
|
105
|
-
value: KEYS.toggle,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
icon: <FileCodeIcon />,
|
|
109
|
-
keywords: ['```'],
|
|
110
|
-
label: 'Code',
|
|
111
|
-
value: KEYS.codeBlock,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
icon: <QuoteIcon />,
|
|
115
|
-
keywords: ['citation', 'blockquote', '>'],
|
|
116
|
-
label: 'Quote',
|
|
117
|
-
value: KEYS.blockquote,
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
icon: <Columns3Icon />,
|
|
121
|
-
label: '3 columns',
|
|
122
|
-
value: 'action_three_columns',
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
export function TurnIntoToolbarButton(props: DropdownMenuProps) {
|
|
127
|
-
const editor = useEditorRef();
|
|
128
|
-
const [open, setOpen] = React.useState(false);
|
|
129
|
-
|
|
130
|
-
const value = useSelectionFragmentProp({
|
|
131
|
-
defaultValue: KEYS.p,
|
|
132
|
-
getProp: (node) => getBlockType(node as TElement),
|
|
133
|
-
});
|
|
134
|
-
const selectedItem = React.useMemo(
|
|
135
|
-
() =>
|
|
136
|
-
turnIntoItems.find((item) => item.value === (value ?? KEYS.p)) ??
|
|
137
|
-
turnIntoItems[0],
|
|
138
|
-
[value]
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<DropdownMenu open={open} onOpenChange={setOpen} modal={false} {...props}>
|
|
143
|
-
<DropdownMenuTrigger asChild>
|
|
144
|
-
<ToolbarButton
|
|
145
|
-
className="min-w-[125px]"
|
|
146
|
-
pressed={open}
|
|
147
|
-
tooltip="Turn into"
|
|
148
|
-
isDropdown
|
|
149
|
-
>
|
|
150
|
-
{selectedItem.label}
|
|
151
|
-
</ToolbarButton>
|
|
152
|
-
</DropdownMenuTrigger>
|
|
153
|
-
|
|
154
|
-
<DropdownMenuContent
|
|
155
|
-
className="ignore-click-outside/toolbar min-w-0"
|
|
156
|
-
onCloseAutoFocus={(e) => {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
editor.tf.focus();
|
|
159
|
-
}}
|
|
160
|
-
align="start"
|
|
161
|
-
>
|
|
162
|
-
<ToolbarMenuGroup
|
|
163
|
-
value={value}
|
|
164
|
-
onValueChange={(type) => {
|
|
165
|
-
setBlockType(editor, type);
|
|
166
|
-
}}
|
|
167
|
-
label="Turn into"
|
|
168
|
-
>
|
|
169
|
-
{turnIntoItems.map(({ icon, label, value: itemValue }) => (
|
|
170
|
-
<DropdownMenuRadioItem
|
|
171
|
-
key={itemValue}
|
|
172
|
-
className="min-w-[180px] pl-2 *:first:[span]:hidden"
|
|
173
|
-
value={itemValue}
|
|
174
|
-
>
|
|
175
|
-
<span className="pointer-events-none absolute right-2 flex size-3.5 items-center justify-center">
|
|
176
|
-
<DropdownMenuItemIndicator>
|
|
177
|
-
<CheckIcon />
|
|
178
|
-
</DropdownMenuItemIndicator>
|
|
179
|
-
</span>
|
|
180
|
-
{icon}
|
|
181
|
-
{label}
|
|
182
|
-
</DropdownMenuRadioItem>
|
|
183
|
-
))}
|
|
184
|
-
</ToolbarMenuGroup>
|
|
185
|
-
</DropdownMenuContent>
|
|
186
|
-
</DropdownMenu>
|
|
187
|
-
);
|
|
188
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export const useDebounce = <T>(value: T, delay = 500) => {
|
|
4
|
-
const [debouncedValue, setDebouncedValue] = React.useState(value);
|
|
5
|
-
|
|
6
|
-
React.useEffect(() => {
|
|
7
|
-
const handler: NodeJS.Timeout = setTimeout(() => {
|
|
8
|
-
setDebouncedValue(value);
|
|
9
|
-
}, delay);
|
|
10
|
-
|
|
11
|
-
// Cancel the timeout if value changes (also on delay change or unmount)
|
|
12
|
-
return () => {
|
|
13
|
-
clearTimeout(handler);
|
|
14
|
-
};
|
|
15
|
-
}, [value, delay]);
|
|
16
|
-
|
|
17
|
-
return debouncedValue;
|
|
18
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export function useIsTouchDevice() {
|
|
4
|
-
const [isTouchDevice, setIsTouchDevice] = React.useState(false);
|
|
5
|
-
|
|
6
|
-
React.useEffect(() => {
|
|
7
|
-
function onResize() {
|
|
8
|
-
setIsTouchDevice(
|
|
9
|
-
'ontouchstart' in window ||
|
|
10
|
-
navigator.maxTouchPoints > 0 ||
|
|
11
|
-
navigator.maxTouchPoints > 0
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
window.addEventListener('resize', onResize);
|
|
16
|
-
onResize();
|
|
17
|
-
|
|
18
|
-
return () => {
|
|
19
|
-
window.removeEventListener('resize', onResize);
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
return isTouchDevice;
|
|
24
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
const MOBILE_BREAKPOINT = 768
|
|
4
|
-
|
|
5
|
-
export function useIsMobile() {
|
|
6
|
-
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
|
7
|
-
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
|
10
|
-
const onChange = () => {
|
|
11
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
12
|
-
}
|
|
13
|
-
mql.addEventListener("change", onChange)
|
|
14
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
15
|
-
return () => mql.removeEventListener("change", onChange)
|
|
16
|
-
}, [])
|
|
17
|
-
|
|
18
|
-
return !!isMobile
|
|
19
|
-
}
|