fix(core): linux redo shortcut key (#15623)

fix #15599

#### PR Dependency Tree


* **PR #15623** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected the Control+Y redo shortcut so it only activates on Windows
and Linux, preventing unintended behavior on other platforms.

* **Tests**
* Updated cross-platform keyboard tests to explicitly verify undo and
redo behavior in a Linux browser environment.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-09-19 20:41:04 +08:00
committed by GitHub
parent 2662f61b3b
commit 3747879413
2 changed files with 9 additions and 4 deletions
@@ -11,7 +11,7 @@ import {
getSelectedModelsCommand,
} from '@blocksuite/affine-shared/commands';
import { matchModels } from '@blocksuite/affine-shared/utils';
import { IS_MAC, IS_WINDOWS } from '@blocksuite/global/env';
import { IS_LINUX, IS_MAC, IS_WINDOWS } from '@blocksuite/global/env';
import {
type BlockComponent,
BlockSelection,
@@ -98,7 +98,7 @@ export class PageKeyboardManager {
}
},
'Control-y': ctx => {
if (!IS_WINDOWS) return;
if (!IS_WINDOWS && !IS_LINUX) return;
ctx.get('defaultState').event.preventDefault();
if (this._doc.canRedo) {
@@ -226,15 +226,20 @@ test(scoped`basic paired undo/redo`, async ({ page }) => {
});
test(scoped`undo/redo with keyboard`, async ({ page }) => {
await page.addInitScript(() => {
Object.defineProperty(navigator, 'platform', {
get: () => 'Linux x86_64',
});
});
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await focusRichText(page);
await type(page, 'hello');
await assertText(page, 'hello');
await undoByKeyboard(page);
await page.keyboard.press('Control+z');
await assertEmpty(page);
await redoByClick(page);
await page.keyboard.press('Control+y');
await assertText(page, 'hello');
});