mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Use event object in createShortcut, fix F8 for highlight
This commit is contained in:
parent
66faa4ec25
commit
95c8f5a12a
9 changed files with 21 additions and 20 deletions
|
@ -29,7 +29,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
theme="primary"
|
||||
on:click={() => save()}
|
||||
tooltip={shortcutLabel}
|
||||
on:mount={createShortcut}>{tr.actionsSave()}</LabelButton
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>{tr.actionsSave()}</LabelButton
|
||||
>
|
||||
</WithShortcut>
|
||||
</ButtonGroupItem>
|
||||
|
|
|
@ -12,8 +12,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
let deregister: () => void;
|
||||
|
||||
function createShortcut({ detail }: CustomEvent): void {
|
||||
const mounted: HTMLButtonElement = detail.button;
|
||||
function createShortcut(mounted: HTMLElement): void {
|
||||
deregister = registerShortcut((event: KeyboardEvent) => {
|
||||
mounted.dispatchEvent(new MouseEvent("click", event));
|
||||
event.preventDefault();
|
||||
|
|
|
@ -65,7 +65,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
theme="primary"
|
||||
on:click={() => save(false)}
|
||||
tooltip={shortcutLabel}
|
||||
on:mount={createShortcut}>{tr.deckConfigSaveButton()}</LabelButton
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>{tr.deckConfigSaveButton()}</LabelButton
|
||||
>
|
||||
</WithShortcut>
|
||||
</ButtonGroupItem>
|
||||
|
|
|
@ -48,7 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
tooltip={`${tr.editingClozeDeletion()} (${shortcutLabel})`}
|
||||
{disabled}
|
||||
on:click={onCloze}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{@html ellipseIcon}
|
||||
</IconButton>
|
||||
|
|
|
@ -44,7 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
)}
|
||||
{disabled}
|
||||
on:click={forecolorWrap}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{@html textColorIcon}
|
||||
{@html colorHelperIcon}
|
||||
|
@ -68,7 +68,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
forecolorWrap = wrapWithForecolor(setColor(event));
|
||||
forecolorWrap();
|
||||
}}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.input)}
|
||||
/>
|
||||
</IconButton>
|
||||
</WithShortcut>
|
||||
|
|
|
@ -48,7 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
tooltip={appendInParentheses(tooltip, shortcutLabel)}
|
||||
{disabled}
|
||||
on:click={() => document.execCommand(key)}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
<slot />
|
||||
</IconButton>
|
||||
|
@ -69,7 +69,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
document.execCommand(key);
|
||||
updateState(event);
|
||||
}}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
<slot />
|
||||
</IconButton>
|
||||
|
|
|
@ -29,7 +29,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<LabelButton
|
||||
tooltip={`${tr.editingCustomizeCardTemplates()} (${shortcutLabel})`}
|
||||
on:click={() => bridgeCommand("cards")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingCards()}...
|
||||
</LabelButton>
|
||||
|
|
|
@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<LabelButton
|
||||
tooltip={tr.browsingPreviewSelectedCard({ val: shortcutLabel })}
|
||||
on:click={() => bridgeCommand("preview")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.actionsPreview()}
|
||||
</LabelButton>
|
||||
|
|
|
@ -53,7 +53,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
iconSize={70}
|
||||
{disabled}
|
||||
on:click={onAttachment}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{@html paperclipIcon}
|
||||
</IconButton>
|
||||
|
@ -72,7 +72,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
iconSize={70}
|
||||
{disabled}
|
||||
on:click={onRecord}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{@html micIcon}
|
||||
</IconButton>
|
||||
|
@ -105,7 +105,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("\\(", "\\)")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingMathjaxInline()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -119,7 +119,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("\\[", "\\]")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingMathjaxBlock()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -133,7 +133,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("\\(\\ce{", "}\\)")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingMathjaxChemistry()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -147,7 +147,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("[latex]", "[/latex]")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingLatex()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -161,7 +161,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("[$]", "[/$]")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingLatexEquation()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -175,7 +175,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
>
|
||||
<DropdownItem
|
||||
on:click={() => wrapCurrent("[$$]", "[/$$]")}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{tr.editingLatexMathEnv()}
|
||||
<span class="ps-1 float-end">{shortcutLabel}</span>
|
||||
|
@ -202,7 +202,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
active={inCodable}
|
||||
disabled={!fieldFocused}
|
||||
on:click={onHtmlEdit}
|
||||
on:mount={createShortcut}
|
||||
on:mount={(event) => createShortcut(event.detail.button)}
|
||||
>
|
||||
{@html xmlIcon}
|
||||
</IconButton>
|
||||
|
|
Loading…
Reference in a new issue