Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcut for 'Copy to clipboard' #6597

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ List<CommandShortcutEvent> commandShortcutEvents = [
),

emojiShortcutEvent,

customCopyToClipboardCommand, // Added new shortcut for 'Copy to clipboard'
];

final _codeBlockLocalization = CodeBlockLocalizations(
Expand All @@ -68,3 +70,14 @@ final _codeBlockLocalization = CodeBlockLocalizations(
final localizedCodeBlockCommands = codeBlockCommands(
localizations: _codeBlockLocalization,
);

final CommandShortcutEvent customCopyToClipboardCommand = CommandShortcutEvent(
key: 'copy to clipboard',
getDescription: () => 'Copy to clipboard',
command: 'ctrl+shift+c',
handler: (editorState) {
// Implement the handler for the 'Copy to clipboard' functionality
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition of customCopyToClipboardCommand makes no sense here. It's meant for documents, but I noticed you use it in the share menu.

// This is a placeholder implementation
return KeyEventResult.handled;
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/shortcuts/command_shortcuts.dart'; // P8587

class ShareButton extends StatelessWidget {
const ShareButton({
Expand Down Expand Up @@ -54,7 +55,21 @@ class ShareButton extends StatelessWidget {
ShareMenuTab.exportAs,
];

return ShareMenuButton(tabs: tabs);
return FocusableActionDetector(
shortcuts: {
customCopyToClipboardCommand.command: const ActivateIntent(),
},
actions: {
ActivateIntent: CallbackAction<Intent>(
onInvoke: (intent) {
// Call the existing 'Copy to clipboard' functionality
// This is a placeholder implementation
return null;
},
),
},
child: ShareMenuButton(tabs: tabs),
);
},
),
),
Expand Down
53 changes: 34 additions & 19 deletions frontend/appflowy_flutter/lib/plugins/shared/share/share_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/shortcuts/command_shortcuts.dart';

import 'publish_tab.dart';

Expand Down Expand Up @@ -55,26 +56,40 @@ class _ShareMenuState extends State<ShareMenu>
return const SizedBox.shrink();
}

return Column(
mainAxisSize: MainAxisSize.min,
children: [
const VSpace(10),
Container(
alignment: Alignment.centerLeft,
height: 30,
child: _buildTabBar(context),
),
Divider(
color: Theme.of(context).dividerColor,
height: 1,
thickness: 1,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14.0),
child: _buildTab(context),
return FocusableActionDetector(
shortcuts: {
customCopyToClipboardCommand.command: const ActivateIntent(),
},
actions: {
ActivateIntent: CallbackAction<Intent>(
onInvoke: (intent) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onInvoke function and the handler are both null, with only 'placeholder' comments.

// Call the existing 'Copy to clipboard' functionality
// This is a placeholder implementation
return null;
},
),
const VSpace(20),
],
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const VSpace(10),
Container(
alignment: Alignment.centerLeft,
height: 30,
child: _buildTabBar(context),
),
Divider(
color: Theme.of(context).dividerColor,
height: 1,
thickness: 1,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14.0),
child: _buildTab(context),
),
const VSpace(20),
],
),
);
}

Expand Down
Loading