anki/ts/editor/ImageHandleFloatButtons.svelte

62 lines
1.9 KiB
Svelte
Raw Normal View History

2021-07-21 16:48:02 +02:00
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "lib/i18n";
import ButtonGroup from "components/ButtonGroup.svelte";
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
import IconButton from "components/IconButton.svelte";
import { createEventDispatcher } from "svelte";
2021-07-21 16:48:02 +02:00
import { floatNoneIcon, floatLeftIcon, floatRightIcon } from "./icons";
2021-08-06 02:19:36 +02:00
export let image: HTMLImageElement;
2021-07-21 16:48:02 +02:00
export let isRtl: boolean;
2021-09-02 21:01:29 +02:00
const [inlineStartIcon, inlineEndIcon] = isRtl
? [floatRightIcon, floatLeftIcon]
: [floatLeftIcon, floatRightIcon];
const dispatch = createEventDispatcher();
2021-07-21 16:48:02 +02:00
</script>
2021-09-02 21:01:29 +02:00
<ButtonGroup size={1.6} wrap={false}>
2021-07-21 16:48:02 +02:00
<ButtonGroupItem>
<IconButton
2021-09-02 21:01:29 +02:00
tooltip={tr.editingFloatLeft()}
active={image.style.float === "left"}
2021-07-21 16:48:02 +02:00
flipX={isRtl}
on:click={() => {
2021-09-02 21:01:29 +02:00
image.style.float = "left";
setTimeout(() => dispatch("update"));
2021-09-02 21:01:29 +02:00
}}>{@html inlineStartIcon}</IconButton
2021-07-21 16:48:02 +02:00
>
</ButtonGroupItem>
<ButtonGroupItem>
<IconButton
2021-09-02 21:01:29 +02:00
tooltip={tr.editingFloatNone()}
active={image.style.float === "" || image.style.float === "none"}
2021-07-21 16:48:02 +02:00
flipX={isRtl}
on:click={() => {
2021-09-02 21:01:29 +02:00
image.style.float = "";
setTimeout(() => dispatch("update"));
2021-09-02 21:01:29 +02:00
}}>{@html floatNoneIcon}</IconButton
2021-07-21 16:48:02 +02:00
>
</ButtonGroupItem>
<ButtonGroupItem>
<IconButton
2021-09-02 21:01:29 +02:00
tooltip={tr.editingFloatRight()}
active={image.style.float === "right"}
2021-07-21 16:48:02 +02:00
flipX={isRtl}
on:click={() => {
2021-09-02 21:01:29 +02:00
image.style.float = "right";
setTimeout(() => dispatch("update"));
2021-09-02 21:01:29 +02:00
}}>{@html inlineEndIcon}</IconButton
2021-07-21 16:48:02 +02:00
>
</ButtonGroupItem>
</ButtonGroup>