mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(ios): can not open keyboard in editor (#11401)
Close [BS-2917](https://linear.app/affine-design/issue/BS-2917/【移动端】ios-唤起键盘的edge-case) This PR fixes an issue where the keyboard cannot be re-triggered on iOS devices after the keyboard toolbar is hidden or executing some actions in keyboard toolbar. Key changes: - Preserve and restore the initial input mode when keyboard toolbar shows/hides - Improve virtual keyboard service interface to better handle keyboard state - Add proper cleanup of input mode state in component lifecycle
This commit is contained in:
@@ -10,9 +10,9 @@ import type {
|
||||
} from '@blocksuite/affine/global/di';
|
||||
import { DisposableGroup } from '@blocksuite/affine/global/disposable';
|
||||
import {
|
||||
DocModeProvider,
|
||||
FeatureFlagService,
|
||||
VirtualKeyboardProvider as BSVirtualKeyboardProvider,
|
||||
type VirtualKeyboardProviderWithAction,
|
||||
} from '@blocksuite/affine/shared/services';
|
||||
import type { SpecBuilder } from '@blocksuite/affine/shared/utils';
|
||||
import {
|
||||
@@ -69,35 +69,12 @@ function KeyboardToolbarExtension(framework: FrameworkProvider): ExtensionType {
|
||||
|
||||
private readonly _disposables = new DisposableGroup();
|
||||
|
||||
private get _rootContentEditable() {
|
||||
const editorMode = this.std.get(DocModeProvider).getEditorMode();
|
||||
if (editorMode !== 'page') return null;
|
||||
|
||||
if (!this.std.host.doc.root) return;
|
||||
return this.std.view.getBlock(this.std.host.doc.root.id);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
readonly visible$ = signal(false);
|
||||
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
readonly height$ = signal(0);
|
||||
|
||||
show() {
|
||||
if ('show' in affineVirtualKeyboardProvider) {
|
||||
affineVirtualKeyboardProvider.show();
|
||||
} else if (this._rootContentEditable) {
|
||||
this._rootContentEditable.inputMode = '';
|
||||
}
|
||||
}
|
||||
hide() {
|
||||
if ('hide' in affineVirtualKeyboardProvider) {
|
||||
affineVirtualKeyboardProvider.hide();
|
||||
} else if (this._rootContentEditable) {
|
||||
this._rootContentEditable.inputMode = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
static override setup(di: Container) {
|
||||
super.setup(di);
|
||||
di.addImpl(BSVirtualKeyboardProvider, provider => {
|
||||
@@ -125,6 +102,20 @@ function KeyboardToolbarExtension(framework: FrameworkProvider): ExtensionType {
|
||||
}
|
||||
}
|
||||
|
||||
if ('show' in affineVirtualKeyboardProvider) {
|
||||
return class
|
||||
extends BSVirtualKeyboardService
|
||||
implements VirtualKeyboardProviderWithAction
|
||||
{
|
||||
show() {
|
||||
affineVirtualKeyboardProvider.show();
|
||||
}
|
||||
hide() {
|
||||
affineVirtualKeyboardProvider.hide();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return BSVirtualKeyboardService;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user