Add api event onRequestCreateNew for creating files

This commit is contained in:
Julia Radzhabova 2020-06-15 20:05:19 +03:00
parent 6e8bdc5e6b
commit 5f03cfae8a
8 changed files with 29 additions and 9 deletions

View file

@ -215,6 +215,7 @@
_config.editorConfig.canRequestMailMergeRecipients = _config.events && !!_config.events.onRequestMailMergeRecipients;
_config.editorConfig.canRequestCompareFile = _config.events && !!_config.events.onRequestCompareFile;
_config.editorConfig.canRequestSharingSettings = _config.events && !!_config.events.onRequestSharingSettings;
_config.editorConfig.canRequestCreateNew = _config.events && !!_config.events.onRequestCreateNew;
_config.frameEditorId = placeholderId;
_config.parentOrigin = window.location.origin;

View file

@ -322,6 +322,10 @@ if (Common === undefined) {
_postMessage({event:'onRequestSharingSettings'});
},
requestCreateNew: function () {
_postMessage({event:'onRequestCreateNew'});
},
on: function(event, handler){
var localHandler = function(event, data){
handler.call(me, data)

View file

@ -503,8 +503,12 @@ define([
onCreateNew: function(menu, type) {
if ( !Common.Controllers.Desktop.process('create:new') ) {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
if (this.mode.canRequestCreateNew)
Common.Gateway.requestCreateNew();
else {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
}
}
if (menu) {

View file

@ -337,11 +337,12 @@ define([
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
this.appOptions.templates = this.editorConfig.templates;
this.appOptions.recent = this.editorConfig.recent;
this.appOptions.createUrl = this.editorConfig.createUrl;
this.appOptions.canRequestCreateNew = this.editorConfig.canRequestCreateNew;
this.appOptions.lang = this.editorConfig.lang;
this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : '';
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;

View file

@ -339,8 +339,12 @@ define([
onCreateNew: function(menu, type) {
if ( !Common.Controllers.Desktop.process('create:new') ) {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
if (this.mode.canRequestCreateNew)
Common.Gateway.requestCreateNew();
else {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
}
}
if (menu) {
menu.hide();

View file

@ -302,11 +302,12 @@ define([
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
this.appOptions.templates = this.editorConfig.templates;
this.appOptions.recent = this.editorConfig.recent;
this.appOptions.createUrl = this.editorConfig.createUrl;
this.appOptions.canRequestCreateNew = this.editorConfig.canRequestCreateNew;
this.appOptions.lang = this.editorConfig.lang;
this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : '';
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;

View file

@ -431,8 +431,12 @@ define([
onCreateNew: function(menu, type) {
if ( !Common.Controllers.Desktop.process('create:new') ) {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
if (this.mode.canRequestCreateNew)
Common.Gateway.requestCreateNew();
else {
var newDocumentPage = window.open(type == 'blank' ? this.mode.createUrl : type, "_blank");
if (newDocumentPage) newDocumentPage.focus();
}
}
if (menu) {
menu.hide();

View file

@ -325,11 +325,12 @@ define([
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, this.textAnonymous);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
this.appOptions.templates = this.editorConfig.templates;
this.appOptions.recent = this.editorConfig.recent;
this.appOptions.createUrl = this.editorConfig.createUrl;
this.appOptions.canRequestCreateNew = this.editorConfig.canRequestCreateNew;
this.appOptions.lang = this.editorConfig.lang;
this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : '';
this.appOptions.region = (typeof (this.editorConfig.region) == 'string') ? this.editorConfig.region.toLowerCase() : this.editorConfig.region;