fix: required named parameter 'onLiveTextInput' must be provided

This commit is contained in:
Lucas.Xu 2023-09-21 10:08:53 +08:00
commit 967e3e82a8
2 changed files with 21 additions and 11 deletions

View file

@ -55,6 +55,18 @@ class _MobileEditorState extends State<MobileEditor> {
child: MobileFloatingToolbar( child: MobileFloatingToolbar(
editorState: editorState, editorState: editorState,
editorScrollController: editorScrollController, editorScrollController: editorScrollController,
toolbarBuilder: (context, anchor) {
return AdaptiveTextSelectionToolbar.editable(
clipboardStatus: ClipboardStatus.pasteable,
onCopy: () => copyCommand.execute(editorState),
onCut: () => cutCommand.execute(editorState),
onPaste: () => pasteCommand.execute(editorState),
onSelectAll: () => selectAllCommand.execute(editorState),
anchors: TextSelectionToolbarAnchors(
primaryAnchor: anchor,
),
);
},
child: AppFlowyEditor( child: AppFlowyEditor(
editorStyle: editorStyle, editorStyle: editorStyle,
editorState: editorState, editorState: editorState,
@ -128,6 +140,11 @@ class _MobileEditorState extends State<MobileEditor> {
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
); );
map[ParagraphBlockKeys.type] = TextBlockComponentBuilder(
configuration: BlockComponentConfiguration(
placeholderText: (node) => 'Type something...',
),
);
return map; return map;
} }
} }

View file

@ -19,11 +19,13 @@ class MobileFloatingToolbar extends StatefulWidget {
required this.editorState, required this.editorState,
required this.editorScrollController, required this.editorScrollController,
required this.child, required this.child,
required this.toolbarBuilder,
}); });
final EditorState editorState; final EditorState editorState;
final EditorScrollController editorScrollController; final EditorScrollController editorScrollController;
final Widget child; final Widget child;
final Widget Function(BuildContext context, Offset anchor) toolbarBuilder;
@override @override
State<MobileFloatingToolbar> createState() => _MobileFloatingToolbarState(); State<MobileFloatingToolbar> createState() => _MobileFloatingToolbarState();
@ -149,18 +151,9 @@ class _MobileFloatingToolbarState extends State<MobileFloatingToolbar>
Widget _buildToolbar( Widget _buildToolbar(
BuildContext context, BuildContext context,
Offset? offset, Offset offset,
) { ) {
return AdaptiveTextSelectionToolbar.editable( return widget.toolbarBuilder(context, offset);
clipboardStatus: ClipboardStatus.pasteable,
onCopy: () => copyCommand.execute(editorState),
onCut: () => cutCommand.execute(editorState),
onPaste: () => pasteCommand.execute(editorState),
onSelectAll: () => selectAllCommand.execute(editorState),
anchors: TextSelectionToolbarAnchors(
primaryAnchor: offset ?? Offset.zero,
),
);
} }
Rect _findSuitableRect(Iterable<Rect> rects) { Rect _findSuitableRect(Iterable<Rect> rects) {