From d42835a98ea1d82889bd88087db062489b81ed61 Mon Sep 17 00:00:00 2001 From: chf Date: Sat, 29 Jun 2024 17:04:12 +0800 Subject: [PATCH] Solve the problem that / cannot evoke toolbox in Chinese input method, and solve the problem that / is automatically entered in searchInput after Chinese input method evokes toolbox --- src/components/modules/blockEvents.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/modules/blockEvents.ts b/src/components/modules/blockEvents.ts index 9504e7b6a..baa7fa9c7 100644 --- a/src/components/modules/blockEvents.ts +++ b/src/components/modules/blockEvents.ts @@ -59,7 +59,7 @@ export default class BlockEvents extends Module { * * @todo probably using "beforeInput" event would be better here */ - if (event.key === '/' && !event.ctrlKey && !event.metaKey) { + if (event.code === 'Slash' && !event.ctrlKey && !event.metaKey) { this.slashPressed(event); } @@ -251,14 +251,9 @@ export default class BlockEvents extends Module { return; } - /** - * The Toolbox will be opened with immediate focus on the Search input, - * and '/' will be added in the search input by default — we need to prevent it and add '/' manually - */ - event.preventDefault(); - this.Editor.Caret.insertContentAtCaretPosition('/'); - - this.activateToolbox(); + setTimeout(() => { + this.activateToolbox(); + }, 0); } /**