Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix richtext image dialog overwriting classes on changing float from UI. Closes #3074.

Kailash Nadh5ad26fb599ce
diff --git a/static/admin/assets/js/richtext-editor.js b/static/admin/assets/js/richtext-editor.js
index bb300f8c..ccebb43a 100644
--- a/static/admin/assets/js/richtext-editor.js
+++ b/static/admin/assets/js/richtext-editor.js
@@ -493,7 +493,7 @@ class RichtextEditor extends HTMLElement {
// Update the existing image in place.
ed.saveUndoState();
img.setAttribute('src', src);
- for (const k of ['alt', 'width', 'height', 'class', 'data-embed']) {
+ for (const k of ['alt', 'width', 'height', 'data-embed']) {
if (attrs[k]) {
img.setAttribute(k, attrs[k]);
} else {
@@ -501,6 +501,12 @@ class RichtextEditor extends HTMLElement {
}
}
+ // Only replace the float classes managed by this dialog.
+ img.classList.remove('img-float-left', 'img-float-right');
+ if (f.float.value) {
+ img.classList.add(f.float.value);
+ }
+
this.sync();
} else {
ed.insertImage(src, attrs);