diff --git a/ts/WoltLabSuite/Core/Media/Manager/Base.ts b/ts/WoltLabSuite/Core/Media/Manager/Base.ts index 8b6989d588f..03357f96e1c 100644 --- a/ts/WoltLabSuite/Core/Media/Manager/Base.ts +++ b/ts/WoltLabSuite/Core/Media/Manager/Base.ts @@ -106,8 +106,8 @@ abstract class MediaManager this._forceClipboard = true; - this._options.ckeditor?.sourceElement.addEventListener( - "ckeditor5:bbcode", - (event: CustomEvent<{ bbcode: string }>) => { - const { bbcode } = event.detail; - if (bbcode === "media") { - event.preventDefault(); - - this._click(event); - } - }, - ); - if (this._options.ckeditor !== undefined) { const ckeditor = this._options.ckeditor; + listenToCkeditor(ckeditor.sourceElement).bbcode(({ bbcode }) => { + if (bbcode !== "media") { + return false; + } + + this._click(); + + return true; + }); + if (!ckeditor.features.attachment) { listenToCkeditor(ckeditor.sourceElement).uploadMedia((payload) => { this._editorUpload(payload); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js index 3649ebef334..2ceb6f575e9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js @@ -75,7 +75,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../../Pe * Handles clicks on the media manager button. */ _click(event) { - event.preventDefault(); + event?.preventDefault(); UiDialog.open(this); } /** diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js index 08e868cef6c..054801ee859 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js @@ -29,15 +29,15 @@ define(["require", "exports", "tslib", "./Base", "../../Core", "../../Event/Hand }, options); super(options); this._forceClipboard = true; - this._options.ckeditor?.sourceElement.addEventListener("ckeditor5:bbcode", (event) => { - const { bbcode } = event.detail; - if (bbcode === "media") { - event.preventDefault(); - this._click(event); - } - }); if (this._options.ckeditor !== undefined) { const ckeditor = this._options.ckeditor; + (0, Event_1.listenToCkeditor)(ckeditor.sourceElement).bbcode(({ bbcode }) => { + if (bbcode !== "media") { + return false; + } + this._click(); + return true; + }); if (!ckeditor.features.attachment) { (0, Event_1.listenToCkeditor)(ckeditor.sourceElement).uploadMedia((payload) => { this._editorUpload(payload);