2021-04-20 15:43:59 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
2021-04-23 18:53:52 +02:00
|
|
|
import type { ToolbarItem, IterableToolbarItem } from "editor-toolbar/types";
|
2021-04-20 15:32:02 +02:00
|
|
|
import type { Writable } from "svelte/store";
|
|
|
|
|
|
|
|
import { getNotetypeGroup } from "./notetype";
|
|
|
|
import { getFormatInlineGroup } from "./formatInline";
|
|
|
|
import { getFormatBlockGroup, getFormatBlockMenus } from "./formatBlock";
|
|
|
|
import { getColorGroup } from "./color";
|
|
|
|
import { getTemplateGroup, getTemplateMenus } from "./template";
|
|
|
|
|
|
|
|
export function initToolbar(i18n: Promise<void>): void {
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
i18n.then(() => {
|
|
|
|
globalThis.$editorToolbar.buttonsPromise.then(
|
|
|
|
(
|
2021-04-23 18:53:52 +02:00
|
|
|
buttons: Writable<IterableToolbarItem[]>
|
|
|
|
): Writable<IterableToolbarItem[]> => {
|
2021-04-20 15:32:02 +02:00
|
|
|
buttons.update(() => [
|
|
|
|
getNotetypeGroup(),
|
|
|
|
getFormatInlineGroup(),
|
|
|
|
getFormatBlockGroup(),
|
|
|
|
getColorGroup(),
|
|
|
|
getTemplateGroup(),
|
|
|
|
]);
|
|
|
|
return buttons;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
globalThis.$editorToolbar.menusPromise.then(
|
|
|
|
(menus: Writable<ToolbarItem[]>): Writable<ToolbarItem[]> => {
|
|
|
|
menus.update(() => [
|
|
|
|
...getFormatBlockMenus(),
|
|
|
|
...getTemplateMenus(),
|
|
|
|
]);
|
|
|
|
return menus;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|