mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor(editor): always show keyboard toolbar in mobile (#13384)
Close [AF-2756](https://linear.app/affine-design/issue/AF-2756/激活输入区的时候,展示toolbar,适配不弹虚拟键盘的场景,比如实体键盘) #### PR Dependency Tree * **PR #13384** 👈 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 * **New Features** * Improved virtual keyboard handling by introducing static keyboard height and app tab safe area tracking for more consistent toolbar behavior. * **Bug Fixes** * Enhanced keyboard visibility detection on Android and iOS, especially when a physical keyboard is connected. * **Refactor** * Simplified and streamlined keyboard toolbar logic, including delayed panel closing and refined height calculations. * Removed unused or redundant toolbar closing methods and position management logic. * **Style** * Updated toolbar and panel styles for better positioning and layout consistency. * Adjusted and removed certain mobile-specific padding styles. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #13384** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { VirtualKeyboardProvider } from '@affine/core/mobile/modules/virtual-keyboard';
|
||||
import { globalVars } from '@affine/core/mobile/styles/variables.css';
|
||||
import type { Container } from '@blocksuite/affine/global/di';
|
||||
import { DisposableGroup } from '@blocksuite/affine/global/disposable';
|
||||
import {
|
||||
@@ -29,6 +30,12 @@ export function KeyboardToolbarExtension(
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
readonly height$ = signal(0);
|
||||
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
readonly staticHeight$ = signal(0);
|
||||
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
readonly appTabSafeArea$ = signal(`calc(${globalVars.appTabSafeArea})`);
|
||||
|
||||
static override setup(di: Container) {
|
||||
super.setup(di);
|
||||
di.addImpl(BSVirtualKeyboardProvider, provider => {
|
||||
@@ -40,6 +47,9 @@ export function KeyboardToolbarExtension(
|
||||
this._disposables.add(
|
||||
affineVirtualKeyboardProvider.onChange(({ visible, height }) => {
|
||||
batch(() => {
|
||||
if (visible && this.staticHeight$.peek() !== height) {
|
||||
this.staticHeight$.value = height;
|
||||
}
|
||||
this.visible$.value = visible;
|
||||
this.height$.value = height;
|
||||
});
|
||||
|
||||
@@ -23,9 +23,6 @@ globalStyle('body:has(>#app-tabs):not(:has(affine-keyboard-toolbar))', {
|
||||
globalStyle('body:has(affine-keyboard-toolbar)', {
|
||||
paddingBottom: `calc(${globalVars.appKeyboardStaticHeight} + 46px)`,
|
||||
});
|
||||
globalStyle('body:has(>#app-tabs) affine-keyboard-tool-panel', {
|
||||
paddingBottom: `calc(${globalVars.appTabSafeArea} + 8px)`,
|
||||
});
|
||||
globalStyle('body:has(>#app-tabs) edgeless-toolbar-widget', {
|
||||
bottom: globalVars.appTabSafeArea,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user