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
fcb9e377
Commit
fcb9e377
authored
Jan 29, 2026
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: streamline memo editor insert menu
parent
b32cba35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
32 deletions
+55
-32
InsertMenu.tsx
web/src/components/MemoEditor/Toolbar/InsertMenu.tsx
+55
-32
No files found.
web/src/components/MemoEditor/Toolbar/InsertMenu.tsx
View file @
fcb9e377
import
{
LatLng
}
from
"leaflet"
;
import
{
uniqBy
}
from
"lodash-es"
;
import
{
FileIcon
,
LinkIcon
,
LoaderIcon
,
MapPinIcon
,
Maximize2Icon
,
MoreHorizontalIcon
,
PlusIcon
}
from
"lucide-react"
;
import
{
use
Effect
,
useState
}
from
"react"
;
import
{
FileIcon
,
LinkIcon
,
LoaderIcon
,
MapPinIcon
,
Maximize2Icon
,
MoreHorizontalIcon
,
PlusIcon
,
type
LucideIcon
}
from
"lucide-react"
;
import
{
use
Callback
,
useEffect
,
useMemo
,
useState
}
from
"react"
;
import
{
useDebounce
}
from
"react-use"
;
import
{
useReverseGeocoding
}
from
"@/components/map"
;
import
{
Button
}
from
"@/components/ui/button"
;
...
...
@@ -26,6 +26,7 @@ import type { LocalFile } from "../types/attachment";
const
InsertMenu
=
(
props
:
InsertMenuProps
)
=>
{
const
t
=
useTranslate
();
const
{
state
,
actions
,
dispatch
}
=
useEditorContext
();
const
{
location
:
initialLocation
,
onLocationChange
,
onToggleFocusMode
,
isUploading
:
isUploadingProp
}
=
props
;
const
[
linkDialogOpen
,
setLinkDialogOpen
]
=
useState
(
false
);
const
[
locationDialogOpen
,
setLocationDialogOpen
]
=
useState
(
false
);
...
...
@@ -70,11 +71,15 @@ const InsertMenu = (props: InsertMenuProps) => {
}
},
[
displayName
]);
const
isUploading
=
selectingFlag
||
props
.
isUploading
;
const
isUploading
=
selectingFlag
||
isUploadingProp
;
const
handleLocationClick
=
()
=>
{
const
handleOpenLinkDialog
=
useCallback
(()
=>
{
setLinkDialogOpen
(
true
);
},
[]);
const
handleLocationClick
=
useCallback
(()
=>
{
setLocationDialogOpen
(
true
);
if
(
!
props
.
l
ocation
&&
!
location
.
locationInitialized
)
{
if
(
!
initialL
ocation
&&
!
location
.
locationInitialized
)
{
if
(
navigator
.
geolocation
)
{
navigator
.
geolocation
.
getCurrentPosition
(
(
position
)
=>
{
...
...
@@ -86,24 +91,54 @@ const InsertMenu = (props: InsertMenuProps) => {
);
}
}
};
}
,
[
initialLocation
,
location
])
;
const
handleLocationConfirm
=
()
=>
{
const
handleLocationConfirm
=
useCallback
(
()
=>
{
const
newLocation
=
location
.
getLocation
();
if
(
newLocation
)
{
props
.
onLocationChange
(
newLocation
);
onLocationChange
(
newLocation
);
setLocationDialogOpen
(
false
);
}
};
}
,
[
location
,
onLocationChange
])
;
const
handleLocationCancel
=
()
=>
{
const
handleLocationCancel
=
useCallback
(
()
=>
{
location
.
reset
();
setLocationDialogOpen
(
false
);
};
}
,
[
location
])
;
const
handlePositionChange
=
(
position
:
LatLng
)
=>
{
const
handlePositionChange
=
useCallback
(
(
position
:
LatLng
)
=>
{
location
.
handlePositionChange
(
position
);
};
},
[
location
]);
const
handleToggleFocusMode
=
useCallback
(()
=>
{
onToggleFocusMode
?.();
setMoreSubmenuOpen
(
false
);
},
[
onToggleFocusMode
]);
const
menuItems
=
useMemo
(
()
=>
[
{
key
:
"upload"
,
label
:
t
(
"common.upload"
),
icon
:
FileIcon
,
onClick
:
handleUploadClick
,
},
{
key
:
"link"
,
label
:
t
(
"tooltip.link-memo"
),
icon
:
LinkIcon
,
onClick
:
handleOpenLinkDialog
,
},
{
key
:
"location"
,
label
:
t
(
"tooltip.select-location"
),
icon
:
MapPinIcon
,
onClick
:
handleLocationClick
,
},
]
satisfies
Array
<
{
key
:
string
;
label
:
string
;
icon
:
LucideIcon
;
onClick
:
()
=>
void
}
>
,
[
handleLocationClick
,
handleOpenLinkDialog
,
handleUploadClick
,
t
],
);
return
(
<>
...
...
@@ -114,18 +149,12 @@ const InsertMenu = (props: InsertMenuProps) => {
</
Button
>
</
DropdownMenuTrigger
>
<
DropdownMenuContent
align=
"start"
>
<
DropdownMenuItem
onClick=
{
handleUploadClick
}
>
<
FileIcon
className=
"w-4 h-4"
/>
{
t
(
"common.upload"
)
}
</
DropdownMenuItem
>
<
DropdownMenuItem
onClick=
{
()
=>
setLinkDialogOpen
(
true
)
}
>
<
LinkIcon
className=
"w-4 h-4"
/>
{
t
(
"tooltip.link-memo"
)
}
</
DropdownMenuItem
>
<
DropdownMenuItem
onClick=
{
handleLocationClick
}
>
<
MapPinIcon
className=
"w-4 h-4"
/>
{
t
(
"tooltip.select-location"
)
}
{
menuItems
.
map
((
item
)
=>
(
<
DropdownMenuItem
key=
{
item
.
key
}
onClick=
{
item
.
onClick
}
>
<
item
.
icon
className=
"w-4 h-4"
/>
{
item
.
label
}
</
DropdownMenuItem
>
))
}
{
/* View submenu with Focus Mode */
}
<
DropdownMenuSub
open=
{
moreSubmenuOpen
}
onOpenChange=
{
setMoreSubmenuOpen
}
>
<
DropdownMenuSubTrigger
onPointerEnter=
{
handleTriggerEnter
}
onPointerLeave=
{
handleTriggerLeave
}
>
...
...
@@ -133,15 +162,9 @@ const InsertMenu = (props: InsertMenuProps) => {
{
t
(
"common.more"
)
}
</
DropdownMenuSubTrigger
>
<
DropdownMenuSubContent
onPointerEnter=
{
handleContentEnter
}
onPointerLeave=
{
handleContentLeave
}
>
<
DropdownMenuItem
onClick=
{
()
=>
{
props
.
onToggleFocusMode
?.();
setMoreSubmenuOpen
(
false
);
}
}
>
<
DropdownMenuItem
onClick=
{
handleToggleFocusMode
}
>
<
Maximize2Icon
className=
"w-4 h-4"
/>
{
t
(
"editor.focus-mode"
)
}
<
span
className=
"ml-auto text-xs text-muted-foreground opacity-60"
>
⌘⇧F
</
span
>
</
DropdownMenuItem
>
</
DropdownMenuSubContent
>
</
DropdownMenuSub
>
...
...
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