|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import { Dropdown, Menu, MenuButton, MenuItem, Tooltip } from "@mui/joy";
|
|
|
|
|
import EmojiRegex from "emoji-regex";
|
|
|
|
|
import { Edit3Icon, MoreVerticalIcon, TrashIcon, PlusIcon } from "lucide-react";
|
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
|
import { userServiceClient } from "@/grpcweb";
|
|
|
|
@ -11,6 +12,8 @@ import { cn } from "@/utils";
|
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
|
import showCreateShortcutDialog from "../CreateShortcutDialog";
|
|
|
|
|
|
|
|
|
|
const emojiRegex = EmojiRegex();
|
|
|
|
|
|
|
|
|
|
const ShortcutsSection = observer(() => {
|
|
|
|
|
const t = useTranslate();
|
|
|
|
|
const user = useCurrentUser();
|
|
|
|
@ -40,16 +43,20 @@ const ShortcutsSection = observer(() => {
|
|
|
|
|
<div className="w-full flex flex-row justify-start items-center relative flex-wrap gap-x-2 gap-y-1">
|
|
|
|
|
{shortcuts.map((shortcut) => {
|
|
|
|
|
const selected = memoFilterStore.shortcut === shortcut.id;
|
|
|
|
|
const maybeEmoji = shortcut.title.split(" ")[0];
|
|
|
|
|
const emoji = emojiRegex.test(maybeEmoji) ? maybeEmoji : undefined;
|
|
|
|
|
const title = emoji ? shortcut.title.replace(emoji, "") : shortcut.title;
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={shortcut.id}
|
|
|
|
|
className="shrink-0 w-full text-sm rounded-md leading-6 flex flex-row justify-between items-center select-none gap-2 text-gray-600 dark:text-gray-400 dark:border-zinc-800"
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
className={cn("truncate cursor-pointer dark:opacity-80", selected && "text-primary font-medium underline")}
|
|
|
|
|
className={cn("truncate cursor-pointer dark:opacity-80", selected && "text-primary font-medium")}
|
|
|
|
|
onClick={() => (selected ? memoFilterStore.setShortcut(undefined) : memoFilterStore.setShortcut(shortcut.id))}
|
|
|
|
|
>
|
|
|
|
|
{shortcut.title}
|
|
|
|
|
{emoji && <span className="text-base mr-1">{emoji}</span>}
|
|
|
|
|
{title.trim()}
|
|
|
|
|
</span>
|
|
|
|
|
<Dropdown>
|
|
|
|
|
<MenuButton slots={{ root: "div" }}>
|
|
|
|
|