diff --git a/src/apps/chat/components/message/ChatMessage.tsx b/src/apps/chat/components/message/ChatMessage.tsx index e25d5cad0..c144841c9 100644 --- a/src/apps/chat/components/message/ChatMessage.tsx +++ b/src/apps/chat/components/message/ChatMessage.tsx @@ -10,6 +10,7 @@ import AlternateEmailIcon from '@mui/icons-material/AlternateEmail'; import CheckRoundedIcon from '@mui/icons-material/CheckRounded'; import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; import ContentCopyIcon from '@mui/icons-material/ContentCopy'; +import ContentCutIcon from '@mui/icons-material/ContentCut'; import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'; import DifferenceIcon from '@mui/icons-material/Difference'; import EditRoundedIcon from '@mui/icons-material/EditRounded'; @@ -1103,6 +1104,14 @@ export function ChatMessage(props: { } + {fromAssistant && + { + handleHighlightSelText('cut'); + closeBubble(); + }}> + + + } {fromAssistant && } {/* Intelligent functions */} diff --git a/src/apps/chat/components/message/useSelHighlighterMemo.ts b/src/apps/chat/components/message/useSelHighlighterMemo.ts index 00fc4385a..f8e44fea0 100644 --- a/src/apps/chat/components/message/useSelHighlighterMemo.ts +++ b/src/apps/chat/components/message/useSelHighlighterMemo.ts @@ -23,8 +23,9 @@ import { BUBBLE_MIN_TEXT_LENGTH } from './ChatMessage'; const APPLY_HTML_HIGHLIGHT = (text: string) => `${text}`; const APPLY_HTML_STRIKE = (text: string) => `${text}`; const APPLY_MD_STRONG = (text: string) => wrapWithMarkdownSyntax(text, '**'); +const APPLY_CUT = (_text: string) => ''; // Cut removes the text entirely -type HighlightTool = 'highlight' | 'strike' | 'strong'; +type HighlightTool = 'highlight' | 'strike' | 'strong' | 'cut'; export function useSelHighlighterMemo( messageId: DMessageId, @@ -60,12 +61,14 @@ export function useSelHighlighterMemo( tool === 'highlight' ? APPLY_HTML_HIGHLIGHT(selText) : tool === 'strike' ? APPLY_HTML_STRIKE(selText) : tool === 'strong' ? APPLY_MD_STRONG(selText) - : selText; + : tool === 'cut' ? APPLY_CUT(selText) + : selText; - // Toggle, if the tooled text is already present + // Toggle, if the tooled text is already present (except for cut which always removes) const newFragmentText = - fragmentText.includes(highlighted) ? fragmentText.replace(highlighted, selText) // toggles selection - : fragmentText.replace(selText, highlighted); + tool === 'cut' ? fragmentText.replace(selText, highlighted) // Cut always removes text + : fragmentText.includes(highlighted) ? fragmentText.replace(highlighted, selText) // toggles selection + : fragmentText.replace(selText, highlighted); // Replace the whole fragment within the message onMessageFragmentReplace(messageId, fragment.fId, createTextContentFragment(newFragmentText));