Skip to content

Commit

Permalink
Merge pull request #9629 from weseek/fix/157898-161512-delete-re-rend…
Browse files Browse the repository at this point in the history
…ering-in-page-editor

imprv: Suppresses unnecessary re-rendering within PageEditor
  • Loading branch information
mergify[bot] authored Feb 10, 2025
2 parents ed6a6b5 + 0fa81fe commit 46fcf8d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import styles from './EditorNavbar.module.scss';

const moduleClass = styles['editor-navbar'] ?? '';

export const EditorNavbar = (): JSX.Element => {
const EditingUsers = (): JSX.Element => {
const { data: editingUsers } = useEditingUsers();
return (
<EditingUserList
userList={editingUsers?.userList ?? []}
/>
);
};

export const EditorNavbar = (): JSX.Element => {
return (
<div className={`${moduleClass} d-flex flex-column flex-sm-row justify-content-between ps-3 ps-md-5 ps-xl-4 pe-4 py-1 align-items-sm-end`}>
<div className="order-2 order-sm-1"><PageHeader /></div>
<div className="order-1 order-sm-2"><EditingUserList
userList={editingUsers?.userList ?? []}
/>
</div>
<div className="order-1 order-sm-2"><EditingUsers /></div>
</div>
);
};
70 changes: 38 additions & 32 deletions apps/app/src/client/components/PageEditor/PageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Props = {
visibility?: boolean,
}

export const PageEditor = React.memo((props: Props): JSX.Element => {
export const PageEditorSubstance = (props: Props): JSX.Element => {

const { t } = useTranslation();

Expand Down Expand Up @@ -361,42 +361,48 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
return <></>;
}

return (
<div className={`flex-expand-horiz ${props.visibility ? '' : 'd-none'}`}>
<div className="page-editor-editor-container flex-expand-vert border-end">
<CodeMirrorEditorMain
isEditorMode={editorMode === EditorMode.Editor}
onSave={saveWithShortcut}
onUpload={uploadHandler}
acceptedUploadFileType={acceptedUploadFileType}
onScroll={scrollEditorHandlerThrottle}
indentSize={currentIndentSize ?? defaultIndentSize}
user={user ?? undefined}
pageId={pageId ?? undefined}
initialValue={initialValue}
editorSettings={editorSettings}
onEditorsUpdated={onEditorsUpdated}
cmProps={cmProps}
/>
</div>
<div
ref={previewRef}
onScroll={scrollPreviewHandlerThrottle}
className="page-editor-preview-container flex-expand-vert overflow-y-auto d-none d-lg-flex"
>
<Preview
rendererOptions={rendererOptions}
markdown={markdownToPreview}
pagePath={currentPagePath}
expandContentWidth={shouldExpandContent}
style={pastEndStyle}
/>
</div>
</div>
);
};

export const PageEditor = React.memo((props: Props): JSX.Element => {
return (
<div data-testid="page-editor" id="page-editor" className={`flex-expand-vert ${props.visibility ? '' : 'd-none'}`}>

<EditorNavbar />

<div className={`flex-expand-horiz ${props.visibility ? '' : 'd-none'}`}>
<div className="page-editor-editor-container flex-expand-vert border-end">
<CodeMirrorEditorMain
isEditorMode={editorMode === EditorMode.Editor}
onSave={saveWithShortcut}
onUpload={uploadHandler}
acceptedUploadFileType={acceptedUploadFileType}
onScroll={scrollEditorHandlerThrottle}
indentSize={currentIndentSize ?? defaultIndentSize}
user={user ?? undefined}
pageId={pageId ?? undefined}
initialValue={initialValue}
editorSettings={editorSettings}
onEditorsUpdated={onEditorsUpdated}
cmProps={cmProps}
/>
</div>
<div
ref={previewRef}
onScroll={scrollPreviewHandlerThrottle}
className="page-editor-preview-container flex-expand-vert overflow-y-auto d-none d-lg-flex"
>
<Preview
rendererOptions={rendererOptions}
markdown={markdownToPreview}
pagePath={currentPagePath}
expandContentWidth={shouldExpandContent}
style={pastEndStyle}
/>
</div>
</div>
<PageEditorSubstance visibility={props.visibility} />

<EditorNavbarBottom />

Expand Down

0 comments on commit 46fcf8d

Please sign in to comment.