@innoviatech/lexical-text-editor 2.0.7 → 3.0.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/README.md +390 -288
- package/dist/components/AlignmentSelectionList.js +19 -0
- package/dist/components/ColorPicker.js +30 -0
- package/dist/components/ContentPreview.js +11 -0
- package/dist/components/DisplayControls.d.ts +16 -0
- package/dist/components/DropdownList.js +18 -0
- package/dist/components/FindReplaceModal.d.ts +11 -0
- package/dist/components/FindReplaceModal.js +120 -0
- package/dist/components/FontSelectionList.d.ts +17 -0
- package/dist/components/FontSelectionList.js +17 -0
- package/dist/components/HeadingSelectionList.js +19 -0
- package/dist/components/ImageComponent.js +111 -0
- package/dist/components/InsertDropdownList.js +17 -0
- package/dist/components/LexicalTextEditor.d.ts +10 -0
- package/dist/components/LexicalTextEditor.js +128 -0
- package/dist/components/LinkModal.js +47 -0
- package/dist/components/Separator.js +4 -0
- package/dist/components/SourceView.d.ts +13 -0
- package/dist/components/SourceView.js +50 -0
- package/dist/components/StatusBar.d.ts +14 -0
- package/dist/components/StatusBar.js +30 -0
- package/dist/components/ToolbarOverflowModal.d.ts +15 -0
- package/dist/components/common/Dialog.js +27 -0
- package/dist/components/common/Popover.d.ts +10 -1
- package/dist/components/common/Popover.js +37 -0
- package/dist/components/common/Tooltip.d.ts +7 -0
- package/dist/components/common/Tooltip.js +20 -0
- package/dist/components/ui/button.js +35 -0
- package/dist/components/ui/command.js +33 -0
- package/dist/components/ui/dialog.js +35 -0
- package/dist/components/ui/input.js +6 -0
- package/dist/components/ui/popover.js +16 -0
- package/dist/components/ui/scroll-area.js +12 -0
- package/dist/components/ui/tooltip.js +16 -0
- package/dist/constants/index.d.ts +23 -1
- package/dist/constants/index.js +224 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical-editor.css +1 -1
- package/dist/lib/utils.js +5 -0
- package/dist/nodes/ExtendedTextNode.js +140 -0
- package/dist/nodes/ImageNode.js +149 -0
- package/dist/nodes/VideoNode.js +80 -0
- package/dist/nodes/YoutubeNode.js +64 -0
- package/dist/plugins/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/CodeBlockPlugin.js +88 -0
- package/dist/plugins/ColorPlugin.js +47 -0
- package/dist/plugins/CustomOnChangePlugin.js +33 -0
- package/dist/plugins/FontFamilyPlugin.d.ts +1 -0
- package/dist/plugins/FontFamilyPlugin.js +53 -0
- package/dist/plugins/FontSizePlugin.d.ts +1 -0
- package/dist/plugins/FontSizePlugin.js +48 -0
- package/dist/plugins/ImagePlugin.js +91 -0
- package/dist/plugins/ListPlugin.js +44 -0
- package/dist/plugins/TablePlugin.d.ts +1 -0
- package/dist/plugins/TablePlugin.js +92 -0
- package/dist/plugins/ToolbarPlugin.d.ts +13 -1
- package/dist/plugins/ToolbarPlugin.js +381 -0
- package/dist/plugins/VideoPlugin.js +49 -0
- package/dist/plugins/YoutubePlugin.js +30 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/editor_screenshot.png +0 -0
- package/package.json +11 -4
- package/googlebd703883f12c69e4.html +0 -1
- package/rollup.config.js +0 -55
- package/src/components/AlignmentSelectionList.tsx +0 -61
- package/src/components/ColorPicker.tsx +0 -66
- package/src/components/ContentPreview.tsx +0 -51
- package/src/components/DropdownList.tsx +0 -57
- package/src/components/HeadingSelectionList.tsx +0 -61
- package/src/components/ImageComponent.tsx +0 -206
- package/src/components/InsertDropdownList.tsx +0 -36
- package/src/components/LexicalTextEditor.tsx +0 -119
- package/src/components/LinkModal.tsx +0 -127
- package/src/components/Separator.tsx +0 -7
- package/src/components/common/Dialog.tsx +0 -47
- package/src/components/common/Popover.tsx +0 -87
- package/src/components/common/Tooltip.tsx +0 -43
- package/src/components/ui/button.tsx +0 -58
- package/src/components/ui/command.tsx +0 -183
- package/src/components/ui/dialog.tsx +0 -142
- package/src/components/ui/input.tsx +0 -21
- package/src/components/ui/popover.tsx +0 -46
- package/src/components/ui/scroll-area.tsx +0 -56
- package/src/components/ui/tooltip.tsx +0 -59
- package/src/constants/index.tsx +0 -177
- package/src/index.ts +0 -6
- package/src/lib/utils.ts +0 -6
- package/src/nodes/ExtendedTextNode.tsx +0 -174
- package/src/nodes/ImageNode.tsx +0 -232
- package/src/nodes/VideoNode.tsx +0 -134
- package/src/nodes/YoutubeNode.tsx +0 -101
- package/src/plugins/ColorPlugin.tsx +0 -85
- package/src/plugins/CustomOnChangePlugin.tsx +0 -50
- package/src/plugins/ImagePlugin.tsx +0 -189
- package/src/plugins/ListPlugin.tsx +0 -58
- package/src/plugins/ToolbarPlugin.tsx +0 -500
- package/src/plugins/VideoPlugin.tsx +0 -100
- package/src/plugins/YoutubePlugin.tsx +0 -83
- package/src/styles/lexical-editor.css +0 -1053
- package/src/types/global.d.ts +0 -34
- package/src/types/other.d.ts +0 -11
- package/src/types/react-icons.d.ts +0 -11
- package/tailwind.config.js +0 -10
- package/tsconfig.json +0 -32
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { BsPencilSquare } from "react-icons/bs";
|
|
3
|
-
import { MdCheck } from "react-icons/md";
|
|
4
|
-
import { BiUnlink } from "react-icons/bi";
|
|
5
|
-
|
|
6
|
-
interface LinkEditorProps {
|
|
7
|
-
linkUrl: string;
|
|
8
|
-
setLinkUrl: React.Dispatch<React.SetStateAction<string>>;
|
|
9
|
-
onConfirm: (url: string) => void;
|
|
10
|
-
onCancel: () => void;
|
|
11
|
-
removeLink: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default function LinkModal({
|
|
15
|
-
linkUrl,
|
|
16
|
-
setLinkUrl,
|
|
17
|
-
onConfirm,
|
|
18
|
-
onCancel,
|
|
19
|
-
removeLink,
|
|
20
|
-
}: LinkEditorProps) {
|
|
21
|
-
const [isEditMode, setEditMode] = useState(false);
|
|
22
|
-
const editorRef = useRef<HTMLDivElement | null>(null);
|
|
23
|
-
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (linkUrl === "https://") setEditMode(true);
|
|
27
|
-
}, [linkUrl]);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (isEditMode) inputRef.current?.focus();
|
|
31
|
-
}, [isEditMode]);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
35
|
-
if (
|
|
36
|
-
editorRef.current &&
|
|
37
|
-
!editorRef.current.contains(event.target as Node)
|
|
38
|
-
) {
|
|
39
|
-
onCancel();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
44
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
45
|
-
}, [onCancel]);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div ref={editorRef} className="lexical-text-editor-link link-editor-container">
|
|
49
|
-
<div className="link-editor-input-wrapper">
|
|
50
|
-
{isEditMode ? (
|
|
51
|
-
<input
|
|
52
|
-
ref={inputRef}
|
|
53
|
-
className="link-editor-input"
|
|
54
|
-
value={linkUrl}
|
|
55
|
-
onChange={(e) => setLinkUrl(e.target.value)}
|
|
56
|
-
onKeyDown={(e) => {
|
|
57
|
-
if (e.key === "Enter") {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
onConfirm(linkUrl);
|
|
60
|
-
setEditMode(false);
|
|
61
|
-
} else if (e.key === "Escape") {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
setEditMode(false);
|
|
64
|
-
onCancel();
|
|
65
|
-
}
|
|
66
|
-
}}
|
|
67
|
-
/>
|
|
68
|
-
) : (
|
|
69
|
-
<a
|
|
70
|
-
href={linkUrl}
|
|
71
|
-
target="_blank"
|
|
72
|
-
rel="noopener noreferrer"
|
|
73
|
-
className="link-editor-url"
|
|
74
|
-
>
|
|
75
|
-
{linkUrl}
|
|
76
|
-
</a>
|
|
77
|
-
)}
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<div className="link-editor-buttons">
|
|
81
|
-
|
|
82
|
-
<button type="button"
|
|
83
|
-
className={`lexical-btn heading-trigger toolbar`}
|
|
84
|
-
onClick={() => {
|
|
85
|
-
if (isEditMode) {
|
|
86
|
-
onConfirm(linkUrl);
|
|
87
|
-
setEditMode(false);
|
|
88
|
-
} else setEditMode(true);
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{isEditMode ? <MdCheck size={18} /> : <BsPencilSquare size={14} />}
|
|
92
|
-
</button>
|
|
93
|
-
|
|
94
|
-
<button type="button"
|
|
95
|
-
className={`lexical-btn heading-trigger toolbar`}
|
|
96
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
97
|
-
onClick={removeLink}
|
|
98
|
-
>
|
|
99
|
-
<BiUnlink size={14} style={{ stroke: 'black' }} />
|
|
100
|
-
</button>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{/* <button type="button"
|
|
105
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
106
|
-
onClick={() => {
|
|
107
|
-
if (isEditMode) {
|
|
108
|
-
onConfirm(linkUrl);
|
|
109
|
-
setEditMode(false);
|
|
110
|
-
} else setEditMode(true);
|
|
111
|
-
}}
|
|
112
|
-
className={`size-8 toolbar icon`}
|
|
113
|
-
>
|
|
114
|
-
{isEditMode ? <MdCheck size={18} /> : <BsPencilSquare size={14} />}
|
|
115
|
-
</button> */}
|
|
116
|
-
|
|
117
|
-
{/* <button type="button"
|
|
118
|
-
onMouseDown={(e) => e.preventDefault()}
|
|
119
|
-
onClick={removeLink}
|
|
120
|
-
className={`size-8 toolbar icon`}
|
|
121
|
-
>
|
|
122
|
-
<BiUnlink size={14} style={{ stroke: 'black' }} />
|
|
123
|
-
</button> */}
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ReactNode, useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
open: boolean;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
forPreview?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default function RawDialog({ open, onClose, forPreview = false, children }: Props) {
|
|
11
|
-
const dialogRef = useRef<HTMLDivElement>(null);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (!open) return;
|
|
15
|
-
|
|
16
|
-
const handleOutsideClick = (e: MouseEvent) => {
|
|
17
|
-
if (dialogRef.current && !dialogRef.current.contains(e.target as Node)) {
|
|
18
|
-
onClose();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const handleEsc = (e: KeyboardEvent) => {
|
|
23
|
-
if (e.key === "Escape") onClose();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
document.addEventListener("mousedown", handleOutsideClick);
|
|
27
|
-
document.addEventListener("keydown", handleEsc);
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
document.removeEventListener("mousedown", handleOutsideClick);
|
|
31
|
-
document.removeEventListener("keydown", handleEsc);
|
|
32
|
-
};
|
|
33
|
-
}, [open, onClose]);
|
|
34
|
-
|
|
35
|
-
if (!open) return null;
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className="lexical-text-editor-dialog lte-dialog-overlay">
|
|
39
|
-
<div ref={dialogRef} className={`lte-dialog ${forPreview ? 'preview' : ''}`}>
|
|
40
|
-
<button type="button" className="lte-dialog-close" onClick={onClose}>
|
|
41
|
-
×
|
|
42
|
-
</button>
|
|
43
|
-
{children}
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, cloneElement } from "react";
|
|
2
|
-
|
|
3
|
-
interface PopoverProps {
|
|
4
|
-
open: boolean;
|
|
5
|
-
onOpenChange: (open: boolean) => void;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function Popover({ open, onOpenChange, children }: PopoverProps) {
|
|
10
|
-
const triggerRef = useRef<HTMLElement | null>(null);
|
|
11
|
-
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
12
|
-
|
|
13
|
-
// Close on outside click
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
function handleClick(e: MouseEvent) {
|
|
16
|
-
if (
|
|
17
|
-
!triggerRef.current?.contains(e.target as Node) &&
|
|
18
|
-
!contentRef.current?.contains(e.target as Node)
|
|
19
|
-
) {
|
|
20
|
-
onOpenChange(false);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (open) document.addEventListener("mousedown", handleClick);
|
|
24
|
-
return () => document.removeEventListener("mousedown", handleClick);
|
|
25
|
-
}, [open, onOpenChange]);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div className="popover-root">
|
|
29
|
-
{/*
|
|
30
|
-
Pass refs to trigger/content via props
|
|
31
|
-
so child components can attach them
|
|
32
|
-
*/}
|
|
33
|
-
{React.Children.map(children, (child) => {
|
|
34
|
-
if (!child || typeof child !== "object") return child;
|
|
35
|
-
|
|
36
|
-
if ((child as any).type === PopoverTrigger) {
|
|
37
|
-
return cloneElement(child as any, { triggerRef });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if ((child as any).type === PopoverContent) {
|
|
41
|
-
return cloneElement(child as any, { contentRef });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return child;
|
|
45
|
-
})}
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface PopoverTriggerProps {
|
|
51
|
-
children: React.ReactNode;
|
|
52
|
-
triggerRef: React.RefObject<HTMLDivElement | null>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function PopoverTrigger({ children, triggerRef }: PopoverTriggerProps) {
|
|
56
|
-
return (
|
|
57
|
-
<div className="popover-trigger" ref={triggerRef}>
|
|
58
|
-
{children}
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface PopoverContentProps {
|
|
64
|
-
open: boolean;
|
|
65
|
-
align?: "start" | "center" | "end";
|
|
66
|
-
onClose: () => void;
|
|
67
|
-
children: React.ReactNode;
|
|
68
|
-
contentRef: React.RefObject<HTMLDivElement | null>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function PopoverContent({
|
|
72
|
-
open,
|
|
73
|
-
align = "start",
|
|
74
|
-
children,
|
|
75
|
-
contentRef,
|
|
76
|
-
}: PopoverContentProps) {
|
|
77
|
-
if (!open) return null;
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div
|
|
81
|
-
ref={contentRef}
|
|
82
|
-
className={`popover-content align-${align}`}
|
|
83
|
-
>
|
|
84
|
-
{children}
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, ReactNode } from "react";
|
|
2
|
-
import '../../styles/lexical-editor.css'
|
|
3
|
-
interface TooltipProps {
|
|
4
|
-
content: ReactNode;
|
|
5
|
-
direction?: "top" | "right" | "bottom" | "left";
|
|
6
|
-
delay?: number;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const TooltipX: React.FC<TooltipProps> = ({ content, direction = "top", delay = 400, children }) => {
|
|
11
|
-
const [active, setActive] = useState(false);
|
|
12
|
-
const timeout = useRef<number | null>(null); // <-- browser setTimeout returns number
|
|
13
|
-
|
|
14
|
-
const showTip = () => {
|
|
15
|
-
timeout.current = window.setTimeout(() => {
|
|
16
|
-
setActive(true);
|
|
17
|
-
}, delay);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const hideTip = () => {
|
|
21
|
-
if (timeout.current) {
|
|
22
|
-
clearTimeout(timeout.current);
|
|
23
|
-
}
|
|
24
|
-
setActive(false);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
className="Lexical-Tooltip-Wrapper"
|
|
30
|
-
onMouseEnter={showTip}
|
|
31
|
-
onMouseLeave={hideTip}
|
|
32
|
-
>
|
|
33
|
-
{children}
|
|
34
|
-
{active && (
|
|
35
|
-
<div className={`Lexical-Tooltip-Tip ${direction}`}>
|
|
36
|
-
{content}
|
|
37
|
-
</div>
|
|
38
|
-
)}
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default TooltipX;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
-
import { cva } from "class-variance-authority"
|
|
4
|
-
|
|
5
|
-
import { cn } from "../../lib/utils"
|
|
6
|
-
|
|
7
|
-
const buttonVariants = cva(
|
|
8
|
-
"cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
9
|
-
{
|
|
10
|
-
variants: {
|
|
11
|
-
variant: {
|
|
12
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
13
|
-
toolbar: "bg-transparent hover:bg-slate-100/80 text-gray-600",
|
|
14
|
-
toolbarActive: "bg-slate-100 text-gray-900 ",
|
|
15
|
-
destructive: "bg-destructive text-white hover:bg-destructive/90",
|
|
16
|
-
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
17
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
18
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
19
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
20
|
-
},
|
|
21
|
-
size: {
|
|
22
|
-
default: "h-9 px-4 py-2 has-[>svg]:px-2",
|
|
23
|
-
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
24
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
25
|
-
icon: "size-9",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
defaultVariants: {
|
|
29
|
-
variant: "default",
|
|
30
|
-
size: "default",
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
// Simple props interface without complex types
|
|
36
|
-
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
37
|
-
variant?: "default" | "toolbar" | "toolbarActive" | "destructive" | "outline" | "secondary" | "ghost" | "link"
|
|
38
|
-
size?: "default" | "sm" | "lg" | "icon"
|
|
39
|
-
asChild?: boolean
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
43
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
44
|
-
const Comp = asChild ? Slot : "button"
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Comp
|
|
48
|
-
data-slot="button"
|
|
49
|
-
className={cn(buttonVariants({ variant, size, className }))}
|
|
50
|
-
ref={ref}
|
|
51
|
-
{...props}
|
|
52
|
-
/>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
Button.displayName = "Button"
|
|
57
|
-
|
|
58
|
-
export { Button, buttonVariants }
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from "react"
|
|
3
|
-
import { Command as CommandPrimitive } from "cmdk"
|
|
4
|
-
import { SearchIcon } from "lucide-react"
|
|
5
|
-
|
|
6
|
-
import { cn } from "../../lib/utils"
|
|
7
|
-
import {
|
|
8
|
-
Dialog,
|
|
9
|
-
DialogContent,
|
|
10
|
-
DialogDescription,
|
|
11
|
-
DialogHeader,
|
|
12
|
-
DialogTitle,
|
|
13
|
-
} from "./dialog"
|
|
14
|
-
|
|
15
|
-
function Command({
|
|
16
|
-
className,
|
|
17
|
-
...props
|
|
18
|
-
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
19
|
-
return (
|
|
20
|
-
<CommandPrimitive
|
|
21
|
-
data-slot="command"
|
|
22
|
-
className={cn(
|
|
23
|
-
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
24
|
-
className
|
|
25
|
-
)}
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function CommandDialog({
|
|
32
|
-
title = "Command Palette",
|
|
33
|
-
description = "Search for a command to run...",
|
|
34
|
-
children,
|
|
35
|
-
className,
|
|
36
|
-
showCloseButton = true,
|
|
37
|
-
...props
|
|
38
|
-
}: React.ComponentProps<typeof Dialog> & {
|
|
39
|
-
title?: string
|
|
40
|
-
description?: string
|
|
41
|
-
className?: string
|
|
42
|
-
showCloseButton?: boolean
|
|
43
|
-
}) {
|
|
44
|
-
return (
|
|
45
|
-
<Dialog {...props}>
|
|
46
|
-
<DialogHeader className="sr-only">
|
|
47
|
-
<DialogTitle>{title}</DialogTitle>
|
|
48
|
-
<DialogDescription>{description}</DialogDescription>
|
|
49
|
-
</DialogHeader>
|
|
50
|
-
<DialogContent
|
|
51
|
-
className={cn("overflow-hidden p-0", className)}
|
|
52
|
-
showCloseButton={showCloseButton}
|
|
53
|
-
>
|
|
54
|
-
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
55
|
-
{children}
|
|
56
|
-
</Command>
|
|
57
|
-
</DialogContent>
|
|
58
|
-
</Dialog>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function CommandInput({
|
|
63
|
-
className,
|
|
64
|
-
...props
|
|
65
|
-
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
66
|
-
return (
|
|
67
|
-
<div
|
|
68
|
-
data-slot="command-input-wrapper"
|
|
69
|
-
className="flex h-9 items-center gap-2 border-b px-3"
|
|
70
|
-
>
|
|
71
|
-
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
72
|
-
<CommandPrimitive.Input
|
|
73
|
-
data-slot="command-input"
|
|
74
|
-
className={cn(
|
|
75
|
-
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
76
|
-
className
|
|
77
|
-
)}
|
|
78
|
-
{...props}
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function CommandList({
|
|
85
|
-
className,
|
|
86
|
-
...props
|
|
87
|
-
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
88
|
-
return (
|
|
89
|
-
<CommandPrimitive.List
|
|
90
|
-
data-slot="command-list"
|
|
91
|
-
className={cn(
|
|
92
|
-
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
93
|
-
className
|
|
94
|
-
)}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function CommandEmpty({
|
|
101
|
-
...props
|
|
102
|
-
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
103
|
-
return (
|
|
104
|
-
<CommandPrimitive.Empty
|
|
105
|
-
data-slot="command-empty"
|
|
106
|
-
className="py-6 text-center text-sm"
|
|
107
|
-
{...props}
|
|
108
|
-
/>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function CommandGroup({
|
|
113
|
-
className,
|
|
114
|
-
...props
|
|
115
|
-
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
116
|
-
return (
|
|
117
|
-
<CommandPrimitive.Group
|
|
118
|
-
data-slot="command-group"
|
|
119
|
-
className={cn(
|
|
120
|
-
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
121
|
-
className
|
|
122
|
-
)}
|
|
123
|
-
{...props}
|
|
124
|
-
/>
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function CommandSeparator({
|
|
129
|
-
className,
|
|
130
|
-
...props
|
|
131
|
-
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
132
|
-
return (
|
|
133
|
-
<CommandPrimitive.Separator
|
|
134
|
-
data-slot="command-separator"
|
|
135
|
-
className={cn("bg-border -mx-1 h-px", className)}
|
|
136
|
-
{...props}
|
|
137
|
-
/>
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function CommandItem({
|
|
142
|
-
className,
|
|
143
|
-
...props
|
|
144
|
-
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
145
|
-
return (
|
|
146
|
-
<CommandPrimitive.Item
|
|
147
|
-
data-slot="command-item"
|
|
148
|
-
className={cn(
|
|
149
|
-
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
150
|
-
className
|
|
151
|
-
)}
|
|
152
|
-
{...props}
|
|
153
|
-
/>
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function CommandShortcut({
|
|
158
|
-
className,
|
|
159
|
-
...props
|
|
160
|
-
}: React.ComponentProps<"span">) {
|
|
161
|
-
return (
|
|
162
|
-
<span
|
|
163
|
-
data-slot="command-shortcut"
|
|
164
|
-
className={cn(
|
|
165
|
-
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
166
|
-
className
|
|
167
|
-
)}
|
|
168
|
-
{...props}
|
|
169
|
-
/>
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export {
|
|
174
|
-
Command,
|
|
175
|
-
CommandDialog,
|
|
176
|
-
CommandInput,
|
|
177
|
-
CommandList,
|
|
178
|
-
CommandEmpty,
|
|
179
|
-
CommandGroup,
|
|
180
|
-
CommandItem,
|
|
181
|
-
CommandShortcut,
|
|
182
|
-
CommandSeparator,
|
|
183
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
3
|
-
import { XIcon } from "lucide-react"
|
|
4
|
-
|
|
5
|
-
import { cn } from "../../lib/utils"
|
|
6
|
-
|
|
7
|
-
function Dialog({
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
10
|
-
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function DialogTrigger({
|
|
14
|
-
...props
|
|
15
|
-
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
16
|
-
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function DialogPortal({
|
|
20
|
-
...props
|
|
21
|
-
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
22
|
-
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function DialogClose({
|
|
26
|
-
...props
|
|
27
|
-
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
28
|
-
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function DialogOverlay({
|
|
32
|
-
className,
|
|
33
|
-
...props
|
|
34
|
-
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
35
|
-
return (
|
|
36
|
-
<DialogPrimitive.Overlay
|
|
37
|
-
data-slot="dialog-overlay"
|
|
38
|
-
className={cn(
|
|
39
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
40
|
-
className
|
|
41
|
-
)}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function DialogContent({
|
|
48
|
-
className,
|
|
49
|
-
children,
|
|
50
|
-
showCloseButton = true,
|
|
51
|
-
...props
|
|
52
|
-
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
53
|
-
showCloseButton?: boolean
|
|
54
|
-
}) {
|
|
55
|
-
return (
|
|
56
|
-
<DialogPortal data-slot="dialog-portal">
|
|
57
|
-
<DialogOverlay />
|
|
58
|
-
<DialogPrimitive.Content
|
|
59
|
-
data-slot="dialog-content"
|
|
60
|
-
aria-describedby=""
|
|
61
|
-
className={cn(
|
|
62
|
-
"bg-[#ffffff] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
63
|
-
className
|
|
64
|
-
)}
|
|
65
|
-
{...props}
|
|
66
|
-
>
|
|
67
|
-
{children}
|
|
68
|
-
{showCloseButton && (
|
|
69
|
-
<DialogPrimitive.Close
|
|
70
|
-
data-slot="dialog-close"
|
|
71
|
-
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
72
|
-
>
|
|
73
|
-
<XIcon />
|
|
74
|
-
<span className="sr-only">Close</span>
|
|
75
|
-
</DialogPrimitive.Close>
|
|
76
|
-
)}
|
|
77
|
-
</DialogPrimitive.Content>
|
|
78
|
-
</DialogPortal>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
83
|
-
return (
|
|
84
|
-
<div
|
|
85
|
-
data-slot="dialog-header"
|
|
86
|
-
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
87
|
-
{...props}
|
|
88
|
-
/>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
93
|
-
return (
|
|
94
|
-
<div
|
|
95
|
-
data-slot="dialog-footer"
|
|
96
|
-
className={cn(
|
|
97
|
-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
98
|
-
className
|
|
99
|
-
)}
|
|
100
|
-
{...props}
|
|
101
|
-
/>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function DialogTitle({
|
|
106
|
-
className,
|
|
107
|
-
...props
|
|
108
|
-
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
109
|
-
return (
|
|
110
|
-
<DialogPrimitive.Title
|
|
111
|
-
data-slot="dialog-title"
|
|
112
|
-
className={cn("text-lg leading-none font-semibold", className)}
|
|
113
|
-
{...props}
|
|
114
|
-
/>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function DialogDescription({
|
|
119
|
-
className,
|
|
120
|
-
...props
|
|
121
|
-
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
122
|
-
return (
|
|
123
|
-
<DialogPrimitive.Description
|
|
124
|
-
data-slot="dialog-description"
|
|
125
|
-
className={cn("text-muted-foreground text-sm", className)}
|
|
126
|
-
{...props}
|
|
127
|
-
/>
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export {
|
|
132
|
-
Dialog,
|
|
133
|
-
DialogClose,
|
|
134
|
-
DialogContent,
|
|
135
|
-
DialogDescription,
|
|
136
|
-
DialogFooter,
|
|
137
|
-
DialogHeader,
|
|
138
|
-
DialogOverlay,
|
|
139
|
-
DialogPortal,
|
|
140
|
-
DialogTitle,
|
|
141
|
-
DialogTrigger,
|
|
142
|
-
}
|