mirror of
https://github.com/outline/outline.git
synced 2026-12-04 02:20:17 +03:00
Show editor tooltip shortcuts on separate line
This commit is contained in:
1 parent
2db7690e27
commit
7fbe442863
3 files changed
+13
-2
No files matched your search
@@ -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("+")
|
||||
|
||||
@@ -12,6 +12,7 @@ const WrappedTooltip: React.FC<Props> = ({
|
||||
delay={150}
|
||||
content={content}
|
||||
placement="top"
|
||||
shortcutOnNewline
|
||||
{...rest}
|
||||
>
|
||||
<TooltipContent>{children}</TooltipContent>
|
||||
|
||||
@@ -252,6 +252,7 @@ export default function formattingMenuItems(
|
||||
name: "copyToClipboard",
|
||||
icon: <CopyIcon />,
|
||||
tooltip: dictionary.copy,
|
||||
shortcut: `${metaDisplay}+C`,
|
||||
visible: isCode && !isCodeBlock && (!isMobile || !isEmpty),
|
||||
},
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user