diff --git a/app/scenes/Document/Shared.tsx b/app/scenes/Document/Shared.tsx index f3f431a92..3e0954d3d 100644 --- a/app/scenes/Document/Shared.tsx +++ b/app/scenes/Document/Shared.tsx @@ -7,7 +7,7 @@ import { RouteComponentProps, useLocation } from "react-router-dom"; import styled, { ThemeProvider } from "styled-components"; import { setCookie } from "tiny-cookie"; import { s } from "@shared/styles"; -import { NavigationNode, PublicTeam } from "@shared/types"; +import { NavigationNode, PublicTeam, TOCPosition } from "@shared/types"; import type { Theme } from "~/stores/UiStore"; import DocumentModel from "~/models/Document"; import Error404 from "~/scenes/Error404"; @@ -102,6 +102,7 @@ function SharedDocumentScene(props: Props) { ? (searchParams.get("theme") as Theme) : undefined; const theme = useBuildTheme(response?.team?.customTheme, themeOverride); + const tocPosition = response?.team?.tocPosition ?? TOCPosition.Left; React.useEffect(() => { if (!user) { @@ -188,6 +189,7 @@ function SharedDocumentScene(props: Props) { document={response.document} sharedTree={response.sharedTree} shareId={shareId} + tocPosition={tocPosition} readOnly /> diff --git a/app/scenes/Document/components/Document.tsx b/app/scenes/Document/components/Document.tsx index 26d79acf8..7e0103279 100644 --- a/app/scenes/Document/components/Document.tsx +++ b/app/scenes/Document/components/Document.tsx @@ -83,6 +83,7 @@ type Props = WithTranslation & revision?: Revision; readOnly: boolean; shareId?: string; + tocPosition?: TOCPosition; onCreateLink?: (title: string, nested?: boolean) => Promise; onSearchLink?: (term: string) => Promise; }; @@ -394,8 +395,17 @@ class DocumentScene extends React.Component { }; render() { - const { document, revision, readOnly, abilities, auth, ui, shareId, t } = - this.props; + const { + document, + revision, + readOnly, + abilities, + auth, + ui, + shareId, + tocPosition, + t, + } = this.props; const { team, user } = auth; const isShare = !!shareId; const embedsDisabled = @@ -404,9 +414,10 @@ class DocumentScene extends React.Component { const hasHeadings = this.headings.length > 0; const showContents = ui.tocVisible && ((readOnly && hasHeadings) || !readOnly); - const tocPosition = - (team?.getPreference(TeamPreference.TocPosition) as TOCPosition) || - TOCPosition.Left; + const tocPos = + tocPosition ?? + ((team?.getPreference(TeamPreference.TocPosition) as TOCPosition) || + TOCPosition.Left); const multiplayerEditor = !document.isArchived && !document.isDeleted && !revision && !isShare; @@ -503,7 +514,7 @@ class DocumentScene extends React.Component { {showContents && ( @@ -511,7 +522,7 @@ class DocumentScene extends React.Component { = 2 ? { document: serializedDocument, - team: team?.getPreference(TeamPreference.PublicBranding) - ? presentPublicTeam(team) + team: team + ? presentPublicTeam( + team, + !!team?.getPreference(TeamPreference.PublicBranding) + ) : undefined, sharedTree: share && share.includeChildDocuments diff --git a/shared/types.ts b/shared/types.ts index 3a0a8a9a6..ff531f488 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -182,6 +182,7 @@ export type PublicTeam = { avatarUrl: string; name: string; customTheme: Partial; + tocPosition: TOCPosition; }; export enum TOCPosition {