mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 18:10:26 +08:00
feat(MessageMenubar): add edit option to dropdown for single message editing
This commit is contained in:
parent
87b106fad6
commit
c6cf790851
@ -26,6 +26,7 @@ import { findImageBlocks, findMainTextBlocks, getMainTextContent } from '@render
|
|||||||
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { AtSign, Copy, Languages, Menu, RefreshCw, Save, Share, Split, ThumbsUp, Trash } from 'lucide-react'
|
import { AtSign, Copy, Languages, Menu, RefreshCw, Save, Share, Split, ThumbsUp, Trash } from 'lucide-react'
|
||||||
|
import { FilePenLine } from 'lucide-react'
|
||||||
import { FC, memo, useCallback, useMemo, useState } from 'react'
|
import { FC, memo, useCallback, useMemo, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
@ -221,6 +222,10 @@ const MessageMenubar: FC<Props> = (props) => {
|
|||||||
[isTranslating, message, getTranslationUpdater, mainTextContent]
|
[isTranslating, message, getTranslationUpdater, mainTextContent]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const isEditable = useMemo(() => {
|
||||||
|
return findMainTextBlocks(message).length === 1
|
||||||
|
}, [message])
|
||||||
|
|
||||||
const dropdownItems = useMemo(
|
const dropdownItems = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@ -232,12 +237,16 @@ const MessageMenubar: FC<Props> = (props) => {
|
|||||||
window.api.file.save(fileName, mainTextContent)
|
window.api.file.save(fileName, mainTextContent)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
...(isEditable
|
||||||
// label: t('common.edit'),
|
? [
|
||||||
// key: 'edit',
|
{
|
||||||
// icon: <FilePenLine size={16} />,
|
label: t('common.edit'),
|
||||||
// onClick: onEdit
|
key: 'edit',
|
||||||
// },
|
icon: <FilePenLine size={16} />,
|
||||||
|
onClick: onEdit
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
label: t('chat.message.new.branch'),
|
label: t('chat.message.new.branch'),
|
||||||
key: 'new-branch',
|
key: 'new-branch',
|
||||||
@ -338,7 +347,7 @@ const MessageMenubar: FC<Props> = (props) => {
|
|||||||
].filter(Boolean)
|
].filter(Boolean)
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[message, messageContainerRef, mainTextContent, onNewBranch, t, topic.name, exportMenuOptions]
|
[message, messageContainerRef, onEdit, mainTextContent, onNewBranch, t, topic.name, exportMenuOptions]
|
||||||
)
|
)
|
||||||
|
|
||||||
const onRegenerate = async (e: React.MouseEvent | undefined) => {
|
const onRegenerate = async (e: React.MouseEvent | undefined) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user