0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 16:38:38 +00:00
This commit is contained in:
Víctor Losada Hernández
2026-05-04 16:03:07 +02:00
parent 102d1f4186
commit 6e39a70706
+6 -6
View File
@@ -181,9 +181,9 @@ const CodeEditor = forwardRef(
return page; return page;
}; };
const getFoldRanges = (state) => { const getFoldRanges = (state)=>{
const folds = []; const folds = [];
state.field(foldState, false)?.between(0, state.doc.length, (from, to) => { state.field(foldState, false)?.between(0, state.doc.length, (from, to)=>{
folds.push({ from, to }); folds.push({ from, to });
}); });
return folds; return folds;
@@ -293,11 +293,11 @@ const CodeEditor = forwardRef(
}; };
}, []); }, []);
const restoreFolds = (view, folds) => { const restoreFolds = (view, folds)=>{
if (!folds?.length) return; if(!folds?.length) return;
view.dispatch({ view.dispatch({
effects: folds.map(f => foldEffect.of(f)) effects : folds.map((f)=>foldEffect.of(f))
}); });
}; };
@@ -326,7 +326,7 @@ const CodeEditor = forwardRef(
restoreFolds(view, foldsRef.current[tab]); restoreFolds(view, foldsRef.current[tab]);
const savedScroll = scrollRef.current[tab]; const savedScroll = scrollRef.current[tab];
if(savedScroll != null) { if(savedScroll != null) {
requestAnimationFrame(()=>{ requestAnimationFrame(()=>{
view.scrollDOM.scrollTop = savedScroll; view.scrollDOM.scrollTop = savedScroll;