jam411 3 лет назад
Родитель
Сommit
2bce532cb0

+ 1 - 1
packages/app/src/client/app.jsx

@@ -30,7 +30,7 @@ import { Page } from '../components/Page';
 import DisplaySwitcher from '../components/Page/DisplaySwitcher';
 import RedirectedAlert from '../components/Page/RedirectedAlert';
 import ShareLinkAlert from '../components/Page/ShareLinkAlert';
-import PageComment from '../components/PageComment';
+import { PageComment } from '../components/PageComment';
 import CommentEditorLazyRenderer from '../components/PageComment/CommentEditorLazyRenderer';
 import PageContentFooter from '../components/PageContentFooter';
 import BookmarkList from '../components/PageList/BookmarkList';

+ 11 - 13
packages/app/src/components/PageComment.tsx

@@ -20,8 +20,7 @@ import DeleteCommentModal from './PageComment/DeleteCommentModal';
 import ReplayComments from './PageComment/ReplayComments';
 
 type Props = {
-  // TODO: Do not use Nullable, create presentaion for if cannot get pageId.
-  pageId?: Nullable<string>,
+  pageId?: Nullable<string>, // TODO: check pageId type
   isReadOnly : boolean,
   titleAlign?: 'center' | 'left' | 'right',
   highlightKeywords?:string[],
@@ -109,16 +108,6 @@ export const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
     }
   }, [commentToBeDeleted, onDeleteCommentAfterOperation]);
 
-  const generateCommentInnerElement = (comment: ICommentHasId) => (
-    <Comment
-      rendererOptions={rendererOptions}
-      deleteBtnClicked={onClickDeleteButton}
-      comment={comment}
-      onComment={mutate}
-      isReadOnly={isReadOnly}
-    />
-  );
-
   const generateAllRepliesElement = (replyComments: ICommentHasIdList) => (
     <ReplayComments
       replyList={replyComments}
@@ -142,11 +131,20 @@ export const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
   if (hideIfEmpty && comments?.length === 0) {
     return <></>;
   }
-
   if (rendererOptions == null) {
     return <></>;
   }
 
+  const generateCommentInnerElement = (comment: ICommentHasId) => (
+    <Comment
+      rendererOptions={rendererOptions}
+      deleteBtnClicked={onClickDeleteButton}
+      comment={comment}
+      onComment={mutate}
+      isReadOnly={isReadOnly}
+    />
+  );
+
   let commentTitleClasses = 'border-bottom py-3 mb-3';
   commentTitleClasses = titleAlign != null ? `${commentTitleClasses} text-${titleAlign}` : `${commentTitleClasses} text-center`;
 

+ 9 - 10
packages/app/src/components/PageComment/Comment.tsx

@@ -51,20 +51,19 @@ export const Comment = (props: CommentProps): JSX.Element => {
   const updatedAt = new Date(comment.updatedAt);
   const isEdited = createdAt < updatedAt;
 
-  // if (interceptorManager === undefined) {
-  //   return <></>;
-  // }
-
   useEffect(() => {
-    setMarkdown(comment.comment);
 
-    // interceptorManager.process('postRenderCommentHtml', comment.comment);
+    if (interceptorManager !== undefined) {
+      setMarkdown(comment.comment);
+      interceptorManager.process('postRenderCommentHtml', comment.comment);
+
+      const isCurrentRevision = () => {
+        return comment.revision === revisionId;
+      };
 
-    const isCurrentRevision = () => {
-      return comment.revision === revisionId;
-    };
+      isCurrentRevision();
+    }
 
-    isCurrentRevision();
   }, [comment, interceptorManager, revisionId]);
 
   const isCurrentUserEqualsToAuthor = () => {

+ 4 - 4
packages/app/src/components/PageComment/ReplayComments.jsx

@@ -1,13 +1,13 @@
 import React from 'react';
-import PropTypes from 'prop-types';
 
+import PropTypes from 'prop-types';
 import { Collapse } from 'reactstrap';
 
+import { RendererOptions } from '~/services/renderer/renderer';
 import { useRendererConfig } from '~/stores/context';
 
-import Comment from './Comment';
+import { Comment } from './Comment';
 
-import { RendererOptions } from '~/services/renderer/renderer';
 
 class ReplayComments extends React.PureComponent {
 
@@ -39,7 +39,7 @@ class ReplayComments extends React.PureComponent {
   }
 
   render() {
-    const { config } = this.props
+    const { config } = this.props;
 
     const isAllReplyShown = config.isAllReplyShown || false;
     const replyList = this.props.replyList;

+ 1 - 1
packages/app/src/components/SearchPage/SearchResultContent.tsx

@@ -24,7 +24,7 @@ import { AdditionalMenuItemsRendererProps, ForceHideMenuItems } from '../Common/
 import { GrowiSubNavigation } from '../Navbar/GrowiSubNavigation';
 import { SubNavButtons } from '../Navbar/SubNavButtons';
 import RevisionLoader from '../Page/RevisionLoader';
-import PageComment from '../PageComment';
+import { PageComment } from '../PageComment';
 import PageContentFooter from '../PageContentFooter';