From 991278b53ca647d4388bc7ada498a167208a0325 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 May 2023 19:10:37 +0200 Subject: [PATCH] Upcast `[wsm]` BBCode See WoltLab/editor#47 --- ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts | 11 +++++++++++ .../js/WoltLabSuite/Core/Component/Ckeditor/Media.js | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts index 169c41ba04..7e03fb0db1 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts @@ -45,6 +45,17 @@ function uploadMedia(element: HTMLElement, file: File, abortController?: AbortCo export function setup(element: HTMLElement): void { listenToCkeditor(element) .setupConfiguration(({ configuration, features }) => { + (configuration as any).woltlabMedia = { + resolveMediaUrl(mediaId: number, mediaSize: string) { + let thumbnail = ""; + if (mediaSize !== "original") { + thumbnail = `&thumbnail=${mediaSize}`; + } + + return `${window.WSC_API_URL}index.php?media/${mediaId}/${thumbnail}`; + }, + }; + if (features.attachment || !features.media) { return; } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Media.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Media.js index d765e5ec70..43e90320e5 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Media.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Media.js @@ -47,6 +47,15 @@ define(["require", "exports", "./Event"], function (require, exports, Event_1) { function setup(element) { (0, Event_1.listenToCkeditor)(element) .setupConfiguration(({ configuration, features }) => { + configuration.woltlabMedia = { + resolveMediaUrl(mediaId, mediaSize) { + let thumbnail = ""; + if (mediaSize !== "original") { + thumbnail = `&thumbnail=${mediaSize}`; + } + return `${window.WSC_API_URL}index.php?media/${mediaId}/${thumbnail}`; + }, + }; if (features.attachment || !features.media) { return; } -- 2.20.1