-
I know I can detect the change of palette using MutationObserver but it seems to me that it is a hack, is there a stable and official way to do it? Any event that provides mkdocs-material? |
Beta Was this translation helpful? Give feedback.
Answered by
squidfunk
Jan 5, 2022
Replies: 1 comment 1 reply
-
This should work: const ref = document.querySelector("[data-md-component=palette]")
component$.subscribe(component => {
if (component.ref === ref) {
alert$.next(`Changed to "${component.color.scheme}"`)
console.log(component.index, component.color)
}
}) In general you can monitor all components through the mkdocs-material/src/assets/javascripts/bundle.ts Lines 249 to 258 in 12a016b |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
eyllanesc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work:
In general you can monitor all components through the
component$
observable. There's also thedocument$
observable to monitor document changes (instant loading) andlocation$
to track location changes, and more:mkdocs-material/src/assets/javascripts/bundle.ts
Lines 249 to 258 in 12a016b