2021-03-30 01:23:39 +02:00
|
|
|
import IconButton from "./IconButton.svelte";
|
2021-04-01 00:45:02 +02:00
|
|
|
import DropdownMenu from "./DropdownMenu.svelte";
|
2021-04-01 01:22:06 +02:00
|
|
|
import DropdownItem from "./DropdownItem.svelte";
|
|
|
|
import WithDropdownMenu from "./WithDropdownMenu.svelte";
|
|
|
|
|
|
|
|
import { bridgeCommand } from "anki/bridgecommand";
|
2021-04-01 01:38:50 +02:00
|
|
|
import { withLazyProperties } from "anki/lazy";
|
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-01 01:38:50 +02:00
|
|
|
const attachmentButton = withLazyProperties(
|
|
|
|
{
|
|
|
|
component: IconButton,
|
|
|
|
icon: paperclipIcon,
|
|
|
|
onClick: onAttachment,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: tr.editingAttachPicturesaudiovideoF3,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const recordButton = withLazyProperties(
|
|
|
|
{ component: IconButton, icon: micIcon, onClick: onRecord },
|
|
|
|
{
|
|
|
|
title: tr.editingRecordAudioF5,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const clozeButton = withLazyProperties(
|
|
|
|
{
|
|
|
|
component: IconButton,
|
|
|
|
icon: bracketsIcon,
|
|
|
|
onClick: onCloze,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: tr.editingClozeDeletionCtrlandshiftandc,
|
|
|
|
}
|
|
|
|
);
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-01 00:45:02 +02:00
|
|
|
const mathjaxButton = {
|
2021-03-30 01:53:27 +02:00
|
|
|
component: IconButton,
|
2021-03-30 02:53:57 +02:00
|
|
|
icon: functionIcon,
|
2021-03-30 01:53:27 +02:00
|
|
|
};
|
2021-03-30 02:53:57 +02:00
|
|
|
|
2021-04-01 01:22:06 +02:00
|
|
|
const mathjaxMenuId = "mathjaxMenu";
|
|
|
|
|
2021-04-01 00:45:02 +02:00
|
|
|
const mathjaxMenu = {
|
|
|
|
component: DropdownMenu,
|
2021-04-01 01:22:06 +02:00
|
|
|
id: mathjaxMenuId,
|
|
|
|
menuItems: [
|
2021-04-01 01:38:50 +02:00
|
|
|
withLazyProperties(
|
|
|
|
{ component: DropdownItem, onClick: () => bridgeCommand("mathjaxInline") },
|
|
|
|
{ label: tr.editingMathjaxInline }
|
|
|
|
),
|
|
|
|
withLazyProperties(
|
|
|
|
{ component: DropdownItem, onClick: () => bridgeCommand("mathjaxBlock") },
|
|
|
|
{ label: tr.editingMathjaxBlock }
|
|
|
|
),
|
|
|
|
withLazyProperties(
|
|
|
|
{
|
|
|
|
component: DropdownItem,
|
|
|
|
onClick: () => bridgeCommand("mathjaxChemistry"),
|
|
|
|
},
|
|
|
|
{ label: tr.editingMathjaxChemistry }
|
|
|
|
),
|
2021-04-01 01:22:06 +02:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
const mathjaxButtonWithMenu = {
|
|
|
|
component: WithDropdownMenu,
|
|
|
|
button: mathjaxButton,
|
|
|
|
menuId: mathjaxMenuId,
|
2021-04-01 00:45:02 +02:00
|
|
|
};
|
|
|
|
|
2021-04-01 01:38:50 +02:00
|
|
|
const htmlButton = withLazyProperties(
|
|
|
|
{
|
|
|
|
component: IconButton,
|
|
|
|
icon: xmlIcon,
|
|
|
|
onClick: onHtmlEdit,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: tr.editingHtmlEditor,
|
|
|
|
}
|
|
|
|
);
|
2021-04-01 01:22:06 +02:00
|
|
|
|
2021-04-01 00:45:02 +02:00
|
|
|
export const templateButtons = [
|
|
|
|
attachmentButton,
|
|
|
|
recordButton,
|
|
|
|
clozeButton,
|
2021-04-01 01:22:06 +02:00
|
|
|
mathjaxButtonWithMenu,
|
2021-04-01 00:45:02 +02:00
|
|
|
htmlButton,
|
|
|
|
];
|
|
|
|
|
|
|
|
export const templateMenus = [mathjaxMenu];
|