Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(text): clicking on a bookmark link won't scroll properly
Elian Doran131e10f4fe58
diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsxindex 760e00e489..26d021168b 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx@@ -61,6 +61,17 @@ export default function EditableText({ note, parentComponent, ntxId, noteContextonContentChange(newContent) {contentRef.current = newContent;watchdogRef.current?.editor?.setData(newContent);++ // Scroll to bookmark anchor if navigated with ?bookmark=...+ const viewScope = noteContext?.viewScope;+ if (viewScope?.bookmark) {+ requestAnimationFrame(() => {+ const el = watchdogRef.current?.editor?.editing.view.getDomRoot()+ ?.querySelector(`[id="${CSS.escape(viewScope.bookmark!)}"]`);+ el?.scrollIntoView({ behavior: "smooth", block: "center" });+ viewScope.bookmark = undefined;+ });+ }},dataSaved(savedData) {// Store back the saved data in order to retrieve it in case the CKEditor crashes.