mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00

* Make eslint sort our imports * fix missing deps in eslint rule (dae) Caught on Linux due to the stricter sandboxing * Remove exports-last eslint rule (for now?) * Adjust browserslist settings - We use ResizeObserver which is not supported in browsers like KaiOS, Baidu or Android UC * Raise minimum iOS version 13.4 - It's the first version that supports ResizeObserver * Apply new eslint rules to sort imports
66 lines
1.7 KiB
Svelte
66 lines
1.7 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import IconButton from "../../components/IconButton.svelte";
|
|
import Shortcut from "../../components/Shortcut.svelte";
|
|
import WithState from "../../components/WithState.svelte";
|
|
import { execCommand, queryCommandState } from "../helpers";
|
|
import { context as noteEditorContext } from "../NoteEditor.svelte";
|
|
import { editingInputIsRichText } from "../rich-text-input";
|
|
|
|
export let key: string;
|
|
export let tooltip: string;
|
|
export let shortcut: string = "";
|
|
|
|
export let withoutShortcut = false;
|
|
export let withoutState = false;
|
|
|
|
const { focusedInput } = noteEditorContext.get();
|
|
|
|
function action() {
|
|
execCommand(key);
|
|
}
|
|
|
|
$: disabled = !editingInputIsRichText($focusedInput);
|
|
</script>
|
|
|
|
{#if withoutState}
|
|
<IconButton {tooltip} {disabled} on:click={action}>
|
|
<slot />
|
|
</IconButton>
|
|
|
|
{#if !withoutShortcut}
|
|
<Shortcut keyCombination={shortcut} on:click={action} />
|
|
{/if}
|
|
{:else}
|
|
<WithState
|
|
{key}
|
|
update={async () => queryCommandState(key)}
|
|
let:state={active}
|
|
let:updateState
|
|
>
|
|
<IconButton
|
|
{tooltip}
|
|
{active}
|
|
{disabled}
|
|
on:click={(event) => {
|
|
action();
|
|
updateState(event);
|
|
}}
|
|
>
|
|
<slot />
|
|
</IconButton>
|
|
|
|
{#if !withoutShortcut}
|
|
<Shortcut
|
|
keyCombination={shortcut}
|
|
on:action={(event) => {
|
|
action();
|
|
updateState(event);
|
|
}}
|
|
/>
|
|
{/if}
|
|
</WithState>
|
|
{/if}
|