Fix bug 68668

This commit is contained in:
Julia Radzhabova
2024-11-06 17:26:22 +03:00
parent 861270da80
commit ee088b2b37
6 changed files with 119 additions and 44 deletions

View File

@ -1178,7 +1178,13 @@ define([
if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked)
return;
}
this.onShowImageActions(obj, x, y);
if (obj.pr && obj.pr.is_Signature()) { // select signature picture only from local file
me.api.asc_addImage(obj.pr);
setTimeout(function(){
me.api.asc_UncheckContentControlButtons();
}, 500);
} else
this.onShowImageActions(obj, x, y);
break;
case Asc.c_oAscContentControlSpecificType.DropDownList:
case Asc.c_oAscContentControlSpecificType.ComboBox:
@ -1199,7 +1205,7 @@ define([
menuContainer = menu ? this.boxSdk.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
this.internalFormObj = obj && obj.pr ? obj.pr.get_InternalId() : null;
this.internalFormObj = obj ? obj.pr : null;
this._fromShowContentControls = true;
Common.UI.Menu.Manager.hideAll();
@ -1288,7 +1294,7 @@ define([
},
setImageUrl: function(url, token) {
this.api.asc_SetContentControlPictureUrl(url, this.internalFormObj && this.internalFormObj.pr ? this.internalFormObj.pr.get_InternalId() : null, token);
this.api.asc_SetContentControlPictureUrl(url, this.internalFormObj ? this.internalFormObj.get_InternalId() : null, token);
},
insertImage: function(data) { // gateway

View File

@ -236,6 +236,8 @@ define([
if (this.mode.isEdit || this.mode.isRestrictedEdit && this.mode.canFillForms) {
this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this));
Common.NotificationCenter.on('forms:image-select', _.bind(this.selectFormImage, this));// select from right pane
}
this.api.asc_registerCallback('onPluginContextMenu', _.bind(this.onPluginContextMenu, this));
this.documentHolder.setApi(this.api);
@ -1757,11 +1759,13 @@ define([
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
})).show();
} else if (obj.pr && obj.pr.is_Signature()) { // select signature picture only from local file
this.api.asc_addImage(obj.pr);
setTimeout(function(){
me.api.asc_UncheckContentControlButtons();
}, 500);
} else
this.api.asc_addImage(obj);
setTimeout(function(){
me.api.asc_UncheckContentControlButtons();
}, 500);
this.onShowImageActions(obj, x, y);
break;
case Asc.c_oAscContentControlSpecificType.DropDownList:
case Asc.c_oAscContentControlSpecificType.ComboBox:
@ -1770,6 +1774,100 @@ define([
}
},
onShowImageActions: function(obj, x, y) {
var cmpEl = this.documentHolder.cmpEl,
menu = this.imageControlMenu,
menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
this.internalFormObj = obj ? obj.pr : null;
this._fromShowContentControls = true;
Common.UI.Menu.Manager.hideAll();
if (!menu) {
this.imageControlMenu = menu = new Common.UI.Menu({
maxHeight: 207,
menuAlign: 'tl-bl',
items: [
{caption: this.documentHolder.mniImageFromFile, value: 0},
{caption: this.documentHolder.mniImageFromUrl, value: 1},
{caption: this.documentHolder.mniImageFromStorage, value: 2, visible: this.mode.canRequestInsertImage || this.mode.fileChoiceUrl && this.mode.fileChoiceUrl.indexOf("{documentType}")>-1}
]
});
menu.on('item:click', function(menu, item) {
setTimeout(function(){
me.onImageSelect(menu, item);
}, 1);
setTimeout(function(){
me.api.asc_UncheckContentControlButtons();
}, 500);
});
// Prepare menu container
if (!menuContainer || menuContainer.length < 1) {
menuContainer = $(Common.Utils.String.format('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id));
cmpEl.append(menuContainer);
}
menu.render(menuContainer);
menu.cmpEl.attr({tabindex: "-1"});
menu.on('hide:after', function(){
if (!me._fromShowContentControls)
me.api.asc_UncheckContentControlButtons();
});
}
menuContainer.css({left: x, top : y});
menuContainer.attr('data-value', 'prevent-canvas-click');
this._preventClick = true;
menu.show();
_.delay(function() {
menu.cmpEl.focus();
}, 10);
this._fromShowContentControls = false;
},
selectFormImage: function(item, obj) {
this.internalFormObj = obj;
this.onImageSelect(null, item);
},
onImageSelect: function(menu, item) {
if (item.value==1) {
var me = this;
(new Common.Views.ImageFromUrlDialog({
handler: function(result, value) {
if (result == 'ok') {
if (me.api) {
var checkUrl = value.replace(/ /g, '');
if (!_.isEmpty(checkUrl)) {
me.setImageUrl(checkUrl);
}
}
}
me.fireEvent('editcomplete', me);
}
})).show();
} else if (item.value==2) {
Common.NotificationCenter.trigger('storage:image-load', 'control');
} else {
if (this._isFromFile) return;
this._isFromFile = true;
this.api.asc_addImage(this.internalFormObj);
this._isFromFile = false;
}
},
setImageUrl: function(url, token) {
this.api && this.api.asc_SetContentControlPictureUrl(url, this.internalFormObj ? this.internalFormObj.get_InternalId() : null, token);
},
insertImageFromStorage: function(data) {
if (data && data._urls && data.c=='control') {
this.setImageUrl(data._urls[0], data.token);
}
},
onApiLockDocumentProps: function() {
this._state.lock_doc = true;
},

View File

@ -286,6 +286,7 @@ define([
Common.NotificationCenter.on('leftmenu:save', _.bind(this.tryToSave, this));
this.onBtnChangeState('undo:disabled', toolbar.btnUndo, toolbar.btnUndo.isDisabled());
this.onBtnChangeState('redo:disabled', toolbar.btnRedo, toolbar.btnRedo.isDisabled());
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
},
attachUIEvents: function(toolbar) {
@ -490,6 +491,7 @@ define([
this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
this.api.asc_registerCallback('asc_onCanCopyCut', _.bind(this.onApiCanCopyCut, this));
this.api.asc_registerCallback('asc_onChangeViewerTargetType', _.bind(this.onChangeViewerTargetType, this));
Common.NotificationCenter.on('storage:image-load', _.bind(this.openImageFromStorage, this));
}
}
this.api.asc_registerCallback('onPluginToolbarMenu', _.bind(this.onPluginToolbarMenu, this));

View File

@ -831,7 +831,6 @@ define([
// this.api.asc_registerCallback('asc_onParaSpacingLine', _.bind(this._onLineSpacing, this));
this.api.asc_registerCallback('asc_onUpdateOFormRoles', _.bind(this.onRefreshRolesList, this));
}
Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this));
return this;
},
@ -1152,41 +1151,8 @@ define([
this.fireEvent('editcomplete', this);
},
setImageUrl: function(url, token) {
this.api.asc_SetContentControlPictureUrl(url, this.internalId, token);
},
insertImageFromStorage: function(data) {
if (data && data._urls && data.c=='control') {
this.setImageUrl(data._urls[0], data.token);
}
},
onImageSelect: function(menu, item) {
if (item.value==1) {
var me = this;
(new Common.Views.ImageFromUrlDialog({
handler: function(result, value) {
if (result == 'ok') {
if (me.api) {
var checkUrl = value.replace(/ /g, '');
if (!_.isEmpty(checkUrl)) {
me.setImageUrl(checkUrl);
}
}
}
me.fireEvent('editcomplete', me);
}
})).show();
} else if (item.value==2) {
Common.NotificationCenter.trigger('storage:image-load', 'control');
} else {
if (this._isFromFile) return;
this._isFromFile = true;
if (this.api) this.api.asc_addImage(this._originalProps);
this.fireEvent('editcomplete', this);
this._isFromFile = false;
}
Common.NotificationCenter.trigger('forms:image-select', item, this._originalProps);
},
onColorBGSelect: function(btn, color) {

View File

@ -2099,6 +2099,9 @@
"DE.Views.DocumentHolder.unicodeText": "Unicode",
"DE.Views.DocumentHolder.updateStyleText": "Update %1 style",
"DE.Views.DocumentHolder.vertAlignText": "Vertical alignment",
"DE.Views.DocumentHolder.mniImageFromFile": "Image from File",
"DE.Views.DocumentHolder.mniImageFromStorage": "Image from Storage",
"DE.Views.DocumentHolder.mniImageFromUrl": "Image from URL",
"DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill",
"DE.Views.DropcapSettingsAdvanced.strDropcap": "Drop cap",
"DE.Views.DropcapSettingsAdvanced.strMargins": "Margins",

View File

@ -1437,7 +1437,7 @@ define([
menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
this.internalFormObj = obj && obj.pr ? obj.pr.get_InternalId() : null;
this.internalFormObj = obj ? obj.pr : null;
this._fromShowContentControls = true;
Common.UI.Menu.Manager.hideAll();
@ -1526,7 +1526,7 @@ define([
},
setImageUrl: function(url, token) {
this.api.asc_SetContentControlPictureUrl(url, this.internalFormObj && this.internalFormObj.pr ? this.internalFormObj.pr.get_InternalId() : null, token);
this.api.asc_SetContentControlPictureUrl(url, this.internalFormObj ? this.internalFormObj.get_InternalId() : null, token);
},
insertImage: function(data) { // gateway