diff --git a/public/script.js b/public/script.js index a8937495a..7efe1d231 100644 --- a/public/script.js +++ b/public/script.js @@ -869,9 +869,6 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) { .replace(/\*\*(.+?)\*\*/g, "$1") .replace(/\n/g, "
"); } else if (!isSystem) { - const image = /<img src="(.*?)".*?alt="(.*?)".*?>/g; - mes = mes.replace(image, '![$2]($1)'); - mes = converter.makeHtml(mes); //mes = mes.replace(/{.*}/g, ""); mes = mes.replace(/{{(\*?.+?\*?)}}/g, ""); @@ -2205,6 +2202,9 @@ function saveReply(type, getMessage, this_mes_is_name) { type = 'normal'; } + const img = extractImageFromMessage(getMessage); + getMessage = img.getMessage; + if (type === 'swipe') { chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipes'].length] = getMessage; if (chat[chat.length - 1]['swipe_id'] === chat[chat.length - 1]['swipes'].length - 1) { @@ -2234,12 +2234,32 @@ function saveReply(type, getMessage, this_mes_is_name) { chat[chat.length - 1]['is_name'] = true; chat[chat.length - 1]['force_avatar'] = avatarImg; } - //console.log('runGenerate calls addOneMessage'); + + saveImageToMessage(img, chat[chat.length - 1]); addOneMessage(chat[chat.length - 1]); } return { type, getMessage }; } +function saveImageToMessage(img, mes) { + if (mes && img.image) { + if (typeof mes.extra !== 'object') { + mes.extra = {}; + } + mes.extra.image = img.image; + mes.title = img.title; + } +} + +function extractImageFromMessage(getMessage) { + const regex = //g; + const results = regex.exec(getMessage); + const image = results ? results[1] : ''; + const title = results ? results[2] : ''; + getMessage = getMessage.replace(regex, ''); + return { getMessage, image, title }; +} + function isMultigenEnabled() { return power_user.multigen && (main_api == 'textgenerationwebui' || main_api == 'kobold' || main_api == 'novel'); } diff --git a/public/style.css b/public/style.css index 1bc34d5fc..4eb0630f6 100644 --- a/public/style.css +++ b/public/style.css @@ -344,7 +344,6 @@ code { outline: none; border: none; position: relative; - display: inline; opacity: 0.7; cursor: pointer; z-index: 2001; @@ -352,6 +351,8 @@ code { padding-top: 0; transition: 0.3s; font-size: 30px; + display: flex; + align-items: center; } .font-family-reset { @@ -407,6 +408,7 @@ code { display: flex; align-items: center; column-gap: 10px; + cursor: pointer; } .options-content a div:first-child {