Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: The click area of the linked text is too large.

Lucas.Xue567158cee02
diff --git a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart
index 0184138fb5..8f6bf64c30 100644
--- a/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/example/lib/main.dart
@@ -46,9 +46,12 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
- body: Container(
- alignment: Alignment.topCenter,
- child: _buildEditor(context),
+ body: Center(
+ child: Container(
+ width: 780,
+ alignment: Alignment.topCenter,
+ child: _buildEditor(context),
+ ),
),
floatingActionButton: _buildExpandableFab(),
);
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/editor/editor_entry.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/editor/editor_entry.dart
index d14d44613f..4167ca1b38 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/editor/editor_entry.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/editor/editor_entry.dart
@@ -32,29 +32,26 @@ class EditorNodeWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return Container(
- color: Colors.red.withOpacity(0.1),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: node.children
- .map(
- (child) =>
- editorState.service.renderPluginService.buildPluginWidget(
- child is TextNode
- ? NodeWidgetContext<TextNode>(
- context: context,
- node: child,
- editorState: editorState,
- )
- : NodeWidgetContext<Node>(
- context: context,
- node: child,
- editorState: editorState,
- ),
- ),
- )
- .toList(),
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: node.children
+ .map(
+ (child) =>
+ editorState.service.renderPluginService.buildPluginWidget(
+ child is TextNode
+ ? NodeWidgetContext<TextNode>(
+ context: context,
+ node: child,
+ editorState: editorState,
+ )
+ : NodeWidgetContext<Node>(
+ context: context,
+ node: child,
+ editorState: editorState,
+ ),
+ ),
+ )
+ .toList(),
);
}
}
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/bulleted_list_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/bulleted_list_text.dart
index 7d69ff459f..5408f862d8 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/bulleted_list_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/bulleted_list_text.dart
@@ -56,8 +56,8 @@ class _BulletedListTextNodeWidgetState extends State<BulletedListTextNodeWidget>
@override
Widget build(BuildContext context) {
- return SizedBox(
- width: defaultMaxTextNodeWidth,
+ return Container(
+ constraints: BoxConstraints(maxWidth: defaultMaxTextNodeWidth),
child: Padding(
padding: EdgeInsets.only(bottom: defaultLinePadding),
child: Row(
@@ -70,14 +70,14 @@ class _BulletedListTextNodeWidgetState extends State<BulletedListTextNodeWidget>
padding: EdgeInsets.only(right: _iconRightPadding),
name: 'point',
),
- Expanded(
+ Flexible(
child: FlowyRichText(
key: _richTextKey,
placeholderText: 'List',
textNode: widget.textNode,
editorState: widget.editorState,
),
- ),
+ )
],
),
),
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart
index 0255a84049..bfda4e3f73 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/checkbox_text.dart
@@ -86,7 +86,7 @@ class _CheckboxNodeWidgetState extends State<CheckboxNodeWidget>
..commit();
},
),
- Expanded(
+ Flexible(
child: FlowyRichText(
key: _richTextKey,
placeholderText: 'To-do',
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart
index 473f29eaa7..3489c2bb52 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/flowy_rich_text.dart
@@ -194,7 +194,9 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {
return RichText(
key: _textKey,
textHeightBehavior: const TextHeightBehavior(
- applyHeightToFirstAscent: false, applyHeightToLastDescent: false),
+ applyHeightToFirstAscent: false,
+ applyHeightToLastDescent: false,
+ ),
text: widget.textSpanDecorator != null
? widget.textSpanDecorator!(textSpan)
: textSpan,
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart
index 050b330f8b..7b94783f03 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/heading_text.dart
@@ -63,8 +63,8 @@ class _HeadingTextNodeWidgetState extends State<HeadingTextNodeWidget>
top: _topPadding,
bottom: defaultLinePadding,
),
- child: SizedBox(
- width: defaultMaxTextNodeWidth,
+ child: Container(
+ constraints: BoxConstraints(maxWidth: defaultMaxTextNodeWidth),
child: FlowyRichText(
key: _richTextKey,
placeholderText: 'Heading',
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/number_list_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/number_list_text.dart
index c1062e1c3c..a4d72bb011 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/number_list_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/number_list_text.dart
@@ -70,7 +70,7 @@ class _NumberListTextNodeWidgetState extends State<NumberListTextNodeWidget>
padding: EdgeInsets.only(right: _iconRightPadding),
number: widget.textNode.attributes.number,
),
- Expanded(
+ Flexible(
child: FlowyRichText(
key: _richTextKey,
placeholderText: 'List',
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/quoted_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/quoted_text.dart
index 78c6653904..04ae379799 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/quoted_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/quoted_text.dart
@@ -69,7 +69,7 @@ class _QuotedTextNodeWidgetState extends State<QuotedTextNodeWidget>
padding: EdgeInsets.only(right: _iconRightPadding),
name: 'quote',
),
- Expanded(
+ Flexible(
child: FlowyRichText(
key: _richTextKey,
placeholderText: 'Quote',
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart
index d8dcfb91f6..5fe65db4b7 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text.dart
@@ -52,8 +52,8 @@ class _RichTextNodeWidgetState extends State<RichTextNodeWidget>
@override
Widget build(BuildContext context) {
- return SizedBox(
- width: defaultMaxTextNodeWidth,
+ return Container(
+ constraints: BoxConstraints(maxWidth: defaultMaxTextNodeWidth),
child: Padding(
padding: EdgeInsets.only(bottom: defaultLinePadding),
child: FlowyRichText(
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart
index 34b38c0444..9a1b2f1c02 100644
--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart
@@ -238,6 +238,12 @@ void showLinkMenu(
}
void _dismissLinkMenu() {
+ // workaround: SelectionService has been released after hot reload.
+ final isSelectionDisposed =
+ _editorState?.service.selectionServiceKey.currentState == null;
+ if (isSelectionDisposed) {
+ return;
+ }
if (_editorState?.service.selectionService.currentSelection.value == null) {
return;
}