|
|
@@ -13,7 +13,7 @@ import { HtmlElementNode } from 'rehype-toc';
|
|
|
import { toastSuccess, toastError } from '~/client/util/apiNotification';
|
|
|
import { getOptionsToSave } from '~/client/util/editor';
|
|
|
import {
|
|
|
- useIsGuestUser, useCurrentPageTocNode, useShareLinkId,
|
|
|
+ useIsGuestUser, useCurrentPageTocNode, useShareLinkId, useIsLatestRevision, useEditingMarkdown,
|
|
|
} from '~/stores/context';
|
|
|
import {
|
|
|
useSWRxSlackChannels, useIsSlackEnabled, usePageTagsForEditors, useIsEnabledUnsavedWarning,
|
|
|
@@ -50,6 +50,8 @@ type PageSubstanceProps = {
|
|
|
isMobile?: boolean,
|
|
|
isSlackEnabled: boolean,
|
|
|
slackChannels: string,
|
|
|
+ revisionMarkdown: string,
|
|
|
+ isLatestRevision: boolean,
|
|
|
};
|
|
|
|
|
|
class PageSubstance extends React.Component<PageSubstanceProps> {
|
|
|
@@ -172,10 +174,11 @@ class PageSubstance extends React.Component<PageSubstanceProps> {
|
|
|
|
|
|
override render() {
|
|
|
const {
|
|
|
- rendererOptions, page, isMobile, isGuestUser,
|
|
|
+ rendererOptions, page, isMobile, isGuestUser, revisionMarkdown, isLatestRevision,
|
|
|
} = this.props;
|
|
|
const { path } = page;
|
|
|
- const { _id: revisionId, body: markdown } = page.revision;
|
|
|
+ const { _id: revisionId } = page.revision;
|
|
|
+ const markdown = isLatestRevision ? page.revision.body : revisionMarkdown;
|
|
|
|
|
|
return (
|
|
|
<div className={`mb-5 ${isMobile ? 'page-mobile' : ''}`}>
|
|
|
@@ -223,6 +226,11 @@ export const Page = (props) => {
|
|
|
const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
|
const { mutate: mutateCurrentPageTocNode } = useCurrentPageTocNode();
|
|
|
|
|
|
+ // TODO: Refactor useSWRxCurrentPage for keep mutate value.
|
|
|
+ // for History "View this version"
|
|
|
+ const { data: isLatestRevision } = useIsLatestRevision();
|
|
|
+ const { data: markdown } = useEditingMarkdown();
|
|
|
+
|
|
|
const pageRef = useRef(null);
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -258,7 +266,7 @@ export const Page = (props) => {
|
|
|
// };
|
|
|
// }, []);
|
|
|
|
|
|
- if (currentPage == null || editorMode == null || isGuestUser == null || rendererOptions == null) {
|
|
|
+ if (currentPage == null || editorMode == null || isGuestUser == null || rendererOptions == null || markdown == null || isLatestRevision == null) {
|
|
|
const entries = Object.entries({
|
|
|
currentPage, editorMode, isGuestUser, rendererOptions,
|
|
|
})
|
|
|
@@ -283,6 +291,8 @@ export const Page = (props) => {
|
|
|
pageTags={pageTags}
|
|
|
slackChannels={slackChannelsData?.toString()}
|
|
|
mutateIsEnabledUnsavedWarning={mutateIsEnabledUnsavedWarning}
|
|
|
+ revisionMarkdown={markdown}
|
|
|
+ isLatestRevision={isLatestRevision}
|
|
|
/>
|
|
|
);
|
|
|
};
|