2021-04-28 02:27:38 +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";
|
|
|
|
|
2021-05-06 01:58:14 +02:00
|
|
|
import ButtonGroup from "components/ButtonGroup.svelte";
|
|
|
|
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
|
2021-04-28 02:27:38 +02:00
|
|
|
import IconButton from "components/IconButton.svelte";
|
2021-05-30 22:58:40 +02:00
|
|
|
import ColorPicker from "components/ColorPicker.svelte";
|
2021-04-28 02:27:38 +02:00
|
|
|
import WithShortcut from "components/WithShortcut.svelte";
|
2021-05-30 21:44:05 +02:00
|
|
|
import WithColorHelper from "./WithColorHelper.svelte";
|
2021-06-18 01:44:15 +02:00
|
|
|
import OnlyEditable from "./OnlyEditable.svelte";
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-31 00:17:06 +02:00
|
|
|
import { textColorIcon, highlightColorIcon, arrowIcon } from "./icons";
|
2021-05-06 02:49:59 +02:00
|
|
|
import { appendInParentheses } from "./helpers";
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 16:10:26 +02:00
|
|
|
export let api = {};
|
|
|
|
|
2021-05-30 21:44:05 +02:00
|
|
|
const wrapWithForecolor = (color: string) => () => {
|
2021-04-28 02:27:38 +02:00
|
|
|
document.execCommand("forecolor", false, color);
|
2021-05-30 22:58:40 +02:00
|
|
|
};
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-30 21:44:05 +02:00
|
|
|
const wrapWithBackcolor = (color: string) => () => {
|
|
|
|
document.execCommand("backcolor", false, color);
|
2021-05-30 22:58:40 +02:00
|
|
|
};
|
2021-06-19 16:26:30 +02:00
|
|
|
|
|
|
|
const initialColor = "black";
|
|
|
|
|
|
|
|
let forecolorWrap = wrapWithForecolor(initialColor);
|
|
|
|
let backcolorWrap = wrapWithForecolor(initialColor);
|
2021-04-28 02:27:38 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-06 19:26:50 +02:00
|
|
|
<ButtonGroup {api}>
|
2021-06-19 16:26:30 +02:00
|
|
|
<WithColorHelper color={initialColor} let:colorHelperIcon let:setColor>
|
2021-06-18 01:44:15 +02:00
|
|
|
<OnlyEditable let:disabled>
|
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithShortcut shortcut={"F7"} let:createShortcut let:shortcutLabel>
|
|
|
|
<IconButton
|
|
|
|
tooltip={appendInParentheses(
|
|
|
|
tr.editingSetForegroundColor(),
|
|
|
|
shortcutLabel
|
|
|
|
)}
|
|
|
|
{disabled}
|
2021-06-19 16:26:30 +02:00
|
|
|
on:click={forecolorWrap}
|
2021-06-18 01:44:15 +02:00
|
|
|
on:mount={createShortcut}
|
|
|
|
>
|
|
|
|
{@html textColorIcon}
|
|
|
|
{@html colorHelperIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithShortcut>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
|
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithShortcut shortcut={"F8"} let:createShortcut let:shortcutLabel>
|
|
|
|
<IconButton
|
|
|
|
tooltip={appendInParentheses(
|
|
|
|
tr.editingChangeColor(),
|
|
|
|
shortcutLabel
|
|
|
|
)}
|
|
|
|
{disabled}
|
|
|
|
widthMultiplier={0.5}
|
|
|
|
>
|
|
|
|
{@html arrowIcon}
|
2021-06-19 16:26:30 +02:00
|
|
|
<ColorPicker
|
|
|
|
on:change={(event) => {
|
|
|
|
forecolorWrap = wrapWithForecolor(setColor(event));
|
|
|
|
forecolorWrap();
|
|
|
|
}}
|
|
|
|
on:mount={createShortcut}
|
|
|
|
/>
|
2021-06-18 01:44:15 +02:00
|
|
|
</IconButton>
|
|
|
|
</WithShortcut>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
</OnlyEditable>
|
|
|
|
</WithColorHelper>
|
|
|
|
|
2021-06-19 16:26:30 +02:00
|
|
|
<WithColorHelper color={initialColor} let:colorHelperIcon let:setColor>
|
2021-06-18 01:44:15 +02:00
|
|
|
<OnlyEditable let:disabled>
|
|
|
|
<ButtonGroupItem>
|
2021-06-19 16:26:30 +02:00
|
|
|
<IconButton on:click={backcolorWrap} {disabled}>
|
2021-06-18 01:44:15 +02:00
|
|
|
{@html highlightColorIcon}
|
2021-05-30 21:44:05 +02:00
|
|
|
{@html colorHelperIcon}
|
|
|
|
</IconButton>
|
2021-06-18 01:44:15 +02:00
|
|
|
</ButtonGroupItem>
|
2021-05-30 22:58:40 +02:00
|
|
|
|
2021-06-18 01:44:15 +02:00
|
|
|
<ButtonGroupItem>
|
2021-05-30 22:58:40 +02:00
|
|
|
<IconButton
|
2021-06-18 01:44:15 +02:00
|
|
|
tooltip={tr.editingChangeColor()}
|
2021-05-31 00:17:06 +02:00
|
|
|
widthMultiplier={0.5}
|
2021-06-18 01:44:15 +02:00
|
|
|
{disabled}
|
2021-05-30 22:58:40 +02:00
|
|
|
>
|
2021-05-31 00:17:06 +02:00
|
|
|
{@html arrowIcon}
|
2021-06-19 16:26:30 +02:00
|
|
|
<ColorPicker
|
|
|
|
on:change={(event) => {
|
|
|
|
backcolorWrap = wrapWithBackcolor(setColor(event));
|
|
|
|
backcolorWrap();
|
|
|
|
}}
|
|
|
|
/>
|
2021-05-30 22:58:40 +02:00
|
|
|
</IconButton>
|
2021-06-18 01:44:15 +02:00
|
|
|
</ButtonGroupItem>
|
|
|
|
</OnlyEditable>
|
2021-05-30 21:44:05 +02:00
|
|
|
</WithColorHelper>
|
2021-04-28 02:27:38 +02:00
|
|
|
</ButtonGroup>
|