diff --git a/ts/change-notetype/change-notetype-base.scss b/ts/change-notetype/change-notetype-base.scss index c1dea6e4e..081bb3c5d 100644 --- a/ts/change-notetype/change-notetype-base.scss +++ b/ts/change-notetype/change-notetype-base.scss @@ -23,7 +23,8 @@ html { overflow-x: hidden; } -html, body { +html, +body { height: 100%; } diff --git a/ts/editor/image-overlay/ImageHandle.svelte b/ts/editor/image-overlay/ImageHandle.svelte index 0094ba9f8..1d412e758 100644 --- a/ts/editor/image-overlay/ImageHandle.svelte +++ b/ts/editor/image-overlay/ImageHandle.svelte @@ -3,11 +3,13 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> @@ -48,12 +51,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { placeCaretAfterContent } from "../../domlib/place-caret"; import ContentEditable from "../../editable/ContentEditable.svelte"; + import { promiseWithResolver } from "../../lib/promise"; + import { singleCallback } from "../../lib/typing"; + import useDOMMirror from "../../sveltelib/dom-mirror"; + import useInputHandler from "../../sveltelib/input-handler"; + import { pageTheme } from "../../sveltelib/theme"; import { context as editingAreaContext } from "../EditingArea.svelte"; import { context as noteEditorContext } from "../NoteEditor.svelte"; import getNormalizingNodeStore from "./normalizing-node-store"; import useRichTextResolve from "./rich-text-resolve"; import RichTextStyles from "./RichTextStyles.svelte"; - import SetContext from "./SetContext.svelte"; import { fragmentToStored, storedToFragment } from "./transform"; export let hidden: boolean; @@ -65,6 +72,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const [richTextPromise, resolve] = useRichTextResolve(); const { mirror, preventResubscription } = useDOMMirror(); const [inputHandler, setupInputHandler] = useInputHandler(); + const [customStyles, stylesResolve] = promiseWithResolver(); export function attachShadow(element: Element): void { element.attachShadow({ mode: "open" }); @@ -123,6 +131,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html preventResubscription, inputHandler, editable: {} as ContentEditableAPI, + customStyles, }; const allContexts = getAllContexts(); @@ -165,13 +174,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ), ); }); + + setContextProperty(api); + setupLifecycleHooks(api);
($focusedInput = api)}>
-
- {#await Promise.all( [richTextPromise, stylesPromise], ) then [container, styles]} - - - - {/await} -
+ {#await Promise.all([richTextPromise, stylesDidLoad]) then _} +
+ +
+ {/await}
diff --git a/ts/editor/rich-text-input/RichTextStyles.svelte b/ts/editor/rich-text-input/RichTextStyles.svelte index f98e8484e..9679a3939 100644 --- a/ts/editor/rich-text-input/RichTextStyles.svelte +++ b/ts/editor/rich-text-input/RichTextStyles.svelte @@ -11,15 +11,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import type { StyleLinkType, StyleObject } from "./CustomStyles.svelte"; import CustomStyles from "./CustomStyles.svelte"; - const [promise, customStylesResolve] = promiseWithResolver(); + export let callback: (styles: CustomStyles) => void; + const [userBaseStyle, userBaseResolve] = promiseWithResolver(); const [userBaseRule, userBaseRuleResolve] = promiseWithResolver(); - const stylesDidLoad: Promise = Promise.all([ - promise, - userBaseStyle, - userBaseRule, - ]); + const stylesDidLoad: Promise = Promise.all([userBaseStyle, userBaseRule]); userBaseStyle.then((baseStyle: StyleObject) => { const sheet = baseStyle.element.sheet as CSSStyleSheet; @@ -56,9 +53,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html props: { styles }, }); - customStyles.addStyleTag("userBase").then(userBaseResolve); - customStylesResolve(customStyles); + customStyles.addStyleTag("userBase").then((styleTag) => { + userBaseResolve(styleTag); + callback(customStyles); + }); } - + diff --git a/ts/editor/rich-text-input/SetContext.svelte b/ts/editor/rich-text-input/SetContext.svelte deleted file mode 100644 index 618dd1a6f..000000000 --- a/ts/editor/rich-text-input/SetContext.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/ts/lib/runtime-require.ts b/ts/lib/runtime-require.ts index 262ce777d..00ef9a018 100644 --- a/ts/lib/runtime-require.ts +++ b/ts/lib/runtime-require.ts @@ -18,6 +18,7 @@ type AnkiPackages = | "anki/NoteEditor" | "anki/EditorField" | "anki/PlainTextInput" + | "anki/RichTextInput" | "anki/TemplateButtons" | "anki/packages" | "anki/bridgecommand"