Add thonk block copy

1dd73e74ab25a569de2251aec5268e36e7606376

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +32 -0Ignore whitespace
public/index.html+1 -0
@@ -6232,6 +6232,7 @@
62326232 <details class="mes_reasoning_details">
62336233 <summary class="mes_reasoning_summary">
62346234 <span data-i18n="Reasoning">Reasoning</span>
6235+ <div class="mes_reasoning_copy right_menu_button fa-solid fa-copy" title="Copy reasoning" data-i18n="[title]Copy reasoning"></div>
62356236 </summary>
62366237 <div class="mes_reasoning"></div>
62376238 </details>
public/scripts/chats.js+20 -0
@@ -37,6 +37,7 @@ import {
3737 saveBase64AsFile,
3838 extractTextFromOffice,
3939 download,
40+ copyText,
4041} from './utils.js';
4142import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
4243import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
@@ -1567,6 +1568,25 @@ jQuery(function () {
15671568 $(document).on('click', '.mes_img_enlarge', enlargeMessageImage);
15681569 $(document).on('click', '.mes_img_delete', deleteMessageImage);
15691570
1571+ $(document).on('click', '.mes_reasoning_copy', (e) => {
1572+ e.stopPropagation();
1573+ e.preventDefault();
1574+ });
1575+
1576+ $(document).on('pointerup', '.mes_reasoning_copy', async function () {
1577+ const mesBlock = $(this).closest('.mes');
1578+ const mesId = mesBlock.attr('mesid');
1579+ const message = chat[mesId];
1580+ const reasoning = message?.extra?.reasoning;
1581+
1582+ if (!reasoning) {
1583+ return;
1584+ }
1585+
1586+ await copyText(reasoning);
1587+ toastr.info(t`Copied!`, '', { timeOut: 2000 });
1588+ });
1589+
15701590 $('#file_form_input').on('change', async () => {
15711591 const fileInput = document.getElementById('file_form_input');
15721592 if (!(fileInput instanceof HTMLInputElement)) return;
public/style.css+11 -0
@@ -345,6 +345,17 @@ input[type='checkbox']:focus-visible {
345345
346346.mes_reasoning_summary {
347347 cursor: pointer;
348+ position: relative;
349+}
350+
351+.mes_reasoning_details:not([open]) .mes_reasoning_copy {
352+ display: none;
353+}
354+
355+.mes_reasoning_copy {
356+ position: absolute;
357+ right: 0;
358+ top: 0;
348359}
349360
350361.mes_reasoning_summary > span {