mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: launch review 0.5.9 (#5443)
* fix: lose focus in editor on open settings dialog * fix: support CTRL+. for sidebar toggle * fix: make notify method private * fix: copy for video block * fix: copy for notification setting * fix: add libmpv to appimage builder * fix: missing tabs bloc from context * ci: add libmpv-dev to missing workflows * fix: do not depend on inherited widget in dispose * test: add media kit ensureInitialized to integration tests * fix: use maybeOf for AFFocusManager * fix: use pattern matching for youtube error * fix: missed null-promise on convertion
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:appflowy/plugins/document/application/document_bloc.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/editor_configuration.dart';
|
||||
@ -20,6 +23,7 @@ import 'package:appflowy/plugins/inline_actions/inline_actions_service.dart';
|
||||
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
||||
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart';
|
||||
import 'package:appflowy/workspace/application/view_info/view_info_bloc.dart';
|
||||
import 'package:appflowy/workspace/presentation/home/af_focus_manager.dart';
|
||||
import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart';
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
|
||||
@ -27,8 +31,6 @@ import 'package:collection/collection.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
final codeBlockLocalization = CodeBlockLocalizations(
|
||||
@ -211,6 +213,10 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
||||
style: styleCustomizer.selectionMenuStyleBuilder(),
|
||||
).handler(editorState);
|
||||
|
||||
AFFocusManager? focusManager;
|
||||
|
||||
void _loseFocus() => widget.editorState.selection = null;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -251,17 +257,35 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
||||
// customize the dynamic theme color
|
||||
_customizeBlockComponentBackgroundColorDecorator();
|
||||
|
||||
if (widget.initialSelection != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.editorState.updateSelectionWithReason(
|
||||
widget.initialSelection,
|
||||
);
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
focusManager = AFFocusManager.maybeOf(context);
|
||||
focusManager?.loseFocusNotifier.addListener(_loseFocus);
|
||||
|
||||
if (widget.initialSelection != null) {
|
||||
widget.editorState.updateSelectionWithReason(widget.initialSelection);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final currFocusManager = AFFocusManager.maybeOf(context);
|
||||
if (focusManager != currFocusManager) {
|
||||
focusManager?.loseFocusNotifier.removeListener(_loseFocus);
|
||||
focusManager = currFocusManager;
|
||||
focusManager?.loseFocusNotifier.addListener(_loseFocus);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
focusManager?.loseFocusNotifier.removeListener(_loseFocus);
|
||||
|
||||
if (widget.useViewInfoBloc && !viewInfoBloc.isClosed) {
|
||||
viewInfoBloc.add(const ViewInfoEvent.unregisterEditorState());
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ class _EmbedUrl extends StatefulWidget {
|
||||
|
||||
class _EmbedUrlState extends State<_EmbedUrl> {
|
||||
bool isUrlValid = true;
|
||||
bool isYouTubeError = false;
|
||||
String inputText = '';
|
||||
|
||||
@override
|
||||
@ -60,11 +61,18 @@ class _EmbedUrlState extends State<_EmbedUrl> {
|
||||
if (!isUrlValid) ...[
|
||||
const VSpace(8),
|
||||
FlowyText(
|
||||
LocaleKeys.document_plugins_video_invalidVideoUrl.tr(),
|
||||
isYouTubeError
|
||||
? LocaleKeys.document_plugins_video_invalidVideoUrlYouTube.tr()
|
||||
: LocaleKeys.document_plugins_video_invalidVideoUrl.tr(),
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
],
|
||||
const VSpace(8),
|
||||
FlowyText(
|
||||
LocaleKeys.document_plugins_video_supportedFormats.tr(),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
const VSpace(8),
|
||||
SizedBox(
|
||||
width: 160,
|
||||
child: FlowyButton(
|
||||
@ -86,6 +94,7 @@ class _EmbedUrlState extends State<_EmbedUrl> {
|
||||
return widget.onSubmit(inputText);
|
||||
}
|
||||
|
||||
isYouTubeError = youtubeUrlRegex.hasMatch(inputText);
|
||||
setState(() => isUrlValid = false);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user