Skip to content

Commit ca8b4f9

Browse files
authored
fix: outline doesn't show when @dates are used in the headline (#8049)
* fix: outline doesn't show when @dates are used in the headline * feat: add open app deeplink handler * fix: database falling infinitely on mobile
1 parent 8d0d968 commit ca8b4f9

File tree

5 files changed

+91
-15
lines changed

5 files changed

+91
-15
lines changed

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/columns/simple_column_block_width_resizer.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/actions/dr
33
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
44
import 'package:appflowy_editor/appflowy_editor.dart';
55
import 'package:flutter/material.dart';
6+
import 'package:universal_platform/universal_platform.dart';
67

78
class SimpleColumnBlockWidthResizer extends StatefulWidget {
89
const SimpleColumnBlockWidthResizer({
@@ -55,6 +56,10 @@ class _SimpleColumnBlockWidthResizerState
5556
child: ValueListenableBuilder<bool>(
5657
valueListenable: isHovering,
5758
builder: (context, isHovering, child) {
59+
if (UniversalPlatform.isMobile) {
60+
return const SizedBox.shrink();
61+
}
62+
5863
final hide = isDraggingAppFlowyEditorBlock.value || !isHovering;
5964
return MouseRegion(
6065
cursor: SystemMouseCursors.resizeLeftRight,

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/outline/outline_block_component.dart

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,22 +287,14 @@ class OutlineItemWidget extends StatelessWidget {
287287

288288
@override
289289
Widget build(BuildContext context) {
290-
final editorState = context.read<EditorState>();
291-
final textStyle = editorState.editorStyle.textStyleConfiguration;
292-
final style = textStyle.href.combine(textStyle.text);
293290
return FlowyButton(
294291
onTap: () => scrollToBlock(context),
295292
text: Row(
296293
textDirection: textDirection,
297294
children: [
298295
HSpace(node.leftIndent),
299296
Flexible(
300-
child: Text(
301-
node.outlineItemText,
302-
textDirection: textDirection,
303-
style: style,
304-
overflow: TextOverflow.ellipsis,
305-
),
297+
child: buildOutlineItemWidget(context),
306298
),
307299
],
308300
),
@@ -320,6 +312,60 @@ class OutlineItemWidget extends StatelessWidget {
320312
Position(path: node.path, offset: node.delta?.length ?? 0),
321313
);
322314
}
315+
316+
Widget buildOutlineItemWidget(BuildContext context) {
317+
final editorState = context.read<EditorState>();
318+
final textStyle = editorState.editorStyle.textStyleConfiguration;
319+
final style = textStyle.href.combine(textStyle.text);
320+
321+
final textInserted = node.delta?.whereType<TextInsert>();
322+
if (textInserted == null) {
323+
return const SizedBox.shrink();
324+
}
325+
326+
final children = <InlineSpan>[];
327+
328+
var i = 0;
329+
for (final e in textInserted) {
330+
final mentionAttribute = e.attributes?[MentionBlockKeys.mention];
331+
final mention =
332+
mentionAttribute is Map<String, dynamic> ? mentionAttribute : null;
333+
final text = e.text;
334+
if (mention != null) {
335+
final type = mention[MentionBlockKeys.type];
336+
children.add(
337+
WidgetSpan(
338+
alignment: PlaceholderAlignment.middle,
339+
child: MentionBlock(
340+
key: ValueKey(type),
341+
node: node,
342+
index: i,
343+
mention: mention,
344+
textStyle: style,
345+
),
346+
),
347+
);
348+
} else {
349+
children.add(
350+
TextSpan(
351+
text: text,
352+
style: style,
353+
),
354+
);
355+
}
356+
357+
i += text.length;
358+
}
359+
360+
return IgnorePointer(
361+
child: Text.rich(
362+
TextSpan(
363+
children: children,
364+
style: style,
365+
),
366+
),
367+
);
368+
}
323369
}
324370

325371
extension on Node {
@@ -339,8 +385,4 @@ extension on Node {
339385

340386
return 0.0;
341387
}
342-
343-
String get outlineItemText {
344-
return delta?.toPlainText() ?? '';
345-
}
346388
}

frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';
99
import 'package:appflowy/startup/tasks/deeplink/expire_login_deeplink_handler.dart';
1010
import 'package:appflowy/startup/tasks/deeplink/invitation_deeplink_handler.dart';
1111
import 'package:appflowy/startup/tasks/deeplink/login_deeplink_handler.dart';
12+
import 'package:appflowy/startup/tasks/deeplink/open_app_deeplink_handler.dart';
1213
import 'package:appflowy/startup/tasks/deeplink/payment_deeplink_handler.dart';
1314
import 'package:appflowy/user/application/auth/auth_error.dart';
1415
import 'package:appflowy/user/application/user_auth_listener.dart';
@@ -28,7 +29,8 @@ class AppFlowyCloudDeepLink {
2829
..register(LoginDeepLinkHandler())
2930
..register(PaymentDeepLinkHandler())
3031
..register(InvitationDeepLinkHandler())
31-
..register(ExpireLoginDeepLinkHandler());
32+
..register(ExpireLoginDeepLinkHandler())
33+
..register(OpenAppDeepLinkHandler());
3234

3335
_deepLinkSubscription = _AppLinkWrapper.instance.listen(
3436
(Uri? uri) async {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'dart:async';
2+
3+
import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';
4+
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
5+
import 'package:appflowy_result/appflowy_result.dart';
6+
7+
class OpenAppDeepLinkHandler extends DeepLinkHandler<void> {
8+
@override
9+
bool canHandle(Uri uri) {
10+
return uri.toString() == 'appflowy-flutter://';
11+
}
12+
13+
@override
14+
Future<FlowyResult<void, FlowyError>> handle({
15+
required Uri uri,
16+
required DeepLinkStateHandler onStateChange,
17+
}) async {
18+
return FlowyResult.success(null);
19+
}
20+
}

frontend/appflowy_flutter/test/unit_test/deeplink/deeplink_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';
22
import 'package:appflowy/startup/tasks/deeplink/invitation_deeplink_handler.dart';
33
import 'package:appflowy/startup/tasks/deeplink/login_deeplink_handler.dart';
4+
import 'package:appflowy/startup/tasks/deeplink/open_app_deeplink_handler.dart';
45
import 'package:appflowy/startup/tasks/deeplink/payment_deeplink_handler.dart';
56
import 'package:flutter_test/flutter_test.dart';
67

@@ -9,7 +10,8 @@ void main() {
910
final deepLinkHandlerRegistry = DeepLinkHandlerRegistry.instance
1011
..register(LoginDeepLinkHandler())
1112
..register(PaymentDeepLinkHandler())
12-
..register(InvitationDeepLinkHandler());
13+
..register(InvitationDeepLinkHandler())
14+
..register(OpenAppDeepLinkHandler());
1315

1416
test('invitation deep link handler', () {
1517
final uri = Uri.parse(
@@ -53,5 +55,10 @@ void main() {
5355
},
5456
);
5557
});
58+
59+
test('open app deep link handler', () {
60+
final uri = Uri.parse('appflowy-flutter://');
61+
expect(OpenAppDeepLinkHandler().canHandle(uri), true);
62+
});
5663
});
5764
}

0 commit comments

Comments
 (0)