mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-08-03 18:27:04 -04:00
fix: ellipsify MainMenu and CommandPalette items (#9743)
* fix: ellipsify MainMenu and CommandPalette items * fix lint
This commit is contained in:
parent
0cfa53b764
commit
678dff25ed
@ -108,6 +108,7 @@ $verticalBreakpoint: 861px;
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ import { useStableCallback } from "../../hooks/useStableCallback";
|
|||||||
import { activeConfirmDialogAtom } from "../ActiveConfirmDialog";
|
import { activeConfirmDialogAtom } from "../ActiveConfirmDialog";
|
||||||
import { useStable } from "../../hooks/useStable";
|
import { useStable } from "../../hooks/useStable";
|
||||||
|
|
||||||
|
import { Ellipsify } from "../Ellipsify";
|
||||||
|
|
||||||
import * as defaultItems from "./defaultCommandPaletteItems";
|
import * as defaultItems from "./defaultCommandPaletteItems";
|
||||||
|
|
||||||
import "./CommandPalette.scss";
|
import "./CommandPalette.scss";
|
||||||
@ -964,7 +966,7 @@ const CommandItem = ({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{command.label}
|
<Ellipsify>{command.label}</Ellipsify>
|
||||||
</div>
|
</div>
|
||||||
{showShortcut && command.shortcut && (
|
{showShortcut && command.shortcut && (
|
||||||
<CommandShortcutHint shortcut={command.shortcut} />
|
<CommandShortcutHint shortcut={command.shortcut} />
|
||||||
|
18
packages/excalidraw/components/Ellipsify.tsx
Normal file
18
packages/excalidraw/components/Ellipsify.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export const Ellipsify = ({
|
||||||
|
children,
|
||||||
|
...rest
|
||||||
|
}: { children: React.ReactNode } & React.HTMLAttributes<HTMLSpanElement>) => {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
{...rest}
|
||||||
|
style={{
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
overflow: "hidden",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
...rest.style,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
@ -7,6 +7,7 @@ export const InlineIcon = ({ icon }: { icon: React.ReactNode }) => {
|
|||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
lineHeight: 0,
|
lineHeight: 0,
|
||||||
verticalAlign: "middle",
|
verticalAlign: "middle",
|
||||||
|
flex: "0 0 auto",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
border-radius: var(--border-radius-lg);
|
border-radius: var(--border-radius-lg);
|
||||||
position: relative;
|
position: relative;
|
||||||
transition: box-shadow 0.5s ease-in-out;
|
transition: box-shadow 0.5s ease-in-out;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
&.zen-mode {
|
&.zen-mode {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
@ -100,6 +102,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: var(--border-radius-md);
|
border-radius: var(--border-radius-md);
|
||||||
|
flex: 1 0 auto;
|
||||||
|
|
||||||
@media screen and (min-width: 1921px) {
|
@media screen and (min-width: 1921px) {
|
||||||
height: 2.25rem;
|
height: 2.25rem;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { useDevice } from "../App";
|
import { useDevice } from "../App";
|
||||||
|
|
||||||
|
import { Ellipsify } from "../Ellipsify";
|
||||||
|
|
||||||
import type { JSX } from "react";
|
import type { JSX } from "react";
|
||||||
|
|
||||||
const MenuItemContent = ({
|
const MenuItemContent = ({
|
||||||
@ -18,7 +20,7 @@ const MenuItemContent = ({
|
|||||||
<>
|
<>
|
||||||
{icon && <div className="dropdown-menu-item__icon">{icon}</div>}
|
{icon && <div className="dropdown-menu-item__icon">{icon}</div>}
|
||||||
<div style={textStyle} className="dropdown-menu-item__text">
|
<div style={textStyle} className="dropdown-menu-item__text">
|
||||||
{children}
|
<Ellipsify>{children}</Ellipsify>
|
||||||
</div>
|
</div>
|
||||||
{shortcut && !device.editor.isMobile && (
|
{shortcut && !device.editor.isMobile && (
|
||||||
<div className="dropdown-menu-item__shortcut">{shortcut}</div>
|
<div className="dropdown-menu-item__shortcut">{shortcut}</div>
|
||||||
|
@ -281,6 +281,7 @@ export { Sidebar } from "./components/Sidebar/Sidebar";
|
|||||||
export { Button } from "./components/Button";
|
export { Button } from "./components/Button";
|
||||||
export { Footer };
|
export { Footer };
|
||||||
export { MainMenu };
|
export { MainMenu };
|
||||||
|
export { Ellipsify } from "./components/Ellipsify";
|
||||||
export { useDevice } from "./components/App";
|
export { useDevice } from "./components/App";
|
||||||
export { WelcomeScreen };
|
export { WelcomeScreen };
|
||||||
export { LiveCollaborationTrigger };
|
export { LiveCollaborationTrigger };
|
||||||
|
@ -14,8 +14,12 @@ exports[`<Excalidraw/> > <MainMenu/> > should render main menu with host menu it
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Click me
|
Click me
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<a
|
<a
|
||||||
@ -26,8 +30,12 @@ exports[`<Excalidraw/> > <MainMenu/> > should render main menu with host menu it
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Excalidraw blog
|
Excalidraw blog
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div
|
<div
|
||||||
@ -87,8 +95,12 @@ exports[`<Excalidraw/> > <MainMenu/> > should render main menu with host menu it
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Help
|
Help
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
@ -137,8 +149,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Open
|
Open
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
@ -174,8 +190,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Save to...
|
Save to...
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@ -230,8 +250,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Export image...
|
Export image...
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
@ -279,8 +303,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Find on canvas
|
Find on canvas
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
@ -336,8 +364,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Help
|
Help
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
@ -373,8 +405,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Reset the canvas
|
Reset the canvas
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
@ -418,8 +454,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
GitHub
|
GitHub
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
@ -464,8 +504,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Follow us
|
Follow us
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
@ -504,8 +548,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Discord chat
|
Discord chat
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -541,8 +589,12 @@ exports[`<Excalidraw/> > Test UIOptions prop > Test canvasActions > should rende
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__text"
|
class="dropdown-menu-item__text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
|
||||||
>
|
>
|
||||||
Dark mode
|
Dark mode
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="dropdown-menu-item__shortcut"
|
class="dropdown-menu-item__shortcut"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user