Ver Fonte

feat: optimzie the hover block action (#2607)

* feat: optimzie the hover block action

* fix: duplicate view CI error
Lucas.Xu há 2 anos atrás
pai
commit
2746666123
17 ficheiros alterados com 194 adições e 82 exclusões
  1. 1 1
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_add_button.dart
  2. 1 1
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_list.dart
  3. 1 1
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_button.dart
  4. 1 1
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option_action_button.dart
  5. 22 8
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/board/board_node_widget.dart
  6. 22 8
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart
  7. 24 9
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dart
  8. 30 9
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/divider/divider_node_widget.dart
  9. 22 8
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/grid/grid_node_widget.dart
  10. 24 10
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dart
  11. 11 5
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart
  12. 12 6
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_node_widget.dart
  13. 13 8
      frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dart
  14. 2 2
      frontend/appflowy_flutter/pubspec.lock
  15. 1 1
      frontend/appflowy_flutter/pubspec.yaml
  16. 4 2
      frontend/appflowy_flutter/test/util.dart
  17. 3 2
      frontend/rust-lib/flowy-core/src/deps_resolve/folder2_deps.rs

+ 1 - 1
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_add_button.dart

@@ -12,7 +12,7 @@ class BlockAddButton extends StatelessWidget {
   }) : super(key: key);
   }) : super(key: key);
 
 
   final BlockComponentContext blockComponentContext;
   final BlockComponentContext blockComponentContext;
-  final BlockComponentState blockComponentState;
+  final BlockComponentActionState blockComponentState;
 
 
   final EditorState editorState;
   final EditorState editorState;
   final VoidCallback showSlashMenu;
   final VoidCallback showSlashMenu;

+ 1 - 1
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_list.dart

@@ -15,7 +15,7 @@ class BlockActionList extends StatelessWidget {
   });
   });
 
 
   final BlockComponentContext blockComponentContext;
   final BlockComponentContext blockComponentContext;
-  final BlockComponentState blockComponentState;
+  final BlockComponentActionState blockComponentState;
   final List<OptionAction> actions;
   final List<OptionAction> actions;
   final VoidCallback showSlashMenu;
   final VoidCallback showSlashMenu;
   final EditorState editorState;
   final EditorState editorState;

+ 1 - 1
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/block_action_option_button.dart

@@ -17,7 +17,7 @@ class BlockOptionButton extends StatelessWidget {
   }) : super(key: key);
   }) : super(key: key);
 
 
   final BlockComponentContext blockComponentContext;
   final BlockComponentContext blockComponentContext;
-  final BlockComponentState blockComponentState;
+  final BlockComponentActionState blockComponentState;
   final List<OptionAction> actions;
   final List<OptionAction> actions;
   final EditorState editorState;
   final EditorState editorState;
 
 

+ 1 - 1
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/actions/option_action_button.dart

@@ -16,7 +16,7 @@ class OptionActionList extends StatelessWidget {
   }) : super(key: key);
   }) : super(key: key);
 
 
   final BlockComponentContext blockComponentContext;
   final BlockComponentContext blockComponentContext;
-  final BlockComponentState blockComponentState;
+  final BlockComponentActionState blockComponentState;
   final List<OptionAction> actions;
   final List<OptionAction> actions;
   final EditorState editorState;
   final EditorState editorState;
 
 

+ 22 - 8
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/board/board_node_widget.dart

@@ -20,12 +20,17 @@ class BoardBlockComponentBuilder extends BlockComponentBuilder {
   final BlockComponentConfiguration configuration;
   final BlockComponentConfiguration configuration;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return BoardBlockComponentWidget(
     return BoardBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -36,16 +41,15 @@ class BoardBlockComponentBuilder extends BlockComponentBuilder {
       node.attributes[DatabaseBlockKeys.kViewID] is String;
       node.attributes[DatabaseBlockKeys.kViewID] is String;
 }
 }
 
 
-class BoardBlockComponentWidget extends StatefulWidget {
+class BoardBlockComponentWidget extends BlockComponentStatefulWidget {
   const BoardBlockComponentWidget({
   const BoardBlockComponentWidget({
     super.key,
     super.key,
-    required this.configuration,
-    required this.node,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
   });
   });
 
 
-  final Node node;
-  final BlockComponentConfiguration configuration;
-
   @override
   @override
   State<BoardBlockComponentWidget> createState() =>
   State<BoardBlockComponentWidget> createState() =>
       _BoardBlockComponentWidgetState();
       _BoardBlockComponentWidgetState();
@@ -62,7 +66,7 @@ class _BoardBlockComponentWidgetState extends State<BoardBlockComponentWidget>
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     final editorState = Provider.of<EditorState>(context, listen: false);
     final editorState = Provider.of<EditorState>(context, listen: false);
-    return BuiltInPageWidget(
+    Widget child = BuiltInPageWidget(
       node: widget.node,
       node: widget.node,
       editorState: editorState,
       editorState: editorState,
       builder: (viewPB) {
       builder: (viewPB) {
@@ -72,5 +76,15 @@ class _BoardBlockComponentWidgetState extends State<BoardBlockComponentWidget>
         );
         );
       },
       },
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: widget.node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 }
 }

+ 22 - 8
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/callout/callout_block_component.dart

@@ -65,12 +65,17 @@ class CalloutBlockComponentBuilder extends BlockComponentBuilder {
   final BlockComponentConfiguration configuration;
   final BlockComponentConfiguration configuration;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return CalloutBlockComponentWidget(
     return CalloutBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -84,16 +89,15 @@ class CalloutBlockComponentBuilder extends BlockComponentBuilder {
 }
 }
 
 
 // the main widget for rendering the callout block
 // the main widget for rendering the callout block
-class CalloutBlockComponentWidget extends StatefulWidget {
+class CalloutBlockComponentWidget extends BlockComponentStatefulWidget {
   const CalloutBlockComponentWidget({
   const CalloutBlockComponentWidget({
     super.key,
     super.key,
-    required this.node,
-    required this.configuration,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
   });
   });
 
 
-  final Node node;
-  final BlockComponentConfiguration configuration;
-
   @override
   @override
   State<CalloutBlockComponentWidget> createState() =>
   State<CalloutBlockComponentWidget> createState() =>
       _CalloutBlockComponentWidgetState();
       _CalloutBlockComponentWidgetState();
@@ -135,7 +139,7 @@ class _CalloutBlockComponentWidgetState
   // build the callout block widget
   // build the callout block widget
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    return Container(
+    Widget child = Container(
       decoration: BoxDecoration(
       decoration: BoxDecoration(
         borderRadius: const BorderRadius.all(Radius.circular(8.0)),
         borderRadius: const BorderRadius.all(Radius.circular(8.0)),
         color: backgroundColor,
         color: backgroundColor,
@@ -168,6 +172,16 @@ class _CalloutBlockComponentWidgetState
         ],
         ],
       ),
       ),
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: widget.node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 
 
   // build the richtext child
   // build the richtext child

+ 24 - 9
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/code_block/code_block_component.dart

@@ -59,13 +59,18 @@ class CodeBlockComponentBuilder extends BlockComponentBuilder {
   final EdgeInsets padding;
   final EdgeInsets padding;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return CodeBlockComponentWidget(
     return CodeBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
       padding: padding,
       padding: padding,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -73,16 +78,16 @@ class CodeBlockComponentBuilder extends BlockComponentBuilder {
   bool validate(Node node) => node.delta != null;
   bool validate(Node node) => node.delta != null;
 }
 }
 
 
-class CodeBlockComponentWidget extends StatefulWidget {
+class CodeBlockComponentWidget extends BlockComponentStatefulWidget {
   const CodeBlockComponentWidget({
   const CodeBlockComponentWidget({
-    Key? key,
-    required this.node,
-    this.configuration = const BlockComponentConfiguration(),
+    super.key,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
     this.padding = const EdgeInsets.all(0),
     this.padding = const EdgeInsets.all(0),
-  }) : super(key: key);
+  });
 
 
-  final Node node;
-  final BlockComponentConfiguration configuration;
   final EdgeInsets padding;
   final EdgeInsets padding;
 
 
   @override
   @override
@@ -166,7 +171,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    return Container(
+    Widget child = Container(
       decoration: BoxDecoration(
       decoration: BoxDecoration(
         borderRadius: const BorderRadius.all(Radius.circular(8.0)),
         borderRadius: const BorderRadius.all(Radius.circular(8.0)),
         color: Colors.grey.withOpacity(0.1),
         color: Colors.grey.withOpacity(0.1),
@@ -181,6 +186,16 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
         ],
         ],
       ),
       ),
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: widget.node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 
 
   Widget _buildCodeBlock(BuildContext context) {
   Widget _buildCodeBlock(BuildContext context) {

+ 30 - 9
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/divider/divider_node_widget.dart

@@ -24,13 +24,18 @@ class DividerBlockComponentBuilder extends BlockComponentBuilder {
   final Color lineColor;
   final Color lineColor;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return DividerBlockComponentWidget(
     return DividerBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       padding: padding,
       padding: padding,
       lineColor: lineColor,
       lineColor: lineColor,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -38,15 +43,17 @@ class DividerBlockComponentBuilder extends BlockComponentBuilder {
   bool validate(Node node) => node.children.isEmpty;
   bool validate(Node node) => node.children.isEmpty;
 }
 }
 
 
-class DividerBlockComponentWidget extends StatefulWidget {
+class DividerBlockComponentWidget extends BlockComponentStatefulWidget {
   const DividerBlockComponentWidget({
   const DividerBlockComponentWidget({
-    Key? key,
-    required this.node,
+    super.key,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
     this.padding = const EdgeInsets.symmetric(vertical: 8.0),
     this.padding = const EdgeInsets.symmetric(vertical: 8.0),
     this.lineColor = Colors.grey,
     this.lineColor = Colors.grey,
-  }) : super(key: key);
+  });
 
 
-  final Node node;
   final EdgeInsets padding;
   final EdgeInsets padding;
   final Color lineColor;
   final Color lineColor;
 
 
@@ -61,13 +68,27 @@ class _DividerBlockComponentWidgetState
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    return Padding(
+    Widget child = Padding(
       padding: widget.padding,
       padding: widget.padding,
       child: Container(
       child: Container(
-        height: 1,
-        color: widget.lineColor,
+        height: 10,
+        alignment: Alignment.center,
+        child: Divider(
+          color: widget.lineColor,
+          thickness: 1,
+        ),
       ),
       ),
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: widget.node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 
 
   @override
   @override

+ 22 - 8
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/grid/grid_node_widget.dart

@@ -20,12 +20,17 @@ class GridBlockComponentBuilder extends BlockComponentBuilder {
   final BlockComponentConfiguration configuration;
   final BlockComponentConfiguration configuration;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return GridBlockComponentWidget(
     return GridBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -36,16 +41,15 @@ class GridBlockComponentBuilder extends BlockComponentBuilder {
       node.attributes[DatabaseBlockKeys.kViewID] is String;
       node.attributes[DatabaseBlockKeys.kViewID] is String;
 }
 }
 
 
-class GridBlockComponentWidget extends StatefulWidget {
+class GridBlockComponentWidget extends BlockComponentStatefulWidget {
   const GridBlockComponentWidget({
   const GridBlockComponentWidget({
     super.key,
     super.key,
-    required this.configuration,
-    required this.node,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
   });
   });
 
 
-  final Node node;
-  final BlockComponentConfiguration configuration;
-
   @override
   @override
   State<GridBlockComponentWidget> createState() =>
   State<GridBlockComponentWidget> createState() =>
       _GridBlockComponentWidgetState();
       _GridBlockComponentWidgetState();
@@ -62,7 +66,7 @@ class _GridBlockComponentWidgetState extends State<GridBlockComponentWidget>
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     final editorState = Provider.of<EditorState>(context, listen: false);
     final editorState = Provider.of<EditorState>(context, listen: false);
-    return BuiltInPageWidget(
+    Widget child = BuiltInPageWidget(
       node: widget.node,
       node: widget.node,
       editorState: editorState,
       editorState: editorState,
       builder: (viewPB) {
       builder: (viewPB) {
@@ -72,5 +76,15 @@ class _GridBlockComponentWidgetState extends State<GridBlockComponentWidget>
         );
         );
       },
       },
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: widget.node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 }
 }

+ 24 - 10
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/math_equation/math_equation_block_component.dart

@@ -61,12 +61,17 @@ class MathEquationBlockComponentBuilder extends BlockComponentBuilder {
   final BlockComponentConfiguration configuration;
   final BlockComponentConfiguration configuration;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return MathEquationBlockComponentWidget(
     return MathEquationBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -76,15 +81,14 @@ class MathEquationBlockComponentBuilder extends BlockComponentBuilder {
       node.attributes[MathEquationBlockKeys.formula] is String;
       node.attributes[MathEquationBlockKeys.formula] is String;
 }
 }
 
 
-class MathEquationBlockComponentWidget extends StatefulWidget {
+class MathEquationBlockComponentWidget extends BlockComponentStatefulWidget {
   const MathEquationBlockComponentWidget({
   const MathEquationBlockComponentWidget({
-    Key? key,
-    required this.node,
-    this.configuration = const BlockComponentConfiguration(),
-  }) : super(key: key);
-
-  final Node node;
-  final BlockComponentConfiguration configuration;
+    super.key,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
+  });
 
 
   @override
   @override
   State<MathEquationBlockComponentWidget> createState() =>
   State<MathEquationBlockComponentWidget> createState() =>
@@ -116,7 +120,7 @@ class _MathEquationBlockComponentWidgetState
   }
   }
 
 
   Widget _buildMathEquation(BuildContext context) {
   Widget _buildMathEquation(BuildContext context) {
-    return Container(
+    Widget child = Container(
       width: double.infinity,
       width: double.infinity,
       constraints: const BoxConstraints(minHeight: 50),
       constraints: const BoxConstraints(minHeight: 50),
       padding: padding,
       padding: padding,
@@ -139,6 +143,16 @@ class _MathEquationBlockComponentWidgetState
               ),
               ),
       ),
       ),
     );
     );
+
+    if (widget.actionBuilder != null) {
+      child = BlockComponentActionWrapper(
+        node: node,
+        actionBuilder: widget.actionBuilder!,
+        child: child,
+      );
+    }
+
+    return child;
   }
   }
 
 
   void showEditingDialog() {
   void showEditingDialog() {

+ 11 - 5
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart

@@ -56,11 +56,16 @@ class AutoCompletionBlockComponentBuilder extends BlockComponentBuilder {
   AutoCompletionBlockComponentBuilder();
   AutoCompletionBlockComponentBuilder();
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return AutoCompletionBlockComponent(
     return AutoCompletionBlockComponent(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -72,14 +77,15 @@ class AutoCompletionBlockComponentBuilder extends BlockComponentBuilder {
   }
   }
 }
 }
 
 
-class AutoCompletionBlockComponent extends StatefulWidget {
+class AutoCompletionBlockComponent extends BlockComponentStatefulWidget {
   const AutoCompletionBlockComponent({
   const AutoCompletionBlockComponent({
     super.key,
     super.key,
-    required this.node,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
   });
   });
 
 
-  final Node node;
-
   @override
   @override
   State<AutoCompletionBlockComponent> createState() =>
   State<AutoCompletionBlockComponent> createState() =>
       _AutoCompletionBlockComponentState();
       _AutoCompletionBlockComponentState();

+ 12 - 6
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/smart_edit_node_widget.dart

@@ -46,11 +46,16 @@ class SmartEditBlockComponentBuilder extends BlockComponentBuilder {
   SmartEditBlockComponentBuilder();
   SmartEditBlockComponentBuilder();
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return SmartEditBlockComponentWidget(
     return SmartEditBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -60,14 +65,15 @@ class SmartEditBlockComponentBuilder extends BlockComponentBuilder {
       node.attributes[SmartEditBlockKeys.content] is String;
       node.attributes[SmartEditBlockKeys.content] is String;
 }
 }
 
 
-class SmartEditBlockComponentWidget extends StatefulWidget {
+class SmartEditBlockComponentWidget extends BlockComponentStatefulWidget {
   const SmartEditBlockComponentWidget({
   const SmartEditBlockComponentWidget({
-    required super.key,
-    required this.node,
+    super.key,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
   });
   });
 
 
-  final Node node;
-
   @override
   @override
   State<SmartEditBlockComponentWidget> createState() =>
   State<SmartEditBlockComponentWidget> createState() =>
       _SmartEditBlockComponentWidgetState();
       _SmartEditBlockComponentWidgetState();

+ 13 - 8
frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/toggle/toggle_block_component.dart

@@ -44,13 +44,18 @@ class ToggleListBlockComponentBuilder extends BlockComponentBuilder {
   final EdgeInsets padding;
   final EdgeInsets padding;
 
 
   @override
   @override
-  Widget build(BlockComponentContext blockComponentContext) {
+  BlockComponentWidget build(BlockComponentContext blockComponentContext) {
     final node = blockComponentContext.node;
     final node = blockComponentContext.node;
     return ToggleListBlockComponentWidget(
     return ToggleListBlockComponentWidget(
       key: node.key,
       key: node.key,
       node: node,
       node: node,
       configuration: configuration,
       configuration: configuration,
       padding: padding,
       padding: padding,
+      showActions: showActions(node),
+      actionBuilder: (context, state) => actionBuilder(
+        blockComponentContext,
+        state,
+      ),
     );
     );
   }
   }
 
 
@@ -58,16 +63,16 @@ class ToggleListBlockComponentBuilder extends BlockComponentBuilder {
   bool validate(Node node) => node.delta != null;
   bool validate(Node node) => node.delta != null;
 }
 }
 
 
-class ToggleListBlockComponentWidget extends StatefulWidget {
+class ToggleListBlockComponentWidget extends BlockComponentStatefulWidget {
   const ToggleListBlockComponentWidget({
   const ToggleListBlockComponentWidget({
-    Key? key,
-    required this.node,
-    this.configuration = const BlockComponentConfiguration(),
+    super.key,
+    required super.node,
+    super.showActions,
+    super.actionBuilder,
+    super.configuration = const BlockComponentConfiguration(),
     this.padding = const EdgeInsets.all(0),
     this.padding = const EdgeInsets.all(0),
-  }) : super(key: key);
+  });
 
 
-  final Node node;
-  final BlockComponentConfiguration configuration;
   final EdgeInsets padding;
   final EdgeInsets padding;
 
 
   @override
   @override

+ 2 - 2
frontend/appflowy_flutter/pubspec.lock

@@ -53,8 +53,8 @@ packages:
     dependency: "direct main"
     dependency: "direct main"
     description:
     description:
       path: "."
       path: "."
-      ref: "21f686"
-      resolved-ref: "21f686d6a43137cf6c6d7d040463a1679d13f858"
+      ref: "25eb16"
+      resolved-ref: "25eb1653252efa0c2695a49e7e7493c4030c11e4"
       url: "https://github.com/LucasXu0/appflowy-editor.git"
       url: "https://github.com/LucasXu0/appflowy-editor.git"
     source: git
     source: git
     version: "0.1.12"
     version: "0.1.12"

+ 1 - 1
frontend/appflowy_flutter/pubspec.yaml

@@ -47,7 +47,7 @@ dependencies:
     # path: /Users/lucas.xu/Desktop/appflowy-editor
     # path: /Users/lucas.xu/Desktop/appflowy-editor
     git:
     git:
       url: https://github.com/LucasXu0/appflowy-editor.git
       url: https://github.com/LucasXu0/appflowy-editor.git
-      ref: 21f686
+      ref: 25eb16
   appflowy_popover:
   appflowy_popover:
     path: packages/appflowy_popover
     path: packages/appflowy_popover
 
 

+ 4 - 2
frontend/appflowy_flutter/test/util.dart

@@ -54,8 +54,10 @@ class AppFlowyUnitTest {
       password: password,
       password: password,
       email: userEmail,
       email: userEmail,
     );
     );
-    return result.fold(
-      (error) {},
+    result.fold(
+      (error) {
+        assert(false, 'Error: $error');
+      },
       (user) {
       (user) {
         userProfile = user;
         userProfile = user;
         userService = UserBackendService(userId: userProfile.id);
         userService = UserBackendService(userId: userProfile.id);

+ 3 - 2
frontend/rust-lib/flowy-core/src/deps_resolve/folder2_deps.rs

@@ -19,6 +19,7 @@ use flowy_folder2::manager::Folder2Manager;
 use flowy_folder2::view_ext::{ViewDataProcessor, ViewDataProcessorMap};
 use flowy_folder2::view_ext::{ViewDataProcessor, ViewDataProcessorMap};
 use flowy_folder2::ViewLayout;
 use flowy_folder2::ViewLayout;
 use flowy_user::services::UserSession;
 use flowy_user::services::UserSession;
+use lib_dispatch::prelude::ToBytes;
 use lib_infra::future::FutureResult;
 use lib_infra::future::FutureResult;
 
 
 pub struct Folder2DepsResolver();
 pub struct Folder2DepsResolver();
@@ -99,8 +100,8 @@ impl ViewDataProcessor for DocumentViewDataProcessor {
     let view_id = view_id.to_string();
     let view_id = view_id.to_string();
     FutureResult::new(async move {
     FutureResult::new(async move {
       let document = manager.get_document(view_id)?;
       let document = manager.get_document(view_id)?;
-      let data = document.lock().get_document()?;
-      let data_bytes = serde_json::to_string(&data)?.as_bytes().to_vec();
+      let data: DocumentDataPB = DocumentDataWrapper(document.lock().get_document()?).into();
+      let data_bytes = data.into_bytes().map_err(|_| FlowyError::invalid_data())?;
       Ok(Bytes::from(data_bytes))
       Ok(Bytes::from(data_bytes))
     })
     })
   }
   }