mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
/**
|
|
* Code that is shared among all entry points in /ts/editor
|
|
*/
|
|
|
|
import "./legacy.scss";
|
|
import "./editor-base.scss";
|
|
import "@tslib/runtime-require";
|
|
import "$lib/sveltelib/export-runtime";
|
|
|
|
import { setupI18n } from "@tslib/i18n";
|
|
import { uiResolve } from "@tslib/ui";
|
|
|
|
import * as contextKeys from "$lib/components/context-keys";
|
|
import IconButton from "$lib/components/IconButton.svelte";
|
|
import LabelButton from "$lib/components/LabelButton.svelte";
|
|
import WithContext from "$lib/components/WithContext.svelte";
|
|
import WithState from "$lib/components/WithState.svelte";
|
|
|
|
import NoteEditor, * as editorContextKeys from "./NoteEditor.svelte";
|
|
|
|
declare global {
|
|
interface Selection {
|
|
addRange(r: Range): void;
|
|
removeAllRanges(): void;
|
|
getRangeAt(n: number): Range;
|
|
}
|
|
}
|
|
|
|
import { ModuleName } from "@tslib/i18n";
|
|
import { mount } from "svelte";
|
|
import type { EditorMode } from "./types";
|
|
|
|
export const editorModules = [
|
|
ModuleName.EDITING,
|
|
ModuleName.KEYBOARD,
|
|
ModuleName.ACTIONS,
|
|
ModuleName.BROWSING,
|
|
ModuleName.NOTETYPES,
|
|
ModuleName.IMPORTING,
|
|
ModuleName.UNDO,
|
|
];
|
|
|
|
export const components = {
|
|
IconButton,
|
|
LabelButton,
|
|
WithContext,
|
|
WithState,
|
|
contextKeys: { ...contextKeys, ...editorContextKeys },
|
|
};
|
|
|
|
export { editorToolbar } from "./editor-toolbar";
|
|
|
|
export async function setupEditor(mode: EditorMode) {
|
|
if (!["add", "browser", "current"].includes(mode)) {
|
|
alert("unexpected editor type");
|
|
return;
|
|
}
|
|
await setupI18n({ modules: editorModules });
|
|
mount(NoteEditor, { target: document.body, props: { uiResolve, mode } });
|
|
}
|