Add thonk block copy

This commit is contained in:
Cohee
2025-01-24 01:21:08 +02:00
parent 03c98fb55a
commit 1dd73e74ab
3 changed files with 32 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ import {
saveBase64AsFile,
extractTextFromOffice,
download,
copyText,
} from './utils.js';
import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
@@ -1567,6 +1568,25 @@ jQuery(function () {
$(document).on('click', '.mes_img_enlarge', enlargeMessageImage);
$(document).on('click', '.mes_img_delete', deleteMessageImage);
$(document).on('click', '.mes_reasoning_copy', (e) => {
e.stopPropagation();
e.preventDefault();
});
$(document).on('pointerup', '.mes_reasoning_copy', async function () {
const mesBlock = $(this).closest('.mes');
const mesId = mesBlock.attr('mesid');
const message = chat[mesId];
const reasoning = message?.extra?.reasoning;
if (!reasoning) {
return;
}
await copyText(reasoning);
toastr.info(t`Copied!`, '', { timeOut: 2000 });
});
$('#file_form_input').on('change', async () => {
const fileInput = document.getElementById('file_form_input');
if (!(fileInput instanceof HTMLInputElement)) return;