Add drop handlers for mediatags in ckeditor
This commit is contained in:
parent
c00d295466
commit
018f71df04
@ -290,10 +290,22 @@ define([
|
|||||||
onFileDrop(dropped, e);
|
onFileDrop(dropped, e);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var createCkeditorDropHandler = function () {
|
||||||
|
var editor = config.ckeditor;
|
||||||
|
editor.document.on('drop', function (ev) {
|
||||||
|
var dropped = ev.data.$.dataTransfer.files;
|
||||||
|
onFileDrop(dropped, ev);
|
||||||
|
ev.data.preventDefault(true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var createUploader = function ($area, $hover, $body) {
|
var createUploader = function ($area, $hover, $body) {
|
||||||
if (!config.noHandlers) {
|
if (!config.noHandlers) {
|
||||||
createAreaHandlers($area, null);
|
if (config.ckeditor) {
|
||||||
|
createCkeditorDropHandler();
|
||||||
|
} else {
|
||||||
|
createAreaHandlers($area, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
createTableContainer($body);
|
createTableContainer($body);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -762,6 +762,20 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLocal();
|
onLocal();
|
||||||
|
|
||||||
|
var fmConfig = {
|
||||||
|
ckeditor: editor,
|
||||||
|
body: $('body'),
|
||||||
|
onUploaded: function (ev, data) {
|
||||||
|
var parsed = Cryptpad.parsePadUrl(data.url);
|
||||||
|
var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel);
|
||||||
|
var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName;
|
||||||
|
var mt = '<media-tag contenteditable="false" src="' + src + '" data-crypto-key="cryptpad:' + parsed.hashData.key + '" tabindex="1"></media-tag>';
|
||||||
|
editor.insertElement(CKEDITOR.dom.element.createFromHtml(mt));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
APP.FM = common.createFileManager(fmConfig);
|
||||||
|
|
||||||
editor.focus();
|
editor.focus();
|
||||||
if (newPad) {
|
if (newPad) {
|
||||||
cursor.setToEnd();
|
cursor.setToEnd();
|
||||||
@ -772,10 +786,8 @@ define([
|
|||||||
|
|
||||||
realtimeOptions.onConnectionChange = function (info) {
|
realtimeOptions.onConnectionChange = function (info) {
|
||||||
setEditable(info.state);
|
setEditable(info.state);
|
||||||
//toolbar.failed(); TODO
|
|
||||||
if (info.state) {
|
if (info.state) {
|
||||||
initializing = true;
|
initializing = true;
|
||||||
//toolbar.reconnecting(info.myId); // TODO
|
|
||||||
Cryptpad.findOKButton().click();
|
Cryptpad.findOKButton().click();
|
||||||
} else {
|
} else {
|
||||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
define(['/common/cryptpad-common.js'], function (Cryptpad) {
|
define(['/customize/messages.js'], function (Messages) {
|
||||||
// Adds a context menu entry to open the selected link in a new tab.
|
// Adds a context menu entry to open the selected link in a new tab.
|
||||||
// See https://github.com/xwiki-contrib/application-ckeditor/commit/755d193497bf23ed874d874b4ae92fbee887fc10
|
// See https://github.com/xwiki-contrib/application-ckeditor/commit/755d193497bf23ed874d874b4ae92fbee887fc10
|
||||||
var Messages = Cryptpad.Messages;
|
|
||||||
return {
|
return {
|
||||||
addSupportForOpeningLinksInNewTab : function (Ckeditor) {
|
addSupportForOpeningLinksInNewTab : function (Ckeditor) {
|
||||||
// Returns the DOM element of the active (currently focused) link. It has also support for linked image widgets.
|
// Returns the DOM element of the active (currently focused) link. It has also support for linked image widgets.
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
'media-tag iframe{' +
|
'media-tag iframe{' +
|
||||||
'border: 6px solid #eee;' +
|
'border: 6px solid #eee;' +
|
||||||
'}' +
|
'}' +
|
||||||
|
'media-tag img{' +
|
||||||
|
'vertical-align: top;' +
|
||||||
|
'}' +
|
||||||
'media-tag *{' +
|
'media-tag *{' +
|
||||||
'width:100%; height:100%;' +
|
'width:100%; height:100%;' +
|
||||||
'}');
|
'}');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user