Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -459,7 +459,7 @@ const $shortcutOptions = computed([$commandMetas], (commandMetas) => {
const shortcutOptions: ShortcutOption[] = [];
for (const [name, meta] of commandMetas) {
if (!meta.hidden) {
const label = humanizeString(name);
const label = meta.label ?? humanizeString(name);
const keys = meta.defaultHotkeys?.[0]?.split("+");
shortcutOptions.push({
tokens: ["shortcuts", "commands", label],
Expand Down Expand Up @@ -493,7 +493,7 @@ const ShortcutOptionsGroup = ({ options }: { options: ShortcutOption[] }) => {
emitCommand(name as never);
}}
>
<Text variant="labelsTitleCase">{label}</Text>
<Text variant="labelsSentenceCase">{label}</Text>
{keys && <Kbd value={keys} />}
</CommandItem>
))}
Expand Down
30 changes: 15 additions & 15 deletions apps/builder/app/builder/shared/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "@webstudio-is/sdk";
import type { Instance } from "@webstudio-is/sdk";
import { toast } from "@webstudio-is/design-system";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
import { createCommandsEmitter, type Command } from "~/shared/commands-emitter";
import {
$editingItemSelector,
Expand Down Expand Up @@ -576,10 +575,12 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
},
{
name: "wrapInElement",
label: "Wrap in Element",
handler: () => wrapIn(elementComponent),
},
{
name: "wrapInLink",
label: "Wrap in Link",
handler: () => wrapIn(elementComponent, "a"),
},
{
Expand All @@ -588,27 +589,26 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
},
{
name: "replaceWithElement",
label: "Replace with Element",
handler: () => replaceWith(elementComponent),
},
{
name: "replaceWithLink",
label: "Replace with Link",
handler: () => replaceWith(elementComponent, "a"),
},

...(isFeatureEnabled("tailwind")
? [
{
name: "pasteHtmlWithTailwindClasses",
handler: async () => {
const html = await navigator.clipboard.readText();
let fragment = generateFragmentFromHtml(html);
fragment = await denormalizeSrcProps(fragment);
fragment = await generateFragmentFromTailwind(fragment);
return insertWebstudioFragmentAt(fragment);
},
},
]
: []),
{
name: "pasteTailwind",
label: "Paste HTML with Tailwind classes",
handler: async () => {
const html = await navigator.clipboard.readText();
let fragment = generateFragmentFromHtml(html);
fragment = await denormalizeSrcProps(fragment);
fragment = await generateFragmentFromTailwind(fragment);
return insertWebstudioFragmentAt(fragment);
},
},

// history

Expand Down
1 change: 1 addition & 0 deletions apps/builder/app/shared/commands-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { clientSyncStore } from "~/shared/sync";
type CommandMeta<CommandName extends string> = {
// @todo category, description
name: CommandName;
label?: string;
/** default because hotkeys can be customized from ui */
defaultHotkeys?: string[];
/** set to false when default browser or radix behavior is desired */
Expand Down