diff --git a/ts/editable/ResizableImage.svelte b/ts/editable/ResizableImage.svelte
deleted file mode 100644
index a95299793..000000000
--- a/ts/editable/ResizableImage.svelte
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
diff --git a/ts/editable/editable-base.scss b/ts/editable/editable-base.scss
index de754052e..54e9ef72c 100644
--- a/ts/editable/editable-base.scss
+++ b/ts/editable/editable-base.scss
@@ -26,3 +26,18 @@ p {
pre {
white-space: pre-wrap;
}
+
+// image size constraints
+img:not(.mathjax) {
+ &:not([data-editor-shrink="false"]) {
+ :host-context(.shrink-image) & {
+ max-width: var(--editor-default-max-width);
+ max-height: var(--editor-default-max-height);
+ }
+ }
+
+ &[data-editor-shrink="true"] {
+ max-width: var(--editor-shrink-max-width);
+ max-height: var(--editor-shrink-max-height);
+ }
+}
diff --git a/ts/editable/index.ts b/ts/editable/index.ts
index e9fbef038..b44eb6435 100644
--- a/ts/editable/index.ts
+++ b/ts/editable/index.ts
@@ -5,4 +5,3 @@ import "./editable-base.scss";
/* only imported for the CSS */
import "./ContentEditable.svelte";
import "./Mathjax.svelte";
-import "./ResizableImage.svelte";
diff --git a/ts/editor/image-overlay/ImageOverlay.svelte b/ts/editor/image-overlay/ImageOverlay.svelte
index 0178b2609..759e7dca3 100644
--- a/ts/editor/image-overlay/ImageOverlay.svelte
+++ b/ts/editor/image-overlay/ImageOverlay.svelte
@@ -24,25 +24,26 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import HandleControl from "../HandleControl.svelte";
import HandleLabel from "../HandleLabel.svelte";
import { context } from "../NoteEditor.svelte";
- import type { RichTextInputAPI } from "../rich-text-input";
- import {
- editingInputIsRichText,
- lifecycle as richTextLifecycle,
- } from "../rich-text-input";
+ import { editingInputIsRichText } from "../rich-text-input";
import FloatButtons from "./FloatButtons.svelte";
import SizeSelect from "./SizeSelect.svelte";
export let maxWidth: number;
export let maxHeight: number;
- richTextLifecycle.onMount(({ element }: RichTextInputAPI): void => {
- (async () => {
- const container = await element;
+ (<[string, number][]>[
+ ["--editor-shrink-max-width", maxWidth],
+ ["--editor-shrink-max-height", maxHeight],
+ ["--editor-default-max-width", maxWidth],
+ ["--editor-default-max-height", maxHeight],
+ ]).forEach(([prop, value]) =>
+ document.documentElement.style.setProperty(prop, `${value}px`),
+ );
- container.style.setProperty("--editor-shrink-max-width", `${maxWidth}px`);
- container.style.setProperty("--editor-shrink-max-height", `${maxHeight}px`);
- })();
- });
+ $: document.documentElement.classList.toggle(
+ "shrink-image",
+ $shrinkImagesByDefault,
+ );
const { focusedInput } = context.get();
@@ -83,24 +84,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
}
- $: {
- if ($shrinkImagesByDefault) {
- document.documentElement.style.setProperty(
- "--editor-default-max-width",
- `${maxWidth}px`,
- );
- document.documentElement.style.setProperty(
- "--editor-default-max-height",
- `${maxHeight}px`,
- );
- } else {
- document.documentElement.style.removeProperty("--editor-default-max-width");
- document.documentElement.style.removeProperty(
- "--editor-default-max-height",
- );
- }
- }
-
async function resetHandle(): Promise {
activeImage = null;
await tick();
@@ -265,6 +248,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
offset={20}
inline
hideIfReferenceHidden
+ portalTarget={document.body}
let:position={positionFloating}
on:close={async ({ detail }) => {
const { reason, originalEvent } = detail;