diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index f27fed0d5..a293c19c7 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -655,7 +655,7 @@ to a cloze type first, via Edit>Change Note Type."""
def addMedia(self, path, canDelete=False):
html = self._addMedia(path, canDelete)
- self.web.eval("setFormat('inserthtml', %s);" % json.dumps(html))
+ self.web.eval("insertHtmlRemovingInitialBR(%s);" % json.dumps(html))
def _addMedia(self, path, canDelete=False):
"Add to media folder and return local img or sound tag."
diff --git a/qt/ts/src/editor.ts b/qt/ts/src/editor.ts
index ae70a31ce..8efe4bf23 100644
--- a/qt/ts/src/editor.ts
+++ b/qt/ts/src/editor.ts
@@ -376,10 +376,10 @@ function hideDupes() {
$("#dupes").hide();
}
-let pasteHTML = function(html, internal, extendedMode) {
- html = filterHTML(html, internal, extendedMode);
+/// If the field has only an empty br, remove it first.
+let insertHtmlRemovingInitialBR = function(html: string) {
if (html !== "") {
- // remove trailing
in empty field
+ // remove
in empty field
if (currentField && currentField.innerHTML === "
") {
currentField.innerHTML = "";
}
@@ -387,6 +387,11 @@ let pasteHTML = function(html, internal, extendedMode) {
}
};
+let pasteHTML = function(html, internal, extendedMode) {
+ html = filterHTML(html, internal, extendedMode);
+ insertHtmlRemovingInitialBR(html);
+};
+
let filterHTML = function(html, internal, extendedMode) {
// wrap it in as we aren't allowed to change top level elements
const top = $.parseHTML("" + html + "")[0] as Element;