});
}
- protected insert(mediaList: Map<number, Media>, insertType: MediaInsertType, thumbnailSize: string): void {
+ protected insert(mediaList: Map<number, Media>, insertType: MediaInsertType, thumbnailSize?: string): void {
switch (insertType) {
case MediaInsertType.Separate: {
+ let sizeArgument = "";
+ if (thumbnailSize) {
+ sizeArgument = ` size="${thumbnailSize}"`;
+ }
+
const content = Array.from(mediaList.values())
- .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
+ .map((item) => `{{ media="${item.mediaID}"${sizeArgument} }}`)
.join("");
(this.element as any).codemirror.replaceSelection(content);
export interface MediaManagerEditorOptions extends MediaManagerOptions {
buttonClass?: string;
- callbackInsert: (media: Map<number, Media>, insertType: MediaInsertType, thumbnailSize: string) => void;
+ callbackInsert: (media: Map<number, Media>, insertType: MediaInsertType, thumbnailSize?: string) => void;
editor?: RedactorEditor;
}
}
if (this._options.callbackInsert !== null) {
- this._options.callbackInsert(this._mediaToInsert, MediaInsertType.Separate, thumbnailSize!);
+ this._options.callbackInsert(this._mediaToInsert, MediaInsertType.Separate, thumbnailSize);
} else {
this._options.editor!.buffer.set();
+
+ this._mediaToInsert.forEach((media) => this._insertMediaItem(thumbnailSize, media));
}
if (this._mediaToInsertByClipboard) {
/**
* Inserts a single media item into the editor.
*/
- protected _insertMediaItem(thumbnailSize: string, media: Media): void {
+ protected _insertMediaItem(thumbnailSize: string | undefined, media: Media): void {
if (media.isImage) {
let available = "";
["small", "medium", "large", "original"].some((size) => {
insert(mediaList, insertType, thumbnailSize) {
switch (insertType) {
case "separate" /* Separate */: {
+ let sizeArgument = "";
+ if (thumbnailSize) {
+ sizeArgument = ` size="${thumbnailSize}"`;
+ }
const content = Array.from(mediaList.values())
- .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
+ .map((item) => `{{ media="${item.mediaID}"${sizeArgument} }}`)
.join("");
this.element.codemirror.replaceSelection(content);
}
}
else {
this._options.editor.buffer.set();
+ this._mediaToInsert.forEach((media) => this._insertMediaItem(thumbnailSize, media));
}
if (this._mediaToInsertByClipboard) {
Clipboard.unmark("com.woltlab.wcf.media", Array.from(this._mediaToInsert.keys()));