PageEditor.tsx 20 KB

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