|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useCallback, useEffect, useMemo } from 'react';
|
|
|
+import React, { useCallback, useEffect } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import loggerFactory from '@alias/logger';
|
|
|
|
|
|
@@ -11,11 +11,8 @@ import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
import StickyStretchableScroller from './StickyStretchableScroller';
|
|
|
|
|
|
-import RecentlyCreatedIcon from './Icons/RecentlyCreatedIcon';
|
|
|
-
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
const logger = loggerFactory('growi:TableOfContents');
|
|
|
-const WIKI_HEADER_LINK = 120;
|
|
|
|
|
|
/**
|
|
|
* @author Yuki Takei <yuki@weseek.co.jp>
|
|
|
@@ -37,22 +34,15 @@ const TableOfContents = (props) => {
|
|
|
const containerPaddingTop = parseFloat(containerComputedStyle['padding-top']);
|
|
|
|
|
|
// get smaller bottom line of window height - .system-version height) and containerTop
|
|
|
- const bottom = Math.min(window.innerHeight - 20, parentBottom);
|
|
|
-
|
|
|
- console.log('calcViewHeight', {
|
|
|
- windowInnerHeight: window.innerHeight,
|
|
|
- parentBottom,
|
|
|
- containerTop,
|
|
|
- viewHeight1: bottom - containerTop,
|
|
|
- viewHeight2: bottom - (containerTop + containerPaddingTop),
|
|
|
- });
|
|
|
-
|
|
|
- // if (isUserPage) {
|
|
|
- // return window.innerHeight - containerTop - 20 - 155 - 26 - 40;
|
|
|
- // }
|
|
|
+ let bottom = Math.min(window.innerHeight - 20, parentBottom);
|
|
|
+
|
|
|
+ if (isUserPage) {
|
|
|
+ // raise the bottom line by the height and margin-top of UserContentLinks
|
|
|
+ bottom -= 45;
|
|
|
+ }
|
|
|
// bottom - revisionToc top
|
|
|
return bottom - (containerTop + containerPaddingTop);
|
|
|
- }, []);
|
|
|
+ }, [isUserPage]);
|
|
|
|
|
|
const { tocHtml } = pageContainer.state;
|
|
|
|
|
|
@@ -63,48 +53,21 @@ const TableOfContents = (props) => {
|
|
|
navigationContainer.addSmoothScrollEvent(anchorsInToc);
|
|
|
}, [tocHtml, navigationContainer]);
|
|
|
|
|
|
- // get element for smoothScroll
|
|
|
- const getBookMarkListHeaderDom = useMemo(() => { return document.getElementById('bookmarks-list') }, []);
|
|
|
- const getRecentlyCreatedListHeaderDom = useMemo(() => { return document.getElementById('recently-created-list') }, []);
|
|
|
-
|
|
|
return (
|
|
|
- <>
|
|
|
- <StickyStretchableScroller
|
|
|
- contentsElemSelector=".revision-toc .markdownIt-TOC"
|
|
|
- stickyElemSelector=".grw-side-contents-sticky-container"
|
|
|
- calcViewHeightFunc={calcViewHeight}
|
|
|
- >
|
|
|
- <div
|
|
|
- id="revision-toc-content"
|
|
|
- className="revision-toc-content"
|
|
|
- // eslint-disable-next-line react/no-danger
|
|
|
- dangerouslySetInnerHTML={{
|
|
|
- __html: tocHtml,
|
|
|
- }}
|
|
|
- />
|
|
|
- </StickyStretchableScroller>
|
|
|
-
|
|
|
- { isUserPage && (
|
|
|
- <div className="mt-3 d-flex justify-content-around">
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-outline-secondary btn-sm"
|
|
|
- onClick={() => navigationContainer.smoothScrollIntoView(getBookMarkListHeaderDom, WIKI_HEADER_LINK)}
|
|
|
- >
|
|
|
- <i className="mr-2 icon-star"></i>
|
|
|
- <span>Bookmarks</span>
|
|
|
- </button>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-outline-secondary btn-sm"
|
|
|
- onClick={() => navigationContainer.smoothScrollIntoView(getRecentlyCreatedListHeaderDom, WIKI_HEADER_LINK)}
|
|
|
- >
|
|
|
- <i className="grw-icon-container-recently-created mr-2"><RecentlyCreatedIcon /></i>
|
|
|
- <span>Recently Created</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </>
|
|
|
+ <StickyStretchableScroller
|
|
|
+ contentsElemSelector=".revision-toc .markdownIt-TOC"
|
|
|
+ stickyElemSelector=".grw-side-contents-sticky-container"
|
|
|
+ calcViewHeightFunc={calcViewHeight}
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ id="revision-toc-content"
|
|
|
+ className="revision-toc-content"
|
|
|
+ // eslint-disable-next-line react/no-danger
|
|
|
+ dangerouslySetInnerHTML={{
|
|
|
+ __html: tocHtml,
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </StickyStretchableScroller>
|
|
|
);
|
|
|
|
|
|
};
|