Gate mac spell checker and log status
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
import { app, BrowserWindow, dialog, ipcMain, nativeTheme } from "electron"
|
import { app, BrowserWindow, dialog, ipcMain, nativeTheme, session } from "electron"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { createApplicationMenu } from "./menu"
|
import { createApplicationMenu } from "./menu"
|
||||||
import { setupInstanceIPC } from "./ipc"
|
import { setupInstanceIPC } from "./ipc"
|
||||||
import { setupStorageIPC } from "./storage"
|
import { setupStorageIPC } from "./storage"
|
||||||
|
|
||||||
app.commandLine.appendSwitch("disable-spell-checking")
|
const isMac = process.platform === "darwin"
|
||||||
|
|
||||||
|
if (isMac) {
|
||||||
|
app.commandLine.appendSwitch("disable-spell-checking")
|
||||||
|
}
|
||||||
|
|
||||||
// Setup IPC handlers before creating windows
|
// Setup IPC handlers before creating windows
|
||||||
setupStorageIPC()
|
setupStorageIPC()
|
||||||
@@ -25,12 +29,14 @@ function createWindow() {
|
|||||||
preload: join(__dirname, "../preload/index.js"),
|
preload: join(__dirname, "../preload/index.js"),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
spellcheck: false,
|
spellcheck: !isMac,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Disable macOS spell server to avoid input lag
|
if (isMac) {
|
||||||
mainWindow.webContents.session.setSpellCheckerEnabled(false)
|
// Disable macOS spell server to avoid input lag
|
||||||
|
mainWindow.webContents.session.setSpellCheckerEnabled(false)
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
mainWindow.loadURL("http://localhost:3000")
|
mainWindow.loadURL("http://localhost:3000")
|
||||||
@@ -47,7 +53,22 @@ function createWindow() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isMac) {
|
||||||
|
app.on("web-contents-created", (_, contents) => {
|
||||||
|
contents.session.setSpellCheckerEnabled(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
if (isMac) {
|
||||||
|
session.defaultSession.setSpellCheckerEnabled(false)
|
||||||
|
app.on("browser-window-created", (_, window) => {
|
||||||
|
window.webContents.session.setSpellCheckerEnabled(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("[spellcheck] default session enabled:", session.defaultSession.isSpellCheckerEnabled())
|
||||||
|
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
app.on("activate", () => {
|
app.on("activate", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user