2021-03-30 01:23:39 +02:00
|
|
|
import IconButton from "./IconButton.svelte";
|
2021-04-08 16:29:28 +02:00
|
|
|
import type { IconButtonProps } from "./IconButton";
|
2021-04-01 00:45:02 +02:00
|
|
|
import DropdownMenu from "./DropdownMenu.svelte";
|
2021-04-08 16:29:28 +02:00
|
|
|
import type { DropdownMenuProps } from "./DropdownMenu";
|
2021-04-01 01:22:06 +02:00
|
|
|
import DropdownItem from "./DropdownItem.svelte";
|
2021-04-08 16:29:28 +02:00
|
|
|
import type { DropdownItemProps } from "./DropdownItem";
|
2021-04-01 01:22:06 +02:00
|
|
|
import WithDropdownMenu from "./WithDropdownMenu.svelte";
|
2021-04-08 16:29:28 +02:00
|
|
|
import type { WithDropdownMenuProps } from "./WithDropdownMenu";
|
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
|
|
|
|
|
|
|
import { bridgeCommand } from "anki/bridgecommand";
|
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-30 02:53:57 +02:00
|
|
|
|
2021-03-30 01:23:39 +02:00
|
|
|
import paperclipIcon from "./paperclip.svg";
|
|
|
|
import micIcon from "./mic.svg";
|
2021-03-30 02:53:57 +02:00
|
|
|
import bracketsIcon from "./code-brackets.svg";
|
|
|
|
import functionIcon from "./function-variant.svg";
|
|
|
|
import xmlIcon from "./xml.svg";
|
2021-03-30 01:53:27 +02:00
|
|
|
|
|
|
|
function onAttachment(): void {
|
|
|
|
bridgeCommand("attach");
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRecord(): void {
|
|
|
|
bridgeCommand("record");
|
|
|
|
}
|
|
|
|
|
2021-03-30 02:53:57 +02:00
|
|
|
function onCloze(): void {
|
|
|
|
bridgeCommand("cloze");
|
|
|
|
}
|
|
|
|
|
2021-03-31 03:34:08 +02:00
|
|
|
function onHtmlEdit(): void {
|
|
|
|
bridgeCommand("htmlEdit");
|
2021-03-30 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2021-04-08 16:29:28 +02:00
|
|
|
const iconButton = dynamicComponent(IconButton);
|
|
|
|
|
|
|
|
const withDropdownMenu = dynamicComponent(WithDropdownMenu);
|
|
|
|
const dropdownMenu = dynamicComponent(DropdownMenu);
|
|
|
|
const dropdownItem = dynamicComponent(DropdownItem);
|
|
|
|
|
2021-04-08 16:40:42 +02:00
|
|
|
const attachmentButton = iconButton<IconButtonProps, "tooltip">(
|
2021-04-01 01:38:50 +02:00
|
|
|
{
|
|
|
|
icon: paperclipIcon,
|
|
|
|
onClick: onAttachment,
|
|
|
|
},
|
|
|
|
{
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: tr.editingAttachPicturesaudiovideoF3,
|
2021-04-01 01:38:50 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-04-08 16:29:28 +02:00
|
|
|
const recordButton = iconButton(
|
|
|
|
{ icon: micIcon, onClick: onRecord },
|
2021-04-01 01:38:50 +02:00
|
|
|
{
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: tr.editingRecordAudioF5,
|
2021-04-01 01:38:50 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-04-08 16:40:42 +02:00
|
|
|
const clozeButton = iconButton<IconButtonProps, "tooltip">(
|
2021-04-01 01:38:50 +02:00
|
|
|
{
|
|
|
|
icon: bracketsIcon,
|
|
|
|
onClick: onCloze,
|
|
|
|
},
|
|
|
|
{
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: tr.editingClozeDeletionCtrlandshiftandc,
|
2021-04-01 01:38:50 +02:00
|
|
|
}
|
|
|
|
);
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-08 16:40:42 +02:00
|
|
|
const mathjaxButton = iconButton<Omit<IconButtonProps, "onClick" | "tooltip">>(
|
2021-04-08 16:29:28 +02:00
|
|
|
{
|
|
|
|
icon: functionIcon,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
2021-03-30 02:53:57 +02:00
|
|
|
|
2021-04-01 01:22:06 +02:00
|
|
|
const mathjaxMenuId = "mathjaxMenu";
|
|
|
|
|
2021-04-08 16:29:28 +02:00
|
|
|
const mathjaxMenu = dropdownMenu<DropdownMenuProps>(
|
|
|
|
{
|
|
|
|
id: mathjaxMenuId,
|
|
|
|
menuItems: [
|
|
|
|
dropdownItem<DropdownItemProps, "label">(
|
|
|
|
{
|
|
|
|
onClick: () => bridgeCommand("mathjaxInline"),
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: "test",
|
2021-04-08 16:29:28 +02:00
|
|
|
endLabel: "test",
|
|
|
|
},
|
|
|
|
{ label: tr.editingMathjaxInline }
|
|
|
|
),
|
|
|
|
dropdownItem<DropdownItemProps, "label">(
|
|
|
|
{
|
|
|
|
onClick: () => bridgeCommand("mathjaxBlock"),
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: "test",
|
2021-04-08 16:29:28 +02:00
|
|
|
endLabel: "test",
|
|
|
|
},
|
|
|
|
{ label: tr.editingMathjaxBlock }
|
|
|
|
),
|
|
|
|
dropdownItem<DropdownItemProps, "label">(
|
|
|
|
{
|
|
|
|
onClick: () => bridgeCommand("mathjaxChemistry"),
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: "test",
|
2021-04-08 16:29:28 +02:00
|
|
|
endLabel: "test",
|
|
|
|
},
|
|
|
|
{ label: tr.editingMathjaxChemistry }
|
|
|
|
),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
|
|
|
|
const mathjaxButtonWithMenu = withDropdownMenu<WithDropdownMenuProps>(
|
|
|
|
{
|
|
|
|
button: mathjaxButton,
|
|
|
|
menuId: mathjaxMenuId,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
|
2021-04-08 16:40:42 +02:00
|
|
|
const htmlButton = iconButton<IconButtonProps, "tooltip">(
|
2021-04-01 01:38:50 +02:00
|
|
|
{
|
|
|
|
icon: xmlIcon,
|
|
|
|
onClick: onHtmlEdit,
|
|
|
|
},
|
|
|
|
{
|
2021-04-08 16:40:42 +02:00
|
|
|
tooltip: tr.editingHtmlEditor,
|
2021-04-01 01:38:50 +02:00
|
|
|
}
|
|
|
|
);
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-08 18:28:43 +02:00
|
|
|
const buttonGroup = dynamicComponent(ButtonGroup);
|
|
|
|
export const templateGroup = buttonGroup<ButtonGroupProps>(
|
|
|
|
{
|
|
|
|
id: "template",
|
|
|
|
buttons: [
|
|
|
|
attachmentButton,
|
|
|
|
recordButton,
|
|
|
|
clozeButton,
|
|
|
|
mathjaxButtonWithMenu,
|
|
|
|
htmlButton,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
);
|
2021-04-01 00:45:02 +02:00
|
|
|
|
|
|
|
export const templateMenus = [mathjaxMenu];
|