diff --git a/ftl/core/editing.ftl b/ftl/core/editing.ftl
index 0b9283dae..fa0d3523b 100644
--- a/ftl/core/editing.ftl
+++ b/ftl/core/editing.ftl
@@ -1,3 +1,4 @@
+editing-actual-size = Actual size
editing-add-media = Add Media
editing-align-left = Align left
editing-align-right = Align right
@@ -17,7 +18,7 @@ editing-edit-html = Edit HTML
editing-fields = Fields
editing-float-left = Float left
editing-float-right = Float right
-editing-float-remove = Remove float
+editing-float-none = No float
editing-html-editor = HTML Editor
editing-indent = Increase indent
editing-italic-text = Italic text
diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel
index e71ee51c9..470777076 100644
--- a/ts/editor/BUILD.bazel
+++ b/ts/editor/BUILD.bazel
@@ -120,9 +120,12 @@ copy_mdi_icons(
"color-helper.svg",
# image handle
+ "format-float-none.svg",
"format-float-left.svg",
"format-float-right.svg",
- "close-circle-outline.svg",
+
+ "image-size-select-large.svg",
+ "image-size-select-actual.svg",
],
visibility = ["//visibility:public"],
)
diff --git a/ts/editor/ImageHandle.svelte b/ts/editor/ImageHandle.svelte
index f27acd1ff..d22184d13 100644
--- a/ts/editor/ImageHandle.svelte
+++ b/ts/editor/ImageHandle.svelte
@@ -4,13 +4,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
-{#if image}
+{#if image && imageRule}
+
+
+
{width}×{height} (Original: {naturalWidth}×{naturalHeight})
@@ -94,13 +104,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
@@ -131,12 +143,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
left: 3px;
}
+ .image-handle-size-select {
+ bottom: 3px;
+ left: 3px;
+ }
+
.image-handle-dimensions {
pointer-events: none;
user-select: none;
bottom: 3px;
right: 3px;
+ font-size: 13px;
background-color: rgba(0 0 0 / 0.3);
border-color: black;
border-radius: 0.25rem;
@@ -148,14 +166,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
height: 7px;
border: 1px solid black;
- &.is-active {
+ &.active {
background-color: black;
}
&.nightMode {
border-color: white;
- &.is-active {
+ &.active {
background-color: white;
}
}
@@ -181,7 +199,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
border-top: none;
border-right: none;
- &.is-active {
+ &.active {
cursor: sw-resize;
}
}
@@ -192,7 +210,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
border-top: none;
border-left: none;
- &.is-active {
+ &.active {
cursor: se-resize;
}
}
diff --git a/ts/editor/ImageHandleButtons.svelte b/ts/editor/ImageHandleButtons.svelte
index b393abb7e..704ce441b 100644
--- a/ts/editor/ImageHandleButtons.svelte
+++ b/ts/editor/ImageHandleButtons.svelte
@@ -10,13 +10,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
import IconButton from "components/IconButton.svelte";
- import { floatLeftIcon, floatRightIcon, resetIcon } from "./icons";
+ import { floatNoneIcon, floatLeftIcon, floatRightIcon } from "./icons";
export let float: string;
+
+ (float = "")}>{@html floatNoneIcon}
+
+
(float = "right")}>{@html floatRightIcon}
-
-
- (float = "")}>{@html resetIcon}
-
diff --git a/ts/editor/ImageHandleSizeSelect.svelte b/ts/editor/ImageHandleSizeSelect.svelte
new file mode 100644
index 000000000..8bd81c758
--- /dev/null
+++ b/ts/editor/ImageHandleSizeSelect.svelte
@@ -0,0 +1,51 @@
+
+
+
+
+
+ {@html icon}
+
+
diff --git a/ts/editor/editable-container.ts b/ts/editor/editable-container.ts
index e389f5ea0..444f04d3f 100644
--- a/ts/editor/editable-container.ts
+++ b/ts/editor/editable-container.ts
@@ -7,6 +7,8 @@
export class EditableContainer extends HTMLDivElement {
baseStyle: HTMLStyleElement;
+ baseRule?: CSSStyleRule;
+ imageRule?: CSSStyleRule;
constructor() {
super();
@@ -27,8 +29,16 @@ export class EditableContainer extends HTMLDivElement {
}
connectedCallback(): void {
- const baseStyleSheet = this.baseStyle.sheet as CSSStyleSheet;
- baseStyleSheet.insertRule("anki-editable {}", 0);
+ const sheet = this.baseStyle.sheet as CSSStyleSheet;
+ const baseIndex = sheet.insertRule("anki-editable {}");
+ this.baseRule = sheet.cssRules[baseIndex] as CSSStyleRule;
+
+ const imageIndex = sheet.insertRule("anki-editable img {}");
+ this.imageRule = sheet.cssRules[imageIndex] as CSSStyleRule;
+ this.imageRule.style.setProperty("width", "auto", "important");
+ this.imageRule.style.setProperty("height", "auto", "important");
+ this.imageRule.style.setProperty("max-width", "min(250px, 100%)", "important");
+ this.imageRule.style.setProperty("max-height", "min(250px, 100%)", "important");
}
initialize(color: string): void {
@@ -36,17 +46,17 @@ export class EditableContainer extends HTMLDivElement {
}
setBaseColor(color: string): void {
- const styleSheet = this.baseStyle.sheet as CSSStyleSheet;
- const firstRule = styleSheet.cssRules[0] as CSSStyleRule;
- firstRule.style.color = color;
+ if (this.baseRule) {
+ this.baseRule.style.color = color;
+ }
}
setBaseStyling(fontFamily: string, fontSize: string, direction: string): void {
- const styleSheet = this.baseStyle.sheet as CSSStyleSheet;
- const firstRule = styleSheet.cssRules[0] as CSSStyleRule;
- firstRule.style.fontFamily = fontFamily;
- firstRule.style.fontSize = fontSize;
- firstRule.style.direction = direction;
+ if (this.baseRule) {
+ this.baseRule.style.fontFamily = fontFamily;
+ this.baseRule.style.fontSize = fontSize;
+ this.baseRule.style.direction = direction;
+ }
}
isRightToLeft(): boolean {
diff --git a/ts/editor/editing-area.ts b/ts/editor/editing-area.ts
index ecee9ac1a..86d9868be 100644
--- a/ts/editor/editing-area.ts
+++ b/ts/editor/editing-area.ts
@@ -47,7 +47,9 @@ export class EditingArea extends HTMLDivElement {
this.imageHandle = new ImageHandle({
target: this,
anchor: this.editableContainer,
- props: { container: this.editable },
+ props: {
+ container: this.editable,
+ },
context,
} as any);
@@ -168,10 +170,12 @@ export class EditingArea extends HTMLDivElement {
if (event.target instanceof HTMLImageElement) {
(this.imageHandle as any).$set({
image: event.target,
+ imageRule: this.editableContainer.imageRule,
});
} else {
(this.imageHandle as any).$set({
image: null,
+ imageRule: null,
});
}
}
diff --git a/ts/editor/icons.ts b/ts/editor/icons.ts
index d80d5282a..00ae6776c 100644
--- a/ts/editor/icons.ts
+++ b/ts/editor/icons.ts
@@ -35,6 +35,9 @@ export const arrowIcon =
'
';
// image handle
+export { default as floatNoneIcon } from "./format-float-none.svg";
export { default as floatLeftIcon } from "./format-float-left.svg";
export { default as floatRightIcon } from "./format-float-right.svg";
-export { default as resetIcon } from "./close-circle-outline.svg";
+
+export { default as sizeActual } from "./image-size-select-actual.svg";
+export { default as sizeMinimized } from "./image-size-select-large.svg";