|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useCallback, useEffect } from 'react';
|
|
|
|
|
|
|
+import React, { useCallback, useEffect, useMemo } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
import loggerFactory from '@alias/logger';
|
|
import loggerFactory from '@alias/logger';
|
|
|
|
|
|
|
@@ -15,6 +15,7 @@ import RecentlyCreatedIcon from './Icons/RecentlyCreatedIcon';
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
const logger = loggerFactory('growi:TableOfContents');
|
|
const logger = loggerFactory('growi:TableOfContents');
|
|
|
|
|
+const WIKI_HEADER_LINK = 120;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author Yuki Takei <yuki@weseek.co.jp>
|
|
* @author Yuki Takei <yuki@weseek.co.jp>
|
|
@@ -47,6 +48,10 @@ const TableOfContents = (props) => {
|
|
|
navigationContainer.addSmoothScrollEvent(anchorsInToc);
|
|
navigationContainer.addSmoothScrollEvent(anchorsInToc);
|
|
|
}, [tocHtml, navigationContainer]);
|
|
}, [tocHtml, navigationContainer]);
|
|
|
|
|
|
|
|
|
|
+ // get element for smoothScroll
|
|
|
|
|
+ const getBookMarkListHeaderDom = useMemo(() => { return document.getElementById('bookmarks-list') }, []);
|
|
|
|
|
+ const getRecentlyCreatedListHeaderDom = useMemo(() => { return document.getElementById('recently-created-list') }, []);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<TopOfTableContents isGuestUserMode={isGuestUserMode} />
|
|
<TopOfTableContents isGuestUserMode={isGuestUserMode} />
|
|
@@ -67,23 +72,22 @@ const TableOfContents = (props) => {
|
|
|
|
|
|
|
|
{ isUserPage && (
|
|
{ isUserPage && (
|
|
|
<div className="mt-3 d-flex justify-content-around">
|
|
<div className="mt-3 d-flex justify-content-around">
|
|
|
- {/* <a className="btn btn-outline-secondary btn-sm" href="#bookmarks-list">
|
|
|
|
|
- <i className="mr-2 icon-star"></i>
|
|
|
|
|
- <span>Bookmarks</span>
|
|
|
|
|
- </a> */}
|
|
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
className="btn btn-outline-secondary btn-sm"
|
|
className="btn btn-outline-secondary btn-sm"
|
|
|
- href="#bookmarks-list"
|
|
|
|
|
|
|
+ onClick={() => navigationContainer.smoothScrollIntoView(getBookMarkListHeaderDom, WIKI_HEADER_LINK)}
|
|
|
>
|
|
>
|
|
|
-
|
|
|
|
|
<i className="mr-2 icon-star"></i>
|
|
<i className="mr-2 icon-star"></i>
|
|
|
<span>Bookmarks</span>
|
|
<span>Bookmarks</span>
|
|
|
</button>
|
|
</button>
|
|
|
- <a className="btn btn-outline-secondary btn-sm" href="#recently-created-list">
|
|
|
|
|
|
|
+ <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>
|
|
<i className="grw-icon-container-recently-created mr-2"><RecentlyCreatedIcon /></i>
|
|
|
<span>Recently Created</span>
|
|
<span>Recently Created</span>
|
|
|
- </a>
|
|
|
|
|
|
|
+ </button>
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
</>
|
|
</>
|