|
@@ -10,7 +10,7 @@ import { type IPageHasId, Origin } from '@growi/core';
|
|
|
import { useGlobalSocket } from '@growi/core/dist/swr';
|
|
import { useGlobalSocket } from '@growi/core/dist/swr';
|
|
|
import { pathUtils } from '@growi/core/dist/utils';
|
|
import { pathUtils } from '@growi/core/dist/utils';
|
|
|
import {
|
|
import {
|
|
|
- CodeMirrorEditorMain, GlobalCodeMirrorEditorKey,
|
|
|
|
|
|
|
+ CodeMirrorEditorMain, CodeMirrorEditorMainReadOnly, GlobalCodeMirrorEditorKey,
|
|
|
useCodeMirrorEditorIsolated, useResolvedThemeForEditor,
|
|
useCodeMirrorEditorIsolated, useResolvedThemeForEditor,
|
|
|
} from '@growi/editor';
|
|
} from '@growi/editor';
|
|
|
import { useRect } from '@growi/ui/dist/utils';
|
|
import { useRect } from '@growi/ui/dist/utils';
|
|
@@ -109,7 +109,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
const { data: acceptedUploadFileType } = useAcceptedUploadFileType();
|
|
const { data: acceptedUploadFileType } = useAcceptedUploadFileType();
|
|
|
const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
|
|
const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
|
|
|
const { data: editorSettings } = useEditorSettings();
|
|
const { data: editorSettings } = useEditorSettings();
|
|
|
- const { mutate: mutateIsLatestRevision } = useIsLatestRevision();
|
|
|
|
|
|
|
+ const { data: isLatestRevision } = useIsLatestRevision();
|
|
|
const { mutate: mutateRemotePageId } = useRemoteRevisionId();
|
|
const { mutate: mutateRemotePageId } = useRemoteRevisionId();
|
|
|
const { mutate: mutateRemoteRevisionId } = useRemoteRevisionBody();
|
|
const { mutate: mutateRemoteRevisionId } = useRemoteRevisionBody();
|
|
|
const { mutate: mutateRemoteRevisionLastUpdatedAt } = useRemoteRevisionLastUpdatedAt();
|
|
const { mutate: mutateRemoteRevisionLastUpdatedAt } = useRemoteRevisionLastUpdatedAt();
|
|
@@ -161,6 +161,11 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
setMarkdownToPreview(value);
|
|
setMarkdownToPreview(value);
|
|
|
})), []);
|
|
})), []);
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ console.log('発火')
|
|
|
|
|
+ setMarkdownToPreview(initialValue);
|
|
|
|
|
+ }, [initialValue]);
|
|
|
|
|
+
|
|
|
const markdownChangedHandler = useCallback((value: string) => {
|
|
const markdownChangedHandler = useCallback((value: string) => {
|
|
|
setMarkdownPreviewWithDebounce(value);
|
|
setMarkdownPreviewWithDebounce(value);
|
|
|
}, [setMarkdownPreviewWithDebounce]);
|
|
}, [setMarkdownPreviewWithDebounce]);
|
|
@@ -437,19 +442,28 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
<div className={`flex-expand-horiz ${props.visibility ? '' : 'd-none'}`}>
|
|
<div className={`flex-expand-horiz ${props.visibility ? '' : 'd-none'}`}>
|
|
|
<div className="page-editor-editor-container flex-expand-vert border-end">
|
|
<div className="page-editor-editor-container flex-expand-vert border-end">
|
|
|
- <CodeMirrorEditorMain
|
|
|
|
|
- onChange={markdownChangedHandler}
|
|
|
|
|
- onSave={saveWithShortcut}
|
|
|
|
|
- onUpload={uploadHandler}
|
|
|
|
|
- acceptedUploadFileType={acceptedUploadFileType}
|
|
|
|
|
- onScroll={scrollEditorHandlerThrottle}
|
|
|
|
|
- indentSize={currentIndentSize ?? defaultIndentSize}
|
|
|
|
|
- user={user ?? undefined}
|
|
|
|
|
- pageId={pageId ?? undefined}
|
|
|
|
|
- initialValue={initialValue}
|
|
|
|
|
- editorSettings={editorSettings}
|
|
|
|
|
- onEditorsUpdated={onEditorsUpdated}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ { isLatestRevision
|
|
|
|
|
+ ? (
|
|
|
|
|
+ <CodeMirrorEditorMain
|
|
|
|
|
+ onChange={markdownChangedHandler}
|
|
|
|
|
+ onSave={saveWithShortcut}
|
|
|
|
|
+ onUpload={uploadHandler}
|
|
|
|
|
+ acceptedUploadFileType={acceptedUploadFileType}
|
|
|
|
|
+ onScroll={scrollEditorHandlerThrottle}
|
|
|
|
|
+ indentSize={currentIndentSize ?? defaultIndentSize}
|
|
|
|
|
+ user={user ?? undefined}
|
|
|
|
|
+ pageId={pageId ?? undefined}
|
|
|
|
|
+ initialValue={initialValue}
|
|
|
|
|
+ editorSettings={editorSettings}
|
|
|
|
|
+ onEditorsUpdated={onEditorsUpdated}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ : (
|
|
|
|
|
+ <CodeMirrorEditorMainReadOnly
|
|
|
|
|
+ body={initialValue}
|
|
|
|
|
+ />
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
</div>
|
|
</div>
|
|
|
<div
|
|
<div
|
|
|
ref={previewRef}
|
|
ref={previewRef}
|