瀏覽代碼

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

Lucas.Xu 2 年之前
父節點
當前提交
e567158cee

+ 6 - 3
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(),
     );

+ 20 - 23
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(),
     );
   }
 }

+ 4 - 4
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,
               ),
-            ),
+            )
           ],
         ),
       ),

+ 1 - 1
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',

+ 3 - 1
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,

+ 2 - 2
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',

+ 1 - 1
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',

+ 1 - 1
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',

+ 2 - 2
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(

+ 6 - 0
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;
   }