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 type { EditingArea } from "./editingArea";
|
|
|
|
import * as tr from "lib/i18n";
|
|
|
|
|
|
|
|
import ButtonGroup from "components/ButtonGroup.svelte";
|
2021-05-06 01:58:14 +02:00
|
|
|
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
|
|
|
|
import IconButton from "components/IconButton.svelte";
|
2021-04-28 02:27:38 +02:00
|
|
|
import ButtonDropdown from "components/ButtonDropdown.svelte";
|
2021-05-06 23:04:38 +02:00
|
|
|
import ButtonToolbarItem from "components/ButtonToolbarItem.svelte";
|
2021-04-28 13:09:25 +02:00
|
|
|
import WithState from "components/WithState.svelte";
|
2021-04-28 02:27:38 +02:00
|
|
|
import WithDropdownMenu from "components/WithDropdownMenu.svelte";
|
|
|
|
|
|
|
|
import { getListItem } from "./helpers";
|
|
|
|
import {
|
|
|
|
ulIcon,
|
|
|
|
olIcon,
|
|
|
|
listOptionsIcon,
|
|
|
|
justifyFullIcon,
|
|
|
|
justifyLeftIcon,
|
|
|
|
justifyRightIcon,
|
|
|
|
justifyCenterIcon,
|
|
|
|
indentIcon,
|
|
|
|
outdentIcon,
|
|
|
|
} from "./icons";
|
|
|
|
|
|
|
|
export let api = {};
|
|
|
|
|
|
|
|
function outdentListItem() {
|
|
|
|
const currentField = document.activeElement as EditingArea;
|
|
|
|
if (getListItem(currentField.shadowRoot!)) {
|
|
|
|
document.execCommand("outdent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function indentListItem() {
|
|
|
|
const currentField = document.activeElement as EditingArea;
|
|
|
|
if (getListItem(currentField.shadowRoot!)) {
|
|
|
|
document.execCommand("indent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-05-06 19:26:50 +02:00
|
|
|
<ButtonGroup {api}>
|
2021-05-06 01:58:14 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="insertUnorderedList"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() => document.queryCommandState("insertUnorderedList")}
|
2021-05-06 01:58:14 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 01:58:14 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingUnorderedList()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("insertUnorderedList");
|
2021-05-06 01:58:14 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 01:58:14 +02:00
|
|
|
{@html ulIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 01:58:14 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="insertOrderedList"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() => document.queryCommandState("insertOrderedList")}
|
2021-05-06 01:58:14 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 01:58:14 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingOrderedList()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("insertOrderedList");
|
2021-05-06 01:58:14 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 01:58:14 +02:00
|
|
|
{@html olIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithDropdownMenu let:createDropdown let:menuId>
|
2021-05-06 01:58:14 +02:00
|
|
|
<IconButton on:mount={createDropdown}>
|
|
|
|
{@html listOptionsIcon}
|
|
|
|
</IconButton>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonDropdown id={menuId}>
|
|
|
|
<ButtonToolbarItem id="justify">
|
|
|
|
<ButtonGroup>
|
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="justifyLeft"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() => document.queryCommandState("justifyLeft")}
|
2021-05-06 23:04:38 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingAlignLeft()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("justifyLeft");
|
2021-05-06 23:04:38 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html justifyLeftIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="justifyCenter"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() =>
|
|
|
|
document.queryCommandState("justifyCenter")}
|
2021-05-06 23:04:38 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingCenter()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("justifyCenter");
|
2021-05-06 23:04:38 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html justifyCenterIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="justifyRight"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() =>
|
|
|
|
document.queryCommandState("justifyRight")}
|
2021-05-06 23:04:38 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingAlignRight()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("justifyRight");
|
2021-05-06 23:04:38 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html justifyRightIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<WithState
|
|
|
|
key="justifyFull"
|
2021-05-26 01:21:33 +02:00
|
|
|
update={() => document.queryCommandState("justifyFull")}
|
2021-05-06 23:04:38 +02:00
|
|
|
let:state={active}
|
2021-05-26 01:21:33 +02:00
|
|
|
let:updateState
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
<IconButton
|
|
|
|
tooltip={tr.editingJustify()}
|
|
|
|
{active}
|
|
|
|
on:click={(event) => {
|
2021-05-26 01:21:33 +02:00
|
|
|
document.execCommand("justifyFull");
|
2021-05-06 23:04:38 +02:00
|
|
|
updateState(event);
|
2021-05-26 01:21:33 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html justifyFullIcon}
|
|
|
|
</IconButton>
|
|
|
|
</WithState>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
</ButtonGroup>
|
|
|
|
</ButtonToolbarItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonToolbarItem id="indentation">
|
|
|
|
<ButtonGroup>
|
|
|
|
<ButtonGroupItem>
|
|
|
|
<IconButton
|
|
|
|
on:click={outdentListItem}
|
2021-05-26 01:21:33 +02:00
|
|
|
tooltip={tr.editingOutdent()}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html outdentIcon}
|
|
|
|
</IconButton>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
|
2021-05-06 23:04:38 +02:00
|
|
|
<ButtonGroupItem>
|
|
|
|
<IconButton
|
|
|
|
on:click={indentListItem}
|
2021-05-26 01:21:33 +02:00
|
|
|
tooltip={tr.editingIndent()}
|
|
|
|
>
|
2021-05-06 23:04:38 +02:00
|
|
|
{@html indentIcon}
|
|
|
|
</IconButton>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
</ButtonGroup>
|
|
|
|
</ButtonToolbarItem>
|
|
|
|
</ButtonDropdown>
|
|
|
|
</WithDropdownMenu>
|
|
|
|
</ButtonGroupItem>
|
2021-04-28 02:27:38 +02:00
|
|
|
</ButtonGroup>
|