Skip to content

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.

feat: support copy/cut command when the selection is collapsed (#6429)

Lucasa0ee47b8097f
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_shortcuts_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_shortcuts_test.dart
new file mode 100644
index 0000000000..cf33a66947
--- /dev/null
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_shortcuts_test.dart
@@ -0,0 +1,140 @@
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+import 'package:universal_platform/universal_platform.dart';
+
+import '../../shared/util.dart';
+
+void main() {
+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+ group('document shortcuts:', () {
+ testWidgets('custom cut command', (tester) async {
+ await tester.initializeAppFlowy();
+ await tester.tapAnonymousSignInButton();
+
+ const pageName = 'Test Document Shortcuts';
+ await tester.createNewPageWithNameUnderParent(name: pageName);
+
+ // focus on the editor
+ await tester.tap(find.byType(AppFlowyEditor));
+
+ // mock the data
+ final editorState = tester.editor.getCurrentEditorState();
+ final transaction = editorState.transaction;
+ const text1 = '1. First line';
+ const text2 = '2. Second line';
+ transaction.insertNodes([
+ 0,
+ ], [
+ paragraphNode(text: text1),
+ paragraphNode(text: text2),
+ ]);
+ await editorState.apply(transaction);
+ await tester.pumpAndSettle();
+
+ // focus on the end of the first line
+ await tester.editor.updateSelection(
+ Selection.collapsed(
+ Position(path: [0], offset: text1.length),
+ ),
+ );
+ // press the keybinding
+ await tester.simulateKeyEvent(
+ LogicalKeyboardKey.keyX,
+ isControlPressed: !UniversalPlatform.isMacOS,
+ isMetaPressed: UniversalPlatform.isMacOS,
+ );
+ await tester.pumpAndSettle();
+
+ // check the clipboard
+ final clipboard = await Clipboard.getData(Clipboard.kTextPlain);
+ expect(
+ clipboard?.text,
+ equals(text1),
+ );
+
+ final node = tester.editor.getNodeAtPath([0]);
+ expect(
+ node.delta?.toPlainText(),
+ equals(text2),
+ );
+
+ // select the whole line
+ await tester.editor.updateSelection(
+ Selection.single(
+ path: [0],
+ startOffset: 0,
+ endOffset: text2.length,
+ ),
+ );
+
+ // press the keybinding
+ await tester.simulateKeyEvent(
+ LogicalKeyboardKey.keyX,
+ isControlPressed: !UniversalPlatform.isMacOS,
+ isMetaPressed: UniversalPlatform.isMacOS,
+ );
+ await tester.pumpAndSettle();
+
+ // all the text should be deleted
+ expect(
+ node.delta?.toPlainText(),
+ equals(''),
+ );
+
+ final clipboard2 = await Clipboard.getData(Clipboard.kTextPlain);
+ expect(
+ clipboard2?.text,
+ equals(text2),
+ );
+ });
+
+ testWidgets(
+ 'custom copy command - copy whole line when selection is collapsed',
+ (tester) async {
+ await tester.initializeAppFlowy();
+ await tester.tapAnonymousSignInButton();
+
+ const pageName = 'Test Document Shortcuts';
+ await tester.createNewPageWithNameUnderParent(name: pageName);
+
+ // focus on the editor
+ await tester.tap(find.byType(AppFlowyEditor));
+
+ // mock the data
+ final editorState = tester.editor.getCurrentEditorState();
+ final transaction = editorState.transaction;
+ const text1 = '1. First line';
+ transaction.insertNodes([
+ 0,
+ ], [
+ paragraphNode(text: text1),
+ ]);
+ await editorState.apply(transaction);
+ await tester.pumpAndSettle();
+
+ // focus on the end of the first line
+ await tester.editor.updateSelection(
+ Selection.collapsed(
+ Position(path: [0], offset: text1.length),
+ ),
+ );
+ // press the keybinding
+ await tester.simulateKeyEvent(
+ LogicalKeyboardKey.keyC,
+ isControlPressed: !UniversalPlatform.isMacOS,
+ isMetaPressed: UniversalPlatform.isMacOS,
+ );
+ await tester.pumpAndSettle();
+
+ // check the clipboard
+ final clipboard = await Clipboard.getData(Clipboard.kTextPlain);
+ expect(
+ clipboard?.text,
+ equals(text1),
+ );
+ });
+ });
+}
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner.dart
index 018ed1b8d4..888267f938 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_test_runner.dart
@@ -5,10 +5,11 @@ import 'document_codeblock_paste_test.dart' as document_codeblock_paste_test;
import 'document_copy_and_paste_test.dart' as document_copy_and_paste_test;
import 'document_create_and_delete_test.dart'
as document_create_and_delete_test;
-import 'document_option_action_test.dart' as document_option_action_test;
import 'document_inline_page_reference_test.dart'
as document_inline_page_reference_test;
import 'document_more_actions_test.dart' as document_more_actions_test;
+import 'document_option_action_test.dart' as document_option_action_test;
+import 'document_shortcuts_test.dart' as document_shortcuts_test;
import 'document_text_direction_test.dart' as document_text_direction_test;
import 'document_with_cover_image_test.dart' as document_with_cover_image_test;
import 'document_with_database_test.dart' as document_with_database_test;
@@ -45,4 +46,5 @@ void startTesting() {
document_inline_page_reference_test.main();
document_more_actions_test.main();
document_with_file_test.main();
+ document_shortcuts_test.main();
}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
index 70564bbcde..e56e1f283c 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart
@@ -1,30 +1,21 @@
import 'dart:ui' as ui;
-import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/application/document_bloc.dart';
import 'package:appflowy/plugins/document/presentation/editor_configuration.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/align_toolbar_item/custom_text_align_command.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/background_color/theme_background_color.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/base/format_arrow_character.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/base/page_reference_commands.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/callout/callout_block_shortcuts.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/i18n/editor_i18n.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy/plugins/inline_actions/handlers/date_reference.dart';
import 'package:appflowy/plugins/inline_actions/handlers/inline_page_reference.dart';
import 'package:appflowy/plugins/inline_actions/handlers/reminder_reference.dart';
-import 'package:appflowy/plugins/inline_actions/inline_actions_command.dart';
import 'package:appflowy/plugins/inline_actions/inline_actions_service.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart';
import 'package:appflowy/workspace/application/view_info/view_info_bloc.dart';
import 'package:appflowy/workspace/presentation/home/af_focus_manager.dart';
-import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
-import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
import 'package:collection/collection.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
@@ -32,53 +23,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:universal_platform/universal_platform.dart';
-final codeBlockLocalization = CodeBlockLocalizations(
- codeBlockNewParagraph:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockNewParagraph.tr(),
- codeBlockIndentLines:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockIndentLines.tr(),
- codeBlockOutdentLines:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockOutdentLines.tr(),
- codeBlockSelectAll:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockSelectAll.tr(),
- codeBlockPasteText:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockPasteText.tr(),
- codeBlockAddTwoSpaces:
- LocaleKeys.settings_shortcutsPage_commands_codeBlockAddTwoSpaces.tr(),
-);
-
-final localizedCodeBlockCommands =
- codeBlockCommands(localizations: codeBlockLocalization);
-
-final List<CommandShortcutEvent> commandShortcutEvents = [
- backspaceToTitle,
- arrowUpToTitle,
- arrowLeftToTitle,
- toggleToggleListCommand,
- ...localizedCodeBlockCommands,
- customCopyCommand,
- customPasteCommand,
- customCutCommand,
- ...customTextAlignCommands,
-
- // remove standard shortcuts for copy, cut, paste, todo
- ...standardCommandShortcutEvents
- ..removeWhere(
- (shortcut) => [
- copyCommand,
- cutCommand,
- pasteCommand,
- toggleTodoListCommand,
- ].contains(shortcut),
- ),
-
- emojiShortcutEvent,
-];
-
-final List<CommandShortcutEvent> defaultCommandShortcutEvents = [
- ...commandShortcutEvents.map((e) => e.copyWith()),
-];
-
/// Wrapper for the appflowy editor.
class AppFlowyEditorPage extends StatefulWidget {
const AppFlowyEditorPage({
@@ -125,7 +69,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
],
);
- late final List<CommandShortcutEvent> cmdShortcutEvents = [
+ late final List<CommandShortcutEvent> commandShortcuts = [
...commandShortcutEvents,
..._buildFindAndReplaceCommands(),
];
@@ -151,60 +95,15 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
late List<SelectionMenuItem> slashMenuItems;
- List<CharacterShortcutEvent> get characterShortcutEvents => [
- // code block
- formatBacktickToCodeBlock,
- ...codeBlockCharacterEvents,
-
- // callout block
- insertNewLineInCalloutBlock,
-
- // quote block
- insertNewLineInQuoteBlock,
-
- // toggle list
- formatGreaterToToggleList,
- insertChildNodeInsideToggleList,
-
- // customize the slash menu command
- customSlashCommand(
- slashMenuItems,
- style: styleCustomizer.selectionMenuStyleBuilder(),
- ),
-
- customFormatGreaterEqual,
-
- ...standardCharacterShortcutEvents
- ..removeWhere(
- (shortcut) => [
- slashCommand, // Remove default slash command
- formatGreaterEqual, // Overridden by customFormatGreaterEqual
- ].contains(shortcut),
- ),
-
- /// Inline Actions
- /// - Reminder
- /// - Inline-page reference
- inlineActionsCommand(
- inlineActionsService,
- style: styleCustomizer.inlineActionsMenuStyleBuilder(),
- ),
-
- /// Inline page menu
- /// - Using `[[`
- pageReferenceShortcutBrackets(
- context,
- documentBloc.documentId,
- styleCustomizer.inlineActionsMenuStyleBuilder(),
- ),
-
- /// - Using `+`
- pageReferenceShortcutPlusSign(
- context,
- documentBloc.documentId,
- styleCustomizer.inlineActionsMenuStyleBuilder(),
- ),
- ];
+ List<CharacterShortcutEvent> get characterShortcutEvents {
+ return buildCharacterShortcutEvents(
+ context,
+ documentBloc,
+ styleCustomizer,
+ inlineActionsService,
+ slashMenuItems,
+ );
+ }
EditorStyleCustomizer get styleCustomizer => widget.styleCustomizer;
DocumentBloc get documentBloc => context.read<DocumentBloc>();
@@ -223,12 +122,6 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
AFFocusManager? focusManager;
- void _loseFocus() {
- if (!widget.editorState.isDisposed) {
- widget.editorState.selection = null;
- }
- }
-
@override
void initState() {
super.initState();
@@ -363,7 +256,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
),
// customize the shortcuts
characterShortcutEvents: characterShortcutEvents,
- commandShortcutEvents: cmdShortcutEvents,
+ commandShortcutEvents: commandShortcuts,
// customize the context menu items
contextMenuItems: customContextMenuItems,
// customize the header and footer.
@@ -469,7 +362,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
final customizeShortcuts =
await settingsShortcutService.getCustomizeShortcuts();
await settingsShortcutService.updateCommandShortcuts(
- cmdShortcutEvents,
+ commandShortcuts,
customizeShortcuts,
);
}
@@ -542,6 +435,12 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
}
await editorState.apply(transaction);
}
+
+ void _loseFocus() {
+ if (!widget.editorState.isDisposed) {
+ widget.editorState.selection = null;
+ }
+ }
}
Color? buildEditorCustomizedColor(
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart
index 8370a24b66..5e8a17dc1d 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_copy_command.dart
@@ -1,10 +1,9 @@
import 'dart:convert';
-import 'package:flutter/material.dart';
-
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:flutter/material.dart';
/// Copy.
///
@@ -23,21 +22,43 @@ final CommandShortcutEvent customCopyCommand = CommandShortcutEvent(
CommandShortcutEventHandler _copyCommandHandler = (editorState) {
final selection = editorState.selection?.normalized;
- if (selection == null || selection.isCollapsed) {
+ if (selection == null) {
return KeyEventResult.ignored;
}
- // plain text.
- final text = editorState.getTextInSelection(selection).join('\n');
+ String? text;
+ String? html;
+ String? inAppJson;
+
+ if (selection.isCollapsed) {
+ // if the selection is collapsed, we will copy the text of the current line.
+ final node = editorState.getNodeAtPath(selection.end.path);
+ if (node == null) {
+ return KeyEventResult.ignored;
+ }
- final nodes = editorState.getSelectedNodes(selection: selection);
- final document = Document.blank()..insert([0], nodes);
+ // plain text.
+ text = node.delta?.toPlainText();
- // in app json
- final inAppJson = jsonEncode(document.toJson());
+ // in app json
+ final document = Document.blank()..insert([0], [node.copyWith()]);
+ inAppJson = jsonEncode(document.toJson());
- // html
- final html = documentToHTML(document);
+ // html
+ html = documentToHTML(document);
+ } else {
+ // plain text.
+ text = editorState.getTextInSelection(selection).join('\n');
+
+ final nodes = editorState.getSelectedNodes(selection: selection);
+ final document = Document.blank()..insert([0], nodes);
+
+ // in app json
+ inAppJson = jsonEncode(document.toJson());
+
+ // html
+ html = documentToHTML(document);
+ }
() async {
await getIt<ClipboardService>().setData(
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_cut_command.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_cut_command.dart
index a2f4442bd0..d4480c0332 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_cut_command.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/copy_and_paste/custom_cut_command.dart
@@ -18,7 +18,30 @@ final CommandShortcutEvent customCutCommand = CommandShortcutEvent(
);
CommandShortcutEventHandler _cutCommandHandler = (editorState) {
+ final selection = editorState.selection;
+ if (selection == null) {
+ return KeyEventResult.ignored;
+ }
+
customCopyCommand.execute(editorState);
- editorState.deleteSelectionIfNeeded();
+
+ if (!selection.isCollapsed) {
+ editorState.deleteSelectionIfNeeded();
+ } else {
+ final node = editorState.getNodeAtPath(selection.end.path);
+ if (node == null) {
+ return KeyEventResult.handled;
+ }
+ final transaction = editorState.transaction;
+ transaction.deleteNode(node);
+ final nextNode = node.next;
+ if (nextNode != null && nextNode.delta != null) {
+ transaction.afterSelection = Selection.collapsed(
+ Position(path: node.path, offset: nextNode.delta?.length ?? 0),
+ );
+ }
+ editorState.apply(transaction);
+ }
+
return KeyEventResult.handled;
};
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart
index 1f3104b5f5..d277a3c11b 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/plugins.dart
@@ -55,6 +55,8 @@ export 'openai/widgets/smart_edit_toolbar_item.dart';
export 'outline/outline_block_component.dart';
export 'parsers/markdown_parsers.dart';
export 'quote/quote_block_shortcuts.dart';
+export 'shortcuts/character_shortcuts.dart';
+export 'shortcuts/command_shortcuts.dart';
export 'slash_menu/slash_menu_items.dart';
export 'table/table_menu.dart';
export 'table/table_option_action.dart';
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/character_shortcuts.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/character_shortcuts.dart
new file mode 100644
index 0000000000..aba1b68a28
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/character_shortcuts.dart
@@ -0,0 +1,74 @@
+import 'package:appflowy/plugins/document/application/document_bloc.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/base/format_arrow_character.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/base/page_reference_commands.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/callout/callout_block_shortcuts.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
+import 'package:appflowy/plugins/document/presentation/editor_style.dart';
+import 'package:appflowy/plugins/inline_actions/inline_actions_command.dart';
+import 'package:appflowy/plugins/inline_actions/inline_actions_service.dart';
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
+import 'package:flutter/material.dart';
+
+List<CharacterShortcutEvent> buildCharacterShortcutEvents(
+ BuildContext context,
+ DocumentBloc documentBloc,
+ EditorStyleCustomizer styleCustomizer,
+ InlineActionsService inlineActionsService,
+ List<SelectionMenuItem> slashMenuItems,
+) {
+ return [
+ // code block
+ formatBacktickToCodeBlock,
+ ...codeBlockCharacterEvents,
+
+ // callout block
+ insertNewLineInCalloutBlock,
+
+ // quote block
+ insertNewLineInQuoteBlock,
+
+ // toggle list
+ formatGreaterToToggleList,
+ insertChildNodeInsideToggleList,
+
+ // customize the slash menu command
+ customSlashCommand(
+ slashMenuItems,
+ style: styleCustomizer.selectionMenuStyleBuilder(),
+ ),
+
+ customFormatGreaterEqual,
+
+ ...standardCharacterShortcutEvents
+ ..removeWhere(
+ (shortcut) => [
+ slashCommand, // Remove default slash command
+ formatGreaterEqual, // Overridden by customFormatGreaterEqual
+ ].contains(shortcut),
+ ),
+
+ /// Inline Actions
+ /// - Reminder
+ /// - Inline-page reference
+ inlineActionsCommand(
+ inlineActionsService,
+ style: styleCustomizer.inlineActionsMenuStyleBuilder(),
+ ),
+
+ /// Inline page menu
+ /// - Using `[[`
+ pageReferenceShortcutBrackets(
+ context,
+ documentBloc.documentId,
+ styleCustomizer.inlineActionsMenuStyleBuilder(),
+ ),
+
+ /// - Using `+`
+ pageReferenceShortcutPlusSign(
+ context,
+ documentBloc.documentId,
+ styleCustomizer.inlineActionsMenuStyleBuilder(),
+ ),
+ ];
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/command_shortcuts.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/command_shortcuts.dart
new file mode 100644
index 0000000000..a65b2387ac
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/shortcuts/command_shortcuts.dart
@@ -0,0 +1,61 @@
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/align_toolbar_item/custom_text_align_command.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
+import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart';
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart';
+import 'package:easy_localization/easy_localization.dart';
+
+final List<CommandShortcutEvent> defaultCommandShortcutEvents = [
+ ...commandShortcutEvents.map((e) => e.copyWith()),
+];
+
+// Command shortcuts are order-sensitive. Verify order when modifying.
+List<CommandShortcutEvent> commandShortcutEvents = [
+ backspaceToTitle,
+
+ arrowUpToTitle,
+ arrowLeftToTitle,
+
+ toggleToggleListCommand,
+
+ ...localizedCodeBlockCommands,
+
+ customCopyCommand,
+ customPasteCommand,
+ customCutCommand,
+
+ ...customTextAlignCommands,
+
+ // remove standard shortcuts for copy, cut, paste, todo
+ ...standardCommandShortcutEvents
+ ..removeWhere(
+ (shortcut) => [
+ copyCommand,
+ cutCommand,
+ pasteCommand,
+ toggleTodoListCommand,
+ ].contains(shortcut),
+ ),
+
+ emojiShortcutEvent,
+];
+
+final _codeBlockLocalization = CodeBlockLocalizations(
+ codeBlockNewParagraph:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockNewParagraph.tr(),
+ codeBlockIndentLines:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockIndentLines.tr(),
+ codeBlockOutdentLines:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockOutdentLines.tr(),
+ codeBlockSelectAll:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockSelectAll.tr(),
+ codeBlockPasteText:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockPasteText.tr(),
+ codeBlockAddTwoSpaces:
+ LocaleKeys.settings_shortcutsPage_commands_codeBlockAddTwoSpaces.tr(),
+);
+
+final localizedCodeBlockCommands = codeBlockCommands(
+ localizations: _codeBlockLocalization,
+);
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart
index 07794e05ac..30c2a05de4 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart
@@ -1,5 +1,5 @@
import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/plugins/document/presentation/editor_page.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_service.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_service.dart
index 35809ac585..25b51c9a81 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_service.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/shortcuts/settings_shortcuts_service.dart
@@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
-import 'package:appflowy/plugins/document/presentation/editor_page.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/settings/application_data_storage.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock
index d727f3f784..13ea0cb4e3 100644
--- a/frontend/appflowy_flutter/pubspec.lock
+++ b/frontend/appflowy_flutter/pubspec.lock
@@ -53,8 +53,8 @@ packages:
dependency: "direct main"
description:
path: "."
- ref: "6da7b4e"
- resolved-ref: "6da7b4e5dc76dd6b9d4361c744359b04ddb5b983"
+ ref: c5de9ed
+ resolved-ref: c5de9ed84dbc7461e5542ce598d803e37838a65a
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
source: git
version: "3.3.0"
@@ -1559,10 +1559,10 @@ packages:
dependency: transitive
description:
name: platform
- sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
+ sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
url: "https://pub.dev"
source: hosted
- version: "3.1.4"
+ version: "3.1.5"
plugin_platform_interface:
dependency: "direct dev"
description:
@@ -1989,10 +1989,10 @@ packages:
dependency: transitive
description:
name: string_scanner
- sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
+ sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
- version: "1.2.0"
+ version: "1.3.0"
string_validator:
dependency: "direct main"
description:
@@ -2311,10 +2311,10 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
+ sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
- version: "14.2.1"
+ version: "14.2.5"
watcher:
dependency: transitive
description:
diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml
index 95dfbdfa78..9a9ec0f089 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -177,7 +177,7 @@ dependency_overrides:
appflowy_editor:
git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git
- ref: "6da7b4e"
+ ref: "c5de9ed"
appflowy_editor_plugins:
git:
diff --git a/frontend/appflowy_flutter/test/bloc_test/shortcuts_test/shortcuts_cubit_test.dart b/frontend/appflowy_flutter/test/bloc_test/shortcuts_test/shortcuts_cubit_test.dart
index 1b896cbd3d..ce57c61bd7 100644
--- a/frontend/appflowy_flutter/test/bloc_test/shortcuts_test/shortcuts_cubit_test.dart
+++ b/frontend/appflowy_flutter/test/bloc_test/shortcuts_test/shortcuts_cubit_test.dart
@@ -1,6 +1,6 @@
import 'dart:ffi';
-import 'package:appflowy/plugins/document/presentation/editor_page.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_cubit.dart';
import 'package:appflowy/workspace/application/settings/shortcuts/settings_shortcuts_service.dart';
import 'package:bloc_test/bloc_test.dart';