Add option for live preview

This commit is contained in:
DominikDoom
2023-05-02 17:59:36 +02:00
parent 94365630c7
commit 0e177d0945
2 changed files with 11 additions and 0 deletions

View File

@@ -202,6 +202,7 @@ async function syncOptions() {
translationFile: opts["tac_translation.translationFile"],
oldFormat: opts["tac_translation.oldFormat"],
searchByTranslation: opts["tac_translation.searchByTranslation"],
liveTranslation: opts["tac_translation.liveTranslation"],
},
// Extra file settings
extra: {
@@ -238,6 +239,13 @@ async function syncOptions() {
});
}
// Remove ruby div if live preview was disabled
if (newCFG.translation.liveTranslation === false) {
[...gradioApp().querySelectorAll('.acRuby')].forEach(r => {
r.remove();
});
}
// Apply changes
CFG = newCFG;
@@ -587,6 +595,8 @@ function updateSelectionStyle(textArea, newIndex, oldIndex) {
}
function updateRuby(textArea, prompt) {
if (!CFG.translation.liveTranslation) return;
let ruby = gradioApp().querySelector('.acRuby' + getTextAreaIdentifier(textArea));
if (!ruby) {
let textAreaId = getTextAreaIdentifier(textArea);