mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Mount TagEditor
This commit is contained in:
parent
9f0929db32
commit
f9b320e105
4 changed files with 84 additions and 3 deletions
26
ts/components/StickyBottom.svelte
Normal file
26
ts/components/StickyBottom.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<script lang="typescript">
|
||||||
|
export let id: string | undefined = undefined;
|
||||||
|
let className: string = "";
|
||||||
|
export { className as class };
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<footer {id} class={`container-fluid py-1 ${className}`}>
|
||||||
|
<slot />
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
background: var(--window-bg);
|
||||||
|
border-top: 1px solid var(--medium-border);
|
||||||
|
}
|
||||||
|
</style>
|
11
ts/editor/TagEditor.svelte
Normal file
11
ts/editor/TagEditor.svelte
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<script lang="typescript">
|
||||||
|
import StickyBottom from "components/StickyBottom.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<StickyBottom>
|
||||||
|
<span>Tags</span>
|
||||||
|
</StickyBottom>
|
|
@ -9,6 +9,9 @@
|
||||||
import "sveltelib/export-runtime";
|
import "sveltelib/export-runtime";
|
||||||
import "lib/register-package";
|
import "lib/register-package";
|
||||||
|
|
||||||
|
import type EditorToolbar from "./EditorToolbar.svelte";
|
||||||
|
import type TagEditor from "./TagEditor.svelte";
|
||||||
|
|
||||||
import { filterHTML } from "html-filter";
|
import { filterHTML } from "html-filter";
|
||||||
import { updateActiveButtons } from "./toolbar";
|
import { updateActiveButtons } from "./toolbar";
|
||||||
import { setupI18n, ModuleName } from "lib/i18n";
|
import { setupI18n, ModuleName } from "lib/i18n";
|
||||||
|
@ -27,7 +30,7 @@ import { EditableContainer } from "./editable-container";
|
||||||
import { Editable } from "./editable";
|
import { Editable } from "./editable";
|
||||||
import { Codable } from "./codable";
|
import { Codable } from "./codable";
|
||||||
import { initToolbar, fieldFocused } from "./toolbar";
|
import { initToolbar, fieldFocused } from "./toolbar";
|
||||||
import { getCurrentField } from "./helpers";
|
import { initTagEditor } from "./tagEditor";
|
||||||
|
|
||||||
export { setNoteId, getNoteId } from "./note-id";
|
export { setNoteId, getNoteId } from "./note-id";
|
||||||
export { saveNow } from "./change-timer";
|
export { saveNow } from "./change-timer";
|
||||||
|
@ -201,6 +204,5 @@ export const i18n = setupI18n({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
import type EditorToolbar from "./EditorToolbar.svelte";
|
|
||||||
|
|
||||||
export const $editorToolbar: Promise<EditorToolbar> = initToolbar(i18n);
|
export const $editorToolbar: Promise<EditorToolbar> = initToolbar(i18n);
|
||||||
|
export const $tagEditor: Promise<TagEditor> = initTagEditor(i18n);
|
||||||
|
|
42
ts/editor/tagEditor.ts
Normal file
42
ts/editor/tagEditor.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
/* eslint
|
||||||
|
@typescript-eslint/no-non-null-assertion: "off",
|
||||||
|
@typescript-eslint/no-explicit-any: "off",
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { disabledKey, nightModeKey } from "components/contextKeys";
|
||||||
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
|
import TagEditor from "./TagEditor.svelte";
|
||||||
|
import "./bootstrap.css";
|
||||||
|
|
||||||
|
const disabled = writable(false);
|
||||||
|
|
||||||
|
export function initTagEditor(i18n: Promise<void>): Promise<TagEditor> {
|
||||||
|
let tagEditorResolve: (value: TagEditor) => void;
|
||||||
|
const tagEditorPromise = new Promise<TagEditor>((resolve) => {
|
||||||
|
tagEditorResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () =>
|
||||||
|
i18n.then(() => {
|
||||||
|
const target = document.body;
|
||||||
|
const anchor = document.getElementById("fields")!;
|
||||||
|
|
||||||
|
const context = new Map();
|
||||||
|
context.set(disabledKey, disabled);
|
||||||
|
context.set(
|
||||||
|
nightModeKey,
|
||||||
|
document.documentElement.classList.contains("night-mode")
|
||||||
|
);
|
||||||
|
|
||||||
|
tagEditorResolve(new TagEditor({ target, anchor, context } as any));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return tagEditorPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export {} from "./TagEditor.svelte";
|
Loading…
Reference in a new issue