mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-13 18:40:50 +08:00
Add syntax highlighting to patch and commit changesets
- This commit doesn't change the way syntax highlighting is done. - But due to changes in `radicle-httpd` we can highlight the entire files of a changeset, and then replace the plain text lines with highlighted ones. - Also highlights only the files currently visible of a changeset. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<script lang="ts" context="module">
|
||||
export function intersection(
|
||||
node: HTMLElement,
|
||||
observer: IntersectionObserver | undefined,
|
||||
) {
|
||||
if (!observer) return;
|
||||
observer.observe(node);
|
||||
return {
|
||||
destroy() {
|
||||
observer.unobserve(node);
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onDestroy } from "svelte";
|
||||
|
||||
let observer: IntersectionObserver | undefined = undefined;
|
||||
let filesVisibility = new Set<string>();
|
||||
|
||||
if ("IntersectionObserver" in window) {
|
||||
observer = new IntersectionObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
filesVisibility = filesVisibility.add(
|
||||
entry.target.id.replace("observer:", ""),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
if (observer) {
|
||||
observer.disconnect();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot {observer} {filesVisibility} />
|
||||
Reference in New Issue
Block a user