Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: remove command

Steven0df3171b6478
diff --git a/web/src/components/MemoEditor/ActionButton/AddMemoRelationPopover.tsx b/web/src/components/MemoEditor/ActionButton/AddMemoRelationPopover.tsx
index d1a210b43..43c0e6205 100644
--- a/web/src/components/MemoEditor/ActionButton/AddMemoRelationPopover.tsx
+++ b/web/src/components/MemoEditor/ActionButton/AddMemoRelationPopover.tsx
@@ -6,7 +6,7 @@ import useDebounce from "react-use/lib/useDebounce";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
-import { Command, CommandInput, CommandItem, CommandList, CommandEmpty } from "@/components/ui/command";
+import { Input } from "@/components/ui/input";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { memoServiceClient } from "@/grpcweb";
import { DEFAULT_LIST_MEMOS_PAGE_SIZE } from "@/helpers/consts";
@@ -157,34 +157,36 @@ const AddMemoRelationPopover = (props: Props) => {
)}
{/* Search and selection interface */}
- <Command className="w-full">
- <CommandInput
+ <div className="w-full">
+ <Input
placeholder={t("reference.search-placeholder")}
value={searchText}
- onValueChange={setSearchText}
- className="h-9"
+ onChange={(e) => setSearchText(e.target.value)}
+ className="h-9 mb-2"
/>
- <CommandList className="max-h-[200px]">
- <CommandEmpty>{isFetching ? "Loading..." : t("reference.no-memos-found")}</CommandEmpty>
- {filteredMemos.map((memo) => (
- <CommandItem
- key={memo.name}
- value={memo.name}
- onSelect={() => {
- setSelectedMemos((prev) => [...prev, memo]);
- }}
- className="cursor-pointer"
- >
- <div className="w-full flex flex-col justify-start items-start">
- <p className="text-xs text-gray-400 select-none">{memo.displayTime?.toLocaleString()}</p>
- <p className="mt-0.5 text-sm leading-5 line-clamp-2">
- {searchText ? getHighlightedContent(memo.content) : memo.snippet}
- </p>
+ <div className="max-h-[200px] overflow-y-auto">
+ {filteredMemos.length === 0 ? (
+ <div className="py-6 text-center text-sm text-gray-500">{isFetching ? "Loading..." : t("reference.no-memos-found")}</div>
+ ) : (
+ filteredMemos.map((memo) => (
+ <div
+ key={memo.name}
+ className="relative flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground"
+ onClick={() => {
+ setSelectedMemos((prev) => [...prev, memo]);
+ }}
+ >
+ <div className="w-full flex flex-col justify-start items-start">
+ <p className="text-xs text-gray-400 select-none">{memo.displayTime?.toLocaleString()}</p>
+ <p className="mt-0.5 text-sm leading-5 line-clamp-2">
+ {searchText ? getHighlightedContent(memo.content) : memo.snippet}
+ </p>
+ </div>
</div>
- </CommandItem>
- ))}
- </CommandList>
- </Command>
+ ))
+ )}
+ </div>
+ </div>
<div className="mt-2 w-full flex flex-row justify-end items-center gap-2">
<div className="flex items-center space-x-2">
diff --git a/web/src/components/ui/command.tsx b/web/src/components/ui/command.tsx
deleted file mode 100644
index fa516f9b8..000000000
--- a/web/src/components/ui/command.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Command as CommandPrimitive } from "cmdk";
-import { SearchIcon } from "lucide-react";
-import * as React from "react";
-import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
-import { cn } from "@/lib/utils";
-
-function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
- return (
- <CommandPrimitive
- data-slot="command"
- className={cn("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md", className)}
- {...props}
- />
- );
-}
-
-function CommandDialog({
- title = "Command Palette",
- description = "Search for a command to run...",
- children,
- className,
- showCloseButton = true,
- ...props
-}: React.ComponentProps<typeof Dialog> & {
- title?: string;
- description?: string;
- className?: string;
- showCloseButton?: boolean;
-}) {
- return (
- <Dialog {...props}>
- <DialogHeader className="sr-only">
- <DialogTitle>{title}</DialogTitle>
- <DialogDescription>{description}</DialogDescription>
- </DialogHeader>
- <DialogContent className={cn("overflow-hidden p-0", className)} showCloseButton={showCloseButton}>
- <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">
- {children}
- </Command>
- </DialogContent>
- </Dialog>
- );
-}
-
-function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {
- return (
- <div data-slot="command-input-wrapper" className="flex h-9 items-center gap-2 border-b px-3">
- <SearchIcon className="size-4 shrink-0 opacity-50" />
- <CommandPrimitive.Input
- data-slot="command-input"
- className={cn(
- "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",
- className,
- )}
- {...props}
- />
- </div>
- );
-}
-
-function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
- return (
- <CommandPrimitive.List
- data-slot="command-list"
- className={cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)}
- {...props}
- />
- );
-}
-
-function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
- return <CommandPrimitive.Empty data-slot="command-empty" className="py-6 text-center text-sm" {...props} />;
-}
-
-function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
- return (
- <CommandPrimitive.Group
- data-slot="command-group"
- className={cn(
- "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",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
- return <CommandPrimitive.Separator data-slot="command-separator" className={cn("bg-border -mx-1 h-px", className)} {...props} />;
-}
-
-function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
- return (
- <CommandPrimitive.Item
- data-slot="command-item"
- className={cn(
- "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",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) {
- return (
- <span data-slot="command-shortcut" className={cn("text-muted-foreground ml-auto text-xs tracking-widest", className)} {...props} />
- );
-}
-
-export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator };