Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: highlight active block for 5 seconds

Abdullah Atta3d25a1d5c200
diff --git a/packages/editor/src/utils/toc.ts b/packages/editor/src/utils/toc.ts
index 986ac62f1..f465d1726 100644
--- a/packages/editor/src/utils/toc.ts
+++ b/packages/editor/src/utils/toc.ts
@@ -47,11 +47,21 @@ export function getTableOfContents(content: HTMLElement) {
}
export function scrollIntoViewById(blockId: string) {
- const element = document.querySelector(
+ const element = document.querySelector<HTMLElement>(
`.active [data-block-id=${JSON.stringify(blockId)}]`
);
if (element) {
+ const css = `.active [data-block-id=${JSON.stringify(blockId)}] {
+ background-color: var(--shade) !important;
+}`;
+ const stylesheet = document.createElement("style");
+ stylesheet.innerText = css;
+ document.head.appendChild(stylesheet);
+ setTimeout(() => {
+ stylesheet.remove();
+ }, 5000);
+
setTimeout(
() =>
element.scrollIntoView({