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(
editorState: editorState,
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(
editorStyle: editorStyle,
editorState: editorState,
@ -128,6 +140,11 @@ class _MobileEditorState extends State<MobileEditor> {
fontWeight: FontWeight.w600,
),
);
map[ParagraphBlockKeys.type] = TextBlockComponentBuilder(
configuration: BlockComponentConfiguration(
placeholderText: (node) => 'Type something...',
),
);
return map;
}
}

View file

@ -19,11 +19,13 @@ class MobileFloatingToolbar extends StatefulWidget {
required this.editorState,
required this.editorScrollController,
required this.child,
required this.toolbarBuilder,
});
final EditorState editorState;
final EditorScrollController editorScrollController;
final Widget child;
final Widget Function(BuildContext context, Offset anchor) toolbarBuilder;
@override
State<MobileFloatingToolbar> createState() => _MobileFloatingToolbarState();
@ -149,18 +151,9 @@ class _MobileFloatingToolbarState extends State<MobileFloatingToolbar>
Widget _buildToolbar(
BuildContext context,
Offset? offset,
Offset offset,
) {
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: offset ?? Offset.zero,
),
);
return widget.toolbarBuilder(context, offset);
}
Rect _findSuitableRect(Iterable<Rect> rects) {