/**
* Handles clicks on the media manager button.
*/
- protected _click(event: Event): void {
- event.preventDefault();
+ protected _click(event?: Event): void {
+ event?.preventDefault();
UiDialog.open(this);
}
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);
* Handles clicks on the media manager button.
*/
_click(event) {
- event.preventDefault();
+ event?.preventDefault();
UiDialog.open(this);
}
/**
}, 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);