mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(editor): android keyboard can not be opened (#10502)
Close [BS-2674](https://linear.app/affine-design/issue/BS-2674/[android]-%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%8C%BA%E5%9F%9F%E7%82%B9%E5%87%BB%E5%90%8E%E6%97%A0%E6%B3%95%E6%BF%80%E6%B4%BB%E9%94%AE%E7%9B%98) [BS-2609](https://linear.app/affine-design/issue/BS-2609/[android]-%E8%BE%93%E5%85%A5%E7%9A%84-toolbar-%E6%B2%A1%E6%9C%89%E4%BA%86)
This commit is contained in:
@@ -97,15 +97,48 @@ framework.impl(ClientSchemeProvider, {
|
||||
});
|
||||
|
||||
framework.impl(VirtualKeyboardProvider, {
|
||||
addEventListener: (event, callback) => {
|
||||
Keyboard.addListener(event as any, callback as any).catch(e => {
|
||||
console.error(e);
|
||||
show: () => {
|
||||
Keyboard.show().catch(console.error);
|
||||
},
|
||||
hide: () => {
|
||||
// In some cases, the keyboard will show again. for example, it will show again
|
||||
// when this function is called in click event of button. It may be a bug of
|
||||
// android webview or capacitor.
|
||||
setTimeout(() => {
|
||||
Keyboard.hide().catch(console.error);
|
||||
});
|
||||
},
|
||||
removeAllListeners: () => {
|
||||
Keyboard.removeAllListeners().catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
onChange: callback => {
|
||||
let disposeRef = {
|
||||
dispose: () => {},
|
||||
};
|
||||
|
||||
Promise.all([
|
||||
Keyboard.addListener('keyboardWillShow', info => {
|
||||
callback({
|
||||
visible: true,
|
||||
height: info.keyboardHeight,
|
||||
});
|
||||
}),
|
||||
Keyboard.addListener('keyboardWillHide', () => {
|
||||
callback({
|
||||
visible: false,
|
||||
height: 0,
|
||||
});
|
||||
}),
|
||||
])
|
||||
.then(handlers => {
|
||||
disposeRef.dispose = () => {
|
||||
Promise.all(handlers.map(handler => handler.remove())).catch(
|
||||
console.error
|
||||
);
|
||||
};
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
return () => {
|
||||
disposeRef.dispose();
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user