A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: fix scroll into view when used by toc (#7764)
01zulfi04519d1db715
diff --git a/apps/web/src/components/editor/table-of-contents.tsx b/apps/web/src/components/editor/table-of-contents.tsxindex c139cab55..b21dbecbd 100644--- a/apps/web/src/components/editor/table-of-contents.tsx+++ b/apps/web/src/components/editor/table-of-contents.tsx@@ -148,7 +148,9 @@ function TableOfContents(props: TableOfContentsProps) {? "accent-selected": "paragraph"}}- onClick={() => scrollIntoViewById(t.id)}+ onClick={() =>+ scrollIntoViewById(t.id, "scroll-margin-top: 35px;")+ }>{t.title}</Button>diff --git a/packages/editor/src/utils/toc.ts b/packages/editor/src/utils/toc.tsindex 62d5ca859..1cad91a83 100644--- a/packages/editor/src/utils/toc.ts+++ b/packages/editor/src/utils/toc.ts@@ -46,7 +46,7 @@ export function getTableOfContents(content: HTMLElement) {return tableOfContents;}-export function scrollIntoViewById(blockId: string) {+export function scrollIntoViewById(blockId: string, optionalStyles = "") {const element = document.querySelector<HTMLElement>(`.active [data-block-id=${JSON.stringify(blockId)}]`);@@ -54,6 +54,7 @@ export function scrollIntoViewById(blockId: string) {if (element) {const css = `.active [data-block-id=${JSON.stringify(blockId)}] {background-color: var(--shade) !important;+ ${optionalStyles}}`;const stylesheet = document.createElement("style");stylesheet.innerText = css;