Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented spellcheck toggle #144

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 60,6 @@ function createWindow() {
defaultWidth: 1280,
defaultHeight: 720,
});

mainWindow = new BrowserWindow({
autoHideMenuBar: true,
title: "Revolt",
Expand All @@ -72,6 71,9 @@ function createWindow() {
preload: path.resolve(App.getAppPath(), "bundle", "app.js"),
contextIsolation: true,
nodeIntegration: false,
//spellcheck needs to be set to true to initilze values
//if set to false toggle won't work properly
spellcheck: true,
},

x: mainWindowState.x,
Expand All @@ -84,6 86,8 @@ function createWindow() {
minWidth: 300,
minHeight: 300,
});
//sets value to whatever the previous state was defualt is same as webPref
mainWindow.webContents.session.setSpellCheckerEnabled(store.get("spellcheck",true));

if (process.platform === "win32") {
App.setAppUserModelId(mainWindow.title);
Expand Down Expand Up @@ -154,7 158,18 @@ function createWindow() {
}),
);
}

menu.append(
new MenuItem({
label: "Toggle spellcheck",
click: ()=>{
//to improve readability, stores current state of spell check
let isSpellcheck = store.get("spellcheck",true);
mainWindow.webContents.session.setSpellCheckerEnabled(!isSpellcheck);
//stores spellcheck state locally to presist between session
store.set("spellcheck",!isSpellcheck);
},
}),
);
if (menu.items.length > 0) {
menu.popup();
}
Expand Down