Add 'Always Show Thought Bubble' setting - keeps thought bubble permanently expanded
This commit is contained in:
@@ -299,6 +299,10 @@ async function initUI() {
|
|||||||
$('#rpg-toggle-always-show-bubble').on('change', function() {
|
$('#rpg-toggle-always-show-bubble').on('change', function() {
|
||||||
extensionSettings.alwaysShowThoughtBubble = $(this).prop('checked');
|
extensionSettings.alwaysShowThoughtBubble = $(this).prop('checked');
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
// Force immediate save to ensure setting is persisted before any other code runs
|
||||||
|
const context = getContext();
|
||||||
|
const extension_settings = context.extension_settings || context.extensionSettings;
|
||||||
|
extension_settings[extensionName] = extensionSettings;
|
||||||
// Re-render thoughts to apply the setting
|
// Re-render thoughts to apply the setting
|
||||||
updateChatThoughts();
|
updateChatThoughts();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -872,9 +872,7 @@ export function createThoughtPanel($message, thoughtsArray) {
|
|||||||
|
|
||||||
// Append to body so it's not clipped by chat container
|
// Append to body so it's not clipped by chat container
|
||||||
$('body').append($thoughtPanel);
|
$('body').append($thoughtPanel);
|
||||||
$('body').append($thoughtIcon);
|
$('body').append($thoughtIcon); // Position the panel next to the avatar
|
||||||
|
|
||||||
// Position the panel next to the avatar
|
|
||||||
const panelWidth = 350;
|
const panelWidth = 350;
|
||||||
const panelMargin = 20;
|
const panelMargin = 20;
|
||||||
|
|
||||||
@@ -980,30 +978,31 @@ export function createThoughtPanel($message, thoughtsArray) {
|
|||||||
|
|
||||||
// Check if always show bubble is enabled
|
// Check if always show bubble is enabled
|
||||||
if (extensionSettings.alwaysShowThoughtBubble) {
|
if (extensionSettings.alwaysShowThoughtBubble) {
|
||||||
// Always show panel, hide icon
|
// Always show panel expanded, hide both close button and icon
|
||||||
$thoughtPanel.show();
|
$thoughtPanel.show();
|
||||||
|
$thoughtPanel.find('.rpg-thought-close').hide();
|
||||||
$thoughtIcon.hide();
|
$thoughtIcon.hide();
|
||||||
} else {
|
} else {
|
||||||
// Initially hide the panel and show the icon
|
// Initially hide the panel and show the icon
|
||||||
$thoughtPanel.hide();
|
$thoughtPanel.hide();
|
||||||
$thoughtIcon.show();
|
$thoughtIcon.show();
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('[RPG Companion] Thought panel created at:', { top, left });
|
// Close button functionality - only when always show is disabled
|
||||||
|
|
||||||
// Close button functionality
|
|
||||||
$thoughtPanel.find('.rpg-thought-close').on('click', function(e) {
|
$thoughtPanel.find('.rpg-thought-close').on('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$thoughtPanel.fadeOut(200);
|
$thoughtPanel.fadeOut(200);
|
||||||
$thoughtIcon.fadeIn(200);
|
$thoughtIcon.fadeIn(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Icon click to show panel
|
// Icon click to show panel - only when always show is disabled
|
||||||
$thoughtIcon.on('click', function(e) {
|
$thoughtIcon.on('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$thoughtIcon.fadeOut(200);
|
$thoughtIcon.fadeOut(200);
|
||||||
$thoughtPanel.fadeIn(200);
|
$thoughtPanel.fadeIn(200);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('[RPG Companion] Thought panel created at:', { top, left });
|
||||||
|
|
||||||
// Add event handlers for editable thoughts in the bubble
|
// Add event handlers for editable thoughts in the bubble
|
||||||
$thoughtPanel.find('.rpg-editable').on('blur', function() {
|
$thoughtPanel.find('.rpg-editable').on('blur', function() {
|
||||||
@@ -1082,7 +1081,8 @@ export function createThoughtPanel($message, thoughtsArray) {
|
|||||||
$('#chat').on('scroll.thoughtPanel', updatePanelPosition);
|
$('#chat').on('scroll.thoughtPanel', updatePanelPosition);
|
||||||
$(window).on('resize.thoughtPanel', updatePanelPosition);
|
$(window).on('resize.thoughtPanel', updatePanelPosition);
|
||||||
|
|
||||||
// Remove panel when clicking outside (but not when clicking icon or panel)
|
// Remove panel when clicking outside - only if always show is disabled
|
||||||
|
if (!extensionSettings.alwaysShowThoughtBubble) {
|
||||||
$(document).on('click.thoughtPanel', function(e) {
|
$(document).on('click.thoughtPanel', function(e) {
|
||||||
if (!$(e.target).closest('#rpg-thought-panel, #rpg-thought-icon').length) {
|
if (!$(e.target).closest('#rpg-thought-panel, #rpg-thought-icon').length) {
|
||||||
// Hide the panel and show the icon instead of removing
|
// Hide the panel and show the icon instead of removing
|
||||||
@@ -1090,4 +1090,5 @@ export function createThoughtPanel($message, thoughtsArray) {
|
|||||||
$thoughtIcon.fadeIn(200);
|
$thoughtIcon.fadeIn(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user