From 28068f49336af2ffb9e30aad433e49cac80ce7b3 Mon Sep 17 00:00:00 2001 From: Kirill Gavrilov Date: Sun, 5 Oct 2025 01:41:24 +0300 Subject: [PATCH] fix: add small delay to wait for `HTMLMediaElement` to become available in Markdown view --- src/TimecodesPlugin.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TimecodesPlugin.ts b/src/TimecodesPlugin.ts index 1516b88..67f7f25 100644 --- a/src/TimecodesPlugin.ts +++ b/src/TimecodesPlugin.ts @@ -1,9 +1,15 @@ -import { Plugin } from 'obsidian' +import { MarkdownPostProcessorContext, Plugin } from 'obsidian' import { turnRawTimecodesIntoClickableLinks } from './ui/timecodes-md-post-processor' export default class TimecodesPlugin extends Plugin { override onload() { - this.registerMarkdownPostProcessor(turnRawTimecodesIntoClickableLinks) + this.registerMarkdownPostProcessor( + (root: HTMLElement, ctx: MarkdownPostProcessorContext) => { + requestAnimationFrame(() => { + turnRawTimecodesIntoClickableLinks(root, ctx) + }) + }, + ) } }