mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Add justify and indentation menu
This commit is contained in:
parent
5414d9f826
commit
48cc9c602f
1 changed files with 86 additions and 13 deletions
|
@ -1,14 +1,16 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
import ButtonDropdown from "./ButtonDropdown.svelte";
|
||||||
|
import type { ButtonDropdownProps } from "./ButtonDropdown";
|
||||||
|
import WithDropdownMenu from "./WithDropdownMenu.svelte";
|
||||||
|
import type { WithDropdownMenuProps } from "./WithDropdownMenu";
|
||||||
|
|
||||||
import CommandIconButton from "./CommandIconButton.svelte";
|
import CommandIconButton from "./CommandIconButton.svelte";
|
||||||
import type { CommandIconButtonProps } from "./CommandIconButton";
|
import type { CommandIconButtonProps } from "./CommandIconButton";
|
||||||
import IconButton from "./IconButton.svelte";
|
import IconButton from "./IconButton.svelte";
|
||||||
import type { IconButtonProps } from "./IconButton";
|
import type { IconButtonProps } from "./IconButton";
|
||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
|
||||||
import type { ButtonGroupProps } from "./ButtonGroup";
|
|
||||||
|
|
||||||
import type ButtonDropdown from "./ButtonDropdown.svelte";
|
|
||||||
import type { ButtonDropdownProps } from "./ButtonDropdown";
|
|
||||||
|
|
||||||
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
@ -17,7 +19,7 @@ import ulIcon from "./list-ul.svg";
|
||||||
import olIcon from "./list-ol.svg";
|
import olIcon from "./list-ol.svg";
|
||||||
import listOptionsIcon from "./text-paragraph.svg";
|
import listOptionsIcon from "./text-paragraph.svg";
|
||||||
|
|
||||||
import justifyIcon from "./justify.svg";
|
import justifyFullIcon from "./justify.svg";
|
||||||
import justifyLeftIcon from "./text-left.svg";
|
import justifyLeftIcon from "./text-left.svg";
|
||||||
import justifyRightIcon from "./text-right.svg";
|
import justifyRightIcon from "./text-right.svg";
|
||||||
import justifyCenterIcon from "./text-center.svg";
|
import justifyCenterIcon from "./text-center.svg";
|
||||||
|
@ -29,8 +31,79 @@ const commandIconButton = dynamicComponent<
|
||||||
typeof CommandIconButton,
|
typeof CommandIconButton,
|
||||||
CommandIconButtonProps
|
CommandIconButtonProps
|
||||||
>(CommandIconButton);
|
>(CommandIconButton);
|
||||||
const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButton);
|
|
||||||
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
||||||
|
const buttonDropdown = dynamicComponent<typeof ButtonDropdown, ButtonDropdownProps>(
|
||||||
|
ButtonDropdown
|
||||||
|
);
|
||||||
|
|
||||||
|
const withDropdownMenu = dynamicComponent<
|
||||||
|
typeof WithDropdownMenu,
|
||||||
|
WithDropdownMenuProps
|
||||||
|
>(WithDropdownMenu);
|
||||||
|
|
||||||
|
export function getFormatBlockMenus(): (DynamicSvelteComponent<typeof ButtonDropdown> &
|
||||||
|
ButtonDropdownProps)[] {
|
||||||
|
const justifyLeftButton = commandIconButton({
|
||||||
|
icon: justifyLeftIcon,
|
||||||
|
command: "justifyLeft",
|
||||||
|
tooltip: "Justify to the left",
|
||||||
|
});
|
||||||
|
|
||||||
|
const justifyCenterButton = commandIconButton({
|
||||||
|
icon: justifyCenterIcon,
|
||||||
|
command: "justifyCenter",
|
||||||
|
tooltip: "Justify to the center",
|
||||||
|
});
|
||||||
|
|
||||||
|
const justifyFullButton = commandIconButton({
|
||||||
|
icon: justifyFullIcon,
|
||||||
|
command: "justifyFull",
|
||||||
|
tooltip: "Justify full",
|
||||||
|
});
|
||||||
|
|
||||||
|
const justifyRightButton = commandIconButton({
|
||||||
|
icon: justifyRightIcon,
|
||||||
|
command: "justifyRight",
|
||||||
|
tooltip: "Justify to the right",
|
||||||
|
});
|
||||||
|
|
||||||
|
const justifyGroup = buttonGroup({
|
||||||
|
id: "justify",
|
||||||
|
buttons: [
|
||||||
|
justifyLeftButton,
|
||||||
|
justifyCenterButton,
|
||||||
|
justifyFullButton,
|
||||||
|
justifyRightButton,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const indentButton = commandIconButton({
|
||||||
|
icon: indentIcon,
|
||||||
|
command: "indent",
|
||||||
|
tooltip: "Indent selection",
|
||||||
|
});
|
||||||
|
|
||||||
|
const outdentButton = commandIconButton({
|
||||||
|
icon: outdentIcon,
|
||||||
|
command: "outdent",
|
||||||
|
tooltip: "Outdent selection",
|
||||||
|
});
|
||||||
|
|
||||||
|
const indentationGroup = buttonGroup({
|
||||||
|
id: "indentation",
|
||||||
|
buttons: [indentButton, outdentButton],
|
||||||
|
});
|
||||||
|
|
||||||
|
const formattingOptions = buttonDropdown({
|
||||||
|
id: "listFormatting",
|
||||||
|
buttons: [justifyGroup, indentationGroup],
|
||||||
|
});
|
||||||
|
|
||||||
|
return [formattingOptions];
|
||||||
|
}
|
||||||
|
|
||||||
|
const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButton);
|
||||||
|
|
||||||
export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
||||||
ButtonGroupProps {
|
ButtonGroupProps {
|
||||||
|
@ -51,13 +124,13 @@ export function getFormatBlockGroup(): DynamicSvelteComponent<typeof ButtonGroup
|
||||||
tooltip: "More list options",
|
tooltip: "More list options",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const listFormatting = withDropdownMenu({
|
||||||
|
button: listFormattingButton,
|
||||||
|
menuId: "listFormatting",
|
||||||
|
});
|
||||||
|
|
||||||
return buttonGroup({
|
return buttonGroup({
|
||||||
id: "formatInline",
|
id: "formatInline",
|
||||||
buttons: [ulButton, olButton, listFormattingButton],
|
buttons: [ulButton, olButton, listFormatting],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFormatBlockMenus(): (DynamicSvelteComponent<typeof ButtonDropdown> &
|
|
||||||
ButtonDropdownProps)[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue