Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
6db7ad76
Commit
6db7ad76
authored
Jan 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update tag selector
parent
4a407668
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
49 deletions
+60
-49
package.json
web/package.json
+1
-0
pnpm-lock.yaml
web/pnpm-lock.yaml
+3
-0
MarkdownMenu.tsx
web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
+1
-3
TagSelector.tsx
web/src/components/MemoEditor/ActionButton/TagSelector.tsx
+50
-29
index.tsx
web/src/components/MemoEditor/index.tsx
+5
-17
No files found.
web/package.json
View file @
6db7ad76
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
"@emotion/react"
:
"^11.11.3"
,
"@emotion/react"
:
"^11.11.3"
,
"@emotion/styled"
:
"^11.11.0"
,
"@emotion/styled"
:
"^11.11.0"
,
"@matejmazur/react-katex"
:
"^3.1.3"
,
"@matejmazur/react-katex"
:
"^3.1.3"
,
"@mui/base"
:
"5.0.0-beta.31"
,
"@mui/joy"
:
"5.0.0-beta.22"
,
"@mui/joy"
:
"5.0.0-beta.22"
,
"@reduxjs/toolkit"
:
"^1.9.7"
,
"@reduxjs/toolkit"
:
"^1.9.7"
,
"axios"
:
"^1.6.5"
,
"axios"
:
"^1.6.5"
,
...
...
web/pnpm-lock.yaml
View file @
6db7ad76
...
@@ -17,6 +17,9 @@ dependencies:
...
@@ -17,6 +17,9 @@ dependencies:
'
@matejmazur/react-katex'
:
'
@matejmazur/react-katex'
:
specifier
:
^3.1.3
specifier
:
^3.1.3
version
:
3.1.3(katex@0.16.9)(react@18.2.0)
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'
:
'
@mui/joy'
:
specifier
:
5.0.0-beta.22
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)
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)
...
...
web/src/components/MemoEditor/ActionButton/MarkdownMenu.tsx
View file @
6db7ad76
...
@@ -67,15 +67,13 @@ const MarkdownMenu = (props: Props) => {
...
@@ -67,15 +67,13 @@ const MarkdownMenu = (props: Props) => {
slots=
{
{
root
:
IconButton
}
}
slots=
{
{
root
:
IconButton
}
}
slotProps=
{
{
slotProps=
{
{
root
:
{
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"
,
size
:
"sm"
,
},
},
}
}
}
}
>
>
<
Icon
.
SquareSlash
className=
"w-5 h-5 mx-auto"
/>
<
Icon
.
SquareSlash
className=
"w-5 h-5 mx-auto"
/>
</
MenuButton
>
</
MenuButton
>
<
Menu
className=
"text-sm"
size=
"sm"
>
<
Menu
className=
"text-sm"
size=
"sm"
placement=
"bottom-start"
>
<
MenuItem
onClick=
{
handleCodeBlockClick
}
>
<
MenuItem
onClick=
{
handleCodeBlockClick
}
>
<
Icon
.
Code2
className=
"w-4 h-auto"
/>
<
Icon
.
Code2
className=
"w-4 h-auto"
/>
<
span
>
Code block
</
span
>
<
span
>
Code block
</
span
>
...
...
web/src/components/MemoEditor/ActionButton/TagSelector.tsx
View file @
6db7ad76
import
{
IconButton
}
from
"@mui/joy"
;
import
{
ClickAwayListener
}
from
"@mui/base/ClickAwayListener"
;
import
{
useEffect
}
from
"react"
;
import
{
Dropdown
,
IconButton
,
Menu
,
MenuButton
}
from
"@mui/joy"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
Icon
from
"@/components/Icon"
;
import
Icon
from
"@/components/Icon"
;
import
OverflowTip
from
"@/components/kit/OverflowTip"
;
import
OverflowTip
from
"@/components/kit/OverflowTip"
;
import
{
useTagStore
}
from
"@/store/module"
;
import
{
useTagStore
}
from
"@/store/module"
;
import
{
EditorRefActions
}
from
"../Editor"
;
interface
Props
{
interface
Props
{
onTagSelectorClick
:
(
tag
:
string
)
=>
void
;
editorRef
:
React
.
RefObject
<
EditorRefActions
>
;
}
}
const
TagSelector
=
(
props
:
Props
)
=>
{
const
TagSelector
=
(
props
:
Props
)
=>
{
const
{
onTagSelectorClick
}
=
props
;
const
{
editorRef
}
=
props
;
const
tagStore
=
useTagStore
();
const
tagStore
=
useTagStore
();
const
[
open
,
setOpen
]
=
useState
(
false
);
const
tags
=
tagStore
.
state
.
tags
;
const
tags
=
tagStore
.
state
.
tags
;
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -23,32 +26,50 @@ const TagSelector = (props: Props) => {
...
@@ -23,32 +26,50 @@ const TagSelector = (props: Props) => {
})();
})();
},
[]);
},
[]);
const
handleTagClick
=
(
tag
:
string
)
=>
{
editorRef
.
current
?.
insertText
(
`#
${
tag
}
`
);
};
return
(
return
(
<
IconButton
<
Dropdown
open=
{
open
}
onOpenChange=
{
(
_
,
isOpen
)
=>
setOpen
(
isOpen
)
}
>
className=
"relative group 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 hover:shadow"
<
MenuButton
size=
"sm"
slots=
{
{
root
:
IconButton
}
}
slotProps=
{
{
root
:
{
size
:
"sm"
,
},
}
}
>
>
<
Icon
.
Hash
className=
"w-5 h-5 mx-auto"
/>
<
Icon
.
Hash
className=
"w-5 h-5 mx-auto"
/>
<
div
className=
"hidden flex-row justify-start items-start flex-wrap absolute top-7 left-0 mt-1 p-1 z-1 rounded w-52 h-auto max-h-48 overflow-y-auto font-mono shadow bg-zinc-100 dark:bg-zinc-700 group-hover:flex"
>
</
MenuButton
>
<
Menu
className=
"relative text-sm"
size=
"sm"
placement=
"bottom-start"
>
<
ClickAwayListener
onClickAway=
{
()
=>
{
setOpen
(
false
);
}
}
>
{
tags
.
length
>
0
?
(
{
tags
.
length
>
0
?
(
tags
.
map
((
tag
)
=>
{
<
div
className=
"flex-row justify-start items-start flex-wrap px-1 max-w-[12rem] h-auto max-h-48 overflow-y-auto font-mono"
>
{
tags
.
map
((
tag
)
=>
{
return
(
return
(
<
div
<
div
className=
"w-auto max-w-full text-black dark:text-gray-300 cursor-pointer rounded text-sm leading-6 px-2 hover:bg-zinc-2
00 dark:hover:bg-zinc-800 shrink-0"
className=
"inline-block w-auto max-w-full cursor-pointer rounded text-sm leading-6 px-2 hover:bg-zinc-1
00 dark:hover:bg-zinc-800 shrink-0"
onClick=
{
()
=>
onTagSelector
Click
(
tag
)
}
onClick=
{
()
=>
handleTag
Click
(
tag
)
}
key=
{
tag
}
key=
{
tag
}
>
>
<
OverflowTip
>
#
{
tag
}
</
OverflowTip
>
<
OverflowTip
>
#
{
tag
}
</
OverflowTip
>
</
div
>
</
div
>
);
);
})
})
}
</
div
>
)
:
(
)
:
(
<
p
className=
"italic text-sm ml-2
"
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
<
p
className=
"italic mx-1
"
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
No tags
found
No tag
found
</
p
>
</
p
>
)
}
)
}
</
div
>
</
ClickAwayListener
>
</
IconButton
>
</
Menu
>
</
Dropdown
>
);
);
};
};
...
...
web/src/components/MemoEditor/index.tsx
View file @
6db7ad76
import
{
Select
,
Option
,
Button
,
IconButton
,
Divider
}
from
"@mui/joy"
;
import
{
Select
,
Option
,
Button
,
IconButton
,
Divider
}
from
"@mui/joy"
;
import
{
uniqBy
}
from
"lodash-es"
;
import
{
uniqBy
}
from
"lodash-es"
;
import
React
,
{
use
Callback
,
use
Effect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
useLocalStorage
from
"react-use/lib/useLocalStorage"
;
import
useLocalStorage
from
"react-use/lib/useLocalStorage"
;
...
@@ -335,10 +335,6 @@ const MemoEditor = (props: Props) => {
...
@@ -335,10 +335,6 @@ const MemoEditor = (props: Props) => {
});
});
};
};
const
handleTagSelectorClick
=
useCallback
((
tag
:
string
)
=>
{
editorRef
.
current
?.
insertText
(
`#
${
tag
}
`
);
},
[]);
const
handleEditorFocus
=
()
=>
{
const
handleEditorFocus
=
()
=>
{
editorRef
.
current
?.
focus
();
editorRef
.
current
?.
focus
();
};
};
...
@@ -368,20 +364,12 @@ const MemoEditor = (props: Props) => {
...
@@ -368,20 +364,12 @@ const MemoEditor = (props: Props) => {
>
>
<
Editor
ref=
{
editorRef
}
{
...
editorConfig
}
/>
<
Editor
ref=
{
editorRef
}
{
...
editorConfig
}
/>
<
div
className=
"relative w-full flex flex-row justify-between items-center pt-2"
onFocus=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
<
div
className=
"relative w-full flex flex-row justify-between items-center pt-2"
onFocus=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center opacity-80"
>
<
TagSelector
onTagSelectorClick=
{
(
tag
)
=>
handleTagSelectorClick
(
tag
)
}
/>
<
TagSelector
editorRef=
{
editorRef
}
/>
<
IconButton
<
IconButton
size=
"sm"
onClick=
{
handleUploadFileBtnClick
}
>
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"
onClick=
{
handleUploadFileBtnClick
}
>
<
Icon
.
Image
className=
"w-5 h-5 mx-auto"
/>
<
Icon
.
Image
className=
"w-5 h-5 mx-auto"
/>
</
IconButton
>
</
IconButton
>
<
IconButton
<
IconButton
size=
"sm"
onClick=
{
handleAddMemoRelationBtnClick
}
>
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"
onClick=
{
handleAddMemoRelationBtnClick
}
>
<
Icon
.
Link
className=
"w-5 h-5 mx-auto"
/>
<
Icon
.
Link
className=
"w-5 h-5 mx-auto"
/>
</
IconButton
>
</
IconButton
>
<
MarkdownMenu
editorRef=
{
editorRef
}
/>
<
MarkdownMenu
editorRef=
{
editorRef
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment