Pass mininotation locations into highlight state
This commit is contained in:
parent
0b5d905120
commit
aded178ab7
2 changed files with 9 additions and 4 deletions
|
|
@ -85,7 +85,7 @@ const miniLocations = StateField.define({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
locations = Decoration.set(decorations); // -> DecorationSet === RangeSet<Decoration>
|
locations = Decoration.set(decorations, true); // -> DecorationSet === RangeSet<Decoration>
|
||||||
}
|
}
|
||||||
if (e.is(showMiniLocations)) {
|
if (e.is(showMiniLocations)) {
|
||||||
// this is called every frame to show the locations that are currently active
|
// this is called every frame to show the locations that are currently active
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,13 @@ export function Repl({ embedded = false }) {
|
||||||
isLineWrappingEnabled,
|
isLineWrappingEnabled,
|
||||||
} = useSettings();
|
} = useSettings();
|
||||||
|
|
||||||
|
const [miniLocations, setMiniLocations] = useState([]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (view) {
|
||||||
|
updateMiniLocations(view, miniLocations);
|
||||||
|
}
|
||||||
|
}, [view, miniLocations]);
|
||||||
|
|
||||||
const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
|
const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
|
||||||
useStrudel({
|
useStrudel({
|
||||||
initialCode: '// LOADING...',
|
initialCode: '// LOADING...',
|
||||||
|
|
@ -138,9 +145,7 @@ export function Repl({ embedded = false }) {
|
||||||
cleanupDraw();
|
cleanupDraw();
|
||||||
},
|
},
|
||||||
afterEval: ({ code, meta }) => {
|
afterEval: ({ code, meta }) => {
|
||||||
console.log('miniLocations', meta.miniLocations, view);
|
setMiniLocations(meta.miniLocations);
|
||||||
// TODO: find a way to get hold of the codemirror view
|
|
||||||
// then call updateMiniLocations
|
|
||||||
setPending(false);
|
setPending(false);
|
||||||
setLatestCode(code);
|
setLatestCode(code);
|
||||||
window.location.hash = '#' + encodeURIComponent(btoa(code));
|
window.location.hash = '#' + encodeURIComponent(btoa(code));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue