Editor selection error caused by Chinese input method deleted

I reproduced this issue in the latest Electron version 31. I haven’t found a way to reproduce it in a regular browser yet. Below is the Electron code. After installing the dependencies, run it, and using the Sogou input method will trigger this behavior.

main.js:

const { app, BrowserWindow, shell } = require('electron');

function createWindow() {
  const win = new BrowserWindow({
    width: 1280,
    height: 800,
    autoHideMenuBar: true,
    webPreferences: {
      // 加载外部站点时的推荐安全设置
      contextIsolation: true,
      nodeIntegration: false,
      sandbox: true
    }
  });

  // 直接加载 ProseMirror 官网
  win.loadURL('https://prosemirror.net/');

  // 阻止窗口内打开新窗口,外链用系统默认浏览器打开
  win.webContents.setWindowOpenHandler(({ url }) => {
    shell.openExternal(url);
    return { action: 'deny' };
  });
  win.webContents.on('before-input-event', (event, input) => {
      const isToggle =
          (input.type === 'keyDown' && input.key === 'F12') ||
          (input.type === 'keyDown' && input.key.toUpperCase() === 'I' && input.control && input.shift);
      if (isToggle) {
          win.webContents.toggleDevTools();
          event.preventDefault();
      }
  });
}

// macOS 保持常规行为;Windows/Linux 关闭即退出
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) createWindow();
});

package.json:

{
  "name": "electron-prosemirror-embed",
  "version": "1.0.0",
  "private": true,
  "description": "Embed https://prosemirror.net/ inside an Electron window",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "devDependencies": {
    "electron": "^31.0.0"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}