Caption: Add 'Show captions in chat' setting

37528c81b3d8fd12907786e32177c1f0554902d7

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

2 files changed, +17 -3Showing whitespace changes
public/scripts/extensions/caption/index.js+9 -0
@@ -53,6 +53,10 @@ function migrateSettings() {
53 if (!extension_settings.caption.template) {53 if (!extension_settings.caption.template) {
54 extension_settings.caption.template = TEMPLATE_DEFAULT;54 extension_settings.caption.template = TEMPLATE_DEFAULT;
55 }55 }
56
57 if (!extension_settings.caption.show_in_chat) {
58 extension_settings.caption.show_in_chat = false;
59 }
56}60}
5761
58/**62/**
@@ -167,6 +171,7 @@ async function sendCaptionedMessage(caption, image) {
167 extra: {171 extra: {
168 image: image,172 image: image,
169 title: messageText,173 title: messageText,
174 inline_image: !!extension_settings.caption.show_in_chat,
170 },175 },
171 };176 };
172 context.chat.push(message);177 context.chat.push(message);
@@ -596,6 +601,10 @@ jQuery(async function () {
596 extension_settings.caption.alt_endpoint_enabled = !!$('#caption_altEndpoint_enabled').prop('checked');601 extension_settings.caption.alt_endpoint_enabled = !!$('#caption_altEndpoint_enabled').prop('checked');
597 saveSettingsDebounced();602 saveSettingsDebounced();
598 });603 });
604 $('#caption_show_in_chat').prop('checked', !!(extension_settings.caption.show_in_chat)).on('input', () => {
605 extension_settings.caption.show_in_chat = !!$('#caption_show_in_chat').prop('checked');
606 saveSettingsDebounced();
607 });
599608
600 const onMessageEvent = async (index) => {609 const onMessageEvent = async (index) => {
601 if (!extension_settings.caption.auto_mode) {610 if (!extension_settings.caption.auto_mode) {
public/scripts/extensions/caption/settings.html+8 -3
@@ -228,23 +228,28 @@
228 </div>228 </div>
229 <div id="caption_prompt_block">229 <div id="caption_prompt_block">
230 <label for="caption_prompt" data-i18n="Caption Prompt">Caption Prompt</label>230 <label for="caption_prompt" data-i18n="Caption Prompt">Caption Prompt</label>
231 <textarea id="caption_prompt" class="text_pole" rows="1" placeholder="&lt; Use default &gt;">{{PROMPT_DEFAULT}}</textarea>231 <textarea id="caption_prompt" class="text_pole textarea_compact autoSetHeight" rows="1" placeholder="&lt; Use default &gt;">{{PROMPT_DEFAULT}}</textarea>
232 <label class="checkbox_label margin-bot-10px" for="caption_prompt_ask" title="Ask for a custom prompt every time an image is captioned.">232 <label class="checkbox_label margin-bot-10px" for="caption_prompt_ask" title="Ask for a custom prompt every time an image is captioned.">
233 <input id="caption_prompt_ask" type="checkbox" class="checkbox">233 <input id="caption_prompt_ask" type="checkbox" class="checkbox">
234 <span data-i18n="Ask every time">Ask every time</span>234 <span data-i18n="Ask every time">Ask every time</span>
235 </label>235 </label>
236 </div>236 </div>
237 <label for="caption_template"><span data-i18n="Message Template">Message Template</span> <small><span data-i18n="(use _space">(use </span> <code>&lcub;&lcub;caption&rcub;&rcub;</code> <span data-i18n="macro)">macro)</span></small></label>237 <label for="caption_template"><span data-i18n="Message Template">Message Template</span> <small><span data-i18n="(use _space">(use </span> <code>&lcub;&lcub;caption&rcub;&rcub;</code> <span data-i18n="macro)">macro)</span></small></label>
238 <textarea id="caption_template" class="text_pole" rows="2" placeholder="&lt; Use default &gt;">{{TEMPLATE_DEFAULT}}</textarea>238 <textarea id="caption_template" class="text_pole textarea_compact autoSetHeight" rows="2" placeholder="&lt; Use default &gt;">{{TEMPLATE_DEFAULT}}</textarea>
239 <label class="checkbox_label" for="caption_auto_mode">239 <label class="checkbox_label" for="caption_auto_mode">
240 <input id="caption_auto_mode" type="checkbox" class="checkbox">240 <input id="caption_auto_mode" type="checkbox" class="checkbox">
241 <span data-i18n="Automatically caption images">Automatically caption images</span>241 <span data-i18n="Automatically caption images">Automatically caption images</span>
242 <i class="fa-solid fa-info-circle" title="Automatically caption images when they are pasted into the chat or attached to messages."></i>242 <i class="fa-solid fa-info-circle" title="Automatically caption images when they are pasted into the chat or attached to messages."></i>
243 </label>243 </label>
244 <label class="checkbox_label margin-bot-10px" for="caption_refine_mode">244 <label class="checkbox_label" for="caption_refine_mode">
245 <input id="caption_refine_mode" type="checkbox" class="checkbox">245 <input id="caption_refine_mode" type="checkbox" class="checkbox">
246 <span data-i18n="Edit captions before saving">Edit captions before saving</span>246 <span data-i18n="Edit captions before saving">Edit captions before saving</span>
247 </label>247 </label>
248 <label class="checkbox_label" for="caption_show_in_chat">
249 <input id="caption_show_in_chat" type="checkbox" class="checkbox">
250 <span data-i18n="Show captions in chat">Show captions in chat</span>
251 </label>
252 <div class="margin-bot-10px"></div>
248 </div>253 </div>
249 </div>254 </div>
250</div>255</div>