Bad access the editor from within a dialog
authorAlexander Ebert <ebert@woltlab.com>
Sat, 28 May 2022 12:40:49 +0000 (14:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 28 May 2022 12:40:49 +0000 (14:40 +0200)
See https://www.woltlab.com/community/thread/295640-%C3%BCber-medien-hinzugef%C3%BCgtes-bild-l%C3%A4sst-sich-nach-der-entfernung-nicht-direkt-erneu/

ts/WoltLabSuite/Core/Media/Manager/Editor.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js

index be26f19e56d3599660e9f1700e526757bb323b8c..82172a174d8062da04172bbb4008c1507ac71061 100644 (file)
@@ -266,11 +266,17 @@ class MediaManagerEditor extends MediaManager<MediaManagerEditorOptions> {
         link = media[thumbnailSize + "ThumbnailLink"];
       }
 
-      this._options.editor!.insert.html(
-        `<img src="${link}" class="woltlabSuiteMedia" data-media-id="${media.mediaID}" data-media-size="${thumbnailSize}">`,
-      );
+      Core.interactWithRedactor(() => {
+        this._options.editor!.insert.html(
+          `<img src="${link}" class="woltlabSuiteMedia" data-media-id="${
+            media.mediaID
+          }" data-media-size="${thumbnailSize!}">`,
+        );
+      });
     } else {
-      this._options.editor!.insert.text(`[wsm='${media.mediaID}'][/wsm]`);
+      Core.interactWithRedactor(() => {
+        this._options.editor!.insert.text(`[wsm='${media.mediaID}'][/wsm]`);
+      });
     }
   }
 
index 38a612e5aad7b59c800d94213009bd0313e049e3..e97a0f042f9fc382080cfb83e471f48ddff484ad 100644 (file)
@@ -205,10 +205,14 @@ define(["require", "exports", "tslib", "./Base", "../../Core", "../../Event/Hand
                 if (thumbnailSize !== "original") {
                     link = media[thumbnailSize + "ThumbnailLink"];
                 }
-                this._options.editor.insert.html(`<img src="${link}" class="woltlabSuiteMedia" data-media-id="${media.mediaID}" data-media-size="${thumbnailSize}">`);
+                Core.interactWithRedactor(() => {
+                    this._options.editor.insert.html(`<img src="${link}" class="woltlabSuiteMedia" data-media-id="${media.mediaID}" data-media-size="${thumbnailSize}">`);
+                });
             }
             else {
-                this._options.editor.insert.text(`[wsm='${media.mediaID}'][/wsm]`);
+                Core.interactWithRedactor(() => {
+                    this._options.editor.insert.text(`[wsm='${media.mediaID}'][/wsm]`);
+                });
             }
         }
         /**