anki/ts/editor/toolbar.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

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-27 23:08:47 +02:00
import EditorToolbar from "./EditorToolbar.svelte";
import "./bootstrap.css";
2021-04-27 23:08:47 +02:00
export function initToolbar(i18n: Promise<void>): Promise<EditorToolbar> {
let toolbarResolve: (value: EditorToolbar) => void;
const toolbarPromise = new Promise<EditorToolbar>((resolve) => {
toolbarResolve = resolve;
});
document.addEventListener("DOMContentLoaded", () => {
i18n.then(() => {
const target = document.body;
const anchor = document.getElementById("fields")!;
2021-04-27 23:08:47 +02:00
toolbarResolve(
new EditorToolbar({
target,
anchor,
props: {
nightMode: document.documentElement.classList.contains(
"night-mode"
),
},
})
);
});
});
return toolbarPromise;
}
2021-04-27 23:08:47 +02:00
/* Exports for editor */
// @ts-expect-error insufficient typing of svelte modules
export { enableButtons, disableButtons, updateActiveButtons, clearActiveButtons } from "./EditorToolbar.svelte";