mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 01:17:39 +01:00
Allow imports in custom CSS. Confirm import usage on theme adding.
This commit is contained in:
parent
2369d35846
commit
60ea9df55e
@ -1074,13 +1074,6 @@ async function applyThemeColor(type) {
|
|||||||
async function applyCustomCSS() {
|
async function applyCustomCSS() {
|
||||||
power_user.custom_css = String(localStorage.getItem(storage_keys.custom_css) ?? '');
|
power_user.custom_css = String(localStorage.getItem(storage_keys.custom_css) ?? '');
|
||||||
|
|
||||||
if (power_user.custom_css.includes('@import')) {
|
|
||||||
var removeImport = /@import[^;]+;/gm;
|
|
||||||
power_user.custom_css = power_user.custom_css.replace(removeImport, '');
|
|
||||||
localStorage.setItem(storage_keys.custom_css, power_user.custom_css);
|
|
||||||
toastr.warning('@import not allowed in Custom CSS. @import lines removed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#customCSS').val(power_user.custom_css);
|
$('#customCSS').val(power_user.custom_css);
|
||||||
var styleId = 'custom-style';
|
var styleId = 'custom-style';
|
||||||
var style = document.getElementById(styleId);
|
var style = document.getElementById(styleId);
|
||||||
@ -2026,6 +2019,13 @@ async function importTheme(file) {
|
|||||||
throw new Error('Theme with that name already exists');
|
throw new Error('Theme with that name already exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parsed.custom_css.includes('@import')) {
|
||||||
|
const confirm = await callPopup('This theme contains @import lines in the Custom CSS. Press "Yes" to proceed.', 'confirm', '', { okButton: 'Yes' });
|
||||||
|
if (!confirm) {
|
||||||
|
throw new Error('Theme contains @import lines');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
themes.push(parsed);
|
themes.push(parsed);
|
||||||
await applyTheme(parsed.name);
|
await applyTheme(parsed.name);
|
||||||
await saveTheme(parsed.name);
|
await saveTheme(parsed.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user