Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: ai writer more actions (#7576)
Richard Shiueaacd795ae040
diff --git a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dartindex de641d479c..c446e30f60 100644--- a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart+++ b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart@@ -22,6 +22,7 @@ class DesktopPromptInput extends StatefulWidget {required this.selectedSourcesNotifier,required this.onUpdateSelectedSources,this.hideDecoration = false,+ this.extraBottomActionButton,});final bool isStreaming;@@ -31,6 +32,7 @@ class DesktopPromptInput extends StatefulWidget {final ValueNotifier<List<String>> selectedSourcesNotifier;final void Function(List<String>) onUpdateSelectedSources;final bool hideDecoration;+ final Widget? extraBottomActionButton;@overrideState<DesktopPromptInput> createState() => _DesktopPromptInputState();@@ -178,6 +180,8 @@ class _DesktopPromptInputState extends State<DesktopPromptInput> {widget.selectedSourcesNotifier,onUpdateSelectedSources:widget.onUpdateSelectedSources,+ extraBottomActionButton:+ widget.extraBottomActionButton,),),),@@ -565,6 +569,7 @@ class _PromptBottomActions extends StatelessWidget {required this.onStopStreaming,required this.selectedSourcesNotifier,required this.onUpdateSelectedSources,+ this.extraBottomActionButton,});final bool showPredefinedFormats;@@ -575,6 +580,7 @@ class _PromptBottomActions extends StatelessWidget {final void Function() onStopStreaming;final ValueNotifier<List<String>> selectedSourcesNotifier;final void Function(List<String>) onUpdateSelectedSources;+ final Widget? extraBottomActionButton;@overrideWidget build(BuildContext context) {@@ -599,6 +605,12 @@ class _PromptBottomActions extends StatelessWidget {DesktopAIChatSizes.inputActionBarButtonSpacing,),],+ if (extraBottomActionButton != null) ...[+ extraBottomActionButton!,+ const HSpace(+ DesktopAIChatSizes.inputActionBarButtonSpacing,+ ),+ ],// _mentionButton(context),// const HSpace(// DesktopAIPromptSizes.actionBarButtonSpacing,diff --git a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_menu.dart b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_menu.dartindex d7c920c49c..51357e6a0b 100644--- a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_menu.dart+++ b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_sources_menu.dart@@ -145,7 +145,7 @@ class _IndicatorButton extends StatelessWidget {children: [FlowySvg(FlowySvgs.ai_page_s,- color: Theme.of(context).iconTheme.color,+ color: Theme.of(context).hintColor,),const HSpace(2.0),ValueListenableBuilder(@@ -170,7 +170,7 @@ class _IndicatorButton extends StatelessWidget {FlowySvg(FlowySvgs.ai_source_drop_down_s,color: Theme.of(context).hintColor,- size: const Size.square(10),+ size: const Size.square(8),),],),diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_block_component.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_block_component.dartindex c1b533ccca..1e0bac83c5 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_block_component.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_block_component.dart@@ -6,7 +6,6 @@ import 'package:appflowy/util/theme_extension.dart';import 'package:appflowy/workspace/application/view/view_bloc.dart';import 'package:appflowy_editor/appflowy_editor.dart';import 'package:easy_localization/easy_localization.dart';-import 'package:flowy_infra/colorscheme/default_colorscheme.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -15,7 +14,8 @@ import 'package:universal_platform/universal_platform.dart';import 'operations/ai_writer_cubit.dart';import 'operations/ai_writer_entities.dart';import 'operations/ai_writer_node_extension.dart';-import 'suggestion_action_bar.dart';+import 'widgets/ai_writer_suggestion_actions.dart';+import 'widgets/ai_writer_prompt_input_more_button.dart';class AiWriterBlockKeys {const AiWriterBlockKeys._();@@ -169,7 +169,7 @@ class _AIWriterBlockComponentState extends State<AiWriterBlockComponent> {}}-class OverlayContent extends StatelessWidget {+class OverlayContent extends StatefulWidget {const OverlayContent({super.key,required this.editorState,@@ -179,6 +179,19 @@ class OverlayContent extends StatelessWidget {final EditorState editorState;final Node node;+ @override+ State<OverlayContent> createState() => _OverlayContentState();+}++class _OverlayContentState extends State<OverlayContent> {+ final showCommandsToggle = ValueNotifier(false);++ @override+ void dispose() {+ showCommandsToggle.dispose();+ super.dispose();+ }+@overrideWidget build(BuildContext context) {return BlocBuilder<AiWriterCubit, AiWriterState>(@@ -186,10 +199,11 @@ class OverlayContent extends StatelessWidget {if (state is IdleAiWriterState) {return const SizedBox.shrink();}- final selection = node.aiWriterSelection;+ final selection = widget.node.aiWriterSelection;final showSuggestionPopup =state is ReadyAiWriterState && !state.isFirstRun;- final showActionPopup = state is ReadyAiWriterState && state.isFirstRun;+ final isInitialReadyState =+ state is ReadyAiWriterState && state.isFirstRun;final markdownText = switch (state) {final ReadyAiWriterState ready => ready.markdownText,final GeneratingAiWriterState generating => generating.markdownText,@@ -200,10 +214,6 @@ class OverlayContent extends StatelessWidget {final isLightMode = Theme.of(context).isLightMode;final darkBorderColor =isLightMode ? Color(0x1F1F2329) : Color(0xFF505469);- final lightBorderColor =- Theme.of(context).brightness == Brightness.light- ? ColorSchemeConstants.lightBorderColor- : ColorSchemeConstants.darkBorderColor;return Column(mainAxisSize: MainAxisSize.min,@@ -220,10 +230,8 @@ class OverlayContent extends StatelessWidget {borderColor: darkBorderColor,),child: SuggestionActionBar(- actions: _getSuggestedActions(- currentCommand: state.command,- hasSelection: hasSelection,- ),+ currentCommand: state.command,+ hasSelection: hasSelection,onTap: (action) {_onSelectSuggestionAction(context, action);},@@ -288,10 +296,8 @@ class OverlayContent extends StatelessWidget {if (showSuggestionPopup) ...[const VSpace(4.0),SuggestionActionBar(- actions: _getSuggestedActions(- currentCommand: state.command,- hasSelection: hasSelection,- ),+ currentCommand: state.command,+ hasSelection: hasSelection,onTap: (action) {_onSelectSuggestionAction(context, action);},@@ -310,16 +316,43 @@ class OverlayContent extends StatelessWidget {decoration: markdownText.isNotEmpty? _getInputChildDecoration(context): _getSingleChildDeocoration(context),- child: MainContentArea(),+ child: MainContentArea(+ isDocumentEmpty: _isDocumentEmpty(),+ isInitialReadyState: isInitialReadyState,+ showCommandsToggle: showCommandsToggle,+ ),),],),),- ..._bottomActions(- context,- showActionPopup,- hasSelection,- lightBorderColor,+ ValueListenableBuilder(+ valueListenable: showCommandsToggle,+ builder: (context, value, child) {+ if (!value || !isInitialReadyState) {+ return const SizedBox.shrink();+ }+ return Align(+ alignment: AlignmentDirectional.centerEnd,+ child: BottomCommandButtons(+ hasSelection: hasSelection,+ editorState: widget.editorState,+ onSelectCommand: (command) {+ final promptInputBloc = context.read<AIPromptInputBloc>();+ final showPredefinedFormats =+ promptInputBloc.state.showPredefinedFormats;+ final predefinedFormat =+ promptInputBloc.state.predefinedFormat;++ context.read<AiWriterCubit>().runCommand(+ command,+ predefinedFormat:+ showPredefinedFormats ? predefinedFormat : null,+ isFirstRun: true,+ );+ },+ ),+ );+ },),],);@@ -327,41 +360,6 @@ class OverlayContent extends StatelessWidget {);}- Widget _bottomButton(AiWriterCommand command) {- return Builder(- builder: (context) {- return SizedBox(- height: 30.0,- child: FlowyButton(- leftIcon: FlowySvg(- command.icon,- size: const Size.square(16),- color: Theme.of(context).iconTheme.color,- ),- margin: const EdgeInsets.all(6.0),- text: FlowyText(- command.i18n,- figmaLineHeight: 20,- ),- onTap: () {- final aiInputBloc = context.read<AIPromptInputBloc>();- final showPredefinedFormats =- aiInputBloc.state.showPredefinedFormats;- final predefinedFormat = aiInputBloc.state.predefinedFormat;-- context.read<AiWriterCubit>().runCommand(- command,- predefinedFormat:- showPredefinedFormats ? predefinedFormat : null,- isFirstRun: false,- );- },- ),- );- },- );- }-BoxDecoration _getModalDecoration(BuildContext context, {required Color? color,@@ -406,119 +404,6 @@ class OverlayContent extends StatelessWidget {);}- List<Widget> _bottomActions(- BuildContext context,- bool showActionPopup,- bool hasSelection,- Color borderColor,- ) {- if (!showActionPopup) {- return [];- }-- if (editorState.isEmptyForContinueWriting()) {- final documentContext = editorState.document.root.context;- if (documentContext == null) {- return [];- }- final view = documentContext.read<ViewBloc>().state.view;- if (view.name.isEmpty) {- return [];- }- }-- return [- // add one here to take into account the border of the main message box.- // It is configured to be on the outside to hide some graphical- // artifacts.- const VSpace(4.0 + 1.0),- Container(- padding: EdgeInsets.all(8.0),- constraints: BoxConstraints(minWidth: 240.0),- decoration: _getModalDecoration(- context,- color: Theme.of(context).colorScheme.surface,- borderColor: borderColor,- borderRadius: BorderRadius.all(Radius.circular(8.0)),- ),- child: IntrinsicWidth(- child: SeparatedColumn(- separatorBuilder: () => const VSpace(4.0),- crossAxisAlignment: CrossAxisAlignment.start,- children: _getCommands(- hasSelection: hasSelection,- ),- ),- ),- ),- ];- }-- List<Widget> _getCommands({required bool hasSelection}) {- if (hasSelection) {- return [- _bottomButton(AiWriterCommand.improveWriting),- _bottomButton(AiWriterCommand.fixSpellingAndGrammar),- _bottomButton(AiWriterCommand.explain),- const Divider(height: 1.0, thickness: 1.0),- _bottomButton(AiWriterCommand.makeLonger),- _bottomButton(AiWriterCommand.makeShorter),- ];- } else {- return [- _bottomButton(AiWriterCommand.continueWriting),- ];- }- }-- List<SuggestionAction> _getSuggestedActions({- required AiWriterCommand currentCommand,- required bool hasSelection,- }) {- if (hasSelection) {- return switch (currentCommand) {- AiWriterCommand.userQuestion || AiWriterCommand.continueWriting => [- SuggestionAction.keep,- SuggestionAction.discard,- SuggestionAction.rewrite,- ],- AiWriterCommand.explain => [- SuggestionAction.insertBelow,- SuggestionAction.tryAgain,- SuggestionAction.close,- ],- AiWriterCommand.fixSpellingAndGrammar ||- AiWriterCommand.improveWriting ||- AiWriterCommand.makeShorter ||- AiWriterCommand.makeLonger =>- [- SuggestionAction.accept,- SuggestionAction.discard,- SuggestionAction.insertBelow,- SuggestionAction.rewrite,- ],- };- } else {- return switch (currentCommand) {- AiWriterCommand.userQuestion || AiWriterCommand.continueWriting => [- SuggestionAction.keep,- SuggestionAction.discard,- SuggestionAction.rewrite,- ],- AiWriterCommand.explain => [- SuggestionAction.insertBelow,- SuggestionAction.tryAgain,- SuggestionAction.close,- ],- _ => [- SuggestionAction.keep,- SuggestionAction.discard,- SuggestionAction.rewrite,- ],- };- }- }-void _onSelectSuggestionAction(BuildContext context,SuggestionAction action,@@ -530,10 +415,33 @@ class OverlayContent extends StatelessWidget {predefinedFormat,);}++ bool _isDocumentEmpty() {+ if (widget.editorState.isEmptyForContinueWriting()) {+ final documentContext = widget.editorState.document.root.context;+ if (documentContext == null) {+ return true;+ }+ final view = documentContext.read<ViewBloc>().state.view;+ if (view.name.isEmpty) {+ return true;+ }+ }+ return false;+ }}class MainContentArea extends StatelessWidget {- const MainContentArea({super.key});+ const MainContentArea({+ super.key,+ required this.isInitialReadyState,+ required this.isDocumentEmpty,+ required this.showCommandsToggle,+ });++ final bool isInitialReadyState;+ final bool isDocumentEmpty;+ final ValueNotifier<bool> showCommandsToggle;@overrideWidget build(BuildContext context) {@@ -553,6 +461,18 @@ class MainContentArea extends StatelessWidget {...sources,];},+ extraBottomActionButton: isInitialReadyState+ ? ValueListenableBuilder(+ valueListenable: showCommandsToggle,+ builder: (context, value, _) {+ return AiWriterPromptMoreButton(+ isEnabled: !isDocumentEmpty,+ isSelected: value,+ onTap: () => showCommandsToggle.value = !value,+ );+ },+ )+ : null,);}if (state is GeneratingAiWriterState) {diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dartindex 1119917e62..168854a34d 100644--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dart+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_node_extension.dart@@ -104,7 +104,7 @@ extension AiWriterNodeExtension on EditorState {start: Position(path: [0]),end: selection?.normalized.end ??this.selection?.normalized.end ??- Position(path: [0]),+ Position(path: getLastSelectable()?.$1.path ?? [0]),);// if the selected nodes are not entirely selected, slice the nodesdiff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/suggestion_action_bar.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/suggestion_action_bar.dartdeleted file mode 100644index a16fc44641..0000000000--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/suggestion_action_bar.dart+++ /dev/null@@ -1,63 +0,0 @@-import 'package:flowy_infra_ui/flowy_infra_ui.dart';-import 'package:flutter/material.dart';--import 'operations/ai_writer_entities.dart';--class SuggestionActionBar extends StatelessWidget {- const SuggestionActionBar({- super.key,- required this.actions,- required this.onTap,- });-- final List<SuggestionAction> actions;- final void Function(SuggestionAction) onTap;-- @override- Widget build(BuildContext context) {- return SeparatedRow(- mainAxisSize: MainAxisSize.min,- separatorBuilder: () => const HSpace(4.0),- children: actions- .map(- (action) => SuggestionActionButton(- action: action,- onTap: () => onTap(action),- ),- )- .toList(),- );- }-}--class SuggestionActionButton extends StatelessWidget {- const SuggestionActionButton({- super.key,- required this.action,- required this.onTap,- });-- final SuggestionAction action;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- return SizedBox(- height: 28,- child: FlowyButton(- text: FlowyText(- action.i18n,- figmaLineHeight: 20,- ),- leftIcon: action.buildIcon(context),- iconPadding: 4.0,- margin: const EdgeInsets.symmetric(- horizontal: 6.0,- vertical: 4.0,- ),- onTap: onTap,- useIntrinsicWidth: true,- ),- );- }-}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_prompt_input_more_button.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_prompt_input_more_button.dartnew file mode 100644index 0000000000..1e2641d796--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_prompt_input_more_button.dart@@ -0,0 +1,175 @@+import 'package:appflowy/ai/ai.dart';+import 'package:appflowy/generated/flowy_svgs.g.dart';+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/plugins/document/presentation/editor_plugins/ai/operations/ai_writer_cubit.dart';+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra/colorscheme/default_colorscheme.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flowy_infra_ui/style_widget/hover.dart';+import 'package:flutter/material.dart';+import 'package:flutter_bloc/flutter_bloc.dart';++import '../operations/ai_writer_entities.dart';++class AiWriterPromptMoreButton extends StatelessWidget {+ const AiWriterPromptMoreButton({+ super.key,+ required this.isEnabled,+ required this.isSelected,+ required this.onTap,+ });++ final bool isEnabled;+ final bool isSelected;+ final void Function() onTap;++ @override+ Widget build(BuildContext context) {+ return IgnorePointer(+ ignoring: !isEnabled,+ child: GestureDetector(+ onTap: onTap,+ behavior: HitTestBehavior.opaque,+ child: SizedBox(+ height: DesktopAIPromptSizes.actionBarButtonSize,+ child: FlowyHover(+ style: const HoverStyle(+ borderRadius: BorderRadius.all(Radius.circular(8)),+ ),+ isSelected: () => isSelected,+ child: Padding(+ padding: const EdgeInsetsDirectional.fromSTEB(6, 6, 4, 6),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ FlowySvg(+ FlowySvgs.ai_sparks_s,+ color: isEnabled+ ? Theme.of(context).hintColor+ : Theme.of(context).disabledColor,+ ),+ const HSpace(2.0),+ FlowyText(+ LocaleKeys.ai_more.tr(),+ fontSize: 12,+ figmaLineHeight: 16,+ color: isEnabled+ ? Theme.of(context).hintColor+ : Theme.of(context).disabledColor,+ ),+ const HSpace(2.0),+ FlowySvg(+ FlowySvgs.ai_source_drop_down_s,+ color: Theme.of(context).hintColor,+ size: const Size.square(8),+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ );+ }+}++class BottomCommandButtons extends StatelessWidget {+ const BottomCommandButtons({+ super.key,+ required this.hasSelection,+ required this.editorState,+ required this.onSelectCommand,+ });++ final EditorState editorState;+ final bool hasSelection;+ final void Function(AiWriterCommand) onSelectCommand;++ @override+ Widget build(BuildContext context) {+ return Container(+ // add one here to take into account the border of the main message box.+ // It is configured to be on the outside to hide some graphical+ // artifacts.+ margin: EdgeInsets.only(top: 4.0 + 1.0),+ padding: EdgeInsets.all(8.0),+ constraints: BoxConstraints(minWidth: 240.0),+ decoration: BoxDecoration(+ color: Theme.of(context).colorScheme.surface,+ border: Border.all(+ color: Theme.of(context).brightness == Brightness.light+ ? ColorSchemeConstants.lightBorderColor+ : ColorSchemeConstants.darkBorderColor,+ strokeAlign: BorderSide.strokeAlignOutside,+ ),+ borderRadius: BorderRadius.all(Radius.circular(8.0)),+ boxShadow: const [+ BoxShadow(+ offset: Offset(0, 4),+ blurRadius: 20,+ color: Color(0x1A1F2329),+ ),+ ],+ ),+ child: IntrinsicWidth(+ child: Column(+ spacing: 4.0,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: _getCommands(+ hasSelection: hasSelection,+ ),+ ),+ ),+ );+ }++ List<Widget> _getCommands({required bool hasSelection}) {+ if (hasSelection) {+ return [+ _bottomButton(AiWriterCommand.improveWriting),+ _bottomButton(AiWriterCommand.fixSpellingAndGrammar),+ _bottomButton(AiWriterCommand.explain),+ const Divider(height: 1.0, thickness: 1.0),+ _bottomButton(AiWriterCommand.makeLonger),+ _bottomButton(AiWriterCommand.makeShorter),+ ];+ } else {+ return [+ _bottomButton(AiWriterCommand.continueWriting),+ ];+ }+ }++ Widget _bottomButton(AiWriterCommand command) {+ return Builder(+ builder: (context) {+ return FlowyButton(+ leftIcon: FlowySvg(+ command.icon,+ size: const Size.square(16),+ color: Theme.of(context).iconTheme.color,+ ),+ margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),+ text: FlowyText(+ command.i18n,+ figmaLineHeight: 20,+ ),+ onTap: () {+ final aiInputBloc = context.read<AIPromptInputBloc>();+ final showPredefinedFormats =+ aiInputBloc.state.showPredefinedFormats;+ final predefinedFormat = aiInputBloc.state.predefinedFormat;++ context.read<AiWriterCubit>().runCommand(+ command,+ predefinedFormat:+ showPredefinedFormats ? predefinedFormat : null,+ isFirstRun: false,+ );+ },+ );+ },+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_suggestion_actions.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_suggestion_actions.dartnew file mode 100644index 0000000000..d39ede2608--- /dev/null+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/widgets/ai_writer_suggestion_actions.dart@@ -0,0 +1,110 @@+import 'package:flowy_infra_ui/flowy_infra_ui.dart';+import 'package:flutter/material.dart';++import '../operations/ai_writer_entities.dart';++class SuggestionActionBar extends StatelessWidget {+ const SuggestionActionBar({+ super.key,+ required this.currentCommand,+ required this.hasSelection,+ required this.onTap,+ });++ final AiWriterCommand currentCommand;+ final bool hasSelection;+ final void Function(SuggestionAction) onTap;++ @override+ Widget build(BuildContext context) {+ return SeparatedRow(+ mainAxisSize: MainAxisSize.min,+ separatorBuilder: () => const HSpace(4.0),+ children: _getSuggestedActions()+ .map(+ (action) => SuggestionActionButton(+ action: action,+ onTap: () => onTap(action),+ ),+ )+ .toList(),+ );+ }++ List<SuggestionAction> _getSuggestedActions() {+ if (hasSelection) {+ return switch (currentCommand) {+ AiWriterCommand.userQuestion || AiWriterCommand.continueWriting => [+ SuggestionAction.keep,+ SuggestionAction.discard,+ SuggestionAction.rewrite,+ ],+ AiWriterCommand.explain => [+ SuggestionAction.insertBelow,+ SuggestionAction.tryAgain,+ SuggestionAction.close,+ ],+ AiWriterCommand.fixSpellingAndGrammar ||+ AiWriterCommand.improveWriting ||+ AiWriterCommand.makeShorter ||+ AiWriterCommand.makeLonger =>+ [+ SuggestionAction.accept,+ SuggestionAction.discard,+ SuggestionAction.insertBelow,+ SuggestionAction.rewrite,+ ],+ };+ } else {+ return switch (currentCommand) {+ AiWriterCommand.userQuestion || AiWriterCommand.continueWriting => [+ SuggestionAction.keep,+ SuggestionAction.discard,+ SuggestionAction.rewrite,+ ],+ AiWriterCommand.explain => [+ SuggestionAction.insertBelow,+ SuggestionAction.tryAgain,+ SuggestionAction.close,+ ],+ _ => [+ SuggestionAction.keep,+ SuggestionAction.discard,+ SuggestionAction.rewrite,+ ],+ };+ }+ }+}++class SuggestionActionButton extends StatelessWidget {+ const SuggestionActionButton({+ super.key,+ required this.action,+ required this.onTap,+ });++ final SuggestionAction action;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ return SizedBox(+ height: 28,+ child: FlowyButton(+ text: FlowyText(+ action.i18n,+ figmaLineHeight: 20,+ ),+ leftIcon: action.buildIcon(context),+ iconPadding: 4.0,+ margin: const EdgeInsets.symmetric(+ horizontal: 6.0,+ vertical: 4.0,+ ),+ onTap: onTap,+ useIntrinsicWidth: true,+ ),+ );+ }+}diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex 55cc15d3ac..7d8cba8b13 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -3160,7 +3160,8 @@"editing": "Editing","analyzing": "Analyzing","continueWritingEmptyDocumentTitle": "Continue writing error",- "continueWritingEmptyDocumentDescription": "We are having trouble expanding on the content in your document. Write a small intro and we can take it from there!"+ "continueWritingEmptyDocumentDescription": "We are having trouble expanding on the content in your document. Write a small intro and we can take it from there!",+ "more": "More"},"autoUpdate": {"criticalUpdateTitle": "Update required to continue",