Merge pull request #5050 from naturalcrit/CleanBrewRendererMore

Remove currentBrewRendererPageNum from brewRenderer
This commit is contained in:
Trevor Buckner
2026-09-24 09:50:19 -04:00
committed by GitHub
5 changed files with 6 additions and 13 deletions
@@ -96,7 +96,6 @@ const BrewRenderer = (props)=>{
lang : '', lang : '',
errors : [], errors : [],
currentEditorCursorPageNum : 1, currentEditorCursorPageNum : 1,
currentBrewRendererPageNum : 1,
themeBundle : {}, themeBundle : {},
onPageChange : ()=>{}, onPageChange : ()=>{},
...props ...props
@@ -154,17 +153,16 @@ const BrewRenderer = (props)=>{
if(index == props.currentEditorCursorPageNum - 1) //Already rendered before this step if(index == props.currentEditorCursorPageNum - 1) //Already rendered before this step
return false; return false;
if(Math.abs(index - props.currentBrewRendererPageNum - 1) <= 3) if(Math.abs(index - centerPage - 1) <= 3)
return true; return true;
return false; return false;
}; };
const renderDummyPage = (index)=>{ const renderDummyPage = (index)=>
return <div className='phb page' id={`p${index + 1}`} key={index}> <div className='phb page' id={`p${index + 1}`} key={index}>
<i className='fas fa-spinner fa-spin' /> <i className='fas fa-spinner fa-spin' />
</div>; </div>;
};
const renderStyle = ()=>{ const renderStyle = ()=>{
const themeStyles = props.themeBundle?.joinedStyles ?? '<style>@import url("/themes/V3/Blank/style.css");</style>'; const themeStyles = props.themeBundle?.joinedStyles ?? '<style>@import url("/themes/V3/Blank/style.css");</style>';
@@ -223,8 +221,7 @@ const BrewRenderer = (props)=>{
}; };
const renderPages = (checkHoists = false)=>{ const renderPages = (checkHoists = false)=>{
if(props.errors?.length)
if(props.errors && props.errors.length)
return renderedPages; return renderedPages;
if(rawPages.length != renderedPages.length) { // Re-render all pages when page count changes if(rawPages.length != renderedPages.length) { // Re-render all pages when page count changes
@@ -246,7 +243,7 @@ const BrewRenderer = (props)=>{
renderedPages[index] = renderPage(page, index); // Render any page not yet rendered, but only re-render those in PPR range renderedPages[index] = renderPage(page, index); // Render any page not yet rendered, but only re-render those in PPR range
} }
}); });
if(!props.hoisted) { props.hoisted = true; } // Only fully hoist once. props.hoisted = true; // Only fully hoist once.
return renderedPages; return renderedPages;
}; };
@@ -337,7 +334,7 @@ const BrewRenderer = (props)=>{
<Frame id='BrewRenderer' title='Rendered Brew Content' initialContent={INITIAL_CONTENT} <Frame id='BrewRenderer' title='Rendered Brew Content' initialContent={INITIAL_CONTENT}
style={{ width: '100%', height: '100%', visibility: state.visibility }} style={{ width: '100%', height: '100%', visibility: state.visibility }}
contentDidMount={frameDidMount} contentDidMount={frameDidMount}
onClick={()=>{emitClick();}} onClick={emitClick}
sandbox='allow-same-origin allow-modals allow-top-navigation' sandbox='allow-same-origin allow-modals allow-top-navigation'
> >
<div className='brewRenderer' <div className='brewRenderer'
@@ -294,7 +294,6 @@ const EditPage = (props)=>{
lang={currentBrew.lang} lang={currentBrew.lang}
onPageChange={setCurrentBrewRendererPageNum} onPageChange={setCurrentBrewRendererPageNum}
currentEditorCursorPageNum={currentEditorCursorPageNum} currentEditorCursorPageNum={currentEditorCursorPageNum}
currentBrewRendererPageNum={currentBrewRendererPageNum}
allowPrint={true} allowPrint={true}
/> />
</SplitPane> </SplitPane>
@@ -141,7 +141,6 @@ const HomePage =(props)=>{
themeBundle={themeBundle} themeBundle={themeBundle}
onPageChange={setCurrentBrewRendererPageNum} onPageChange={setCurrentBrewRendererPageNum}
currentEditorCursorPageNum={currentEditorCursorPageNum} currentEditorCursorPageNum={currentEditorCursorPageNum}
currentBrewRendererPageNum={currentBrewRendererPageNum}
/> />
</SplitPane> </SplitPane>
</div> </div>
@@ -188,7 +188,6 @@ const NewPage = (props)=>{
lang={currentBrew.lang} lang={currentBrew.lang}
onPageChange={setCurrentBrewRendererPageNum} onPageChange={setCurrentBrewRendererPageNum}
currentEditorCursorPageNum={currentEditorCursorPageNum} currentEditorCursorPageNum={currentEditorCursorPageNum}
currentBrewRendererPageNum={currentBrewRendererPageNum}
allowPrint={true} allowPrint={true}
/> />
</SplitPane> </SplitPane>
@@ -149,7 +149,6 @@ const SharePage = (props)=>{
theme={currentBrew.theme} theme={currentBrew.theme}
themeBundle={themeBundle} themeBundle={themeBundle}
onPageChange={handleBrewRendererPageChange} onPageChange={handleBrewRendererPageChange}
currentBrewRendererPageNum={currentBrewRendererPageNum}
allowPrint={true} allowPrint={true}
/> />
</div> </div>