(frontend) can remove emoji in the tree item actions

Add action button to remove emoji
from a document title from the document tree.
This commit is contained in:
Olivier Laurendeau
2025-09-15 15:43:11 +02:00
committed by Anthony LC
parent b667200ebd
commit 192fa76b54
2 changed files with 42 additions and 1 deletions

View File

@@ -13,8 +13,10 @@ import {
Doc,
ModalRemoveDoc,
Role,
getEmojiAndTitle,
useCopyDocLink,
useCreateChildDoc,
useDocTitleUpdate,
useDuplicateDoc,
} from '@/docs/doc-management';
@@ -44,6 +46,7 @@ export const DocTreeItemActions = ({
const copyLink = useCopyDocLink(doc.id);
const { mutate: detachDoc } = useDetachDoc();
const treeContext = useTreeContext<Doc | null>();
const { mutate: duplicateDoc } = useDuplicateDoc({
onSuccess: (duplicatedDoc) => {
// Reset the tree context root will reset the full tree view.
@@ -52,6 +55,13 @@ export const DocTreeItemActions = ({
},
});
// Emoji Management
const { emoji } = getEmojiAndTitle(doc.title ?? '');
const { updateDocEmoji } = useDocTitleUpdate();
const removeEmoji = () => {
updateDocEmoji(doc.id, doc.title ?? '', '');
};
const handleDetachDoc = () => {
if (!treeContext?.root) {
return;
@@ -82,6 +92,15 @@ export const DocTreeItemActions = ({
},
...(!isRoot
? [
...(emoji && doc.abilities.partial_update
? [
{
label: t('Remove emoji'),
icon: <Icon iconName="emoji_emotions" $size="24px" />,
callback: removeEmoji,
},
]
: []),
{
label: t('Move to my docs'),
isDisabled: doc.user_role !== Role.OWNER,