Add onRequestInsertImage event, insertImage method for inserting image from storage
This commit is contained in:
parent
b9917f6dff
commit
d45d04f0a1
|
@ -203,6 +203,7 @@
|
|||
_config.editorConfig.canRequestSendNotify = _config.events && !!_config.events.onRequestSendNotify;
|
||||
_config.editorConfig.mergeFolderUrl = _config.editorConfig.mergeFolderUrl || _config.editorConfig.saveAsUrl;
|
||||
_config.editorConfig.canRequestSaveAs = _config.events && !!_config.events.onRequestSaveAs;
|
||||
_config.editorConfig.canRequestInsertImage = _config.events && !!_config.events.onRequestInsertImage;
|
||||
_config.frameEditorId = placeholderId;
|
||||
|
||||
_config.events && !!_config.events.onReady && console.log("Obsolete: The onReady event is deprecated. Please use onAppReady instead.");
|
||||
|
@ -561,6 +562,13 @@
|
|||
});
|
||||
};
|
||||
|
||||
var _insertImage = function(data) {
|
||||
_sendCommand({
|
||||
command: 'insertImage',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
var _processMouse = function(evt) {
|
||||
var r = iframe.getBoundingClientRect();
|
||||
var data = {
|
||||
|
@ -603,7 +611,8 @@
|
|||
destroyEditor : _destroyEditor,
|
||||
setUsers : _setUsers,
|
||||
showSharingSettings : _showSharingSettings,
|
||||
setSharingSettings : _setSharingSettings
|
||||
setSharingSettings : _setSharingSettings,
|
||||
insertImage : _insertImage
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -110,6 +110,10 @@ if (Common === undefined) {
|
|||
|
||||
'setSharingSettings': function(data) {
|
||||
$me.trigger('setsharingsettings', data);
|
||||
},
|
||||
|
||||
'insertImage': function(data) {
|
||||
$me.trigger('insertimage', data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -292,6 +296,10 @@ if (Common === undefined) {
|
|||
_postMessage({event:'onRequestSendNotify', data: emails})
|
||||
},
|
||||
|
||||
requestInsertImage: function () {
|
||||
_postMessage({event:'onRequestInsertImage'})
|
||||
},
|
||||
|
||||
on: function(event, handler){
|
||||
var localHandler = function(event, data){
|
||||
handler.call(me, data)
|
||||
|
|
|
@ -350,6 +350,7 @@ define([
|
|||
this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers;
|
||||
this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify;
|
||||
this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs;
|
||||
this.appOptions.canRequestInsertImage = this.editorConfig.canRequestInsertImage;
|
||||
|
||||
appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header');
|
||||
appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '')
|
||||
|
|
|
@ -323,6 +323,7 @@ define([
|
|||
toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this));
|
||||
toolbar.mnuNoControlsColor.on('click', _.bind(this.onNoControlsColor, this));
|
||||
toolbar.mnuControlsColorPicker.on('select', _.bind(this.onSelectControlsColor, this));
|
||||
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
|
||||
$('#id-toolbar-menu-new-control-color').on('click', _.bind(this.onNewControlsColor, this));
|
||||
|
||||
$('#id-save-style-plus, #id-save-style-link', toolbar.$el).on('click', this.onMenuSaveStyle.bind(this));
|
||||
|
@ -1427,14 +1428,24 @@ define([
|
|||
}
|
||||
})).show();
|
||||
} else if (item.value === 'storage') {
|
||||
if (this.toolbar.mode.canRequestInsertImage) {
|
||||
Common.Gateway.requestInsertImage();
|
||||
} else {
|
||||
(new Common.Views.SelectFileDlg({
|
||||
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
|
||||
})).on('selectfile', function(obj, file){
|
||||
me.toolbar.fireEvent('insertimage', me.toolbar);
|
||||
me.api.AddImageUrl(file.url, undefined, true);// for loading from storage
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
me.insertImage(file);
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
insertImage: function(data) {
|
||||
if (data && data.url) {
|
||||
this.toolbar.fireEvent('insertimage', this.toolbar);
|
||||
this.api.AddImageUrl(data.url, undefined, data.token);// for loading from storage
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
}
|
||||
},
|
||||
|
||||
onBtnInsertTextClick: function(btn, e) {
|
||||
|
|
|
@ -317,6 +317,7 @@ define([
|
|||
this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers;
|
||||
this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify;
|
||||
this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs;
|
||||
this.appOptions.canRequestInsertImage = this.editorConfig.canRequestInsertImage;
|
||||
|
||||
appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header');
|
||||
appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '')
|
||||
|
|
|
@ -314,6 +314,7 @@ define([
|
|||
toolbar.btnEditHeader.on('click', _.bind(this.onEditHeaderClick, this, 'header'));
|
||||
toolbar.btnInsDateTime.on('click', _.bind(this.onEditHeaderClick, this, 'datetime'));
|
||||
toolbar.btnInsSlideNum.on('click', _.bind(this.onEditHeaderClick, this, 'slidenum'));
|
||||
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
|
||||
|
||||
this.onSetupCopyStyleButton();
|
||||
},
|
||||
|
@ -1390,14 +1391,24 @@ define([
|
|||
}
|
||||
})).show();
|
||||
} else if (opts === 'storage') {
|
||||
if (this.toolbar.mode.canRequestInsertImage) {
|
||||
Common.Gateway.requestInsertImage();
|
||||
} else {
|
||||
(new Common.Views.SelectFileDlg({
|
||||
fileChoiceUrl: me.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
|
||||
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
|
||||
})).on('selectfile', function(obj, file){
|
||||
me.toolbar.fireEvent('insertimage', me.toolbar);
|
||||
me.api.AddImageUrl(file.url, undefined, true);// for loading from storage;
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
me.insertImage(file);
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
insertImage: function(data) {
|
||||
if (data && data.url) {
|
||||
this.toolbar.fireEvent('insertimage', this.toolbar);
|
||||
this.api.AddImageUrl(data.url, undefined, data.token);// for loading from storage
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
}
|
||||
},
|
||||
|
||||
onInsertText: function(status) {
|
||||
|
|
|
@ -323,6 +323,7 @@ define([
|
|||
this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers;
|
||||
this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify;
|
||||
this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs;
|
||||
this.appOptions.canRequestInsertImage = this.editorConfig.canRequestInsertImage;
|
||||
|
||||
this.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header');
|
||||
this.headerView.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '')
|
||||
|
|
|
@ -365,6 +365,7 @@ define([
|
|||
toolbar.btnImgForward.on('click', this.onImgArrangeSelect.bind(this, 'forward'));
|
||||
toolbar.btnImgBackward.on('click', this.onImgArrangeSelect.bind(this, 'backward'));
|
||||
toolbar.btnEditHeader.on('click', _.bind(this.onEditHeaderClick, this));
|
||||
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
|
||||
|
||||
this.onSetupCopyStyleButton();
|
||||
}
|
||||
|
@ -862,15 +863,24 @@ define([
|
|||
}
|
||||
})).show();
|
||||
} else if (item.value === 'storage') {
|
||||
var me = this;
|
||||
if (this.toolbar.mode.canRequestInsertImage) {
|
||||
Common.Gateway.requestInsertImage();
|
||||
} else {
|
||||
(new Common.Views.SelectFileDlg({
|
||||
fileChoiceUrl: me.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
|
||||
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
|
||||
})).on('selectfile', function(obj, file){
|
||||
me.toolbar.fireEvent('insertimage', me.toolbar);
|
||||
me.api.asc_addImageDrawingObject(file.url, undefined, true);// for loading from storage;
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
me.insertImage(file);
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
insertImage: function(data) {
|
||||
if (data && data.url) {
|
||||
this.toolbar.fireEvent('insertimage', this.toolbar);
|
||||
this.api.asc_addImageDrawingObject(data.url, undefined, data.token);// for loading from storage
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Image');
|
||||
}
|
||||
},
|
||||
|
||||
onHyperlink: function(btn) {
|
||||
|
|
Loading…
Reference in a new issue