Make editor-toolbar pass eslint
This commit is contained in:
parent
b0fab9c967
commit
60515f579e
@ -1,7 +1,7 @@
|
|||||||
import IconButton from "./IconButton.svelte";
|
import IconButton from "./IconButton.svelte";
|
||||||
import type { IconButtonProps } from "./IconButton";
|
import type { IconButtonProps } from "./IconButton";
|
||||||
|
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
|
||||||
import bracketsIcon from "./code-brackets.svg";
|
import bracketsIcon from "./code-brackets.svg";
|
||||||
@ -35,7 +35,7 @@ function onCloze(event: MouseEvent): void {
|
|||||||
|
|
||||||
const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButton);
|
const iconButton = dynamicComponent<typeof IconButton, IconButtonProps>(IconButton);
|
||||||
|
|
||||||
export function getClozeButton() {
|
export function getClozeButton(): DynamicSvelteComponent<typeof IconButton> & IconButtonProps {
|
||||||
return iconButton({
|
return iconButton({
|
||||||
id: "cloze",
|
id: "cloze",
|
||||||
icon: bracketsIcon,
|
icon: bracketsIcon,
|
||||||
|
@ -5,7 +5,7 @@ import type { ColorPickerProps } from "./ColorPicker";
|
|||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
import type { ButtonGroupProps } from "./ButtonGroup";
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
|
||||||
import squareFillIcon from "./square-fill.svg";
|
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 colorPicker = dynamicComponent<typeof ColorPicker, ColorPickerProps>(ColorPicker);
|
||||||
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
||||||
|
|
||||||
export function getColorGroup() {
|
export function getColorGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
|
||||||
const forecolorButton = iconButton({
|
const forecolorButton = iconButton({
|
||||||
icon: squareFillIcon,
|
icon: squareFillIcon,
|
||||||
className: "forecolor",
|
className: "forecolor",
|
||||||
|
@ -3,7 +3,7 @@ import type { CommandIconButtonProps } from "./CommandIconButton";
|
|||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
import type { ButtonGroupProps } from "./ButtonGroup";
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
|
||||||
import boldIcon from "./type-bold.svg";
|
import boldIcon from "./type-bold.svg";
|
||||||
@ -19,7 +19,7 @@ const commandIconButton = dynamicComponent<
|
|||||||
>(CommandIconButton);
|
>(CommandIconButton);
|
||||||
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
||||||
|
|
||||||
export function getFormatGroup() {
|
export function getFormatGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
|
||||||
const boldButton = commandIconButton({
|
const boldButton = commandIconButton({
|
||||||
icon: boldIcon,
|
icon: boldIcon,
|
||||||
command: "bold",
|
command: "bold",
|
||||||
|
@ -23,15 +23,15 @@ interface Hideable {
|
|||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showComponent(component: Hideable) {
|
function showComponent(component: Hideable): void {
|
||||||
component.hidden = false;
|
component.hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideComponent(component: Hideable) {
|
function hideComponent(component: Hideable): void {
|
||||||
component.hidden = true;
|
component.hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleComponent(component: Hideable) {
|
function toggleComponent(component: Hideable): void {
|
||||||
component.hidden = !component.hidden;
|
component.hidden = !component.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,14 +97,14 @@ class EditorToolbar extends HTMLElement {
|
|||||||
this.updateButtonGroup<Hideable>(toggleComponent, group);
|
this.updateButtonGroup<Hideable>(toggleComponent, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0) {
|
insertButtonGroup(newGroup: ButtonGroupProps, group: string | number = 0): void {
|
||||||
this.buttons?.update((buttonGroups) => {
|
this.buttons?.update((buttonGroups) => {
|
||||||
const newButtonGroup = buttonGroup(newGroup);
|
const newButtonGroup = buttonGroup(newGroup);
|
||||||
return insert(buttonGroups, newButtonGroup, group);
|
return insert(buttonGroups, newButtonGroup, group);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1) {
|
addButtonGroup(newGroup: ButtonGroupProps, group: string | number = -1): void {
|
||||||
this.buttons?.update((buttonGroups) => {
|
this.buttons?.update((buttonGroups) => {
|
||||||
const newButtonGroup = buttonGroup(newGroup);
|
const newButtonGroup = buttonGroup(newGroup);
|
||||||
return add(buttonGroups, newButtonGroup, group);
|
return add(buttonGroups, newButtonGroup, group);
|
||||||
@ -141,7 +141,7 @@ class EditorToolbar extends HTMLElement {
|
|||||||
newButton: ToolbarItem & Identifiable,
|
newButton: ToolbarItem & Identifiable,
|
||||||
group: string | number,
|
group: string | number,
|
||||||
button: string | number = 0
|
button: string | number = 0
|
||||||
) {
|
): void {
|
||||||
this.updateButtonGroup((component) => {
|
this.updateButtonGroup((component) => {
|
||||||
component.buttons = insert(
|
component.buttons = insert(
|
||||||
component.buttons as (ToolbarItem & Identifiable)[],
|
component.buttons as (ToolbarItem & Identifiable)[],
|
||||||
@ -155,7 +155,7 @@ class EditorToolbar extends HTMLElement {
|
|||||||
newButton: ToolbarItem & Identifiable,
|
newButton: ToolbarItem & Identifiable,
|
||||||
group: string | number,
|
group: string | number,
|
||||||
button: string | number = -1
|
button: string | number = -1
|
||||||
) {
|
): void {
|
||||||
this.updateButtonGroup((component) => {
|
this.updateButtonGroup((component) => {
|
||||||
component.buttons = add(
|
component.buttons = add(
|
||||||
component.buttons as (ToolbarItem & Identifiable)[],
|
component.buttons as (ToolbarItem & Identifiable)[],
|
||||||
|
@ -3,14 +3,14 @@ import type { LabelButtonProps } from "./LabelButton";
|
|||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
import type { ButtonGroupProps } from "./ButtonGroup";
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import { bridgeCommand } from "anki/bridgecommand";
|
import { bridgeCommand } from "anki/bridgecommand";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
|
||||||
const labelButton = dynamicComponent<typeof LabelButton, LabelButtonProps>(LabelButton);
|
const labelButton = dynamicComponent<typeof LabelButton, LabelButtonProps>(LabelButton);
|
||||||
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
||||||
|
|
||||||
export function getNotetypeGroup() {
|
export function getNotetypeGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
|
||||||
const fieldsButton = labelButton({
|
const fieldsButton = labelButton({
|
||||||
onClick: () => bridgeCommand("fields"),
|
onClick: () => bridgeCommand("fields"),
|
||||||
disables: false,
|
disables: false,
|
||||||
|
@ -10,7 +10,7 @@ import ButtonGroup from "./ButtonGroup.svelte";
|
|||||||
import type { ButtonGroupProps } from "./ButtonGroup";
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
||||||
|
|
||||||
import { bridgeCommand } from "anki/bridgecommand";
|
import { bridgeCommand } from "anki/bridgecommand";
|
||||||
import { dynamicComponent } from "sveltelib/dynamicComponent";
|
import { DynamicSvelteComponent, dynamicComponent } from "sveltelib/dynamicComponent";
|
||||||
import * as tr from "anki/i18n";
|
import * as tr from "anki/i18n";
|
||||||
|
|
||||||
import paperclipIcon from "./paperclip.svg";
|
import paperclipIcon from "./paperclip.svg";
|
||||||
@ -47,7 +47,7 @@ const dropdownItem = dynamicComponent<typeof DropdownItem, DropdownItemProps>(
|
|||||||
);
|
);
|
||||||
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
const buttonGroup = dynamicComponent<typeof ButtonGroup, ButtonGroupProps>(ButtonGroup);
|
||||||
|
|
||||||
export function getTemplateGroup() {
|
export function getTemplateGroup(): DynamicSvelteComponent<typeof ButtonGroup> & ButtonGroupProps {
|
||||||
const attachmentButton = iconButton({
|
const attachmentButton = iconButton({
|
||||||
icon: paperclipIcon,
|
icon: paperclipIcon,
|
||||||
onClick: onAttachment,
|
onClick: onAttachment,
|
||||||
@ -88,7 +88,7 @@ export function getTemplateGroup() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTemplateMenus() {
|
export function getTemplateMenus(): (DynamicSvelteComponent<typeof DropdownMenu> & DropdownMenuProps)[] {
|
||||||
const mathjaxMenu = dropdownMenu({
|
const mathjaxMenu = dropdownMenu({
|
||||||
id: mathjaxMenuId,
|
id: mathjaxMenuId,
|
||||||
menuItems: [
|
menuItems: [
|
||||||
|
Loading…
Reference in New Issue
Block a user