Browse Source

Jump to element via ToC

master
buttercat1791 9 months ago
parent
commit
d299017b9e
  1. 15
      src/lib/components/publications/Publication.svelte

15
src/lib/components/publications/Publication.svelte

@ -22,6 +22,7 @@
import Interactions from "$components/util/Interactions.svelte"; import Interactions from "$components/util/Interactions.svelte";
import type { SveltePublicationTree } from "./svelte_publication_tree.svelte"; import type { SveltePublicationTree } from "./svelte_publication_tree.svelte";
import TableOfContents from "./TableOfContents.svelte"; import TableOfContents from "./TableOfContents.svelte";
import { goto } from "$app/navigation";
let { rootAddress, publicationType, indexEvent } = $props<{ let { rootAddress, publicationType, indexEvent } = $props<{
rootAddress: string; rootAddress: string;
@ -33,8 +34,6 @@
// #region Loading // #region Loading
// TODO: Test load handling.
let leaves = $state<Array<NDKEvent | null>>([]); let leaves = $state<Array<NDKEvent | null>>([]);
let isLoading = $state<boolean>(false); let isLoading = $state<boolean>(false);
let isDone = $state<boolean>(false); let isDone = $state<boolean>(false);
@ -82,7 +81,8 @@
// #endregion // #endregion
// region Columns visibility // #region Columns visibility
let currentBlog: null | string = $state(null); let currentBlog: null | string = $state(null);
let currentBlogEvent: null | NDKEvent = $state(null); let currentBlogEvent: null | NDKEvent = $state(null);
const isLeaf = $derived(indexEvent.kind === 30041); const isLeaf = $derived(indexEvent.kind === 30041);
@ -123,6 +123,10 @@
return currentBlog && currentBlogEvent && window.innerWidth < 1140; return currentBlog && currentBlogEvent && window.innerWidth < 1140;
} }
// #endregion
// #region Lifecycle hooks
onDestroy(() => { onDestroy(() => {
// reset visibility // reset visibility
publicationColumnVisibility.reset(); publicationColumnVisibility.reset();
@ -157,6 +161,8 @@
observer.disconnect(); observer.disconnect();
}; };
}); });
// #endregion
</script> </script>
<!-- Table of contents --> <!-- Table of contents -->
@ -170,6 +176,9 @@
depth={2} depth={2}
onSectionFocused={(address: string) => { onSectionFocused={(address: string) => {
publicationTree.setBookmark(address); publicationTree.setBookmark(address);
goto(`#${address}`, {
replaceState: true,
});
}} }}
/> />
</Sidebar> </Sidebar>

Loading…
Cancel
Save