2021-03-30 06:14:00 +02:00
|
|
|
import CommandIconButton from "./CommandIconButton.svelte";
|
2021-04-08 16:29:28 +02:00
|
|
|
import type { CommandIconButtonProps } from "./CommandIconButton";
|
2021-04-08 18:28:43 +02:00
|
|
|
import ButtonGroup from "./ButtonGroup.svelte";
|
|
|
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-08 16:29:28 +02:00
|
|
|
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
2021-04-01 01:22:06 +02:00
|
|
|
import * as tr from "anki/i18n";
|
|
|
|
|
2021-03-29 21:05:30 +02:00
|
|
|
import boldIcon from "./type-bold.svg";
|
|
|
|
import italicIcon from "./type-italic.svg";
|
|
|
|
import underlineIcon from "./type-underline.svg";
|
|
|
|
import superscriptIcon from "./format-superscript.svg";
|
|
|
|
import subscriptIcon from "./format-subscript.svg";
|
|
|
|
import eraserIcon from "./eraser.svg";
|
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const commandIconButton = dynamicComponent<
|
|
|
|
typeof CommandIconButton,
|
|
|
|
CommandIconButtonProps
|
|
|
|
>(CommandIconButton);
|
|
|
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
2021-04-08 16:29:28 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
export function getFormatGroup() {
|
|
|
|
const boldButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: boldIcon,
|
|
|
|
command: "bold",
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingBoldTextCtrlandb(),
|
|
|
|
});
|
2021-03-29 21:05:30 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const italicButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: italicIcon,
|
|
|
|
command: "italic",
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingItalicTextCtrlandi(),
|
|
|
|
});
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const underlineButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: underlineIcon,
|
|
|
|
command: "underline",
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingUnderlineTextCtrlandu(),
|
|
|
|
});
|
2021-03-29 21:05:30 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const superscriptButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: superscriptIcon,
|
|
|
|
command: "superscript",
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingSuperscriptCtrlandand(),
|
|
|
|
});
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const subscriptButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: subscriptIcon,
|
|
|
|
command: "subscript",
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingSubscriptCtrland(),
|
|
|
|
});
|
2021-03-29 21:05:30 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
const removeFormatButton = commandIconButton({
|
2021-04-01 01:38:50 +02:00
|
|
|
icon: eraserIcon,
|
|
|
|
command: "removeFormat",
|
|
|
|
activatable: false,
|
2021-04-09 18:42:41 +02:00
|
|
|
tooltip: tr.editingRemoveFormattingCtrlandr(),
|
|
|
|
});
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-09 18:42:41 +02:00
|
|
|
return buttonGroup({
|
2021-04-08 22:11:50 +02:00
|
|
|
id: "format",
|
2021-04-08 18:28:43 +02:00
|
|
|
buttons: [
|
|
|
|
boldButton,
|
|
|
|
italicButton,
|
|
|
|
underlineButton,
|
|
|
|
superscriptButton,
|
|
|
|
subscriptButton,
|
|
|
|
removeFormatButton,
|
|
|
|
],
|
2021-04-09 18:42:41 +02:00
|
|
|
});
|
|
|
|
}
|