});
}
insert(mediaList, insertType, thumbnailSize) {
- let content;
- if (insertType === "gallery") {
- const mediaIds = Array.from(mediaList.values()).map((item) => item.mediaID);
- content = `{{ mediaGallery="${mediaIds.join(",")}" }}`;
+ switch (insertType) {
+ case "separate" /* Separate */: {
+ const content = Array.from(mediaList.values())
+ .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
+ .join("");
+ this.element.codemirror.replaceSelection(content);
+ }
}
- else {
- content = Array.from(mediaList.values())
- .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
- .join("");
- }
- this.element.codemirror.replaceSelection(content);
}
}
Core.enableLegacyInheritance(AcpUiCodeMirrorMedia);
thumbnailSize = thumbnailSizeSelect.value;
}
if (this._options.callbackInsert !== null) {
- this._options.callbackInsert(this._mediaToInsert, "separate", thumbnailSize);
+ this._options.callbackInsert(this._mediaToInsert, "separate" /* Separate */, thumbnailSize);
}
else {
this._options.editor.buffer.set();
-import { Media } from "../../../Media/Data";
+import { Media, MediaInsertType } from "../../../Media/Data";
import MediaManagerEditor from "../../../Media/Manager/Editor";
import * as Core from "../../../Core";
});
}
- protected insert(mediaList: Map<number, Media>, insertType: string, thumbnailSize: string): void {
- let content: string;
+ protected insert(mediaList: Map<number, Media>, insertType: MediaInsertType, thumbnailSize: string): void {
+ switch (insertType) {
+ case MediaInsertType.Separate: {
+ const content = Array.from(mediaList.values())
+ .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
+ .join("");
- if (insertType === "gallery") {
- const mediaIds = Array.from(mediaList.values()).map((item) => item.mediaID);
-
- content = `{{ mediaGallery="${mediaIds.join(",")}" }}`;
- } else {
- content = Array.from(mediaList.values())
- .map((item) => `{{ media="${item.mediaID}" size="${thumbnailSize}" }}`)
- .join("");
+ (this.element as any).codemirror.replaceSelection(content);
+ }
}
-
- (this.element as any).codemirror.replaceSelection(content);
}
}
minSearchLength: number;
}
+export const enum MediaInsertType {
+ Separate = "separate",
+}
+
export interface MediaManagerEditorOptions extends MediaManagerOptions {
buttonClass?: string;
- callbackInsert: (media: Map<number, Media>, insertType: string, thumbnailSize: string) => void;
+ callbackInsert: (media: Map<number, Media>, insertType: MediaInsertType, thumbnailSize: string) => void;
editor?: RedactorEditor;
}
import MediaManager from "./Base";
import * as Core from "../../Core";
-import { Media, MediaManagerEditorOptions, MediaUploadSuccessEventData } from "../Data";
+import { Media, MediaInsertType, MediaManagerEditorOptions, MediaUploadSuccessEventData } from "../Data";
import * as EventHandler from "../../Event/Handler";
import * as DomTraverse from "../../Dom/Traverse";
import * as Language from "../../Language";
}
if (this._options.callbackInsert !== null) {
- this._options.callbackInsert(this._mediaToInsert, "separate", thumbnailSize!);
+ this._options.callbackInsert(this._mediaToInsert, MediaInsertType.Separate, thumbnailSize!);
} else {
this._options.editor!.buffer.set();
}