Show editor tooltip shortcuts on separate line

This commit is contained in:
Tom Moor committed 2024-12-07 14:10:36 -05:00
1 parent 2db7690e27
commit 7fbe442863
3 files changed
+13 -2

No files matched your search

+11 -2
View File
@@ -12,6 +12,8 @@ export type Props = Omit<TippyProps, "content" | "theme"> & {
content?: React.ReactChild | React.ReactChild[];
/** A keyboard shortcut to display next to the content */
shortcut?: React.ReactNode;
/** Whether to show the shortcut on a new line */
shortcutOnNewline?: boolean;
};
/**
@@ -21,7 +23,13 @@ export type Props = Omit<TippyProps, "content" | "theme"> & {
* Wrap this component in a TooltipProvider to allow multiple tooltips to share the same
* singleton instance (delay, animation, etc).
*/
function Tooltip({ shortcut, content: tooltip, delay = 500, ...rest }: Props) {
function Tooltip({
shortcut,
shortcutOnNewline,
content: tooltip,
delay = 500,
...rest
}: Props) {
const isMobile = useMobile();
const singleton = useTooltipContext();
@@ -34,7 +42,8 @@ function Tooltip({ shortcut, content: tooltip, delay = 500, ...rest }: Props) {
if (shortcut) {
content = (
<>
{tooltip}{" "}
{tooltip}
{shortcutOnNewline ? <br /> : " "}
{typeof shortcut === "string" ? (
shortcut
.split("+")
+1
View File
@@ -12,6 +12,7 @@ const WrappedTooltip: React.FC<Props> = ({
delay={150}
content={content}
placement="top"
shortcutOnNewline
{...rest}
>
<TooltipContent>{children}</TooltipContent>
+1
View File
@@ -252,6 +252,7 @@ export default function formattingMenuItems(
name: "copyToClipboard",
icon: <CopyIcon />,
tooltip: dictionary.copy,
shortcut: `${metaDisplay}+C`,
visible: isCode && !isCodeBlock && (!isMobile || !isEmpty),
},
];