[PE][SSE] Fix Bug 42393

This commit is contained in:
Julia Radzhabova 2022-06-03 15:32:57 +03:00
parent bb7f081dcf
commit 9566b6d0cc
3 changed files with 187 additions and 45 deletions

View file

@ -191,8 +191,8 @@
if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
}
(keys.length > 0) && (key = keys[keys.length - 1]);
key = code(key);
@ -304,8 +304,8 @@
if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
}
(keys.length > 0) && (key = keys[keys.length - 1]);
key = code(key);

View file

@ -122,7 +122,8 @@ define([
me.userTooltip = true;
me.wrapEvents = {
userTipMousover: _.bind(me.userTipMousover, me),
userTipMousout: _.bind(me.userTipMousout, me)
userTipMousout: _.bind(me.userTipMousout, me),
onKeyUp: _.bind(me.onKeyUp, me)
};
// Hotkeys
@ -640,6 +641,9 @@ define([
var me = this;
if (me.api){
var key = event.keyCode;
if (me.hkSpecPaste) {
me._needShowSpecPasteMenu = !event.shiftKey && !event.altKey && event.keyCode == Common.UI.Keys.CTRL;
}
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey){
if (key === Common.UI.Keys.NUM_PLUS || key === Common.UI.Keys.EQUALITY || (Common.Utils.isGecko && key === Common.UI.Keys.EQUALITY_FF) || (Common.Utils.isOpera && key == 43)){
me.api.zoomIn();
@ -1170,8 +1174,10 @@ define([
parentEl: $('#id-document-holder-btn-special-paste'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-paste',
caption : Common.Utils.String.platformKey('Ctrl', '({0})'),
menu : new Common.UI.Menu({items: []})
});
me.initSpecialPasteEvents();
}
if (pasteItems.length>0) {
@ -1184,31 +1190,70 @@ define([
var group_prev = -1;
_.each(pasteItems, function(menuItem, index) {
var mnu = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem],
caption: me._arrSpecialPaste[menuItem] + ' (' + me.hkSpecPaste[menuItem] + ')',
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
me.api.asc_SpecialPaste(item.value);
setTimeout(function(){menu.hide();}, 100);
});
}).on('click', _.bind(me.onSpecialPasteItemClick, me));
menu.addItem(mnu);
});
(menu.items.length>0) && menu.items[0].setChecked(true, true);
}
if (coord.asc_getX()<0 || coord.asc_getY()<0) {
if (pasteContainer.is(':visible')) pasteContainer.hide();
$(document).off('keyup', this.wrapEvents.onKeyUp);
} else {
var showPoint = [coord.asc_getX() + coord.asc_getWidth() + 3, coord.asc_getY() + coord.asc_getHeight() + 3];
pasteContainer.css({left: showPoint[0], top : showPoint[1]});
pasteContainer.show();
setTimeout(function() {
$(document).on('keyup', me.wrapEvents.onKeyUp);
}, 10);
}
},
onHideSpecialPasteOptions: function() {
var pasteContainer = this.documentHolder.cmpEl.find('#special-paste-container');
if (pasteContainer.is(':visible'))
if (pasteContainer.is(':visible')) {
pasteContainer.hide();
$(document).off('keyup', this.wrapEvents.onKeyUp);
}
},
onKeyUp: function (e) {
if (e.keyCode == Common.UI.Keys.CTRL && this._needShowSpecPasteMenu && !this.btnSpecialPaste.menu.isVisible() && /area_id/.test(e.target.id)) {
$('button', this.btnSpecialPaste.cmpEl).click();
e.preventDefault();
}
this._needShowSpecPasteMenu = false;
},
initSpecialPasteEvents: function() {
var me = this;
me.hkSpecPaste = [];
me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = 'H';
for(var key in me.hkSpecPaste){
if(me.hkSpecPaste.hasOwnProperty(key)){
var keymap = {};
keymap[me.hkSpecPaste[key]] = _.bind(me.onSpecialPasteItemClick, me, {value: parseInt(key)});
Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap});
Common.util.Shortcuts.suspendEvents(me.hkSpecPaste[key], undefined, true);
}
}
me.btnSpecialPaste.menu.on('show:after', function(menu) {
for (var i = 0; i < menu.items.length; i++) {
me.hkSpecPaste[menu.items[i].value] && Common.util.Shortcuts.resumeEvents(me.hkSpecPaste[menu.items[i].value]);
}
}).on('hide:after', function(menu) {
for (var i = 0; i < menu.items.length; i++) {
me.hkSpecPaste[menu.items[i].value] && Common.util.Shortcuts.suspendEvents(me.hkSpecPaste[menu.items[i].value], undefined, true);
}
});
},
onChangeCropState: function(state) {
@ -2017,6 +2062,21 @@ define([
}
},
onSpecialPasteItemClick: function(item, e) {
if (this.api) {
this.api.asc_SpecialPaste(item.value);
var menu = this.btnSpecialPaste.menu;
if (!item.cmpEl) {
for (var i = 0; i < menu.items.length; i++) {
menu.items[i].setChecked(menu.items[i].value===item.value, true);
}
}
setTimeout(function(){
menu.hide();
}, 100);
}
return false;
},
SetDisabled: function(state) {
this._isDisabled = state;

View file

@ -121,7 +121,8 @@ define([
me._TtHeight = 20;
/** coauthoring begin **/
this.wrapEvents = {
apiHideComment: _.bind(this.onApiHideComment, this)
apiHideComment: _.bind(this.onApiHideComment, this),
onKeyUp: _.bind(this.onKeyUp, this)
};
/** coauthoring end **/
@ -1846,6 +1847,9 @@ define([
onDocumentKeyDown: function(event){
if (this.api){
var key = event.keyCode;
if (this.hkSpecPaste) {
this._needShowSpecPasteMenu = !event.shiftKey && !event.altKey && event.keyCode == Common.UI.Keys.CTRL;
}
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey){
if (key === Common.UI.Keys.NUM_PLUS || key === Common.UI.Keys.EQUALITY || (Common.Utils.isGecko && key === Common.UI.Keys.EQUALITY_FF) || (Common.Utils.isOpera && key == 43)){
if (!this.api.isCellEdited) {
@ -2944,8 +2948,10 @@ define([
parentEl: $('#id-document-holder-btn-special-paste'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-paste',
caption : Common.Utils.String.platformKey('Ctrl', '({0})'),
menu : new Common.UI.Menu({items: []})
});
me.initSpecialPasteEvents();
}
if (pasteItems.length>0) {
@ -2963,49 +2969,19 @@ define([
_.each(pasteItems, function(menuItem, index) {
if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) {
importText = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem][0],
caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''),
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
(new Common.Views.OpenDialog({
title: me.txtImportWizard,
closable: true,
type: Common.Utils.importTextType.Paste,
preview: true,
api: me.api,
handler: function (result, settings) {
if (result == 'ok') {
if (me && me.api) {
var props = new Asc.SpecialPasteProps();
props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport);
props.asc_setAdvancedOptions(settings.textOptions);
me.api.asc_SpecialPaste(props);
}
me._state.lastSpecPasteChecked = item;
} else {
item.setChecked(false, true);
me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true);
}
}
})).show();
setTimeout(function(){menu.hide();}, 100);
});
}).on('click', _.bind(me.onSpecialPasteItemClick, me));
me._arrSpecialPaste[menuItem][2] = importText;
} else if (me._arrSpecialPaste[menuItem]) {
var mnu = new Common.UI.MenuItem({
caption: me._arrSpecialPaste[menuItem][0],
caption: me._arrSpecialPaste[menuItem][0] + (me.hkSpecPaste[menuItem] ? ' (' + me.hkSpecPaste[menuItem] + ')' : ''),
value: menuItem,
checkable: true,
toggleGroup : 'specialPasteGroup'
}).on('click', function(item, e) {
me._state.lastSpecPasteChecked = item;
var props = new Asc.SpecialPasteProps();
props.asc_setProps(item.value);
me.api.asc_SpecialPaste(props);
setTimeout(function(){menu.hide();}, 100);
});
}).on('click', _.bind(me.onSpecialPasteItemClick, me));
groups[me._arrSpecialPaste[menuItem][1]].push(mnu);
me._arrSpecialPaste[menuItem][2] = mnu;
}
@ -3056,6 +3032,7 @@ define([
if ( coord[0].asc_getX()<0 || coord[0].asc_getY()<0) {
if (pasteContainer.is(':visible')) pasteContainer.hide();
$(document).off('keyup', this.wrapEvents.onKeyUp);
return;
}
@ -3081,12 +3058,117 @@ define([
pasteContainer.css({left: showPoint[0], top : showPoint[1]});
pasteContainer.show();
setTimeout(function() {
$(document).on('keyup', me.wrapEvents.onKeyUp);
}, 10);
},
onHideSpecialPasteOptions: function() {
var pasteContainer = this.documentHolder.cmpEl.find('#special-paste-container');
if (pasteContainer.is(':visible'))
if (pasteContainer.is(':visible')) {
pasteContainer.hide();
$(document).off('keyup', this.wrapEvents.onKeyUp);
}
},
onSpecialPasteItemClick: function(item, e) {
var me = this,
menu = this.btnSpecialPaste.menu;
if (item.value == Asc.c_oSpecialPasteProps.useTextImport) {
(new Common.Views.OpenDialog({
title: me.txtImportWizard,
closable: true,
type: Common.Utils.importTextType.Paste,
preview: true,
api: me.api,
handler: function (result, settings) {
if (result == 'ok') {
if (me && me.api) {
var props = new Asc.SpecialPasteProps();
props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport);
props.asc_setAdvancedOptions(settings.textOptions);
me.api.asc_SpecialPaste(props);
}
me._state.lastSpecPasteChecked = item;
} else if (item.cmpEl) {
item.setChecked(false, true);
me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true);
}
}
})).show();
setTimeout(function(){menu.hide();}, 100);
} else {
me._state.lastSpecPasteChecked = item;
var props = new Asc.SpecialPasteProps();
props.asc_setProps(item.value);
me.api.asc_SpecialPaste(props);
setTimeout(function(){menu.hide();}, 100);
}
if (!item.cmpEl && me._state.lastSpecPasteChecked) {
for (var i = 0; i < menu.items.length; i++) {
menu.items[i].setChecked(menu.items[i].value===me._state.lastSpecPasteChecked.value, true);
}
}
return false;
},
onKeyUp: function (e) {
if (e.keyCode == Common.UI.Keys.CTRL && this._needShowSpecPasteMenu && !this.btnSpecialPaste.menu.isVisible() && /area_id/.test(e.target.id)) {
$('button', this.btnSpecialPaste.cmpEl).click();
e.preventDefault();
}
this._needShowSpecPasteMenu = false;
},
initSpecialPasteEvents: function() {
var me = this;
me.hkSpecPaste = [];
me.hkSpecPaste[Asc.c_oSpecialPasteProps.paste] = 'P';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = 'F';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = 'O';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = 'K';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = 'B';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = 'W';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = 'G';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.transpose] = 'T';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = 'V';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = 'A';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = 'E';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = 'R';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.link] = 'N';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.picture] = 'U';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.linkedPicture] = 'I';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.sourceformatting] = 'K';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = 'M';
me.hkSpecPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = 'T';
// me.hkSpecPaste[Asc.c_oSpecialPasteProps.useTextImport] = '';
var str = '';
for(var key in me.hkSpecPaste){
if(me.hkSpecPaste.hasOwnProperty(key)){
if (str.indexOf(me.hkSpecPaste[key])<0)
str += me.hkSpecPaste[key] + ',';
}
}
str = str.substring(0, str.length-1)
var keymap = {};
keymap[str] = _.bind(function(e) {
var menu = this.btnSpecialPaste.menu;
for (var i = 0; i < menu.items.length; i++) {
if (this.hkSpecPaste[menu.items[i].value] === String.fromCharCode(e.keyCode)) {
return me.onSpecialPasteItemClick({value: menu.items[i].value});
}
}
}, me);
Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap});
Common.util.Shortcuts.suspendEvents(str, undefined, true);
me.btnSpecialPaste.menu.on('show:after', function(menu) {
Common.util.Shortcuts.resumeEvents(str);
}).on('hide:after', function(menu) {
Common.util.Shortcuts.suspendEvents(str, undefined, true);
});
},
onToggleAutoCorrectOptions: function(autoCorrectOptions) {