apply autocomplete colors to stscript codeblocks (hljs)

This commit is contained in:
LenAnderson
2024-04-25 15:45:58 -04:00
parent c16965730c
commit b542c4395e
3 changed files with 139 additions and 83 deletions

View File

@@ -1570,10 +1570,13 @@ function loadPowerUserSettings(settings, data) {
$('#chat_width_slider').val(power_user.chat_width);
$('#token_padding').val(power_user.token_padding);
$('#aux_field').val(power_user.aux_field);
$('#stscript_matching').val(power_user.stscript.matching ?? 'fuzzy');
$('#stscript_autocomplete_style').val(power_user.stscript.autocomplete_style ?? 'theme');
document.body.setAttribute('data-stscript-style', power_user.stscript.autocomplete_style);
$('#stscript_parser_flag_strict_escaping').prop('checked', power_user.stscript.parser.flags[PARSER_FLAG.STRICT_ESCAPING] ?? false);
$('#stscript_parser_flag_replace_getvar').prop('checked', power_user.stscript.parser.flags[PARSER_FLAG.REPLACE_GETVAR] ?? false);
$('#restore_user_input').prop('checked', power_user.restore_user_input);
$('#chat_truncation').val(power_user.chat_truncation);
@@ -3531,6 +3534,7 @@ $(document).ready(() => {
$('#stscript_autocomplete_style').on('change', function () {
const value = $(this).find(':selected').val();
power_user.stscript.autocomplete_style = String(value);
document.body.setAttribute('data-stscript-style', power_user.stscript.autocomplete_style);
saveSettingsDebounced();
});

View File

@@ -434,30 +434,6 @@ export class SlashCommandAutoComplete {
// render autocomplete list
if (this.isReplaceable) {
this.dom.innerHTML = '';
this.dom.classList.remove('defaultDark');
this.dom.classList.remove('defaultLight');
this.dom.classList.remove('defaultThemed');
this.detailsDom.classList.remove('defaultDark');
this.detailsDom.classList.remove('defaultLight');
this.detailsDom.classList.remove('defaultThemed');
switch (power_user.stscript.autocomplete_style ?? 'theme') {
case 'dark': {
this.dom.classList.add('defaultDark');
this.detailsDom.classList.add('defaultDark');
break;
}
case 'light': {
this.dom.classList.add('defaultLight');
this.detailsDom.classList.add('defaultLight');
break;
}
case 'theme':
default: {
this.dom.classList.add('defaultThemed');
this.detailsDom.classList.add('defaultThemed');
break;
}
}
const frag = document.createDocumentFragment();
for (const item of this.result) {
if (item == this.selectedItem) {