From 0cde7e7a7fe6d13b279d8bda6cb8e36eaf2d7f87 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 11 Mar 2025 04:42:03 +0100 Subject: [PATCH 1/2] Add md hotkey support for expando editor - When original textarea supports markdown, the textarea of the expanded popup will also have markdown support - Also add the small markdown icon at the top --- public/scripts/chats.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/scripts/chats.js b/public/scripts/chats.js index a6f2432d2..2386b88d6 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -1506,7 +1506,7 @@ jQuery(function () { embedMessageFile(messageId, messageBlock); }); - $(document).on('click', '.editor_maximize', function () { + $(document).on('click', '.editor_maximize', async function () { const broId = $(this).attr('data-for'); const bro = $(`#${broId}`); const contentEditable = bro.is('[contenteditable]'); @@ -1525,6 +1525,12 @@ jQuery(function () { textarea.value = String(contentEditable ? bro[0].innerText : bro.val()); textarea.classList.add('height100p', 'wide100p', 'maximized_textarea'); bro.hasClass('monospace') && textarea.classList.add('monospace'); + if (power_user.enable_md_hotkeys && bro.hasClass('mdHotkeys')) { + textarea.classList.add('mdHotkeys'); + const mdIcon = document.createElement('i'); + mdIcon.classList.add('fa-brands', 'fa-markdown', 'mdhotkey_icon', 'alignSelfStart'); + wrapper.appendChild(mdIcon); + } textarea.addEventListener('input', function () { if (contentEditable) { bro[0].innerText = textarea.value; @@ -1565,7 +1571,7 @@ jQuery(function () { }); } - callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true }); + await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true }); }); $(document).on('click', 'body.documentstyle .mes .mes_text', function () { From 90cfdebff8a08708760bde65b928d508a30f2170 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 11 Mar 2025 10:39:14 +0100 Subject: [PATCH 2/2] Remove unnecessary markdown icon --- public/scripts/chats.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 2386b88d6..4584bfc8a 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -1525,12 +1525,7 @@ jQuery(function () { textarea.value = String(contentEditable ? bro[0].innerText : bro.val()); textarea.classList.add('height100p', 'wide100p', 'maximized_textarea'); bro.hasClass('monospace') && textarea.classList.add('monospace'); - if (power_user.enable_md_hotkeys && bro.hasClass('mdHotkeys')) { - textarea.classList.add('mdHotkeys'); - const mdIcon = document.createElement('i'); - mdIcon.classList.add('fa-brands', 'fa-markdown', 'mdhotkey_icon', 'alignSelfStart'); - wrapper.appendChild(mdIcon); - } + bro.hasClass('mdHotkeys') && textarea.classList.add('mdHotkeys'); textarea.addEventListener('input', function () { if (contentEditable) { bro[0].innerText = textarea.value;