mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 17:26:36 -04:00
Move initialization logic from EditorToolbar to index.ts
This commit is contained in:
parent
bf433f13be
commit
2f808fe60c
4 changed files with 61 additions and 42 deletions
|
@ -1,8 +1,10 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript" context="module">
|
||||||
type Buttons =
|
export type Buttons =
|
||||||
| { component: SvelteComponent; [...arg: string]: unknown }
|
| { component: SvelteComponent; [...arg: string]: unknown }
|
||||||
| Buttons[];
|
| Buttons[];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="typescript">
|
||||||
export let buttons: Buttons;
|
export let buttons: Buttons;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,8 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import ButtonGroup from "./ButtonGroup.svelte";
|
import ButtonGroup from "./ButtonGroup.svelte";
|
||||||
|
import type { Buttons } from "./ButtonGroup.svelte";
|
||||||
|
|
||||||
import LabelButton from "./LabelButton.svelte";
|
export let buttons: Buttons = [];
|
||||||
import IconButton from "./IconButton.svelte";
|
|
||||||
|
|
||||||
import bracketsIcon from "./code-brackets.svg";
|
|
||||||
|
|
||||||
import paperclipIcon from "./paperclip.svg";
|
|
||||||
import micIcon from "./mic.svg";
|
|
||||||
import threeDotsIcon from "./three-dots.svg";
|
|
||||||
|
|
||||||
import {
|
|
||||||
boldButton,
|
|
||||||
italicButton,
|
|
||||||
underlineButton,
|
|
||||||
superscriptButton,
|
|
||||||
subscriptButton,
|
|
||||||
eraserButton,
|
|
||||||
} from "./format";
|
|
||||||
import { forecolorButton, colorpickerButton } from "./color";
|
|
||||||
|
|
||||||
export let buttons = [
|
|
||||||
[
|
|
||||||
{ component: LabelButton, label: "Fields..." },
|
|
||||||
{ component: LabelButton, label: "Cards..." },
|
|
||||||
],
|
|
||||||
[
|
|
||||||
boldButton,
|
|
||||||
italicButton,
|
|
||||||
underlineButton,
|
|
||||||
superscriptButton,
|
|
||||||
subscriptButton,
|
|
||||||
eraserButton,
|
|
||||||
],
|
|
||||||
[forecolorButton, colorpickerButton],
|
|
||||||
[
|
|
||||||
{ component: IconButton, icon: bracketsIcon },
|
|
||||||
{ component: IconButton, icon: paperclipIcon },
|
|
||||||
{ component: IconButton, icon: micIcon },
|
|
||||||
{ component: IconButton, icon: threeDotsIcon },
|
|
||||||
],
|
|
||||||
];
|
|
||||||
export let nightMode: boolean;
|
export let nightMode: boolean;
|
||||||
|
|
||||||
console.log(nightMode);
|
console.log(nightMode);
|
||||||
|
@ -58,6 +20,18 @@
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
|
||||||
background: var(--bg-color);
|
background: var(--bg-color);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
|
||||||
|
/* Remove most outer marigns */
|
||||||
|
& > :global(ul) {
|
||||||
|
& > :global(li:nth-child(1)) {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > :global(li:nth-last-child(1)) {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
10
ts/editor-toolbar/extra.ts
Normal file
10
ts/editor-toolbar/extra.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import IconButton from "./IconButton.svelte";
|
||||||
|
import bracketsIcon from "./code-brackets.svg";
|
||||||
|
import paperclipIcon from "./paperclip.svg";
|
||||||
|
import micIcon from "./mic.svg";
|
||||||
|
import threeDotsIcon from "./three-dots.svg";
|
||||||
|
|
||||||
|
export const clozeButton = { component: IconButton, icon: bracketsIcon };
|
||||||
|
export const attachmentButton = { component: IconButton, icon: paperclipIcon };
|
||||||
|
export const micButton = { component: IconButton, icon: micIcon };
|
||||||
|
export const etcButton = { component: IconButton, icon: threeDotsIcon };
|
|
@ -2,6 +2,38 @@ import type { SvelteComponent } from "svelte";
|
||||||
import { checkNightMode } from "anki/nightmode";
|
import { checkNightMode } from "anki/nightmode";
|
||||||
import EditorToolbarSvelte from "./EditorToolbar.svelte";
|
import EditorToolbarSvelte from "./EditorToolbar.svelte";
|
||||||
|
|
||||||
|
import LabelButton from "./LabelButton.svelte";
|
||||||
|
|
||||||
|
import {
|
||||||
|
boldButton,
|
||||||
|
italicButton,
|
||||||
|
underlineButton,
|
||||||
|
superscriptButton,
|
||||||
|
subscriptButton,
|
||||||
|
eraserButton,
|
||||||
|
} from "./format";
|
||||||
|
|
||||||
|
import { forecolorButton, colorpickerButton } from "./color";
|
||||||
|
|
||||||
|
import { clozeButton, attachmentButton, micButton, etcButton } from "./extra";
|
||||||
|
|
||||||
|
const defaultButtons = [
|
||||||
|
[
|
||||||
|
{ component: LabelButton, label: "Fields..." },
|
||||||
|
{ component: LabelButton, label: "Cards..." },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
boldButton,
|
||||||
|
italicButton,
|
||||||
|
underlineButton,
|
||||||
|
superscriptButton,
|
||||||
|
subscriptButton,
|
||||||
|
eraserButton,
|
||||||
|
],
|
||||||
|
[forecolorButton, colorpickerButton],
|
||||||
|
[clozeButton, attachmentButton, micButton, etcButton],
|
||||||
|
];
|
||||||
|
|
||||||
class EditorToolbar extends HTMLElement {
|
class EditorToolbar extends HTMLElement {
|
||||||
component?: SvelteComponent;
|
component?: SvelteComponent;
|
||||||
|
|
||||||
|
@ -12,6 +44,7 @@ class EditorToolbar extends HTMLElement {
|
||||||
target: this,
|
target: this,
|
||||||
props: {
|
props: {
|
||||||
nightMode,
|
nightMode,
|
||||||
|
buttons: defaultButtons,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue