Editor selection error caused by Chinese input method deleted

In the client of Electron, opening the ProseMirror webpage may cause issues such as in GIF images, which may be due to the Chinese Pinyin not being in the editor during combined input. How can this be resolved. Browser kernel and electron version: Chrome/126.0.6478.234 Electron/31.6.0

问题

I suspect this isn’t specific to Electron, as there appear to be several IME-related issues circulating. Unfortunately, I don’t currently have an IME available to reproduce and debug the problem, I may need to set up an environment to reproduce it.

Thank you for your reply. The issue I reproduced mainly occurs when using composed input, where the editor replaces the pinyin selection with Chinese text. However, some input methods do not display pinyin within the editor, which might be environment-related. Has ProseMirror considered replacing the original selection replacement with an alternative approach.

Does using a more recent electron help? Can you reproduce this issue in modern Chrome?

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"
}

It looks like 31 is over a year old and the current version is 40. That’s why I’m asking if upgrading Electron helps.

I only work on bugs that show up in major browsers, not platforms like Electron or various custom webviews. So setting up a self-contained reproduction example that runs in plain Chrome would be useful.