diff --git a/ts/components/StickyBottom.svelte b/ts/components/StickyBottom.svelte new file mode 100644 index 000000000..9546b83b9 --- /dev/null +++ b/ts/components/StickyBottom.svelte @@ -0,0 +1,26 @@ + + + + + + diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte new file mode 100644 index 000000000..6c97a51e3 --- /dev/null +++ b/ts/editor/TagEditor.svelte @@ -0,0 +1,11 @@ + + + + + Tags + diff --git a/ts/editor/index.ts b/ts/editor/index.ts index bdb0c7f03..4d9c159da 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -9,6 +9,9 @@ import "sveltelib/export-runtime"; import "lib/register-package"; +import type EditorToolbar from "./EditorToolbar.svelte"; +import type TagEditor from "./TagEditor.svelte"; + import { filterHTML } from "html-filter"; import { updateActiveButtons } from "./toolbar"; import { setupI18n, ModuleName } from "lib/i18n"; @@ -27,7 +30,7 @@ import { EditableContainer } from "./editable-container"; import { Editable } from "./editable"; import { Codable } from "./codable"; import { initToolbar, fieldFocused } from "./toolbar"; -import { getCurrentField } from "./helpers"; +import { initTagEditor } from "./tagEditor"; export { setNoteId, getNoteId } from "./note-id"; export { saveNow } from "./change-timer"; @@ -201,6 +204,5 @@ export const i18n = setupI18n({ ], }); -import type EditorToolbar from "./EditorToolbar.svelte"; - export const $editorToolbar: Promise = initToolbar(i18n); +export const $tagEditor: Promise = initTagEditor(i18n); diff --git a/ts/editor/tagEditor.ts b/ts/editor/tagEditor.ts new file mode 100644 index 000000000..c55ab6217 --- /dev/null +++ b/ts/editor/tagEditor.ts @@ -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): Promise { + let tagEditorResolve: (value: TagEditor) => void; + const tagEditorPromise = new Promise((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";