inline_actions_result.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:appflowy/plugins/inline_actions/inline_actions_menu.dart';
  2. import 'package:appflowy_editor/appflowy_editor.dart';
  3. import 'package:flutter/material.dart';
  4. typedef SelectItemHandler = void Function(
  5. BuildContext context,
  6. EditorState editorState,
  7. InlineActionsMenuService menuService,
  8. (int start, int end) replacement,
  9. );
  10. class InlineActionsMenuItem {
  11. InlineActionsMenuItem({
  12. required this.label,
  13. this.icon,
  14. this.keywords,
  15. this.onSelected,
  16. });
  17. final String label;
  18. final Widget Function(bool onSelected)? icon;
  19. final List<String>? keywords;
  20. final SelectItemHandler? onSelected;
  21. }
  22. class InlineActionsResult {
  23. InlineActionsResult({
  24. required this.title,
  25. required this.results,
  26. this.startsWithKeywords,
  27. });
  28. /// Localized title to be displayed above the results
  29. /// of the current group.
  30. ///
  31. final String title;
  32. /// List of results that will be displayed for this group
  33. /// made up of [SelectionMenuItem]s.
  34. ///
  35. final List<InlineActionsMenuItem> results;
  36. /// If the search term start with one of these keyword,
  37. /// the results will be reordered such that these results
  38. /// will be above.
  39. ///
  40. final List<String>? startsWithKeywords;
  41. }