From af73de4128833408ee5f533abd1e428e0be30d08 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 8 Nov 2020 19:50:00 -0800 Subject: [PATCH] feat: Show table of contents when useful on publicly shared docs closes #1625 --- app/scenes/Document/components/Document.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js index d6e036246..639472288 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.js @@ -328,6 +328,12 @@ class DocumentScene extends React.Component { const disableEmbeds = (team && team.documentEmbeds === false) || document.embedsDisabled; + const headings = this.editor.current + ? this.editor.current.getHeadings() + : []; + const showContents = + (ui.tocVisible && readOnly) || (isShare && !!headings.length); + return ( { )} @@ -413,15 +419,7 @@ class DocumentScene extends React.Component { )} }> - {ui.tocVisible && readOnly && ( - - )} + {showContents && } (props.tocVisible ? "64em" : "46em")}); + max-width: calc(48px + ${(props) => + props.showContents ? "64em" : "46em"}); `}; ${breakpoint("desktopLarge")`