Skip to content

Commit

Permalink
Add copy link command (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhabib committed Feb 29, 2024
1 parent b1766c2 commit 90edcc8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-fireants-yell.md
@@ -0,0 +1,5 @@
---
'playroom': minor
---

Add keybinding for copying Playroom link to clipboard with <kbd>⌘</kbd> + <kbd>⇧</kbd> + <kbd>C</kbd> (or, on Windows, <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>C</kbd>).
9 changes: 9 additions & 0 deletions src/Playroom/CodeEditor/CodeEditor.tsx
Expand Up @@ -259,6 +259,15 @@ export const CodeEditor = ({ code, onChange, previewCode, hints }: Props) => {
[`${keymapModifierKey}-D`]: selectNextOccurrence,
[`Shift-${keymapModifierKey}-,`]: wrapInTag,
[`${keymapModifierKey}-/`]: toggleComment,
[`Shift-${keymapModifierKey}-C`]: () => {
dispatch({
type: 'copyToClipboard',
payload: {
url: window.location.href,
trigger: 'toolbarItem',
},
});
},
},
}}
/>
Expand Down
1 change: 1 addition & 0 deletions src/Playroom/SettingsPanel/SettingsPanel.tsx
Expand Up @@ -29,6 +29,7 @@ const getKeyBindings = () => {
'Wrap selection in tag': [metaKeySymbol, shiftKeySymbol, ','],
'Format code': [metaKeySymbol, 'S'],
'Insert snippet': [metaKeySymbol, 'K'],
'Copy Playroom link': [metaKeySymbol, shiftKeySymbol, 'C'],
'Select next occurrence': [metaKeySymbol, 'D'],
'Swap line up': [altKeySymbol, '↑'],
'Swap line down': [altKeySymbol, '↓'],
Expand Down
2 changes: 1 addition & 1 deletion src/Playroom/Toolbar/Toolbar.tsx
Expand Up @@ -127,7 +127,7 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {

<div>
<ToolbarItem
title="Copy link to clipboard"
title={`Copy Playroom link (${isMac() ? '⌘⇧C' : 'Ctrl+Shift+C'})`}
success={copying}
onClick={copyHandler}
data-testid="copyToClipboard"
Expand Down
2 changes: 1 addition & 1 deletion src/StoreContext/StoreContext.tsx
Expand Up @@ -162,7 +162,7 @@ const createReducer =
statusMessage:
trigger === 'toolbarItem'
? {
message: 'Copied to clipboard',
message: 'Copied Playroom link to clipboard',
tone: 'positive',
}
: undefined,
Expand Down

0 comments on commit 90edcc8

Please sign in to comment.