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
|
|
|
|
-->
|
2021-10-26 00:43:02 +02:00
|
|
|
<script lang="ts">
|
2021-10-18 14:01:15 +02:00
|
|
|
import * as tr from "../../lib/ftl";
|
|
|
|
import type { Readable } from "svelte/store";
|
|
|
|
import { getContext } from "svelte";
|
|
|
|
import { directionKey } from "../../lib/context-keys";
|
2021-07-21 16:48:02 +02:00
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
import ButtonGroup from "../../components/ButtonGroup.svelte";
|
|
|
|
import ButtonGroupItem from "../../components/ButtonGroupItem.svelte";
|
|
|
|
import IconButton from "../../components/IconButton.svelte";
|
2021-07-21 16:48:02 +02:00
|
|
|
|
2021-08-06 03:53:44 +02:00
|
|
|
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
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
const direction = getContext<Readable<"ltr" | "rtl">>(directionKey);
|
|
|
|
const [inlineStartIcon, inlineEndIcon] =
|
|
|
|
$direction === "ltr"
|
|
|
|
? [floatLeftIcon, floatRightIcon]
|
|
|
|
: [floatRightIcon, floatLeftIcon];
|
2021-08-06 03:53:44 +02:00
|
|
|
|
|
|
|
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-10-18 14:01:15 +02:00
|
|
|
flipX={$direction === "rtl"}
|
2021-08-06 03:53:44 +02:00
|
|
|
on:click={() => {
|
2021-09-02 21:01:29 +02:00
|
|
|
image.style.float = "left";
|
2021-08-06 03:53:44 +02:00
|
|
|
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-10-18 14:01:15 +02:00
|
|
|
flipX={$direction === "rtl"}
|
2021-08-06 03:53:44 +02:00
|
|
|
on:click={() => {
|
2021-09-15 17:36:48 +02:00
|
|
|
image.style.removeProperty("float");
|
|
|
|
|
|
|
|
if (image.getAttribute("style")?.length === 0) {
|
|
|
|
image.removeAttribute("style");
|
|
|
|
}
|
|
|
|
|
2021-08-06 03:53:44 +02:00
|
|
|
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-10-18 14:01:15 +02:00
|
|
|
flipX={$direction === "rtl"}
|
2021-08-06 03:53:44 +02:00
|
|
|
on:click={() => {
|
2021-09-02 21:01:29 +02:00
|
|
|
image.style.float = "right";
|
2021-08-06 03:53:44 +02:00
|
|
|
setTimeout(() => dispatch("update"));
|
2021-09-02 21:01:29 +02:00
|
|
|
}}>{@html inlineEndIcon}</IconButton
|
2021-07-21 16:48:02 +02:00
|
|
|
>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
</ButtonGroup>
|