Skip to content

Commit eb9037a

Browse files
committed
Merge branch 'main' into enable_ci_on_windows_linux_2
2 parents ce91b0c + 5d33d72 commit eb9037a

File tree

20 files changed

+590
-300
lines changed

20 files changed

+590
-300
lines changed

frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:io';
2-
31
import 'package:appflowy/generated/flowy_svgs.g.dart';
42
import 'package:appflowy/generated/locale_keys.g.dart';
53
import 'package:appflowy/plugins/database/application/cell/bloc/checklist_cell_bloc.dart';
@@ -16,6 +14,7 @@ import 'package:flutter/material.dart';
1614
import 'package:flutter/services.dart';
1715
import 'package:flutter_bloc/flutter_bloc.dart';
1816
import 'package:provider/provider.dart';
17+
import 'package:universal_platform/universal_platform.dart';
1918

2019
import '../editable_cell_skeleton/checklist.dart';
2120

@@ -201,19 +200,16 @@ class _ChecklistItems extends StatelessWidget {
201200
physics: const NeverScrollableScrollPhysics(),
202201
proxyDecorator: (child, index, _) => Material(
203202
color: Colors.transparent,
204-
child: Stack(
205-
children: [
206-
BlocProvider.value(
203+
child: MouseRegion(
204+
cursor: UniversalPlatform.isWindows
205+
? SystemMouseCursors.click
206+
: SystemMouseCursors.grabbing,
207+
child: IgnorePointer(
208+
child: BlocProvider.value(
207209
value: context.read<ChecklistCellBloc>(),
208210
child: child,
209211
),
210-
MouseRegion(
211-
cursor: Platform.isWindows
212-
? SystemMouseCursors.click
213-
: SystemMouseCursors.grabbing,
214-
child: const SizedBox.expand(),
215-
),
216-
],
212+
),
217213
),
218214
),
219215
buildDefaultDragHandles: false,

frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/checklist_cell_editor.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
1414
import 'package:flutter/material.dart';
1515
import 'package:flutter/services.dart';
1616
import 'package:flutter_bloc/flutter_bloc.dart';
17+
import 'package:universal_platform/universal_platform.dart';
1718

1819
import '../../application/cell/bloc/checklist_cell_bloc.dart';
1920
import 'checklist_cell_textfield.dart';
@@ -125,19 +126,16 @@ class ChecklistItemList extends StatelessWidget {
125126
shrinkWrap: true,
126127
proxyDecorator: (child, index, _) => Material(
127128
color: Colors.transparent,
128-
child: Stack(
129-
children: [
130-
BlocProvider.value(
129+
child: MouseRegion(
130+
cursor: UniversalPlatform.isWindows
131+
? SystemMouseCursors.click
132+
: SystemMouseCursors.grabbing,
133+
child: IgnorePointer(
134+
child: BlocProvider.value(
131135
value: context.read<ChecklistCellBloc>(),
132136
child: child,
133137
),
134-
MouseRegion(
135-
cursor: Platform.isWindows
136-
? SystemMouseCursors.click
137-
: SystemMouseCursors.grabbing,
138-
child: const SizedBox.expand(),
139-
),
140-
],
138+
),
141139
),
142140
),
143141
buildDefaultDragHandles: false,

frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
271271
return;
272272
}
273273

274-
if (options.inMemoryUpdate) {
274+
if (options.inMemoryUpdate && enableDocumentInternalLog) {
275275
Log.trace('skip transaction for in-memory update');
276276
return;
277277
}

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -432,44 +432,50 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage>
432432
);
433433
}
434434
return Center(
435-
child: FloatingToolbar(
436-
floatingToolbarHeight: 40,
437-
padding: EdgeInsets.symmetric(horizontal: 6),
438-
style: FloatingToolbarStyle(
439-
backgroundColor: Theme.of(context).cardColor,
440-
toolbarActiveColor: Color(0xffe0f8fd),
441-
),
442-
items: toolbarItems,
443-
decoration: BoxDecoration(
444-
borderRadius: BorderRadius.circular(8),
445-
color: Theme.of(context).cardColor,
446-
boxShadow: [
447-
BoxShadow(
448-
offset: Offset(0, 4),
449-
blurRadius: 24,
450-
color: themeV2.shadow_medium,
435+
child: BlocProvider.value(
436+
value: context.read<DocumentBloc>(),
437+
child: FloatingToolbar(
438+
floatingToolbarHeight: 40,
439+
padding: EdgeInsets.symmetric(horizontal: 6),
440+
style: FloatingToolbarStyle(
441+
backgroundColor: Theme.of(context).cardColor,
442+
toolbarActiveColor: Color(0xffe0f8fd),
443+
),
444+
items: toolbarItems,
445+
decoration: BoxDecoration(
446+
borderRadius: BorderRadius.circular(8),
447+
color: Theme.of(context).cardColor,
448+
boxShadow: [
449+
BoxShadow(
450+
offset: Offset(0, 4),
451+
blurRadius: 24,
452+
color: themeV2.shadow_medium,
453+
),
454+
],
455+
),
456+
toolbarBuilder: (_, child, onDismiss, isMetricsChanged) =>
457+
BlocProvider.value(
458+
value: context.read<DocumentBloc>(),
459+
child: DesktopFloatingToolbar(
460+
editorState: editorState,
461+
onDismiss: onDismiss,
462+
enableAnimation: false,
463+
child: child,
451464
),
452-
],
453-
),
454-
toolbarBuilder: (context, child, onDismiss, isMetricsChanged) =>
455-
DesktopFloatingToolbar(
465+
),
466+
placeHolderBuilder: (_) => customPlaceholderItem,
456467
editorState: editorState,
457-
onDismiss: onDismiss,
458-
enableAnimation: !isMetricsChanged,
459-
child: child,
460-
),
461-
placeHolderBuilder: (_) => customPlaceholderItem,
462-
editorState: editorState,
463-
editorScrollController: editorScrollController,
464-
textDirection: textDirection,
465-
tooltipBuilder: (context, id, message, child) =>
466-
widget.styleCustomizer.buildToolbarItemTooltip(
467-
context,
468-
id,
469-
message,
470-
child,
468+
editorScrollController: editorScrollController,
469+
textDirection: textDirection,
470+
tooltipBuilder: (context, id, message, child) =>
471+
widget.styleCustomizer.buildToolbarItemTooltip(
472+
context,
473+
id,
474+
message,
475+
child,
476+
),
477+
child: editor,
471478
),
472-
child: editor,
473479
),
474480
);
475481
}

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_scroll_wrapper.dart

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,26 @@ class _AiWriterScrollWrapperState extends State<AiWriterScrollWrapper> {
208208
throttler.call(() {
209209
if (aiWriterCubit.aiWriterNode != null) {
210210
final path = aiWriterCubit.aiWriterNode!.path;
211-
if (path.isNotEmpty) {
212-
widget.editorState.updateSelectionWithReason(
213-
Selection.collapsed(Position(path: path)),
214-
);
211+
212+
if (path.isEmpty) {
213+
return;
215214
}
215+
216+
if (path.previous.isNotEmpty) {
217+
final node = widget.editorState.getNodeAtPath(path.previous);
218+
if (node != null && node.delta != null && node.delta!.isNotEmpty) {
219+
widget.editorState.updateSelectionWithReason(
220+
Selection.collapsed(
221+
Position(path: path, offset: node.delta!.length),
222+
),
223+
);
224+
return;
225+
}
226+
}
227+
228+
widget.editorState.updateSelectionWithReason(
229+
Selection.collapsed(Position(path: path)),
230+
);
216231
}
217232
});
218233
}

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/desktop_floating_toolbar.dart

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/toolbar_extension.dart';
2+
import 'package:appflowy/startup/startup.dart';
23
import 'package:appflowy_editor/appflowy_editor.dart';
34
import 'package:flutter/material.dart';
4-
import 'package:flutter_bloc/flutter_bloc.dart';
55

66
import 'toolbar_animation.dart';
7-
import 'toolbar_cubit.dart';
87

98
class DesktopFloatingToolbar extends StatefulWidget {
109
const DesktopFloatingToolbar({
@@ -28,6 +27,7 @@ class _DesktopFloatingToolbarState extends State<DesktopFloatingToolbar> {
2827
EditorState get editorState => widget.editorState;
2928

3029
_Position? position;
30+
final toolbarController = getIt<FloatingToolbarController>();
3131

3232
@override
3333
void initState() {
@@ -39,24 +39,32 @@ class _DesktopFloatingToolbarState extends State<DesktopFloatingToolbar> {
3939
final selectionRect = editorState.selectionRects();
4040
if (selectionRect.isEmpty) return;
4141
position = calculateSelectionMenuOffset(selectionRect.first);
42+
toolbarController._addCallback(dismiss);
43+
}
44+
45+
@override
46+
void dispose() {
47+
toolbarController._removeCallback(dismiss);
48+
super.dispose();
4249
}
4350

4451
@override
4552
Widget build(BuildContext context) {
4653
if (position == null) return Container();
47-
return BlocProvider<ToolbarCubit>(
48-
create: (_) => ToolbarCubit(widget.onDismiss),
49-
child: Positioned(
50-
left: position!.left,
51-
top: position!.top,
52-
right: position!.right,
53-
child: widget.enableAnimation
54-
? ToolbarAnimationWidget(child: widget.child)
55-
: widget.child,
56-
),
54+
return Positioned(
55+
left: position!.left,
56+
top: position!.top,
57+
right: position!.right,
58+
child: widget.enableAnimation
59+
? ToolbarAnimationWidget(child: widget.child)
60+
: widget.child,
5761
);
5862
}
5963

64+
void dismiss() {
65+
widget.onDismiss.call();
66+
}
67+
6068
_Position calculateSelectionMenuOffset(
6169
Rect rect,
6270
) {
@@ -92,3 +100,33 @@ class _Position {
92100
final double? top;
93101
final double? right;
94102
}
103+
104+
class FloatingToolbarController {
105+
final Set<VoidCallback> _dismissCallbacks = {};
106+
final Set<VoidCallback> _displayListeners = {};
107+
108+
void _addCallback(VoidCallback callback) {
109+
_dismissCallbacks.add(callback);
110+
for (final listener in Set.of(_displayListeners)) {
111+
listener.call();
112+
}
113+
}
114+
115+
void _removeCallback(VoidCallback callback) =>
116+
_dismissCallbacks.remove(callback);
117+
118+
bool get isToolbarShowing => _dismissCallbacks.isNotEmpty;
119+
120+
void addDisplayListener(VoidCallback listener) =>
121+
_displayListeners.add(listener);
122+
123+
void removeDisplayListener(VoidCallback listener) =>
124+
_displayListeners.remove(listener);
125+
126+
void hideToolbar() {
127+
if (_dismissCallbacks.isEmpty) return;
128+
for (final callback in _dismissCallbacks) {
129+
callback.call();
130+
}
131+
}
132+
}

0 commit comments

Comments
 (0)