PageEditor.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. import React, {
  2. useCallback, useEffect, useMemo, useRef, useState,
  3. } from 'react';
  4. import EventEmitter from 'events';
  5. import nodePath from 'path';
  6. import type { IPageHasId } from '@growi/core';
  7. import { pathUtils } from '@growi/core/dist/utils';
  8. import { CodeMirrorEditorContainer, useCodeMirrorEditor } from '@growi/editor';
  9. import detectIndent from 'detect-indent';
  10. import { useTranslation } from 'next-i18next';
  11. import { useRouter } from 'next/router';
  12. import { throttle, debounce } from 'throttle-debounce';
  13. import { useUpdateStateAfterSave, useSaveOrUpdate } from '~/client/services/page-operation';
  14. import { apiGet, apiPostForm } from '~/client/util/apiv1-client';
  15. import { toastError, toastSuccess } from '~/client/util/toastr';
  16. import { IEditorMethods } from '~/interfaces/editor-methods';
  17. import { OptionsToSave } from '~/interfaces/page-operation';
  18. import { SocketEventName } from '~/interfaces/websocket';
  19. import {
  20. useCurrentPathname, useIsEnabledAttachTitleHeader,
  21. useIsEditable, useIsUploadableFile, useIsUploadableImage, useIsIndentSizeForced,
  22. } from '~/stores/context';
  23. import {
  24. useCurrentIndentSize, useIsSlackEnabled, usePageTagsForEditors,
  25. useIsEnabledUnsavedWarning,
  26. useIsConflict,
  27. useEditingMarkdown,
  28. useWaitingSaveProcessing,
  29. } from '~/stores/editor';
  30. import { useConflictDiffModal } from '~/stores/modal';
  31. import {
  32. useCurrentPagePath, useSWRMUTxCurrentPage, useSWRxCurrentPage, useSWRxTagsInfo, useCurrentPageId, useIsNotFound, useIsLatestRevision, useTemplateBodyData,
  33. } from '~/stores/page';
  34. import { mutatePageTree } from '~/stores/page-listing';
  35. import {
  36. useRemoteRevisionId,
  37. useRemoteRevisionBody,
  38. useRemoteRevisionLastUpdatedAt,
  39. useRemoteRevisionLastUpdateUser,
  40. } from '~/stores/remote-latest-page';
  41. import { usePreviewOptions } from '~/stores/renderer';
  42. import {
  43. EditorMode,
  44. useEditorMode, useSelectedGrant,
  45. } from '~/stores/ui';
  46. import { useGlobalSocket } from '~/stores/websocket';
  47. import loggerFactory from '~/utils/logger';
  48. // import { ConflictDiffModal } from './PageEditor/ConflictDiffModal';
  49. // import { ConflictDiffModal } from './ConflictDiffModal';
  50. // import Editor from './Editor';
  51. import Preview from './Preview';
  52. import scrollSyncHelper from './ScrollSyncHelper';
  53. import '@growi/editor/dist/style.css';
  54. const logger = loggerFactory('growi:PageEditor');
  55. declare global {
  56. // eslint-disable-next-line vars-on-top, no-var
  57. var globalEmitter: EventEmitter;
  58. }
  59. // for scrolling
  60. let lastScrolledDateWithCursor: Date | null = null;
  61. let isOriginOfScrollSyncEditor = false;
  62. let isOriginOfScrollSyncPreview = false;
  63. type Props = {
  64. visibility?: boolean,
  65. }
  66. export const PageEditor = React.memo((props: Props): JSX.Element => {
  67. const { t } = useTranslation();
  68. const router = useRouter();
  69. const editorRef = useRef<IEditorMethods>(null);
  70. const previewRef = useRef<HTMLDivElement>(null);
  71. const codeMirrorEditorContainerRef = useRef<HTMLDivElement>(null);
  72. const { data: isNotFound } = useIsNotFound();
  73. const { data: pageId, mutate: mutateCurrentPageId } = useCurrentPageId();
  74. const { data: currentPagePath } = useCurrentPagePath();
  75. const { data: currentPathname } = useCurrentPathname();
  76. const { data: currentPage } = useSWRxCurrentPage();
  77. const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
  78. const { data: grantData } = useSelectedGrant();
  79. const { data: pageTags, sync: syncTagsInfoForEditor } = usePageTagsForEditors(pageId);
  80. const { mutate: mutateTagsInfo } = useSWRxTagsInfo(pageId);
  81. const { data: editingMarkdown, mutate: mutateEditingMarkdown } = useEditingMarkdown();
  82. const { data: isEnabledAttachTitleHeader } = useIsEnabledAttachTitleHeader();
  83. const { data: templateBodyData } = useTemplateBodyData();
  84. const { data: isEditable } = useIsEditable();
  85. const { mutate: mutateWaitingSaveProcessing } = useWaitingSaveProcessing();
  86. const { data: editorMode, mutate: mutateEditorMode } = useEditorMode();
  87. const { data: isSlackEnabled } = useIsSlackEnabled();
  88. const { data: isIndentSizeForced } = useIsIndentSizeForced();
  89. const { data: currentIndentSize, mutate: mutateCurrentIndentSize } = useCurrentIndentSize();
  90. const { data: isUploadableFile } = useIsUploadableFile();
  91. const { data: isUploadableImage } = useIsUploadableImage();
  92. const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
  93. const { mutate: mutateIsLatestRevision } = useIsLatestRevision();
  94. const { mutate: mutateRemotePageId } = useRemoteRevisionId();
  95. const { mutate: mutateRemoteRevisionId } = useRemoteRevisionBody();
  96. const { mutate: mutateRemoteRevisionLastUpdatedAt } = useRemoteRevisionLastUpdatedAt();
  97. const { mutate: mutateRemoteRevisionLastUpdateUser } = useRemoteRevisionLastUpdateUser();
  98. const { setContainer } = useCodeMirrorEditor({
  99. container: codeMirrorEditorContainerRef.current,
  100. });
  101. useEffect(() => {
  102. if (codeMirrorEditorContainerRef.current != null) {
  103. setContainer(codeMirrorEditorContainerRef.current);
  104. }
  105. }, [setContainer]);
  106. const { data: rendererOptions } = usePreviewOptions();
  107. const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
  108. const saveOrUpdate = useSaveOrUpdate();
  109. const updateStateAfterSave = useUpdateStateAfterSave(pageId, { supressEditingMarkdownMutation: true });
  110. // TODO: remove workaround
  111. // for https://redmine.weseek.co.jp/issues/125923
  112. const [createdPageRevisionIdWithAttachment, setCreatedPageRevisionIdWithAttachment] = useState();
  113. // TODO: remove workaround
  114. // for https://redmine.weseek.co.jp/issues/125923
  115. const currentRevisionId = currentPage?.revision?._id ?? createdPageRevisionIdWithAttachment;
  116. const initialValue = useMemo(() => {
  117. if (!isNotFound) {
  118. return editingMarkdown ?? '';
  119. }
  120. let initialValue = '';
  121. if (isEnabledAttachTitleHeader && currentPathname != null) {
  122. const pageTitle = nodePath.basename(currentPathname);
  123. initialValue += `${pathUtils.attachTitleHeader(pageTitle)}\n`;
  124. }
  125. if (templateBodyData != null) {
  126. initialValue += `${templateBodyData}\n`;
  127. }
  128. return initialValue;
  129. }, [isNotFound, currentPathname, editingMarkdown, isEnabledAttachTitleHeader, templateBodyData]);
  130. const markdownToSave = useRef<string>(initialValue);
  131. const [markdownToPreview, setMarkdownToPreview] = useState<string>(initialValue);
  132. const { data: socket } = useGlobalSocket();
  133. const { mutate: mutateIsConflict } = useIsConflict();
  134. const checkIsConflict = useCallback((data) => {
  135. const { s2cMessagePageUpdated } = data;
  136. const isConflict = markdownToPreview !== s2cMessagePageUpdated.revisionBody;
  137. mutateIsConflict(isConflict);
  138. }, [markdownToPreview, mutateIsConflict]);
  139. // TODO: remove workaround
  140. // for https://redmine.weseek.co.jp/issues/125923
  141. useEffect(() => {
  142. setCreatedPageRevisionIdWithAttachment(undefined);
  143. }, [router]);
  144. useEffect(() => {
  145. markdownToSave.current = initialValue;
  146. setMarkdownToPreview(initialValue);
  147. }, [initialValue]);
  148. useEffect(() => {
  149. if (socket == null) { return }
  150. socket.on(SocketEventName.PageUpdated, checkIsConflict);
  151. return () => {
  152. socket.off(SocketEventName.PageUpdated, checkIsConflict);
  153. };
  154. }, [socket, checkIsConflict]);
  155. const optionsToSave = useMemo((): OptionsToSave | undefined => {
  156. if (grantData == null) {
  157. return;
  158. }
  159. const optionsToSave = {
  160. isSlackEnabled: isSlackEnabled ?? false,
  161. slackChannels: '', // set in save method by opts in SavePageControlls.tsx
  162. grant: grantData.grant,
  163. pageTags: pageTags ?? [],
  164. grantUserGroupId: grantData.grantedGroup?.id,
  165. grantUserGroupName: grantData.grantedGroup?.name,
  166. };
  167. return optionsToSave;
  168. }, [grantData, isSlackEnabled, pageTags]);
  169. const setMarkdownWithDebounce = useMemo(() => debounce(100, throttle(150, (value: string, isClean: boolean) => {
  170. markdownToSave.current = value;
  171. setMarkdownToPreview(value);
  172. // Displays an unsaved warning alert
  173. mutateIsEnabledUnsavedWarning(!isClean);
  174. })), [mutateIsEnabledUnsavedWarning]);
  175. const markdownChangedHandler = useCallback((value: string, isClean: boolean): void => {
  176. setMarkdownWithDebounce(value, isClean);
  177. }, [setMarkdownWithDebounce]);
  178. const save = useCallback(async(opts?: {slackChannels: string, overwriteScopesOfDescendants?: boolean}): Promise<IPageHasId | null> => {
  179. if (currentPathname == null || optionsToSave == null) {
  180. logger.error('Some materials to save are invalid', { grantData, isSlackEnabled, currentPathname });
  181. throw new Error('Some materials to save are invalid');
  182. }
  183. const options = Object.assign(optionsToSave, opts);
  184. try {
  185. mutateWaitingSaveProcessing(true);
  186. const { page } = await saveOrUpdate(
  187. markdownToSave.current,
  188. { pageId, path: currentPagePath || currentPathname, revisionId: currentRevisionId },
  189. options,
  190. );
  191. // to sync revision id with page tree: https://github.com/weseek/growi/pull/7227
  192. mutatePageTree();
  193. return page;
  194. }
  195. catch (error) {
  196. logger.error('failed to save', error);
  197. toastError(error);
  198. if (error.code === 'conflict') {
  199. mutateRemotePageId(error.data.revisionId);
  200. mutateRemoteRevisionId(error.data.revisionBody);
  201. mutateRemoteRevisionLastUpdatedAt(error.data.createdAt);
  202. mutateRemoteRevisionLastUpdateUser(error.data.user);
  203. }
  204. return null;
  205. }
  206. finally {
  207. mutateWaitingSaveProcessing(false);
  208. }
  209. }, [
  210. currentPathname, optionsToSave, grantData, isSlackEnabled, saveOrUpdate, pageId,
  211. currentPagePath, currentRevisionId,
  212. mutateWaitingSaveProcessing, mutateRemotePageId, mutateRemoteRevisionId, mutateRemoteRevisionLastUpdatedAt, mutateRemoteRevisionLastUpdateUser,
  213. ]);
  214. const saveAndReturnToViewHandler = useCallback(async(opts: {slackChannels: string, overwriteScopesOfDescendants?: boolean}) => {
  215. if (editorMode !== EditorMode.Editor) {
  216. return;
  217. }
  218. const page = await save(opts);
  219. if (page == null) {
  220. return;
  221. }
  222. if (isNotFound) {
  223. await router.push(`/${page._id}`);
  224. }
  225. else {
  226. updateStateAfterSave?.();
  227. }
  228. mutateEditorMode(EditorMode.View);
  229. }, [editorMode, save, isNotFound, mutateEditorMode, router, updateStateAfterSave]);
  230. const saveWithShortcut = useCallback(async() => {
  231. if (editorMode !== EditorMode.Editor) {
  232. return;
  233. }
  234. const page = await save();
  235. if (page == null) {
  236. return;
  237. }
  238. if (isNotFound) {
  239. await router.push(`/${page._id}#edit`);
  240. }
  241. else {
  242. updateStateAfterSave?.();
  243. }
  244. toastSuccess(t('toaster.save_succeeded'));
  245. mutateEditorMode(EditorMode.Editor);
  246. }, [editorMode, isNotFound, mutateEditorMode, router, save, t, updateStateAfterSave]);
  247. /**
  248. * the upload event handler
  249. * @param {any} file
  250. */
  251. const uploadHandler = useCallback(async(file) => {
  252. if (editorRef.current == null) {
  253. return;
  254. }
  255. try {
  256. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  257. let res: any = await apiGet('/attachments.limit', {
  258. fileSize: file.size,
  259. });
  260. if (!res.isUploadable) {
  261. throw new Error(res.errorMessage);
  262. }
  263. const formData = new FormData();
  264. // const { pageId, path } = pageContainer.state;
  265. formData.append('file', file);
  266. if (currentPagePath != null) {
  267. formData.append('path', currentPagePath);
  268. }
  269. if (pageId != null) {
  270. formData.append('page_id', pageId);
  271. }
  272. if (pageId == null && markdownToSave.current != null) {
  273. formData.append('page_body', markdownToSave.current);
  274. }
  275. res = await apiPostForm('/attachments.add', formData);
  276. const attachment = res.attachment;
  277. const fileName = attachment.originalName;
  278. let insertText = `[${fileName}](${attachment.filePathProxied})`;
  279. // when image
  280. if (attachment.fileFormat.startsWith('image/')) {
  281. // modify to "![fileName](url)" syntax
  282. insertText = `!${insertText}`;
  283. }
  284. editorRef.current.insertText(insertText);
  285. // when if created newly
  286. // Not using 'mutateGrant' to inherit the grant of the parent page
  287. if (res.pageCreated) {
  288. logger.info('Page is created', res.page._id);
  289. globalEmitter.emit('resetInitializedHackMdStatus');
  290. mutateIsLatestRevision(true);
  291. setCreatedPageRevisionIdWithAttachment(res.page.revision);
  292. await mutateCurrentPageId(res.page._id);
  293. await mutateCurrentPage();
  294. }
  295. }
  296. catch (e) {
  297. logger.error('failed to upload', e);
  298. toastError(e);
  299. }
  300. finally {
  301. editorRef.current.terminateUploadingState();
  302. }
  303. }, [currentPagePath, mutateCurrentPage, mutateCurrentPageId, mutateIsLatestRevision, pageId]);
  304. const scrollPreviewByEditorLine = useCallback((line: number) => {
  305. if (previewRef.current == null) {
  306. return;
  307. }
  308. // prevent circular invocation
  309. if (isOriginOfScrollSyncPreview) {
  310. isOriginOfScrollSyncPreview = false; // turn off the flag
  311. return;
  312. }
  313. // turn on the flag
  314. isOriginOfScrollSyncEditor = true;
  315. scrollSyncHelper.scrollPreview(previewRef.current, line);
  316. }, []);
  317. const scrollPreviewByEditorLineWithThrottle = useMemo(() => throttle(20, scrollPreviewByEditorLine), [scrollPreviewByEditorLine]);
  318. /**
  319. * the scroll event handler from codemirror
  320. * @param {any} data {left, top, width, height, clientWidth, clientHeight} object that represents the current scroll position,
  321. * the size of the scrollable area, and the size of the visible area (minus scrollbars).
  322. * And data.line is also available that is added by Editor component
  323. * @see https://codemirror.net/doc/manual.html#events
  324. */
  325. const editorScrolledHandler = useCallback(({ line }: { line: number }) => {
  326. // prevent scrolling
  327. // if the elapsed time from last scroll with cursor is shorter than 40ms
  328. const now = new Date();
  329. if (lastScrolledDateWithCursor != null && now.getTime() - lastScrolledDateWithCursor.getTime() < 40) {
  330. return;
  331. }
  332. scrollPreviewByEditorLineWithThrottle(line);
  333. }, [scrollPreviewByEditorLineWithThrottle]);
  334. /**
  335. * scroll Preview element by cursor moving
  336. * @param {number} line
  337. */
  338. const scrollPreviewByCursorMoving = useCallback((line: number) => {
  339. if (previewRef.current == null) {
  340. return;
  341. }
  342. // prevent circular invocation
  343. if (isOriginOfScrollSyncPreview) {
  344. isOriginOfScrollSyncPreview = false; // turn off the flag
  345. return;
  346. }
  347. // turn on the flag
  348. isOriginOfScrollSyncEditor = true;
  349. if (previewRef.current != null) {
  350. scrollSyncHelper.scrollPreviewToRevealOverflowing(previewRef.current, line);
  351. }
  352. }, []);
  353. const scrollPreviewByCursorMovingWithThrottle = useMemo(() => throttle(20, scrollPreviewByCursorMoving), [scrollPreviewByCursorMoving]);
  354. /**
  355. * the scroll event handler from codemirror
  356. * @param {number} line
  357. * @see https://codemirror.net/doc/manual.html#events
  358. */
  359. const editorScrollCursorIntoViewHandler = useCallback((line: number) => {
  360. // record date
  361. lastScrolledDateWithCursor = new Date();
  362. scrollPreviewByCursorMovingWithThrottle(line);
  363. }, [scrollPreviewByCursorMovingWithThrottle]);
  364. /**
  365. * scroll Editor component by scroll event of Preview component
  366. * @param {number} offset
  367. */
  368. const scrollEditorByPreviewScroll = useCallback((offset: number) => {
  369. if (editorRef.current == null || previewRef.current == null) {
  370. return;
  371. }
  372. // prevent circular invocation
  373. if (isOriginOfScrollSyncEditor) {
  374. isOriginOfScrollSyncEditor = false; // turn off the flag
  375. return;
  376. }
  377. // turn on the flag
  378. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  379. isOriginOfScrollSyncPreview = true;
  380. scrollSyncHelper.scrollEditor(editorRef.current, previewRef.current, offset);
  381. }, []);
  382. const scrollEditorByPreviewScrollWithThrottle = useMemo(() => throttle(20, scrollEditorByPreviewScroll), [scrollEditorByPreviewScroll]);
  383. const afterResolvedHandler = useCallback(async() => {
  384. // get page data from db
  385. const pageData = await mutateCurrentPage();
  386. // update tag
  387. await mutateTagsInfo(); // get from DB
  388. syncTagsInfoForEditor(); // sync global state for client
  389. // clear isConflict
  390. mutateIsConflict(false);
  391. // set resolved markdown in editing markdown
  392. const markdown = pageData?.revision.body ?? '';
  393. mutateEditingMarkdown(markdown);
  394. }, [mutateCurrentPage, mutateEditingMarkdown, mutateIsConflict, mutateTagsInfo, syncTagsInfoForEditor]);
  395. // initialize
  396. useEffect(() => {
  397. if (initialValue == null) {
  398. return;
  399. }
  400. markdownToSave.current = initialValue;
  401. setMarkdownToPreview(initialValue);
  402. mutateIsEnabledUnsavedWarning(false);
  403. }, [initialValue, mutateIsEnabledUnsavedWarning]);
  404. // initial caret line
  405. useEffect(() => {
  406. if (editorRef.current != null) {
  407. editorRef.current.setCaretLine(0);
  408. }
  409. }, []);
  410. // set handler to set caret line
  411. useEffect(() => {
  412. const handler = (line) => {
  413. if (editorRef.current != null) {
  414. editorRef.current.setCaretLine(line);
  415. }
  416. if (previewRef.current != null) {
  417. scrollSyncHelper.scrollPreview(previewRef.current, line);
  418. }
  419. };
  420. globalEmitter.on('setCaretLine', handler);
  421. return function cleanup() {
  422. globalEmitter.removeListener('setCaretLine', handler);
  423. };
  424. }, []);
  425. // set handler to save and return to View
  426. useEffect(() => {
  427. globalEmitter.on('saveAndReturnToView', saveAndReturnToViewHandler);
  428. return function cleanup() {
  429. globalEmitter.removeListener('saveAndReturnToView', saveAndReturnToViewHandler);
  430. };
  431. }, [saveAndReturnToViewHandler]);
  432. // set handler to focus
  433. useEffect(() => {
  434. if (editorRef.current != null && editorMode === EditorMode.Editor) {
  435. editorRef.current.forceToFocus();
  436. }
  437. }, [editorMode]);
  438. // Detect indent size from contents (only when users are allowed to change it)
  439. useEffect(() => {
  440. // do nothing if the indent size fixed
  441. if (isIndentSizeForced == null || isIndentSizeForced) {
  442. return;
  443. }
  444. // detect from markdown
  445. if (initialValue != null) {
  446. const detectedIndent = detectIndent(initialValue);
  447. if (detectedIndent.type === 'space' && new Set([2, 4]).has(detectedIndent.amount)) {
  448. mutateCurrentIndentSize(detectedIndent.amount);
  449. }
  450. }
  451. }, [initialValue, isIndentSizeForced, mutateCurrentIndentSize]);
  452. // when transitioning to a different page, if the initialValue is the same,
  453. // UnControlled CodeMirror value does not reset, so explicitly set the value to initialValue
  454. const onRouterChangeComplete = useCallback(() => {
  455. editorRef.current?.setValue(initialValue);
  456. editorRef.current?.setCaretLine(0);
  457. }, [initialValue]);
  458. useEffect(() => {
  459. router.events.on('routeChangeComplete', onRouterChangeComplete);
  460. return () => {
  461. router.events.off('routeChangeComplete', onRouterChangeComplete);
  462. };
  463. }, [onRouterChangeComplete, router.events]);
  464. if (!isEditable) {
  465. return <></>;
  466. }
  467. if (rendererOptions == null) {
  468. return <></>;
  469. }
  470. const isUploadable = isUploadableImage || isUploadableFile;
  471. return (
  472. <div data-testid="page-editor" id="page-editor" className={`flex-grow-1 d-flex overflow-y-auto ${props.visibility ? '' : 'd-none'}`}>
  473. <div className="page-editor-editor-container flex-expand-vert">
  474. {/* <Editor
  475. ref={editorRef}
  476. value={initialValue}
  477. isUploadable={isUploadable}
  478. isUploadableFile={isUploadableFile}
  479. indentSize={currentIndentSize}
  480. onScroll={editorScrolledHandler}
  481. onScrollCursorIntoView={editorScrollCursorIntoViewHandler}
  482. onChange={markdownChangedHandler}
  483. onUpload={uploadHandler}
  484. onSave={saveWithShortcut}
  485. /> */}
  486. <CodeMirrorEditorContainer ref={codeMirrorEditorContainerRef} />
  487. </div>
  488. <div className="page-editor-preview-container flex-expand-vert d-none d-lg-flex">
  489. <Preview
  490. ref={previewRef}
  491. rendererOptions={rendererOptions}
  492. markdown={markdownToPreview}
  493. pagePath={currentPagePath}
  494. onScroll={offset => scrollEditorByPreviewScrollWithThrottle(offset)}
  495. />
  496. </div>
  497. {/*
  498. <ConflictDiffModal
  499. isOpen={conflictDiffModalStatus?.isOpened}
  500. onClose={() => closeConflictDiffModal()}
  501. markdownOnEdit={markdownToPreview}
  502. optionsToSave={optionsToSave}
  503. afterResolvedHandler={afterResolvedHandler}
  504. />
  505. */}
  506. </div>
  507. );
  508. });
  509. PageEditor.displayName = 'PageEditor';