fix(style): tooltip shown when no content

This commit is contained in:
jialin
2024-10-25 22:36:26 +08:00
parent a185bd9463
commit f730548c8f
6 changed files with 57 additions and 48 deletions
@@ -246,25 +246,26 @@ const MessageInput: React.FC<MessageInputProps> = ({
};
const handleOnPaste = (e: any) => {
e.preventDefault();
// e.preventDefault();
const text = e.clipboardData.getData('text');
if (text) {
const startPos = e.target.selectionStart;
const endPos = e.target.selectionEnd;
setMessage?.({
...message,
content:
message.content.slice(0, startPos) +
text +
message.content.slice(endPos)
});
if (endPos !== startPos) {
setTimeout(() => {
e.target.setSelectionRange(endPos, endPos);
}, 0);
}
// const startPos = e.target.selectionStart;
// const endPos = e.target.selectionEnd;
// setMessage?.({
// ...message,
// content:
// message.content.slice(0, startPos) +
// text +
// message.content.slice(endPos)
// });
// if (endPos !== startPos) {
// setTimeout(() => {
// e.target.setSelectionRange(endPos, endPos);
// }, 0);
// }
} else {
e.preventDefault();
getPasteContent(e);
}
};
@@ -105,23 +105,24 @@ const ContentItem: React.FC<MessageItemProps> = ({
);
const handleOnPaste = (e: any) => {
e.preventDefault();
// e.preventDefault();
const text = e.clipboardData.getData('text');
if (text) {
const startPos = e.target.selectionStart;
const endPos = e.target.selectionEnd;
updateMessage?.({
role: data.role,
content:
data.content.slice(0, startPos) + text + data.content.slice(endPos),
uid: data.uid
});
if (endPos !== startPos) {
setTimeout(() => {
e.target.setSelectionRange(endPos, endPos);
}, 0);
}
// const startPos = e.target.selectionStart;
// const endPos = e.target.selectionEnd;
// updateMessage?.({
// role: data.role,
// content:
// data.content.slice(0, startPos) + text + data.content.slice(endPos),
// uid: data.uid
// });
// if (endPos !== startPos) {
// setTimeout(() => {
// e.target.setSelectionRange(endPos, endPos);
// }, 0);
// }
} else {
e.preventDefault();
getPasteContent(e);
}
};