<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script context="module" lang="typescript">
    import "./legacy.css";
    // @ts-expect-error Insufficient typing
    import { updateAllState, resetAllState } from "components/WithState.svelte";

    export function updateActiveButtons(event: Event) {
        updateAllState(event);
    }

    export function clearActiveButtons() {
        resetAllState(false);
    }

    /* Export components */
    import AddonButtons from "./AddonButtons.svelte";
    import PreviewButton from "./PreviewButton.svelte";
    import LabelButton from "components/LabelButton.svelte";
    import IconButton from "components/IconButton.svelte";

    export const editorToolbar = {
        AddonButtons,
        PreviewButton,
        LabelButton,
        IconButton,
    };
</script>

<script lang="typescript">
    import { isApplePlatform } from "lib/platform";
    import StickyBar from "components/StickyBar.svelte";
    import ButtonToolbar from "components/ButtonToolbar.svelte";
    import SectionItem from "components/SectionItem.svelte";

    import NoteTypeButtons from "./NoteTypeButtons.svelte";
    import FormatInlineButtons from "./FormatInlineButtons.svelte";
    import FormatBlockButtons from "./FormatBlockButtons.svelte";
    import ColorButtons from "./ColorButtons.svelte";
    import TemplateButtons from "./TemplateButtons.svelte";

    export let size = isApplePlatform() ? 1.6 : 2.0;
    export let wrap = true;

    export const toolbar = {};
    export const notetypeButtons = {};
    export const formatInlineButtons = {};
    export const formatBlockButtons = {};
    export const colorButtons = {};
    export const templateButtons = {};
</script>

<StickyBar>
    <ButtonToolbar {size} {wrap} api={toolbar}>
        <SectionItem id="notetype">
            <NoteTypeButtons api={notetypeButtons} />
        </SectionItem>

        <SectionItem id="inlineFormatting">
            <FormatInlineButtons api={formatInlineButtons} />
        </SectionItem>

        <SectionItem id="blockFormatting">
            <FormatBlockButtons api={formatBlockButtons} />
        </SectionItem>

        <SectionItem id="color">
            <ColorButtons api={colorButtons} />
        </SectionItem>

        <SectionItem id="template">
            <TemplateButtons api={templateButtons} />
        </SectionItem>
    </ButtonToolbar>
</StickyBar>
