diff --git a/web/package.json b/web/package.json index 4b74b4d8..9ee0e41d 100644 --- a/web/package.json +++ b/web/package.json @@ -13,6 +13,7 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@matejmazur/react-katex": "^3.1.3", + "@mui/base": "5.0.0-beta.31", "@mui/joy": "5.0.0-beta.22", "@reduxjs/toolkit": "^1.9.7", "axios": "^1.6.5", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 265f30eb..64e6f372 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -17,6 +17,9 @@ dependencies: '@matejmazur/react-katex': specifier: ^3.1.3 version: 3.1.3(katex@0.16.9)(react@18.2.0) + '@mui/base': + specifier: 5.0.0-beta.31 + version: 5.0.0-beta.31(@types/react@18.2.47)(react-dom@18.2.0)(react@18.2.0) '@mui/joy': specifier: 5.0.0-beta.22 version: 5.0.0-beta.22(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.47)(react-dom@18.2.0)(react@18.2.0) diff --git a/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx b/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx index 97017909..555c1f26 100644 --- a/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx +++ b/web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx @@ -67,15 +67,13 @@ const MarkdownMenu = (props: Props) => { slots={{ root: IconButton }} slotProps={{ root: { - className: - "flex flex-row justify-center items-center p-1 w-auto h-auto mr-1 select-none rounded cursor-pointer text-gray-600 dark:!text-gray-400 hover:bg-gray-300 dark:hover:bg-zinc-800 hover:shadow", size: "sm", }, }} > - + Code block diff --git a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx index 436d4b86..24a8b3c9 100644 --- a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx +++ b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx @@ -1,16 +1,19 @@ -import { IconButton } from "@mui/joy"; -import { useEffect } from "react"; +import { ClickAwayListener } from "@mui/base/ClickAwayListener"; +import { Dropdown, IconButton, Menu, MenuButton } from "@mui/joy"; +import { useEffect, useState } from "react"; import Icon from "@/components/Icon"; import OverflowTip from "@/components/kit/OverflowTip"; import { useTagStore } from "@/store/module"; +import { EditorRefActions } from "../Editor"; interface Props { - onTagSelectorClick: (tag: string) => void; + editorRef: React.RefObject; } const TagSelector = (props: Props) => { - const { onTagSelectorClick } = props; + const { editorRef } = props; const tagStore = useTagStore(); + const [open, setOpen] = useState(false); const tags = tagStore.state.tags; useEffect(() => { @@ -23,32 +26,50 @@ const TagSelector = (props: Props) => { })(); }, []); + const handleTagClick = (tag: string) => { + editorRef.current?.insertText(`#${tag} `); + }; + return ( - - -
- {tags.length > 0 ? ( - tags.map((tag) => { - return ( -
onTagSelectorClick(tag)} - key={tag} - > - #{tag} -
- ); - }) - ) : ( -

e.stopPropagation()}> - No tags found -

- )} -
-
+ setOpen(isOpen)}> + + + + + { + setOpen(false); + }} + > + {tags.length > 0 ? ( +
+ {tags.map((tag) => { + return ( +
handleTagClick(tag)} + key={tag} + > + #{tag} +
+ ); + })} +
+ ) : ( +

e.stopPropagation()}> + No tag found +

+ )} +
+
+
); }; diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index 9a72c991..34b86eaa 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -1,6 +1,6 @@ import { Select, Option, Button, IconButton, Divider } from "@mui/joy"; import { uniqBy } from "lodash-es"; -import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import React, { useEffect, useMemo, useRef, useState } from "react"; import { toast } from "react-hot-toast"; import { useTranslation } from "react-i18next"; import useLocalStorage from "react-use/lib/useLocalStorage"; @@ -335,10 +335,6 @@ const MemoEditor = (props: Props) => { }); }; - const handleTagSelectorClick = useCallback((tag: string) => { - editorRef.current?.insertText(`#${tag} `); - }, []); - const handleEditorFocus = () => { editorRef.current?.focus(); }; @@ -368,20 +364,12 @@ const MemoEditor = (props: Props) => { >
e.stopPropagation()}> -
- handleTagSelectorClick(tag)} /> - +
+ + - +