|
@@ -1,13 +1,17 @@
|
|
|
-import React from 'react';
|
|
|
|
|
|
|
+import React, { useMemo } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import { TabContent, TabPane } from 'reactstrap';
|
|
import { TabContent, TabPane } from 'reactstrap';
|
|
|
|
|
|
|
|
|
|
+import { pagePathUtils } from '@growi/core';
|
|
|
|
|
+
|
|
|
import { EditorMode, useEditorMode, useDescendantsPageListModal } from '~/stores/ui';
|
|
import { EditorMode, useEditorMode, useDescendantsPageListModal } from '~/stores/ui';
|
|
|
import {
|
|
import {
|
|
|
useCurrentPagePath, useIsSharedUser, useIsEditable, useCurrentPageId, useIsUserPage, usePageUser,
|
|
useCurrentPagePath, useIsSharedUser, useIsEditable, useCurrentPageId, useIsUserPage, usePageUser,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import { smoothScrollIntoView } from '~/client/util/smooth-scroll';
|
|
|
|
|
+
|
|
|
import PageListIcon from '../Icons/PageListIcon';
|
|
import PageListIcon from '../Icons/PageListIcon';
|
|
|
import Editor from '../PageEditor';
|
|
import Editor from '../PageEditor';
|
|
|
import Page from '../Page';
|
|
import Page from '../Page';
|
|
@@ -19,9 +23,19 @@ import EditorNavbarBottom from '../PageEditor/EditorNavbarBottom';
|
|
|
import HashChanged from '../EventListeneres/HashChanged';
|
|
import HashChanged from '../EventListeneres/HashChanged';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+const WIKI_HEADER_LINK = 120;
|
|
|
|
|
+
|
|
|
|
|
+const { isTopPage } = pagePathUtils;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const DisplaySwitcher = (): JSX.Element => {
|
|
const DisplaySwitcher = (): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // get element for smoothScroll
|
|
|
|
|
+ const getCommentListDom = useMemo(() => { return document.getElementById('page-comments-list') }, []);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const { data: currentPageId } = useCurrentPageId();
|
|
const { data: currentPageId } = useCurrentPageId();
|
|
|
const { data: currentPath } = useCurrentPagePath();
|
|
const { data: currentPath } = useCurrentPagePath();
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
@@ -35,6 +49,7 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
|
|
|
|
|
const isPageExist = currentPageId != null;
|
|
const isPageExist = currentPageId != null;
|
|
|
const isViewMode = editorMode === EditorMode.View;
|
|
const isViewMode = editorMode === EditorMode.View;
|
|
|
|
|
+ const isTopPagePath = isTopPage(currentPath ?? '');
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
@@ -46,11 +61,12 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
<div className="grw-side-contents-container">
|
|
<div className="grw-side-contents-container">
|
|
|
<div className="grw-side-contents-sticky-container">
|
|
<div className="grw-side-contents-sticky-container">
|
|
|
|
|
|
|
|
|
|
+ {/* Page list */}
|
|
|
<div className="grw-page-accessories-control">
|
|
<div className="grw-page-accessories-control">
|
|
|
{ currentPath != null && !isSharedUser && (
|
|
{ currentPath != null && !isSharedUser && (
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
- className="btn btn-block btn-outline-secondary grw-btn-page-accessories rounded-pill d-flex justify-content-between"
|
|
|
|
|
|
|
+ className="btn btn-block btn-outline-secondary grw-btn-page-accessories rounded-pill d-flex justify-content-between align-items-center"
|
|
|
onClick={() => openDescendantPageListModal(currentPath)}
|
|
onClick={() => openDescendantPageListModal(currentPath)}
|
|
|
>
|
|
>
|
|
|
<PageListIcon />
|
|
<PageListIcon />
|
|
@@ -60,6 +76,21 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
) }
|
|
) }
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+ {/* Comments */}
|
|
|
|
|
+ { getCommentListDom != null && !isTopPagePath && (
|
|
|
|
|
+ <div className="mt-2">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ className="btn btn-block btn-outline-secondary grw-btn-page-accessories rounded-pill d-flex justify-content-between align-items-center"
|
|
|
|
|
+ onClick={() => smoothScrollIntoView(getCommentListDom, WIKI_HEADER_LINK)}
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className="mr-2 icon-fw icon-bubbles"></i>
|
|
|
|
|
+ <span>Comments</span>
|
|
|
|
|
+ <span></span> {/* for a count badge */}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ) }
|
|
|
|
|
+
|
|
|
<div className="d-none d-lg-block">
|
|
<div className="d-none d-lg-block">
|
|
|
<div id="revision-toc" className="revision-toc">
|
|
<div id="revision-toc" className="revision-toc">
|
|
|
<TableOfContents />
|
|
<TableOfContents />
|