30bbbaf00b
* Make eslint sort our imports * fix missing deps in eslint rule (dae) Caught on Linux due to the stricter sandboxing * Remove exports-last eslint rule (for now?) * Adjust browserslist settings - We use ResizeObserver which is not supported in browsers like KaiOS, Baidu or Android UC * Raise minimum iOS version 13.4 - It's the first version that supports ResizeObserver * Apply new eslint rules to sort imports
97 lines
3.1 KiB
Svelte
97 lines
3.1 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script context="module" lang="ts">
|
|
import { resetAllState, updateAllState } from "../../components/WithState.svelte";
|
|
import type { DefaultSlotInterface } from "../../sveltelib/dynamic-slotting";
|
|
|
|
export function updateActiveButtons(event: Event) {
|
|
updateAllState(event);
|
|
}
|
|
|
|
export function clearActiveButtons() {
|
|
resetAllState(false);
|
|
}
|
|
|
|
export interface EditorToolbarAPI {
|
|
toolbar: DefaultSlotInterface;
|
|
notetypeButtons: DefaultSlotInterface;
|
|
formatInlineButtons: DefaultSlotInterface;
|
|
formatBlockButtons: DefaultSlotInterface;
|
|
colorButtons: DefaultSlotInterface;
|
|
templateButtons: DefaultSlotInterface;
|
|
}
|
|
|
|
/* Our dynamic components */
|
|
import AddonButtons from "./AddonButtons.svelte";
|
|
|
|
export const editorToolbar = {
|
|
AddonButtons,
|
|
};
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import ButtonToolbar from "../../components/ButtonToolbar.svelte";
|
|
import DynamicallySlottable from "../../components/DynamicallySlottable.svelte";
|
|
import Item from "../../components/Item.svelte";
|
|
import StickyContainer from "../../components/StickyContainer.svelte";
|
|
import ColorButtons from "./ColorButtons.svelte";
|
|
import FormatBlockButtons from "./FormatBlockButtons.svelte";
|
|
import FormatInlineButtons from "./FormatInlineButtons.svelte";
|
|
import NotetypeButtons from "./NotetypeButtons.svelte";
|
|
import TemplateButtons from "./TemplateButtons.svelte";
|
|
|
|
export let size: number;
|
|
export let wrap: boolean;
|
|
|
|
export let textColor: string;
|
|
export let highlightColor: string;
|
|
|
|
const toolbar = {};
|
|
const notetypeButtons = {};
|
|
const formatInlineButtons = {};
|
|
const formatBlockButtons = {};
|
|
const colorButtons = {};
|
|
const templateButtons = {};
|
|
|
|
export let api: Partial<EditorToolbarAPI> = {};
|
|
|
|
Object.assign(api, {
|
|
toolbar,
|
|
notetypeButtons,
|
|
formatInlineButtons,
|
|
formatBlockButtons,
|
|
colorButtons,
|
|
templateButtons,
|
|
} as EditorToolbarAPI);
|
|
</script>
|
|
|
|
<StickyContainer --gutter-block="0.1rem" --sticky-borders="0 0 1px">
|
|
<ButtonToolbar {size} {wrap}>
|
|
<DynamicallySlottable slotHost={Item} api={toolbar}>
|
|
<Item id="notetype">
|
|
<NotetypeButtons api={notetypeButtons}>
|
|
<slot name="notetypeButtons" />
|
|
</NotetypeButtons>
|
|
</Item>
|
|
|
|
<Item id="inlineFormatting">
|
|
<FormatInlineButtons api={formatInlineButtons} />
|
|
</Item>
|
|
|
|
<Item id="blockFormatting">
|
|
<FormatBlockButtons api={formatBlockButtons} />
|
|
</Item>
|
|
|
|
<Item id="color">
|
|
<ColorButtons {textColor} {highlightColor} api={colorButtons} />
|
|
</Item>
|
|
|
|
<Item id="template">
|
|
<TemplateButtons api={templateButtons} />
|
|
</Item>
|
|
</DynamicallySlottable>
|
|
</ButtonToolbar>
|
|
</StickyContainer>
|