Skip to content

refactor: Use consistent naming of the meta key #5069

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

Merged
merged 1 commit into from
Mar 28, 2025
Merged
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 @@ -81,7 +81,7 @@ export const CommandPanel: StoryFn = () => {
<button onClick={openCommandPanel}>Open command panel</button>
<br />
<input
defaultValue="Press cmd+k to open command panel"
defaultValue="Press meta+k to open command panel"
style={{ width: 300 }}
/>
<CommandPanelComponent />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ const $shortcutOptions = computed([$commandMetas], (commandMetas) => {
for (const [name, meta] of commandMetas) {
if (!meta.hidden) {
const label = humanizeString(name);
const keys = meta.defaultHotkeys?.[0]
?.split("+")
.map((key) => (key === "meta" ? "cmd" : key));
const keys = meta.defaultHotkeys?.[0]?.split("+");
shortcutOptions.push({
tokens: ["shortcuts", "commands", label],
type: "shortcut",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useModifierKeys = () => {
window.addEventListener("keydown", handler);
window.addEventListener("keyup", handler);
// The use of only the keyup/keydown events may not be sufficient.
// on a Mac, when the cmd-shift-4 (printscreen) combination is triggered, there is a possibility of losing the keyup event.
// on a Mac, when the meta-shift-4 (printscreen) combination is triggered, there is a possibility of losing the keyup event.
window.addEventListener("mousemove", handler);

return () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/builder/app/builder/features/topbar/builder-mode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export const BuilderModeDropDown = () => {
icon: <PaintBrushIcon />,
description: "Edit components, styles, and properties",
title: "Design",
shortcut: ["cmd", "shift", "d"],
shortcut: ["meta", "shift", "d"],
enabled: isDesignModeAllowed,
},
content: {
icon: <NotebookAndPenIcon />,
description: "Modify the page content",
title: "Content",
shortcut: ["cmd", "shift", "c"],
shortcut: ["meta", "shift", "c"],
enabled: isContentModeAllowed,
},
} as const;
Expand All @@ -74,7 +74,7 @@ export const BuilderModeDropDown = () => {
content={
<Flex gap="1">
<Text variant="regular">Toggle preview</Text>
<Kbd value={["cmd", "shift", "p"]} />
<Kbd value={["meta", "shift", "p"]} />
</Flex>
}
>
Expand Down
12 changes: 6 additions & 6 deletions apps/builder/app/builder/features/topbar/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ export const Menu = () => {
<DropdownMenuItem onSelect={() => emitCommand("undo")}>
Undo
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "z"]} />
<Kbd value={["meta", "z"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => emitCommand("redo")}>
Redo
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "shift", "z"]} />
<Kbd value={["meta", "shift", "z"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>
{/* https://github.com/webstudio-is/webstudio/issues/499
Expand All @@ -124,15 +124,15 @@ export const Menu = () => {
}}
>
Copy
<DropdownMenuItemRightSlot><Kbd value={["cmd", "c"]} /></DropdownMenuItemRightSlot>
<DropdownMenuItemRightSlot><Kbd value={["meta", "c"]} /></DropdownMenuItemRightSlot>
</DropdownMenuItem>
<DropdownMenuItem
onSelect={() => {
// TODO
}}
>
Paste
<DropdownMenuItemRightSlot><Kbd value={["cmd", "v"]} /></DropdownMenuItemRightSlot>
<DropdownMenuItemRightSlot><Kbd value={["meta", "v"]} /></DropdownMenuItemRightSlot>
</DropdownMenuItem>

*/}
Expand All @@ -146,7 +146,7 @@ export const Menu = () => {
<DropdownMenuItem onSelect={() => emitCommand("togglePreviewMode")}>
Preview
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "shift", "p"]} />
<Kbd value={["meta", "shift", "p"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>

Expand Down Expand Up @@ -242,7 +242,7 @@ export const Menu = () => {
<DropdownMenuItem onSelect={() => emitCommand("openCommandPanel")}>
Search & Commands
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "k"]} />
<Kbd value={["meta", "k"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/app/builder/shared/code-editor-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export const EditorContent = ({
{showShortcuts && (
<Flex align="center" justify="end" gap="1" className={shortcutStyle()}>
<Text variant="small">Submit</Text>
<Kbd value={["cmd", "enter"]} />
<Kbd value={["meta", "enter"]} />
</Flex>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/app/builder/shared/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({

{
name: "undo",
// safari use cmd+z to reopen closed tabs, here added ctrl as alternative
// safari use meta+z to reopen closed tabs, here added ctrl as alternative
defaultHotkeys: ["meta+z", "ctrl+z"],
disableOnInputLikeControls: true,
handler: () => {
Expand All @@ -522,7 +522,7 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
},
{
name: "redo",
// safari use cmd+z to reopen closed tabs, here added ctrl as alternative
// safari use meta+z to reopen closed tabs, here added ctrl as alternative
defaultHotkeys: ["meta+shift+z", "ctrl+shift+z"],
disableOnInputLikeControls: true,
handler: () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/app/shared/commands-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type CommandMeta<CommandName extends string> = {
**/
disableOnInputLikeControls?: boolean;
/**
* hide the command in cmd+k panel
* hide the command in meta+k panel
*/
hidden?: boolean;
};
Expand Down
6 changes: 3 additions & 3 deletions packages/design-system/src/components/command.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const CommandContent = () => {
</CommandIcon>
<Text variant="labelsTitleCase">Profile</Text>
</Flex>
<Kbd value={["cmd", "p"]} />
<Kbd value={["meta", "p"]} />
</CommandItem>
<CommandItem>
<Flex gap={2}>
Expand All @@ -76,7 +76,7 @@ const CommandContent = () => {
</CommandIcon>
<Text variant="labelsTitleCase">Billing</Text>
</Flex>
<Kbd value={["cmd", "b"]} />
<Kbd value={["meta", "b"]} />
</CommandItem>
<CommandItem>
<Flex gap={2}>
Expand All @@ -85,7 +85,7 @@ const CommandContent = () => {
</CommandIcon>
<Text variant="labelsTitleCase">Settings</Text>
</Flex>
<Kbd value={["cmd", "s"]} />
<Kbd value={["meta", "s"]} />
</CommandItem>
</CommandGroup>
</CommandList>
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/src/components/kbd.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default {
title: "Library/Kbd",
};

const KbdStory = () => <Kbd value={["cmd", "z"]} />;
const KbdStory = () => <Kbd value={["meta", "z"]} />;

export { KbdStory as Kbd };
2 changes: 1 addition & 1 deletion packages/design-system/src/components/kbd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const isMac =
typeof navigator === "object" ? /mac/i.test(navigator.platform) : false;

const shortcutSymbolMap: Record<string, string> = {
cmd: isMac ? "⌘" : "Ctrl",
meta: isMac ? "⌘" : "Ctrl",
shift: "⇧",
alt: isMac ? "⌥" : "Alt",
backspace: "⌫",
Expand Down