Add new mediatag options in rich text pads

pull/1/head
yflory 4 years ago
parent 4027e48fd2
commit 3de5ca75a6

@ -46,6 +46,7 @@ define([
'/common/test.js',
'/bower_components/diff-dom/diffDOM.js',
'/bower_components/file-saver/FileSaver.min.js',
'css!/customize/src/print.css',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
@ -1085,6 +1086,9 @@ define([
border: Messages.pad_mediatagBorder,
preview: Messages.pad_mediatagPreview,
'import': Messages.pad_mediatagImport,
download: Messages.download_mt_button,
share: Messages.pad_mediatagShare,
open: Messages.pad_mediatagOpen,
options: Messages.pad_mediatagOptions
};
Ckeditor._commentsTranslations = {
@ -1165,6 +1169,26 @@ define([
editor.plugins.mediatag.import = function($mt) {
framework._.sfCommon.importMediaTag($mt);
};
editor.plugins.mediatag.download = function($mt) {
var media = Util.find($mt, [0, '_mediaObject']);
if (!(media && media._blob)) { return void console.error($mt); }
window.saveAs(media._blob.content, media.name);
};
editor.plugins.mediatag.open = function($mt) {
var hash = framework._.sfCommon.getHashFromMediaTag($mt);
framework._.sfCommon.openURL(Hash.hashToHref(hash, 'file'));
};
editor.plugins.mediatag.share = function($mt) {
var data = {
file: true,
pathname: '/file/',
hashes: {
fileHash: framework._.sfCommon.getHashFromMediaTag($mt)
},
title: Util.find($mt[0], ['_mediaObject', 'name']) || ''
};
framework._.sfCommon.getSframeChannel().event('EV_SHARE_OPEN', data);
};
Links.init(Ckeditor, editor);
}).nThen(function() {
// Move ckeditor parts to have a structure like the other apps

@ -53,15 +53,57 @@
editor.plugins.mediatag.import($mt);
}
});
editor.addCommand('downloadMT', {
exec: function (editor) {
var w = targetWidget;
targetWidget = undefined;
var $mt = $(w.$).find('media-tag');
editor.plugins.mediatag.download($mt);
}
});
editor.addCommand('openMT', {
exec: function (editor) {
var w = targetWidget;
targetWidget = undefined;
var $mt = $(w.$).find('media-tag');
editor.plugins.mediatag.open($mt);
}
});
editor.addCommand('shareMT', {
exec: function (editor) {
var w = targetWidget;
targetWidget = undefined;
var $mt = $(w.$).find('media-tag');
editor.plugins.mediatag.share($mt);
}
});
if (editor.addMenuItems) {
editor.addMenuGroup('mediatag');
editor.addMenuItem('open', {
label: Messages.open,
icon: 'iframe',
command: 'openMT',
group: 'mediatag'
});
editor.addMenuItem('share', {
label: Messages.share,
icon: 'link',
command: 'shareMT',
group: 'mediatag'
});
editor.addMenuItem('importMediatag', {
label: Messages.import,
icon: 'save',
command: 'importMediatag',
group: 'mediatag'
});
editor.addMenuItem('download', {
label: Messages.download,
icon: 'save',
command: 'downloadMT',
group: 'mediatag'
});
editor.addMenuItem('mediatag', {
label: Messages.options,
icon: 'image',
@ -76,6 +118,9 @@
targetWidget = element;
return {
mediatag: CKEDITOR.TRISTATE_OFF,
open: CKEDITOR.TRISTATE_OFF,
share: CKEDITOR.TRISTATE_OFF,
download: CKEDITOR.TRISTATE_OFF,
importMediatag: CKEDITOR.TRISTATE_OFF,
};
}

Loading…
Cancel
Save