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

a11y: add keyboard shortcut for copy, cut, paste #2694

Merged
merged 9 commits into from
Apr 28, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ const KeyboardNodeEditingShortcuts = {
'Windows.Control.c': KeyboardCommandTypes.Node.Copy,
'Windows.Control.X': KeyboardCommandTypes.Node.Cut,
'Windows.Control.x': KeyboardCommandTypes.Node.Cut,
'Windows.Control.V': KeyboardCommandTypes.Node.Paste,
'Windows.Control.v': KeyboardCommandTypes.Node.Paste,

'Mac.Meta.C': KeyboardCommandTypes.Node.Copy,
'Mac.Meta.c': KeyboardCommandTypes.Node.Copy,
'Mac.Meta.X': KeyboardCommandTypes.Node.Cut,
'Mac.Meta.x': KeyboardCommandTypes.Node.Cut,
'Mac.Meta.V': KeyboardCommandTypes.Node.Paste,
'Mac.Meta.v': KeyboardCommandTypes.Node.Paste,
};

const KeyboardOperationEditingShortcuts = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,16 @@ export const ObiEditor: FC<ObiEditorProps> = ({
case KeyboardCommandTypes.Node.Cut:
dispatchEvent(NodeEventTypes.CutSelection, { actionIds: getClipboardTargetsFromContext() });
break;
case KeyboardCommandTypes.Node.Paste:
dispatchEvent(NodeEventTypes.AppendSelection, {
target: focusedId,
actions: clipboardActions,
});
case KeyboardCommandTypes.Node.Paste: {
const currentSelectedId = selectionContext.selectedIds[0];
if (currentSelectedId.endsWith('+')) {
dispatchEvent(NodeEventTypes.AppendSelection, {
target: focusedId,
actions: clipboardActions,
});
alanlong9278 marked this conversation as resolved.
Show resolved Hide resolved
}
break;
}
}
break;
case KeyboardPrimaryTypes.Cursor: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const EditorConfig = {
showEvents: false,
arrowNavigation: true,
tabNavigation: true,
keyboardNodeEditing: false,
keyboardNodeEditing: true,
keyboardOperationEditing: true,
},
};