Toggle spell checker in the session rather than the webPreferences.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-03-08 15:40:16 -08:00
parent c6022e94bb
commit 4ed4328bf8
5 changed files with 18 additions and 19 deletions

View File

@@ -71,13 +71,7 @@ export default class WebView {
? html``
: html`preload="${props.preload}"`}
partition="persist:webviewsession"
webpreferences="
contextIsolation,
spellcheck=${Boolean(
ConfigUtil.getConfigItem("enableSpellchecker", true),
)},
worldSafeExecuteJavaScript=true
"
webpreferences="contextIsolation, worldSafeExecuteJavaScript=true"
>
</webview>
`;

View File

@@ -128,7 +128,6 @@ export class ServerManagerView {
await this.initTabs();
this.initActions();
this.registerIpcs();
ipcRenderer.send("set-spellcheck-langs");
}
async loadProxy(): Promise<void> {

View File

@@ -425,6 +425,7 @@ export function initGeneralSection({$root}: GeneralSectionProps): void {
clickHandler: () => {
const newValue = !ConfigUtil.getConfigItem("enableSpellchecker", true);
ConfigUtil.setConfigItem("enableSpellchecker", newValue);
ipcRenderer.send("configure-spell-checker");
enableSpellchecker();
const spellcheckerLanguageInput: HTMLElement =
$root.querySelector("#spellcheck-langs")!;
@@ -664,7 +665,7 @@ export function initGeneralSection({$root}: GeneralSectionProps): void {
tagField.addEventListener("change", () => {
if (tagField.value.length === 0) {
ConfigUtil.setConfigItem("spellcheckerLanguages", []);
ipcRenderer.send("set-spellcheck-langs");
ipcRenderer.send("configure-spell-checker");
} else {
const data: unknown = JSON.parse(tagField.value);
const spellLangs: string[] = z
@@ -672,7 +673,7 @@ export function initGeneralSection({$root}: GeneralSectionProps): void {
.parse(data)
.map((elt) => languagePairs.get(elt.value)!);
ConfigUtil.setConfigItem("spellcheckerLanguages", spellLangs);
ipcRenderer.send("set-spellcheck-langs");
ipcRenderer.send("configure-spell-checker");
}
});
}