{include file='mediaJavaScript'}
var element = elById('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}');
- UiRedactorMetacode.convert(element);
var autosave = elData(element, 'autosave') || null;
if (autosave) {
buttons: buttonOptions,
buttonMobile: buttonMobile,
customButtons: customButtons,
- highlighters: highlighters
+ highlighters: highlighters,
+ mediaUrl: '{link controller='Media' id=-123456789 thumbnail='void' forceFrontend=true}{/link}'
}
};
content = '<p><br></p>';
}
+ content = UiRedactorMetacode.convertFromHtml(element.id, content);
+
var redactor = $(element).data('redactor');
// set code
{include file='mediaJavaScript'}
var element = elById('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}');
- UiRedactorMetacode.convert(element);
var autosave = elData(element, 'autosave') || null;
if (autosave) {
buttons: buttonOptions,
buttonMobile: buttonMobile,
customButtons: customButtons,
- highlighters: highlighters
+ highlighters: highlighters,
+ mediaUrl: '{link controller='Media' id=-123456789 thumbnail='void' forceFrontend=true}{/link}'
}
};
content = '<p><br></p>';
}
+ content = UiRedactorMetacode.convertFromHtml(element.id, content);
+
var redactor = $(element).data('redactor');
// set code
var button = this.button.add('woltlabMedia', '');
$(button).addClass('jsMediaEditorButton');
+ var metacodeUuid = WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'metacode_wsm_' + this.$element[0].id, (function(data) {
+ if (data.attributes.length === 1) {
+ // ignore non-image files
+ return;
+ }
+
+ var float = '';
+ if (data.attributes === 3) {
+ if (data.attributes[2] === 'left') {
+ float = ' messageFloatObjectLeft';
+ }
+ else if (data.attributes[2] === 'right') {
+ float = ' messageFloatObjectRight';
+ }
+ }
+
+ var image = elCreate('img');
+ image.className = 'woltlabSuiteMedia' + float;
+ //noinspection JSUnresolvedVariable
+ image.src = this.opts.woltlab.mediaUrl.replace('-123456789', data.attributes[0]).replace('thumbnail=void', 'thumbnail=' + data.attributes[1]);
+ elData(image, 'media-id', data.attributes[0]);
+ elData(image, 'media-size', data.attributes[1]);
+
+ var metacode = data.metacode;
+ metacode.parentNode.insertBefore(image, metacode);
+ elRemove(metacode);
+
+ data.cancel = true;
+ }).bind(this));
+
+ WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'destroy_' + this.$element[0].id, (function () {
+ WCF.System.Event.removeListener('com.woltlab.wcf.redactor2', 'metacode_wsm_' + this.$element[0].id, metacodeUuid);
+ }).bind(this));
+
require(['WoltLabSuite/Core/Media/Manager/Editor'], function(MediaManagerEditor) {
new MediaManagerEditor({
editor: this
WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'dragAndDrop_' + this._editorId, this._editorUpload.bind(this));
WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'pasteFromClipboard_' + this._editorId, this._editorUpload.bind(this));
- var metacodeAttachUuid = WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'metacode_attach', (function(data) {
+ var metacodeAttachUuid = WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'metacode_attach_' + this._editorId, (function(data) {
var images = this._getImageAttachments();
var attachmentId = data.attributes[0] || 0;
if (images.hasOwnProperty(attachmentId)) {
WCF.System.Event.removeAllListeners('com.woltlab.wcf.redactor2', 'dragAndDrop_' + this._editorId);
WCF.System.Event.removeAllListeners('com.woltlab.wcf.redactor2', 'pasteFromClipboard_' + this._editorId);
- WCF.System.Event.removeListener('com.woltlab.wcf.redactor2', 'metacode_attach', metacodeAttachUuid);
+ WCF.System.Event.removeListener('com.woltlab.wcf.redactor2', 'metacode_attach_' + this._editorId, metacodeAttachUuid);
}).bind(this));
}
},
element.textContent = this.convertFromHtml(element.textContent);
},
- convertFromHtml: function (html) {
+ convertFromHtml: function (editorId, html) {
var div = elCreate('div');
div.innerHTML = html;
cancel: false,
metacode: metacode
};
- EventHandler.fire('com.woltlab.wcf.redactor2', 'metacode_' + name, data);
+
+ EventHandler.fire('com.woltlab.wcf.redactor2', 'metacode_' + name + '_' + editorId, data);
if (data.cancel === true) {
continue;
}
content = content.replace(/\n/g, '<br>');
}
else {
- content = UiRedactorMetacode.convertFromHtml(content);
+ //noinspection JSUnresolvedFunction
+ content = UiRedactorMetacode.convertFromHtml(this._editor.$element[0].id, content);
}
// bypass the editor as `insert.html()` doesn't like us