mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Fix clicking the bold button immediately showing the updated button state
- rather than only after typing
This commit is contained in:
parent
bb64f73c1a
commit
2046b00c38
1 changed files with 4 additions and 3 deletions
|
@ -1,9 +1,9 @@
|
|||
<script lang="typescript" context="module">
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export const commandMap = writable(new Map<string, boolean>());
|
||||
const commandMap = writable(new Map<string, boolean>());
|
||||
|
||||
function initializeButton(key: string): void {
|
||||
function updateButton(key: string): void {
|
||||
commandMap.update(
|
||||
(map: Map<string, boolean>): Map<string, boolean> =>
|
||||
new Map([...map, [key, document.queryCommandState(key)]])
|
||||
|
@ -48,7 +48,7 @@
|
|||
let active = false;
|
||||
|
||||
if (activatable) {
|
||||
initializeButton(command);
|
||||
updateButton(command);
|
||||
|
||||
commandMap.subscribe((map: Map<string, boolean>): void => {
|
||||
active = map.get(command);
|
||||
|
@ -58,6 +58,7 @@
|
|||
|
||||
function onClick(): void {
|
||||
document.execCommand(command);
|
||||
updateButton(command);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue