perf: Reduce rendering when editing title

This commit is contained in:
Tom Moor committed 2024-08-30 13:04:43 -04:00
1 parent 5374784df6
commit 0a4d67d96f
2 files changed
+12 -8

No files matched your search

+1 -1
View File
@@ -309,4 +309,4 @@ const StyledTabPanel = styled(TabPanel)`
overflow-y: auto;
`;
export default IconPicker;
export default React.memo(IconPicker);
+11 -7
View File
@@ -178,6 +178,16 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
const handleRefChanged = React.useCallback(setEditor, [setEditor]);
const EditorComponent = multiplayer ? MultiplayerEditor : Editor;
const childOffsetHeight = childRef.current?.offsetHeight || 0;
const editorStyle = React.useMemo(
() => ({
padding: "0 32px",
margin: "0 -32px",
paddingBottom: `calc(50vh - ${childOffsetHeight}px)`,
}),
[childOffsetHeight]
);
return (
<Flex auto column>
<DocumentTitle
@@ -231,13 +241,7 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
: undefined
}
extensions={extensions}
editorStyle={{
padding: "0 32px",
margin: "0 -32px",
paddingBottom: `calc(50vh - ${
childRef.current?.offsetHeight || 0
}px)`,
}}
editorStyle={editorStyle}
{...rest}
/>
<div ref={childRef}>{children}</div>