mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved keyboard interactions for palette toggle
This commit is contained in:
parent
a3655e8307
commit
78e93ac0af
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -249,7 +249,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.bd41221c.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.1e8ae164.min.js' | url }}"></script>
|
||||||
{% for script in config.extra_javascript %}
|
{% for script in config.extra_javascript %}
|
||||||
{{ script | script_tag }}
|
{{ script | script_tag }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
Subject,
|
Subject,
|
||||||
asyncScheduler,
|
asyncScheduler,
|
||||||
defer,
|
defer,
|
||||||
|
filter,
|
||||||
finalize,
|
finalize,
|
||||||
fromEvent,
|
fromEvent,
|
||||||
map,
|
map,
|
||||||
@ -36,7 +37,8 @@ import {
|
|||||||
skip,
|
skip,
|
||||||
startWith,
|
startWith,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
tap
|
tap,
|
||||||
|
withLatestFrom
|
||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
|
|
||||||
import { getElements, watchMedia } from "~/browser"
|
import { getElements, watchMedia } from "~/browser"
|
||||||
@ -162,6 +164,17 @@ export function mountPalette(
|
|||||||
__md_set("__palette", palette)
|
__md_set("__palette", palette)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Handle color switch on Enter or Space - see https://t.ly/YIhVj
|
||||||
|
fromEvent<KeyboardEvent>(el, "keydown").pipe(
|
||||||
|
filter(ev => ev.key === "Enter"),
|
||||||
|
withLatestFrom(push$, (_, palette) => palette)
|
||||||
|
)
|
||||||
|
.subscribe(({ index }) => {
|
||||||
|
index = (index + 1) % inputs.length
|
||||||
|
inputs[index].click()
|
||||||
|
inputs[index].focus()
|
||||||
|
})
|
||||||
|
|
||||||
/* Update theme-color meta tag */
|
/* Update theme-color meta tag */
|
||||||
push$
|
push$
|
||||||
.pipe(
|
.pipe(
|
||||||
|
Loading…
Reference in New Issue
Block a user