8000 Wrap headings on mobile ToC by hmacr · Pull Request #8531 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Wrap headings on mobile ToC #8531

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 2 commits into from
Feb 22, 2025
Merged
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
19 changes: 14 additions & 5 deletions app/menus/TableOfContentsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TableOfContentsIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { MenuButton, useMenuState } from "reakit/Menu";
import styled from "styled-components";
import Button from "~/components/Button";
import ContextMenu from "~/components/ContextMenu";
import Template from "~/components/ContextMenu/Template";
Expand All @@ -23,7 +24,6 @@ function TableOfContentsMenu() {
Infinity
);

// @ts-expect-error check
const items: MenuItem[] = React.useMemo(() => {
const i = [
{
Expand All @@ -34,17 +34,20 @@ function TableOfContentsMenu() {
...headings.map((heading) => ({
type: "link",
href: `#${heading.id}`,
title: t(heading.title),
title: <HeadingWrapper>{t(heading.title)}</HeadingWrapper>,
level: heading.level - minHeading,
})),
];
] as MenuItem[];

if (i.length === 1) {
i.push({
type: "link",
href: "#",
title: t("Headings you add to the document will appear here"),
// @ts-expect-error check
title: (
<HeadingWrapper>
{t("Headings you add to the document will appear here")}
</HeadingWrapper>
),
disabled: true,
});
}
Expand All @@ -71,4 +74,10 @@ function TableOfContentsMenu() {
);
}

const HeadingWrapper = styled.div`
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
`;

export default observer(TableOfContentsMenu);
Loading
0