Add thonk block copy
| @@ -6232,6 +6232,7 @@ | ||
| 6232 | 6232 | <details class="mes_reasoning_details"> |
| 6233 | 6233 | <summary class="mes_reasoning_summary"> |
| 6234 | 6234 | <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> | |
| 6235 | 6236 | </summary> |
| 6236 | 6237 | <div class="mes_reasoning"></div> |
| 6237 | 6238 | </details> |
| @@ -37,6 +37,7 @@ import { | ||
| 37 | 37 | saveBase64AsFile, |
| 38 | 38 | extractTextFromOffice, |
| 39 | 39 | download, |
| 40 | + copyText, | |
| 40 | 41 | } from './utils.js'; |
| 41 | 42 | import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js'; |
| 42 | 43 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; |
| @@ -1567,6 +1568,25 @@ jQuery(function () { | ||
| 1567 | 1568 | $(document).on('click', '.mes_img_enlarge', enlargeMessageImage); |
| 1568 | 1569 | $(document).on('click', '.mes_img_delete', deleteMessageImage); |
| 1569 | 1570 | |
| 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 | + | |
| 1570 | 1590 | $('#file_form_input').on('change', async () => { |
| 1571 | 1591 | const fileInput = document.getElementById('file_form_input'); |
| 1572 | 1592 | if (!(fileInput instanceof HTMLInputElement)) return; |
| @@ -345,6 +345,17 @@ input[type='checkbox']:focus-visible { | ||
| 345 | 345 | |
| 346 | 346 | .mes_reasoning_summary { |
| 347 | 347 | 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; | |
| 348 | 359 | } |
| 349 | 360 | |
| 350 | 361 | .mes_reasoning_summary > span { |