DomChangeListener = tslib_1.__importStar(DomChangeListener);
Clipboard = tslib_1.__importStar(Clipboard);
const _mediaEditor = new Editor_1.default({
- _editorSuccess: function (media, oldCategoryId) {
+ _editorSuccess: (media, oldCategoryId) => {
if (media.categoryID != oldCategoryId) {
- window.setTimeout(function () {
+ window.setTimeout(() => {
window.location.reload();
}, 500);
}
*/
_initEditor(content, data) {
this._availableLanguageCount = ~~data.returnValues.availableLanguageCount;
- this._categoryIds = data.returnValues.categoryIDs.map((number) => number);
+ this._categoryIds = data.returnValues.categoryIDs.map((number) => ~~number);
if (data.returnValues.mediaData) {
this._media = data.returnValues.mediaData;
}
+ const mediaId = this._media.mediaID;
// make sure that the language chooser is initialized first
setTimeout(() => {
+ var _a, _b, _c;
if (this._availableLanguageCount > 1) {
- LanguageChooser.setLanguageId(`mediaEditor_${this._media.mediaID}_languageID`, this._media.languageID || window.LANGUAGE_ID);
+ LanguageChooser.setLanguageId(`mediaEditor_${mediaId}_languageID`, this._media.languageID || window.LANGUAGE_ID);
}
if (this._categoryIds.length) {
const categoryID = content.querySelector("select[name=categoryID]");
const title = content.querySelector("input[name=title]");
const altText = content.querySelector("input[name=altText]");
const caption = content.querySelector("textarea[name=caption]");
- const mediaId = this._media.mediaID;
if (this._availableLanguageCount > 1 && this._media.isMultilingual) {
if (document.getElementById(`altText_${mediaId}`)) {
- LanguageInput.setValues(`altText_${this._media.mediaID}`, (this._media.altText || {}));
+ LanguageInput.setValues(`altText_${mediaId}`, (this._media.altText || {}));
}
if (document.getElementById(`caption_${mediaId}`)) {
- LanguageInput.setValues(`caption_${this._media.mediaID}`, (this._media.caption || {}));
+ LanguageInput.setValues(`caption_${mediaId}`, (this._media.caption || {}));
}
- LanguageInput.setValues(`title_${this._media.mediaID}`, (this._media.title || {}));
+ LanguageInput.setValues(`title_${mediaId}`, (this._media.title || {}));
}
else {
- title.value = this._media.title ? this._media.title[this._media.languageID || window.LANGUAGE_ID] : "";
+ title.value = ((_a = this._media) === null || _a === void 0 ? void 0 : _a.title[this._media.languageID || window.LANGUAGE_ID]) || "";
if (altText) {
- altText.value = this._media.altText
- ? this._media.altText[this._media.languageID || window.LANGUAGE_ID]
- : "";
+ altText.value = ((_b = this._media) === null || _b === void 0 ? void 0 : _b.altText[this._media.languageID || window.LANGUAGE_ID]) || "";
}
if (caption) {
- caption.value = this._media.caption
- ? this._media.caption[this._media.languageID || window.LANGUAGE_ID]
- : "";
+ caption.value = ((_c = this._media) === null || _c === void 0 ? void 0 : _c.caption[this._media.languageID || window.LANGUAGE_ID]) || "";
}
}
if (this._availableLanguageCount > 1) {
content.querySelector("button[data-type=submit]").addEventListener("click", () => this._saveData());
// remove focus from input elements and scroll dialog to top
document.activeElement.blur();
- document.getElementById(`mediaEditor_${this._media.mediaID}`).parentNode.scrollTop = 0;
+ document.getElementById(`mediaEditor_${mediaId}`).parentNode.scrollTop = 0;
// Initialize button to replace media file.
const uploadButton = content.querySelector(".mediaManagerMediaReplaceButton");
let target = content.querySelector(".mediaThumbnail");
target = document.createElement("div");
content.appendChild(target);
}
- new Replace_1.default(~~this._media.mediaID, DomUtil.identify(uploadButton),
+ new Replace_1.default(mediaId, DomUtil.identify(uploadButton),
// Pass an anonymous element for non-images which is required internally
// but not needed in this case.
DomUtil.identify(target), {
* Returns the id of the insert dialog based on the media files to be inserted.
*/
_getInsertDialogId() {
- let dialogId = "mediaInsert";
- this._mediaToInsert.forEach((media, mediaId) => {
- dialogId += `-${mediaId}`;
- });
- return dialogId;
+ return ["mediaInsert", ...this._mediaToInsert.keys()].join("-");
}
/**
* Returns the supported thumbnail sizes (excluding `original`) for all media images to be inserted.
_getThumbnailSizes() {
return ["small", "medium", "large"]
.map((size) => {
- const supportSize = Array.from(this._mediaToInsert).every(([_mediaId, media]) => {
+ const sizeSupported = Array.from(this._mediaToInsert.values()).every((media) => {
return media[size + "ThumbnailType"] !== null;
});
- if (supportSize) {
+ if (sizeSupported) {
return size;
}
return null;
* Inserts a series of uploaded images into the editor using a slider.
*/
_insertMediaGallery() {
- const mediaIds = [];
- this._mediaToInsert.forEach(function (media) {
- mediaIds.push(media.mediaID);
- });
+ const mediaIds = Array.from(this._mediaToInsert.keys());
this._options.editor.buffer.set();
this._options.editor.insert.text("[wsmg='" + mediaIds.join(",") + "'][/wsmg]");
}
import MediaEditor from "../../Media/Editor";
import * as DomChangeListener from "../../Dom/Change/Listener";
import * as Clipboard from "../../Controller/Clipboard";
-import { MediaUploadSuccessEventData } from "../../Media/Data";
+import { Media, MediaUploadSuccessEventData } from "../../Media/Data";
import MediaManager from "../../Media/Manager/Base";
const _mediaEditor = new MediaEditor({
- _editorSuccess: function (media, oldCategoryId) {
+ _editorSuccess: (media: Media, oldCategoryId: number) => {
if (media.categoryID != oldCategoryId) {
- window.setTimeout(function () {
+ window.setTimeout(() => {
window.location.reload();
}, 500);
}
*/
protected _initEditor(content: HTMLElement, data: InitEditorData): void {
this._availableLanguageCount = ~~data.returnValues.availableLanguageCount;
- this._categoryIds = data.returnValues.categoryIDs.map((number) => number);
+ this._categoryIds = data.returnValues.categoryIDs.map((number) => ~~number);
if (data.returnValues.mediaData) {
this._media = data.returnValues.mediaData;
}
+ const mediaId = this._media!.mediaID;
// make sure that the language chooser is initialized first
setTimeout(() => {
if (this._availableLanguageCount > 1) {
LanguageChooser.setLanguageId(
- `mediaEditor_${this._media!.mediaID}_languageID`,
+ `mediaEditor_${mediaId}_languageID`,
this._media!.languageID || window.LANGUAGE_ID,
);
}
const title = content.querySelector("input[name=title]") as HTMLInputElement;
const altText = content.querySelector("input[name=altText]") as HTMLInputElement;
const caption = content.querySelector("textarea[name=caption]") as HTMLInputElement;
- const mediaId = this._media!.mediaID;
if (this._availableLanguageCount > 1 && this._media!.isMultilingual) {
if (document.getElementById(`altText_${mediaId}`)) {
- LanguageInput.setValues(`altText_${this._media!.mediaID}`, (this._media!.altText || {}) as I18nValues);
+ LanguageInput.setValues(`altText_${mediaId}`, (this._media!.altText || {}) as I18nValues);
}
if (document.getElementById(`caption_${mediaId}`)) {
- LanguageInput.setValues(`caption_${this._media!.mediaID}`, (this._media!.caption || {}) as I18nValues);
+ LanguageInput.setValues(`caption_${mediaId}`, (this._media!.caption || {}) as I18nValues);
}
- LanguageInput.setValues(`title_${this._media!.mediaID}`, (this._media!.title || {}) as I18nValues);
+ LanguageInput.setValues(`title_${mediaId}`, (this._media!.title || {}) as I18nValues);
} else {
- title.value = this._media!.title ? this._media!.title[this._media!.languageID || window.LANGUAGE_ID] : "";
+ title.value = this._media?.title[this._media!.languageID || window.LANGUAGE_ID] || "";
if (altText) {
- altText.value = this._media!.altText
- ? this._media!.altText[this._media!.languageID || window.LANGUAGE_ID]
- : "";
+ altText.value = this._media?.altText[this._media!.languageID || window.LANGUAGE_ID] || "";
}
if (caption) {
- caption.value = this._media!.caption
- ? this._media!.caption[this._media!.languageID || window.LANGUAGE_ID]
- : "";
+ caption.value = this._media?.caption[this._media!.languageID || window.LANGUAGE_ID] || "";
}
}
// remove focus from input elements and scroll dialog to top
(document.activeElement! as HTMLElement).blur();
- (document.getElementById(`mediaEditor_${this._media!.mediaID}`)!.parentNode as HTMLElement).scrollTop = 0;
+ (document.getElementById(`mediaEditor_${mediaId}`)!.parentNode as HTMLElement).scrollTop = 0;
// Initialize button to replace media file.
const uploadButton = content.querySelector(".mediaManagerMediaReplaceButton")!;
content.appendChild(target);
}
new MediaReplace(
- ~~this._media!.mediaID,
+ mediaId,
DomUtil.identify(uploadButton),
// Pass an anonymous element for non-images which is required internally
// but not needed in this case.
import { OnDropPayload } from "../../Ui/Redactor/DragAndDrop";
import DomUtil from "../../Dom/Util";
-type PasteFromClipboard = {
+interface PasteFromClipboard {
blob: Blob;
-};
+}
class MediaManagerEditor extends MediaManager<MediaManagerEditorOptions> {
protected _activeButton;
* Returns the id of the insert dialog based on the media files to be inserted.
*/
protected _getInsertDialogId(): string {
- let dialogId = "mediaInsert";
-
- this._mediaToInsert.forEach((media, mediaId) => {
- dialogId += `-${mediaId}`;
- });
-
- return dialogId;
+ return ["mediaInsert", ...this._mediaToInsert.keys()].join("-");
}
/**
protected _getThumbnailSizes(): string[] {
return ["small", "medium", "large"]
.map((size) => {
- const supportSize = Array.from(this._mediaToInsert).every(([_mediaId, media]) => {
+ const sizeSupported = Array.from(this._mediaToInsert.values()).every((media) => {
return media[size + "ThumbnailType"] !== null;
});
- if (supportSize) {
+ if (sizeSupported) {
return size;
}
* Inserts a series of uploaded images into the editor using a slider.
*/
protected _insertMediaGallery(): void {
- const mediaIds: number[] = [];
- this._mediaToInsert.forEach(function (media) {
- mediaIds.push(media.mediaID);
- });
+ const mediaIds = Array.from(this._mediaToInsert.keys());
this._options.editor!.buffer.set();
this._options.editor!.insert.text("[wsmg='" + mediaIds.join(",") + "'][/wsmg]");