mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into scored-search-sorting
This commit is contained in:
@@ -192,7 +192,8 @@ class WorldInfoBuffer {
|
||||
return haystack.includes(transformedString);
|
||||
}
|
||||
else {
|
||||
const regex = new RegExp(`\\b${escapeRegex(transformedString)}\\b`);
|
||||
// Use custom boundaries to include punctuation and other non-alphanumeric characters
|
||||
const regex = new RegExp(`(?:^|\\W)(${escapeRegex(transformedString)})(?:$|\\W)`);
|
||||
if (regex.test(haystack)) {
|
||||
return true;
|
||||
}
|
||||
@@ -753,7 +754,12 @@ function nullWorldInfo() {
|
||||
function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
updateEditor = (navigation) => displayWorldEntries(name, data, navigation);
|
||||
|
||||
$('#world_popup_entries_list').empty().show();
|
||||
const worldEntriesList = $('#world_popup_entries_list');
|
||||
|
||||
// We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements
|
||||
// This prevents jQuery from actually going through all registered events on the controls for each entry when removing it
|
||||
worldEntriesList.find('*').off();
|
||||
worldEntriesList.empty().show();
|
||||
|
||||
if (!data || !('entries' in data)) {
|
||||
$('#world_popup_new').off('click').on('click', nullWorldInfo);
|
||||
@@ -761,7 +767,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
$('#world_popup_export').off('click').on('click', nullWorldInfo);
|
||||
$('#world_popup_delete').off('click').on('click', nullWorldInfo);
|
||||
$('#world_duplicate').off('click').on('click', nullWorldInfo);
|
||||
$('#world_popup_entries_list').hide();
|
||||
worldEntriesList.hide();
|
||||
$('#world_info_pagination').html('');
|
||||
return;
|
||||
}
|
||||
@@ -808,7 +814,11 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
formatNavigator: PAGINATION_TEMPLATE,
|
||||
showNavigator: true,
|
||||
callback: function (/** @type {object[]} */ page) {
|
||||
$('#world_popup_entries_list').empty();
|
||||
// We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements
|
||||
// This prevents jQuery from actually going through all registered events on the controls for each entry when removing it
|
||||
worldEntriesList.find('*').off();
|
||||
worldEntriesList.empty();
|
||||
|
||||
const keywordHeaders = `
|
||||
<div id="WIEntryHeaderTitlesPC" class="flex-container wide100p spaceBetween justifyCenter textAlignCenter" style="padding:0 4.5em;">
|
||||
<small class="flex1">
|
||||
@@ -837,8 +847,8 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
block.find('.drag-handle').remove();
|
||||
});
|
||||
}
|
||||
$('#world_popup_entries_list').append(keywordHeaders);
|
||||
$('#world_popup_entries_list').append(blocks);
|
||||
worldEntriesList.append(keywordHeaders);
|
||||
worldEntriesList.append(blocks);
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
localStorage.setItem(storageKey, e.target.value);
|
||||
@@ -850,6 +860,8 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (typeof navigation === 'number' && Number(navigation) >= 0) {
|
||||
const selector = `#world_popup_entries_list [uid="${navigation}"]`;
|
||||
const data = getDataArray();
|
||||
@@ -951,12 +963,12 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
||||
});
|
||||
|
||||
// Check if a sortable instance exists
|
||||
if ($('#world_popup_entries_list').sortable('instance') !== undefined) {
|
||||
if (worldEntriesList.sortable('instance') !== undefined) {
|
||||
// Destroy the instance
|
||||
$('#world_popup_entries_list').sortable('destroy');
|
||||
worldEntriesList.sortable('destroy');
|
||||
}
|
||||
|
||||
$('#world_popup_entries_list').sortable({
|
||||
worldEntriesList.sortable({
|
||||
delay: getSortableDelay(),
|
||||
handle: '.drag-handle',
|
||||
stop: async function (event, ui) {
|
||||
@@ -2545,11 +2557,11 @@ function convertAgnaiMemoryBook(inputObj) {
|
||||
useProbability: false,
|
||||
group: '',
|
||||
groupOverride: false,
|
||||
scanDepth: entry.extensions?.scan_depth ?? null,
|
||||
caseSensitive: entry.extensions?.case_sensitive ?? null,
|
||||
matchWholeWords: entry.extensions?.match_whole_words ?? null,
|
||||
automationId: entry.extensions?.automation_id ?? '',
|
||||
role: entry.extensions?.role ?? extension_prompt_roles.SYSTEM,
|
||||
scanDepth: null,
|
||||
caseSensitive: null,
|
||||
matchWholeWords: null,
|
||||
automationId: '',
|
||||
role: extension_prompt_roles.SYSTEM,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -2581,11 +2593,11 @@ function convertRisuLorebook(inputObj) {
|
||||
useProbability: entry.activationPercent ?? false,
|
||||
group: '',
|
||||
groupOverride: false,
|
||||
scanDepth: entry.extensions?.scan_depth ?? null,
|
||||
caseSensitive: entry.extensions?.case_sensitive ?? null,
|
||||
matchWholeWords: entry.extensions?.match_whole_words ?? null,
|
||||
automationId: entry.extensions?.automation_id ?? '',
|
||||
role: entry.extensions?.role ?? extension_prompt_roles.SYSTEM,
|
||||
scanDepth: null,
|
||||
caseSensitive: null,
|
||||
matchWholeWords: null,
|
||||
automationId: '',
|
||||
role: extension_prompt_roles.SYSTEM,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -2622,11 +2634,11 @@ function convertNovelLorebook(inputObj) {
|
||||
useProbability: false,
|
||||
group: '',
|
||||
groupOverride: false,
|
||||
scanDepth: entry.extensions?.scan_depth ?? null,
|
||||
caseSensitive: entry.extensions?.case_sensitive ?? null,
|
||||
matchWholeWords: entry.extensions?.match_whole_words ?? null,
|
||||
automationId: entry.extensions?.automation_id ?? '',
|
||||
role: entry.extensions?.role ?? extension_prompt_roles.SYSTEM,
|
||||
scanDepth: null,
|
||||
caseSensitive: null,
|
||||
matchWholeWords: null,
|
||||
automationId: '',
|
||||
role: extension_prompt_roles.SYSTEM,
|
||||
};
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user