Make editor-toolbar pass eslint

This commit is contained in:
Henrik Giesel 2021-04-15 02:49:46 +02:00
parent b0fab9c967
commit 60515f579e
6 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,7 @@
import IconButton from "./IconButton.svelte";
import type { IconButtonProps } from "./IconButton";
import { dynamicComponent } from "sveltelib/dynamicComponent";
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
import * as tr from "anki/i18n";
import bracketsIcon from "./code-brackets.svg";
@ -35,7 +35,7 @@ function onCloze(event: MouseEvent): void {
const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButton);
export function getClozeButton() {
export function getClozeButton(): DynamicSvelteComponent<typeof IconButton> & IconButtonProps {
return iconButton({
id: "cloze",
icon: bracketsIcon,

View File

@ -5,7 +5,7 @@ import type { ColorPickerProps } from "./ColorPicker";
import ButtonGroup from "./ButtonGroup.svelte";
import type { ButtonGroupProps } from "./ButtonGroup";
import { dynamicComponent } from "sveltelib/dynamicComponent";
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
import * as tr from "anki/i18n";
import squareFillIcon from "./square-fill.svg";
@ -29,7 +29,7 @@ const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButt
const colorPicker = dynamicComponent<typeof ColorPicker, ColorPickerProps>(ColorPicker);
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
export function getColorGroup() {
export function getColorGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
const forecolorButton = iconButton({
icon: squareFillIcon,
className: "forecolor",

View File

@ -3,7 +3,7 @@ import type { CommandIconButtonProps } from "./CommandIconButton";
import ButtonGroup from "./ButtonGroup.svelte";
import type { ButtonGroupProps } from "./ButtonGroup";
import { dynamicComponent } from "sveltelib/dynamicComponent";
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
import * as tr from "anki/i18n";
import boldIcon from "./type-bold.svg";
@ -19,7 +19,7 @@ const commandIconButton = dynamicComponent<
>(CommandIconButton);
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
export function getFormatGroup() {
export function getFormatGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
const boldButton = commandIconButton({
icon: boldIcon,
command: "bold",

View File

@ -23,15 +23,15 @@ interface Hideable {
hidden?: boolean;
}
function showComponent(component: Hideable) {
function showComponent(component: Hideable): void {
component.hidden = false;
}
function hideComponent(component: Hideable) {
function hideComponent(component: Hideable): void {
component.hidden = true;
}
function toggleComponent(component: Hideable) {
function toggleComponent(component: Hideable): void {
component.hidden = !component.hidden;
}
@ -97,14 +97,14 @@ class EditorToolbar extends HTMLElement {
this.updateButtonGroup<Hideable>(toggleComponent, group);
}
insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0) {
insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0): void {
this.buttons?.update((buttonGroups) => {
const newButtonGroup = buttonGroup(newGroup);
return insert(buttonGroups, newButtonGroup, group);
});
}
addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1) {
addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1): void {
this.buttons?.update((buttonGroups) => {
const newButtonGroup = buttonGroup(newGroup);
return add(buttonGroups, newButtonGroup, group);
@ -141,7 +141,7 @@ class EditorToolbar extends HTMLElement {
newButton: ToolbarItem & Identifiable,
group: string | number,
button: string | number = 0
) {
): void {
this.updateButtonGroup((component) => {
component.buttons = insert(
component.buttons as (ToolbarItem & Identifiable)[],
@ -155,7 +155,7 @@ class EditorToolbar extends HTMLElement {
newButton: ToolbarItem & Identifiable,
group: string | number,
button: string | number = -1
) {
): void {
this.updateButtonGroup((component) => {
component.buttons = add(
component.buttons as (ToolbarItem & Identifiable)[],

View File

@ -3,14 +3,14 @@ import type { LabelButtonProps } from "./LabelButton";
import ButtonGroup from "./ButtonGroup.svelte";
import type { ButtonGroupProps } from "./ButtonGroup";
import { dynamicComponent } from "sveltelib/dynamicComponent";
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
import { bridgeCommand } from "anki/bridgecommand";
import * as tr from "anki/i18n";
const labelButton = dynamicComponent<typeof LabelButton, LabelButtonProps>(LabelButton);
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
export function getNotetypeGroup() {
export function getNotetypeGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
const fieldsButton = labelButton({
onClick: () => bridgeCommand("fields"),
disables: false,

View File

@ -10,7 +10,7 @@ import ButtonGroup from "./ButtonGroup.svelte";
import type { ButtonGroupProps } from "./ButtonGroup";
import { bridgeCommand } from "anki/bridgecommand";
import { dynamicComponent } from "sveltelib/dynamicComponent";
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
import * as tr from "anki/i18n";
import paperclipIcon from "./paperclip.svg";
@ -47,7 +47,7 @@ const dropdownItem = dynamicComponent<typeof DropdownItem, DropdownItemProps>(
);
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
export function getTemplateGroup() {
export function getTemplateGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
const attachmentButton = iconButton({
icon: paperclipIcon,
onClick: onAttachment,
@ -88,7 +88,7 @@ export function getTemplateGroup() {
});
}
export function getTemplateMenus() {
export function getTemplateMenus(): (DynamicSvelteComponent<typeof DropdownMenu> & DropdownMenuProps)[] {
const mathjaxMenu = dropdownMenu({
id: mathjaxMenuId,
menuItems: [