generated from dellevin/template
bug修复
This commit is contained in:
4
assets/vditor/dist/vditor_editor.html
vendored
4
assets/vditor/dist/vditor_editor.html
vendored
@@ -148,6 +148,10 @@
|
|||||||
cursor.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
cursor.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requestHeightUpdate() {
|
||||||
|
requestAnimationFrame(notifyHeight);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -318,7 +318,17 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
|||||||
theme: light,
|
theme: light,
|
||||||
darkTheme: dark,
|
darkTheme: dark,
|
||||||
themeMode: provider.themeMode,
|
themeMode: provider.themeMode,
|
||||||
builder: (ctx, nav) => AppShell(child: nav!),
|
builder: (ctx, nav) {
|
||||||
|
Widget shell = AppShell(child: nav!);
|
||||||
|
// Android: 点击空白区域收起键盘
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
shell = GestureDetector(
|
||||||
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
child: shell,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return shell;
|
||||||
|
},
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_autoSaveTimer?.cancel();
|
_autoSaveTimer?.cancel();
|
||||||
_saveStatusTimer?.cancel();
|
_saveStatusTimer?.cancel();
|
||||||
|
_scrollController.dispose();
|
||||||
_titleController.dispose();
|
_titleController.dispose();
|
||||||
_contentController.dispose();
|
_contentController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|||||||
@@ -153,6 +153,14 @@ class VditorEditorState extends State<VditorEditor> {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _requestHeightUpdate() async {
|
||||||
|
if (_controller == null || !_isReady) return;
|
||||||
|
try {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
await _controller!.evaluateJavascript(source: 'requestHeightUpdate()');
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
void _onVditorReady() {
|
void _onVditorReady() {
|
||||||
if (_isReady) return;
|
if (_isReady) return;
|
||||||
_fallbackTimer?.cancel();
|
_fallbackTimer?.cancel();
|
||||||
@@ -276,10 +284,13 @@ class VditorEditorState extends State<VditorEditor> {
|
|||||||
}
|
}
|
||||||
debugPrint('[VditorEditor] loading: $initialUrl');
|
debugPrint('[VditorEditor] loading: $initialUrl');
|
||||||
|
|
||||||
// 键盘弹出时,滚动到光标位置
|
// 键盘弹出时,滚动到光标位置;键盘收起时,重新通知高度
|
||||||
final keyboardH = MediaQuery.of(context).viewInsets.bottom;
|
final keyboardH = MediaQuery.of(context).viewInsets.bottom;
|
||||||
if (keyboardH > 0 && _lastKeyboardH == 0 && _isReady) {
|
if (keyboardH > 0 && _lastKeyboardH == 0 && _isReady) {
|
||||||
Future.microtask(() => _scrollToCursor());
|
Future.microtask(() => _scrollToCursor());
|
||||||
|
} else if (keyboardH == 0 && _lastKeyboardH > 0 && _isReady) {
|
||||||
|
// 键盘收起,请求 JS 端重新计算高度
|
||||||
|
Future.microtask(() => _requestHeightUpdate());
|
||||||
}
|
}
|
||||||
_lastKeyboardH = keyboardH;
|
_lastKeyboardH = keyboardH;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user