feat: add reset font button in toolbar

This commit is contained in:
Lucas.Xu
2023-09-22 15:49:11 +08:00
parent 5dfc470873
commit 57b78ee3c6
4 changed files with 54 additions and 0 deletions

View File

@ -137,6 +137,9 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
convertibleBlockTypes.add(ToggleListBlockKeys.type);
slashMenuItems = _customSlashMenuItems();
effectiveScrollController = widget.scrollController ?? ScrollController();
// keep the previous font style when typing new text.
AppFlowyRichTextKeys.supportSliced.add(AppFlowyRichTextKeys.fontFamily);
}
@override

View File

@ -20,6 +20,7 @@ final customizeFontToolbarItem = ToolbarItem(
popoverController: popoverController,
onOpen: () => keepEditorFocusNotifier.value += 1,
onClose: () => keepEditorFocusNotifier.value -= 1,
showResetButton: true,
onFontFamilyChanged: (fontFamily) async {
await popoverController.close();
try {
@ -30,6 +31,9 @@ final customizeFontToolbarItem = ToolbarItem(
Log.error('Failed to set font family: $e');
}
},
onResetFont: () async => await editorState.formatDelta(selection, {
AppFlowyRichTextKeys.fontFamily: null,
}),
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 4.0),
child: FlowySvg(