PageEditor.tsx 21 KB

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