Skip to content

Commit

Permalink
Use the new CKEditor5 BBCode event API
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdesign committed Aug 9, 2023
1 parent a67d67a commit 8ecd0a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ts/WoltLabSuite/Core/Media/Manager/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ abstract class MediaManager<TOptions extends MediaManagerOptions = MediaManagerO
/**
* Handles clicks on the media manager button.
*/
protected _click(event: Event): void {
event.preventDefault();
protected _click(event?: Event): void {
event?.preventDefault();

UiDialog.open(this);
}
Expand Down
22 changes: 10 additions & 12 deletions ts/WoltLabSuite/Core/Media/Manager/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,18 @@ export class MediaManagerEditor extends MediaManager<MediaManagerEditorOptions>

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);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ecd0a1

Please sign in to comment.