mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: slash menu background color (#2616)
This commit is contained in:
@ -63,13 +63,19 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
|||||||
// code block
|
// code block
|
||||||
...codeBlockCharacterEvents,
|
...codeBlockCharacterEvents,
|
||||||
|
|
||||||
|
// toggle list
|
||||||
|
// formatGreaterToToggleList,
|
||||||
|
|
||||||
|
// customize the slash menu command
|
||||||
|
customSlashCommand(
|
||||||
|
slashMenuItems,
|
||||||
|
style: styleCustomizer.selectionMenuStyleBuilder(),
|
||||||
|
),
|
||||||
|
|
||||||
...standardCharacterShortcutEvents
|
...standardCharacterShortcutEvents
|
||||||
..removeWhere(
|
..removeWhere(
|
||||||
(element) => element == slashCommand,
|
(element) => element == slashCommand,
|
||||||
), // remove the default slash command.
|
), // remove the default slash command.
|
||||||
customSlashCommand(slashMenuItems),
|
|
||||||
|
|
||||||
// formatGreaterToToggleList,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
late final showSlashMenu = customSlashCommand(
|
late final showSlashMenu = customSlashCommand(
|
||||||
@ -189,7 +195,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
|
|||||||
),
|
),
|
||||||
AutoCompletionBlockKeys.type: AutoCompletionBlockComponentBuilder(),
|
AutoCompletionBlockKeys.type: AutoCompletionBlockComponentBuilder(),
|
||||||
SmartEditBlockKeys.type: SmartEditBlockComponentBuilder(),
|
SmartEditBlockKeys.type: SmartEditBlockComponentBuilder(),
|
||||||
// ToggleListBlockKeys.type: ToggleListBlockComponentBuilder(),
|
ToggleListBlockKeys.type: ToggleListBlockComponentBuilder(),
|
||||||
};
|
};
|
||||||
|
|
||||||
final builders = {
|
final builders = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:flowy_infra/image.dart';
|
import 'package:flowy_infra/image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -6,20 +7,21 @@ class SelectableSvgWidget extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.isSelected,
|
required this.isSelected,
|
||||||
|
required this.style,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
|
final SelectionMenuStyle style;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
return svgWidget(
|
return svgWidget(
|
||||||
name,
|
name,
|
||||||
size: const Size.square(18.0),
|
size: const Size.square(18.0),
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? theme.colorScheme.onSurface
|
? style.selectionMenuItemSelectedIconColor
|
||||||
: theme.colorScheme.onBackground,
|
: style.selectionMenuItemIconColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,20 +31,21 @@ class SelectableIconWidget extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.isSelected,
|
required this.isSelected,
|
||||||
|
required this.style,
|
||||||
});
|
});
|
||||||
|
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
|
final SelectionMenuStyle style;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
|
||||||
return Icon(
|
return Icon(
|
||||||
icon,
|
icon,
|
||||||
size: 18.0,
|
size: 18.0,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? theme.colorScheme.onSurface
|
? style.selectionMenuItemSelectedIconColor
|
||||||
: theme.colorScheme.onBackground,
|
: style.selectionMenuItemIconColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,10 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
SelectionMenuItem boardMenuItem = SelectionMenuItem(
|
SelectionMenuItem boardMenuItem = SelectionMenuItem(
|
||||||
name: LocaleKeys.document_plugins_referencedBoard.tr(),
|
name: LocaleKeys.document_plugins_referencedBoard.tr(),
|
||||||
icon: (editorState, onSelected) => SelectableSvgWidget(
|
icon: (editorState, onSelected, style) => SelectableSvgWidget(
|
||||||
name: 'editor/board',
|
name: 'editor/board',
|
||||||
isSelected: onSelected,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['referenced', 'board', 'kanban'],
|
keywords: ['referenced', 'board', 'kanban'],
|
||||||
handler: (editorState, menuService, context) {
|
handler: (editorState, menuService, context) {
|
||||||
|
@ -10,9 +10,10 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
SelectionMenuItem boardViewMenuItem(DocumentBloc documentBloc) =>
|
SelectionMenuItem boardViewMenuItem(DocumentBloc documentBloc) =>
|
||||||
SelectionMenuItem(
|
SelectionMenuItem(
|
||||||
name: LocaleKeys.document_slashMenu_board_createANewBoard.tr(),
|
name: LocaleKeys.document_slashMenu_board_createANewBoard.tr(),
|
||||||
icon: (editorState, onSelected) => SelectableSvgWidget(
|
icon: (editorState, onSelected, style) => SelectableSvgWidget(
|
||||||
name: 'editor/board',
|
name: 'editor/board',
|
||||||
isSelected: onSelected,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['board', 'kanban'],
|
keywords: ['board', 'kanban'],
|
||||||
handler: (editorState, menuService, context) async {
|
handler: (editorState, menuService, context) async {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/selectable_svg_widget.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/divider/divider_node_widget.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/divider/divider_node_widget.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -41,9 +42,10 @@ CharacterShortcutEventHandler _convertMinusesToDividerHandler =
|
|||||||
|
|
||||||
SelectionMenuItem dividerMenuItem = SelectionMenuItem(
|
SelectionMenuItem dividerMenuItem = SelectionMenuItem(
|
||||||
name: 'Divider',
|
name: 'Divider',
|
||||||
icon: (editorState, onSelected) => const Icon(
|
icon: (editorState, onSelected, style) => SelectableIconWidget(
|
||||||
Icons.horizontal_rule,
|
icon: Icons.horizontal_rule,
|
||||||
size: 18.0,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['horizontal rule', 'divider'],
|
keywords: ['horizontal rule', 'divider'],
|
||||||
handler: (editorState, _, __) {
|
handler: (editorState, _, __) {
|
||||||
|
@ -7,9 +7,10 @@ import 'emoji_picker.dart';
|
|||||||
|
|
||||||
SelectionMenuItem emojiMenuItem = SelectionMenuItem(
|
SelectionMenuItem emojiMenuItem = SelectionMenuItem(
|
||||||
name: 'Emoji',
|
name: 'Emoji',
|
||||||
icon: (editorState, onSelected) => SelectableIconWidget(
|
icon: (editorState, onSelected, style) => SelectableIconWidget(
|
||||||
icon: Icons.emoji_emotions_outlined,
|
icon: Icons.emoji_emotions_outlined,
|
||||||
isSelected: onSelected,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['emoji'],
|
keywords: ['emoji'],
|
||||||
handler: (editorState, menuService, context) {
|
handler: (editorState, menuService, context) {
|
||||||
|
@ -8,9 +8,10 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
SelectionMenuItem gridMenuItem = SelectionMenuItem(
|
SelectionMenuItem gridMenuItem = SelectionMenuItem(
|
||||||
name: LocaleKeys.document_plugins_referencedGrid.tr(),
|
name: LocaleKeys.document_plugins_referencedGrid.tr(),
|
||||||
icon: (editorState, onSelected) => SelectableSvgWidget(
|
icon: (editorState, onSelected, style) => SelectableSvgWidget(
|
||||||
name: 'editor/board',
|
name: 'editor/board',
|
||||||
isSelected: onSelected,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['referenced', 'grid'],
|
keywords: ['referenced', 'grid'],
|
||||||
handler: (editorState, menuService, context) {
|
handler: (editorState, menuService, context) {
|
||||||
|
@ -10,9 +10,10 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
SelectionMenuItem gridViewMenuItem(DocumentBloc documentBloc) =>
|
SelectionMenuItem gridViewMenuItem(DocumentBloc documentBloc) =>
|
||||||
SelectionMenuItem(
|
SelectionMenuItem(
|
||||||
name: LocaleKeys.document_slashMenu_grid_createANewGrid.tr(),
|
name: LocaleKeys.document_slashMenu_grid_createANewGrid.tr(),
|
||||||
icon: (editorState, onSelected) => SelectableSvgWidget(
|
icon: (editorState, onSelected, style) => SelectableSvgWidget(
|
||||||
name: 'editor/grid',
|
name: 'editor/grid',
|
||||||
isSelected: onSelected,
|
isSelected: onSelected,
|
||||||
|
style: style,
|
||||||
),
|
),
|
||||||
keywords: ['grid'],
|
keywords: ['grid'],
|
||||||
handler: (editorState, menuService, context) async {
|
handler: (editorState, menuService, context) async {
|
||||||
|
@ -126,7 +126,7 @@ class _ToggleListBlockComponentWidgetState
|
|||||||
|
|
||||||
// build the richtext child
|
// build the richtext child
|
||||||
Widget buildToggleListBlockComponent(BuildContext context) {
|
Widget buildToggleListBlockComponent(BuildContext context) {
|
||||||
return Row(
|
Widget child = Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// the emoji picker button for the note
|
// the emoji picker button for the note
|
||||||
@ -158,6 +158,16 @@ class _ToggleListBlockComponentWidgetState
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (widget.actionBuilder != null) {
|
||||||
|
child = BlockComponentActionWrapper(
|
||||||
|
node: node,
|
||||||
|
actionBuilder: widget.actionBuilder!,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onCollapsed() async {
|
Future<void> onCollapsed() async {
|
||||||
|
@ -124,4 +124,16 @@ class EditorStyleCustomizer {
|
|||||||
color: theme.colorScheme.onBackground,
|
color: theme.colorScheme.onBackground,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectionMenuStyle selectionMenuStyleBuilder() {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return SelectionMenuStyle(
|
||||||
|
selectionMenuBackgroundColor: theme.cardColor,
|
||||||
|
selectionMenuItemTextColor: theme.colorScheme.onBackground,
|
||||||
|
selectionMenuItemIconColor: theme.colorScheme.onBackground,
|
||||||
|
selectionMenuItemSelectedIconColor: theme.colorScheme.onSurface,
|
||||||
|
selectionMenuItemSelectedTextColor: theme.colorScheme.onSurface,
|
||||||
|
selectionMenuItemSelectedColor: theme.hoverColor,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
class AddButton extends StatelessWidget {
|
class AddButton extends StatelessWidget {
|
||||||
final Function(
|
final Function(
|
||||||
PluginBuilder,
|
PluginBuilder,
|
||||||
|
String? name,
|
||||||
List<int>? initialDataBytes,
|
List<int>? initialDataBytes,
|
||||||
bool openAfterCreated,
|
bool openAfterCreated,
|
||||||
) onSelected;
|
) onSelected;
|
||||||
@ -71,20 +72,20 @@ class AddButton extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
onSelected: (action, controller) {
|
onSelected: (action, controller) {
|
||||||
if (action is AddButtonActionWrapper) {
|
if (action is AddButtonActionWrapper) {
|
||||||
onSelected(action.pluginBuilder, null, true);
|
onSelected(action.pluginBuilder, null, null, true);
|
||||||
}
|
}
|
||||||
if (action is ImportActionWrapper) {
|
if (action is ImportActionWrapper) {
|
||||||
showImportPanel(context, (type, initialDataBytes) {
|
showImportPanel(context, (type, name, initialDataBytes) {
|
||||||
if (initialDataBytes == null) {
|
if (initialDataBytes == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ImportType.historyDocument:
|
case ImportType.historyDocument:
|
||||||
case ImportType.historyDatabase:
|
case ImportType.historyDatabase:
|
||||||
onSelected(action.pluginBuilder, initialDataBytes, false);
|
onSelected(action.pluginBuilder, name, initialDataBytes, false);
|
||||||
break;
|
break;
|
||||||
case ImportType.markdownOrText:
|
case ImportType.markdownOrText:
|
||||||
onSelected(action.pluginBuilder, initialDataBytes, true);
|
onSelected(action.pluginBuilder, name, initialDataBytes, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -108,10 +108,10 @@ class MenuAppHeader extends StatelessWidget {
|
|||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: LocaleKeys.menuAppHeader_addPageTooltip.tr(),
|
message: LocaleKeys.menuAppHeader_addPageTooltip.tr(),
|
||||||
child: AddButton(
|
child: AddButton(
|
||||||
onSelected: (pluginBuilder, initialDataBytes, openAfterCreated) {
|
onSelected: (pluginBuilder, name, initialDataBytes, openAfterCreated) {
|
||||||
context.read<AppBloc>().add(
|
context.read<AppBloc>().add(
|
||||||
AppEvent.createView(
|
AppEvent.createView(
|
||||||
LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
name ?? LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
||||||
pluginBuilder,
|
pluginBuilder,
|
||||||
initialDataBytes: initialDataBytes,
|
initialDataBytes: initialDataBytes,
|
||||||
openAfterCreated: openAfterCreated,
|
openAfterCreated: openAfterCreated,
|
||||||
|
@ -12,8 +12,13 @@ import 'package:flowy_infra_ui/style_widget/container.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
typedef ImportCallback = void Function(ImportType type, List<int>? document);
|
typedef ImportCallback = void Function(
|
||||||
|
ImportType type,
|
||||||
|
String name,
|
||||||
|
List<int>? document,
|
||||||
|
);
|
||||||
|
|
||||||
Future<void> showImportPanel(
|
Future<void> showImportPanel(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@ -183,7 +188,11 @@ class _ImportPanelState extends State<_ImportPanel> {
|
|||||||
}
|
}
|
||||||
if (document != null) {
|
if (document != null) {
|
||||||
final data = DocumentDataPBFromTo.fromDocument(document);
|
final data = DocumentDataPBFromTo.fromDocument(document);
|
||||||
widget.importCallback(importType, data?.writeToBuffer());
|
widget.importCallback(
|
||||||
|
importType,
|
||||||
|
p.basenameWithoutExtension(path),
|
||||||
|
data?.writeToBuffer(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "25eb16"
|
ref: "09e91c"
|
||||||
resolved-ref: "25eb1653252efa0c2695a49e7e7493c4030c11e4"
|
resolved-ref: "09e91c6e09f03f12aa2f499767109e70c4791535"
|
||||||
url: "https://github.com/LucasXu0/appflowy-editor.git"
|
url: "https://github.com/LucasXu0/appflowy-editor.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.12"
|
version: "0.1.12"
|
||||||
|
@ -47,7 +47,7 @@ dependencies:
|
|||||||
# path: /Users/lucas.xu/Desktop/appflowy-editor
|
# path: /Users/lucas.xu/Desktop/appflowy-editor
|
||||||
git:
|
git:
|
||||||
url: https://github.com/LucasXu0/appflowy-editor.git
|
url: https://github.com/LucasXu0/appflowy-editor.git
|
||||||
ref: 25eb16
|
ref: 09e91c
|
||||||
appflowy_popover:
|
appflowy_popover:
|
||||||
path: packages/appflowy_popover
|
path: packages/appflowy_popover
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user