itizawa 6 лет назад
Родитель
Сommit
0f4b1906e6
2 измененных файлов с 22 добавлено и 0 удалено
  1. 8 0
      src/client/js/components/TableOfContents.jsx
  2. 14 0
      src/lib/util/path-utils.js

+ 8 - 0
src/client/js/components/TableOfContents.jsx

@@ -10,6 +10,7 @@ import StickyEvents from 'sticky-events';
 import AppContainer from '../services/AppContainer';
 import AppContainer from '../services/AppContainer';
 import PageContainer from '../services/PageContainer';
 import PageContainer from '../services/PageContainer';
 
 
+import { isUserPage } from '../../../lib/util/path-utils';
 import { createSubscribedElement } from './UnstatedUtils';
 import { createSubscribedElement } from './UnstatedUtils';
 
 
 const logger = loggerFactory('growi:TableOfContents');
 const logger = loggerFactory('growi:TableOfContents');
@@ -17,6 +18,7 @@ const logger = loggerFactory('growi:TableOfContents');
 // get these value with
 // get these value with
 //   document.querySelector('.revision-toc').getBoundingClientRect().top
 //   document.querySelector('.revision-toc').getBoundingClientRect().top
 const DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT = 190;
 const DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT = 190;
+const DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT_USER_PAGE = 230;
 const DEFAULT_REVISION_TOC_TOP_FOR_KIBELA_LAYOUT = 105;
 const DEFAULT_REVISION_TOC_TOP_FOR_KIBELA_LAYOUT = 105;
 
 
 /**
 /**
@@ -35,8 +37,14 @@ class TableOfContents extends React.Component {
     this.resetScrollbarDebounced = debounce(100, this.resetScrollbar);
     this.resetScrollbarDebounced = debounce(100, this.resetScrollbar);
 
 
     const { layoutType } = this.props.appContainer.config;
     const { layoutType } = this.props.appContainer.config;
+    const { path } = this.props.pageContainer.state;
 
 
     this.defaultRevisionTocTop = DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT;
     this.defaultRevisionTocTop = DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT;
+
+    if (isUserPage(path)) {
+      this.defaultRevisionTocTop = DEFAULT_REVISION_TOC_TOP_FOR_GROWI_LAYOUT_USER_PAGE;
+    }
+
     if (layoutType === 'kibela') {
     if (layoutType === 'kibela') {
       this.defaultRevisionTocTop = DEFAULT_REVISION_TOC_TOP_FOR_KIBELA_LAYOUT;
       this.defaultRevisionTocTop = DEFAULT_REVISION_TOC_TOP_FOR_KIBELA_LAYOUT;
     }
     }

+ 14 - 0
src/lib/util/path-utils.js

@@ -12,6 +12,19 @@ const isTrashPage = (path) => {
   return false;
   return false;
 };
 };
 
 
+/**
+ * Whether path belongs to the user page
+ * @param {string} path
+ * @returns {boolean}
+ */
+const isUserPage = (path) => {
+  if (path.match(/^\/user(\/.*)?$/)) {
+    return true;
+  }
+
+  return false;
+};
+
 /**
 /**
  * return user path
  * return user path
  * @param {Object} user
  * @param {Object} user
@@ -26,5 +39,6 @@ const userPageRoot = (user) => {
 
 
 module.exports = {
 module.exports = {
   isTrashPage,
   isTrashPage,
+  isUserPage,
   userPageRoot,
   userPageRoot,
 };
 };