Skip to content
Discussion options

You must be logged in to vote

Correct

export function TocElementStatic(props: SlateElementProps) {
  const { editor } = props;
  const headingList = getHeadingList(editor);
  const handleClick = (id: string) => {
    let el = document.querySelector(`[data-block-id="${id}"]`);
    // Jika tidak ketemu, coba data-slate-id
    if (!el) el = document.querySelector(`[data-slate-id="${id}"]`);
    if (el) {
      // Jika perlu offset (misal sticky header), pakai ini:
      // const y = el.getBoundingClientRect().top + window.scrollY - TOP_OFFSET;
      // window.scrollTo({ top: y, behavior: 'smooth' });
      // Kalau tidak perlu offset, cukup:
      el.scrollIntoView({ behavior: "smooth" });
    } else {
      console.log(`…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Thebibii
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Thebibii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant