Skip to content

Commit

Permalink
Add more fixes for sse shortcut actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Coolcooo committed Feb 7, 2025
1 parent 50fd9f3 commit 657d900
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 260 deletions.
4 changes: 2 additions & 2 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9545,8 +9545,8 @@ var editor;
[Asc.c_oAscSpreadsheetShortcutType.DrawingSubscript, 190, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.CellGeneralFormat, 192, true, true, false],
[Asc.c_oAscSpreadsheetShortcutType.ShowFormulas, 192, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.DrawingDecreaseFontSize, 219, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.DrawingIncreaseFontSize, 221, true, false, false]
[Asc.c_oAscSpreadsheetShortcutType.DecreaseFontSize, 219, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize, 221, true, false, false]
];
this.initShortcuts(aShortcuts, false);
};
Expand Down
159 changes: 4 additions & 155 deletions cell/apiDefines.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ var c_oAscPopUpSelectorType = {
CellExponentialFormat : 26,
CellGeneralFormat : 27,
ShowFormulas : 28,
DrawingIncreaseFontSize : 29,
DrawingDecreaseFontSize : 31,
IncreaseFontSize : 29,
DecreaseFontSize : 31,
DrawingSubscript : 32,
DrawingSuperscript : 33,
DrawingCenterPara : 34,
Expand All @@ -687,81 +687,6 @@ var c_oAscPopUpSelectorType = {
manual: 2
};

const c_oAscCellShortcutType = {
refreshAllConnections : 0,
refreshSelectedConnections: 1,
changeFormatTableInfo : 2,
calculateAll : 3,
calculateActiveSheet : 5,
focusOnCellEditor : 7,
addDate : 8,
addTime : 9,
removeActiveCell : 10,
emptyRange : 11,
moveActiveCellToLeft : 12,
moveActiveCellToRight : 13,
moveActiveCellToDown : 14,
moveActiveCellToUp : 15,
reset : 16,
disableNumLock : 17,
disableScrollLock : 18,
selectColumn : 19,
selectRow : 20,
selectSheet : 21,
addSeparator : 22,
goToPreviousSheet : 23,
moveToTopCell : 24,
moveToNextSheet : 25,
moveToLeftEdgeCell : 26,
selectToLeftEdgeCell : 27,
moveToLeftCell : 28,
selectToLeftCell : 29,
moveToRightEdgeCell : 30,
selectToRightEdgeCell : 31,
moveToRightCell : 32,
selectToRightCell : 33,
selectToTopCell : 34,
moveToUpCell : 35,
selectToUpCell : 36,
moveToBottomCell : 37,
selectToBottomCell : 38,
moveToDownCell : 39,
selectToDownCell : 40,
moveToFirstColumn : 41,
selectToFirstColumn : 42,
moveToLeftEdgeTop : 43,
selectToLeftEdgeTop : 44,
moveToRightBottomEdge : 45,
selectToRightBottomEdge : 46,
setNumberFormat : 47,
setTimeFormat : 48,
setDateFormat : 49,
setCurrencyFormat : 50,
setPercentFormat : 51,
setStrikethrough : 52,
setExponentialFormat : 53,
setBold : 54,
setItalic : 55,
setUnderline : 56,
setGeneralFormat : 57,
redo : 58,
undo : 59,
print : 60,
addSum : 61,
moveToUpperCell : 62,
contextMenu : 63,
moveToLowerCell : 64,
selectToLowerCell : 65,
selectToUpperCell : 66,
showFilterOptions : 67,
showAutoComplete : 68,
showDataValidation : 69,
increaseFontSize : 70,
decreaseFontSize : 71,
selectAll : 72,
save : 73
};

//----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].c_oAscDrawDepOptions = c_oAscDrawDepOptions;
Expand Down Expand Up @@ -1248,8 +1173,8 @@ var c_oAscPopUpSelectorType = {
prot["CellExponentialFormat"] = prot.CellExponentialFormat;
prot["CellGeneralFormat"] = prot.CellGeneralFormat;
prot["ShowFormulas"] = prot.ShowFormulas;
prot["DrawingIncreaseFontSize"] = prot.DrawingIncreaseFontSize;
prot["DrawingDecreaseFontSize"] = prot.DrawingDecreaseFontSize;
prot["IncreaseFontSize"] = prot.IncreaseFontSize;
prot["DecreaseFontSize"] = prot.DecreaseFontSize;
prot["DrawingSubscript"] = prot.DrawingSubscript;
prot["DrawingSuperscript"] = prot.DrawingSuperscript;
prot["DrawingCenterPara"] = prot.DrawingCenterPara;
Expand All @@ -1265,80 +1190,4 @@ var c_oAscPopUpSelectorType = {
prot['autoNoTable'] = prot.autoNoTable;
prot['manual'] = prot.manual;


window['Asc']['c_oAscCellShortcutType'] = window['Asc'].c_oAscCellShortcutType = c_oAscCellShortcutType;
prot = c_oAscCellShortcutType;
prot['refreshAllConnections'] = c_oAscCellShortcutType.refreshAllConnections;
prot['refreshSelectedConnections'] = c_oAscCellShortcutType.refreshSelectedConnections;
prot['changeFormatTableInfo'] = c_oAscCellShortcutType.changeFormatTableInfo;
prot['calculateAll'] = c_oAscCellShortcutType.calculateAll;
prot['calculateActiveSheet'] = c_oAscCellShortcutType.calculateActiveSheet;
prot['focusOnCellEditor'] = c_oAscCellShortcutType.focusOnCellEditor;
prot['addDate'] = c_oAscCellShortcutType.addDate;
prot['addTime'] = c_oAscCellShortcutType.addTime;
prot['removeActiveCell'] = c_oAscCellShortcutType.removeActiveCell;
prot['emptyRange'] = c_oAscCellShortcutType.emptyRange;
prot['moveActiveCellToLeft'] = c_oAscCellShortcutType.moveActiveCellToLeft;
prot['moveActiveCellToRight'] = c_oAscCellShortcutType.moveActiveCellToRight;
prot['moveActiveCellToDown'] = c_oAscCellShortcutType.moveActiveCellToDown;
prot['moveActiveCellToUp'] = c_oAscCellShortcutType.moveActiveCellToUp;
prot['reset'] = c_oAscCellShortcutType.reset;
prot['disableNumLock'] = c_oAscCellShortcutType.disableNumLock;
prot['disableScrollLock'] = c_oAscCellShortcutType.disableScrollLock;
prot['selectColumn'] = c_oAscCellShortcutType.selectColumn;
prot['selectRow'] = c_oAscCellShortcutType.selectRow;
prot['selectSheet'] = c_oAscCellShortcutType.selectSheet;
prot['addSeparator'] = c_oAscCellShortcutType.addSeparator;
prot['goToPreviousSheet'] = c_oAscCellShortcutType.goToPreviousSheet;
prot['moveToTopCell'] = c_oAscCellShortcutType.moveToTopCell;
prot['moveToNextSheet'] = c_oAscCellShortcutType.moveToNextSheet;
prot['moveToLeftEdgeCell'] = c_oAscCellShortcutType.moveToLeftEdgeCell;
prot['selectToLeftEdgeCell'] = c_oAscCellShortcutType.selectToLeftEdgeCell;
prot['moveToLeftCell'] = c_oAscCellShortcutType.moveToLeftCell;
prot['selectToLeftCell'] = c_oAscCellShortcutType.selectToLeftCell;
prot['moveToRightEdgeCell'] = c_oAscCellShortcutType.moveToRightEdgeCell;
prot['selectToRightEdgeCell'] = c_oAscCellShortcutType.selectToRightEdgeCell;
prot['moveToRightCell'] = c_oAscCellShortcutType.moveToRightCell;
prot['selectToRightCell'] = c_oAscCellShortcutType.selectToRightCell;
prot['selectToTopCell'] = c_oAscCellShortcutType.selectToTopCell;
prot['moveToUpCell'] = c_oAscCellShortcutType.moveToUpCell;
prot['selectToUpCell'] = c_oAscCellShortcutType.selectToUpCell;
prot['moveToBottomCell'] = c_oAscCellShortcutType.moveToBottomCell;
prot['selectToBottomCell'] = c_oAscCellShortcutType.selectToBottomCell;
prot['moveToDownCell'] = c_oAscCellShortcutType.moveToDownCell;
prot['selectToDownCell'] = c_oAscCellShortcutType.selectToDownCell;
prot['moveToFirstColumn'] = c_oAscCellShortcutType.moveToFirstColumn;
prot['selectToFirstColumn'] = c_oAscCellShortcutType.selectToFirstColumn;
prot['moveToLeftEdgeTop'] = c_oAscCellShortcutType.moveToLeftEdgeTop;
prot['selectToLeftEdgeTop'] = c_oAscCellShortcutType.selectToLeftEdgeTop;
prot['moveToRightBottomEdge'] = c_oAscCellShortcutType.moveToRightBottomEdge;
prot['selectToRightBottomEdge'] = c_oAscCellShortcutType.selectToRightBottomEdge;
prot['setNumberFormat'] = c_oAscCellShortcutType.setNumberFormat;
prot['setTimeFormat'] = c_oAscCellShortcutType.setTimeFormat;
prot['setDateFormat'] = c_oAscCellShortcutType.setDateFormat;
prot['setCurrencyFormat'] = c_oAscCellShortcutType.setCurrencyFormat;
prot['setPercentFormat'] = c_oAscCellShortcutType.setPercentFormat;
prot['setStrikethrough'] = c_oAscCellShortcutType.setStrikethrough;
prot['setExponentialFormat'] = c_oAscCellShortcutType.setExponentialFormat;
prot['setBold'] = c_oAscCellShortcutType.setBold;
prot['setItalic'] = c_oAscCellShortcutType.setItalic;
prot['setUnderline'] = c_oAscCellShortcutType.setUnderline;
prot['setGeneralFormat'] = c_oAscCellShortcutType.setGeneralFormat;
prot['redo'] = c_oAscCellShortcutType.redo;
prot['undo'] = c_oAscCellShortcutType.undo;
prot['print'] = c_oAscCellShortcutType.print;
prot['addSum'] = c_oAscCellShortcutType.addSum;
prot['moveToUpperCell'] = c_oAscCellShortcutType.moveToUpperCell;
prot['contextMenu'] = c_oAscCellShortcutType.contextMenu;
prot['moveToLowerCell'] = c_oAscCellShortcutType.moveToLowerCell;
prot['selectToLowerCell'] = c_oAscCellShortcutType.selectToLowerCell;
prot['selectToUpper Cell'] = c_oAscCellShortcutType.selectToUpperCell;
prot['showFilterOptions'] = c_oAscCellShortcutType.showFilterOptions;
prot['showAutoComplete'] = c_oAscCellShortcutType.showAutoComplete;
prot['showDataValidation'] = c_oAscCellShortcutType.showDataValidation;
prot['increaseFontSize'] = c_oAscCellShortcutType.increaseFontSize;
prot['decreaseFontSize'] = c_oAscCellShortcutType.decreaseFontSize;
prot['selectAll'] = c_oAscCellShortcutType.selectAll;
prot['save'] = c_oAscCellShortcutType.save;

})(window);
22 changes: 9 additions & 13 deletions cell/view/CellEditorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ function (window, undefined) {
// Event handlers
CellEditor.prototype.executeShortcut = function(nShortcutAction) {
let oResult = {keyResult: keydownresult_PreventAll};

const oApi = window["Asc"]["editor"];
const bHieroglyph = this.isTopLineActive && AscCommonExcel.getFragmentsLength(this.options.fragments) !== this.input.value.length;
switch (nShortcutAction) {
case Asc.c_oAscSpreadsheetShortcutType.Strikeout: {
Expand Down Expand Up @@ -2572,6 +2572,14 @@ function (window, undefined) {
}
break;
}
case Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize:
case Asc.c_oAscSpreadsheetShortcutType.DecreaseFontSize: {
if (bHieroglyph) {
this._syncEditors();
}
this.setTextStyle("changeFontSize", nShortcutAction === Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize);
break;
}
default: {
const oCustom = oApi.getCustomShortcutAction(nShortcutAction);
if (oCustom) {
Expand Down Expand Up @@ -2805,18 +2813,6 @@ function (window, undefined) {
}
break;
}
case 219:
case 221: {
if (ctrlKey) {
nRetValue = keydownresult_PreventAll;
if (bHieroglyph) {
oThis._syncEditors();
}
oThis.setTextStyle("changeFontSize", oEvent.GetKeyCode() === 221);
return true;
}
break;
}
default: {
nRetValue = keydownresult_PreventNothing;
break;
Expand Down
18 changes: 9 additions & 9 deletions cell/view/EventsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,14 @@
this.handlers.trigger("showFormulas");
break;
}
case Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize:
case Asc.c_oAscSpreadsheetShortcutType.DecreaseFontSize: {
if (this.getCellEditMode() || !bCanEdit || bSelectionDialogMode) {
return true;
}
this.view.setFontAttributes("changeFontSize", nShortcutAction === Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize);
break;
}
default: {
const oCustom = this.view.Api.getCustomShortcutAction(nShortcutAction);
if (oCustom) {
Expand Down Expand Up @@ -1075,7 +1083,7 @@


const oShortcutRes = this.executeShortcut(nShortcutAction);
if (this.executeShortcut(nShortcutAction)) {
if (oShortcutRes) {
nRetValue = oShortcutRes.keyResult;
} else {
switch (oEvent.GetKeyCode()) {
Expand Down Expand Up @@ -1277,14 +1285,6 @@
this.handlers.trigger('onContextMenu', oEvent);
}
break;
case 219:
case 221:
if (!oEvent.CtrlKey || oThis.getCellEditMode() || !bCanEdit || bSelectionDialogMode) {
return true;
}
nRetValue = keydownresult_PreventAll;
oThis.view.setFontAttributes("changeFontSize", oEvent.KeyCode === 221);
break;
default:
nRetValue = keydownresult_PreventNothing;
break;
Expand Down
9 changes: 5 additions & 4 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,17 +1160,18 @@
};

WorkbookView.prototype.executeShortcut = function(nShortcutAction) {
const objectRender = this.getWorksheet().objectRender;
if (objectRender && !this.getCellEditMode() && !this.controller.isMousePressed && this.enableKeyEvents) {
const oGraphicRet = objectRender.executeShortcut(nShortcutAction);
const oObjectRender = this.getWorksheet().objectRender;
if (oObjectRender && oObjectRender.getSelectedGraphicObjects().length > 0 && !this.getCellEditMode() && !this.controller.isMousePressed && this.enableKeyEvents) {
const oGraphicRet = oObjectRender.controller.executeShortcut(nShortcutAction);
if (oGraphicRet) {
return true;
}
}

let oRetValue = this.controller.executeShortcut(nShortcutAction);
if (this.isCellEditMode && !this.controller.skipCellEditor) {
oRetValue = oRetValue || this.cellEditor.executeShortcut(nShortcutAction);
const oCellRetValue = this.cellEditor.executeShortcut(nShortcutAction);
oRetValue = oRetValue || oCellRetValue;
}
this.controller.setSkipCellEditor(false);
return !!oRetValue;
Expand Down
7 changes: 4 additions & 3 deletions common/Drawings/CommonController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5720,6 +5720,7 @@
executeShortcut: function(nShortcutAction) {
let oRet = {keyResult: keydownresult_PreventDefault};
const bCanEdit = this.canEdit();
const oApi = window["Asc"]["editor"];
switch (nShortcutAction) {
case Asc.c_oAscSpreadsheetShortcutType.Bold: {
if (bCanEdit) {
Expand Down Expand Up @@ -5757,14 +5758,14 @@
{
break;
}
case Asc.c_oAscSpreadsheetShortcutType.DrawingIncreaseFontSize: {
case Asc.c_oAscSpreadsheetShortcutType.IncreaseFontSize: {
if (!bCanEdit) {
break;
}
this.increaseFontSize();
break;
}
case Asc.c_oAscSpreadsheetShortcutType.DrawingDecreaseFontSize: {
case Asc.c_oAscSpreadsheetShortcutType.DecreaseFontSize: {
if (!bCanEdit) {
break;
}
Expand Down Expand Up @@ -5914,7 +5915,7 @@
if (null !== oMath && oMath.Is_InInnerContent()) {
this.checkSelectedObjectsAndCallback(function () {
oMath.Handle_AddNewLine();
let oShape = target_doc_content.Is_DrawingShape(true);
let oShape = oTargetDocContent.Is_DrawingShape(true);
if(oShape)
oShape.checkExtentsByDocContent();
}, [], false, AscDFH.historydescription_Spreadsheet_AddNewParagraph, undefined, window["Asc"]["editor"].collaborativeEditing.getFast());
Expand Down
2 changes: 1 addition & 1 deletion common/Drawings/Format/SlicerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@
return false;
};
CSlicer.prototype.onKeyUp = function (e) {
if(e.keyCode === 91 /*meta*/|| e.keyCode === 17/*ctrl*/) {
if(e.KeyCode === 91 /*meta*/|| e.KeyCode === 17/*ctrl*/) {
if(this.isSubscribed()) {
this.unsubscribeFromEvents();
if(!this.eventListener) {
Expand Down
1 change: 0 additions & 1 deletion tests/cell/shortcuts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@
new CNativeEvent(keyCodes.ArrowBottom, false, false, true, false),
new CNativeEvent(keyCodes.ArrowTop, false, false, true, false)
];
tableEvents[tableHotkeyTypes.showDataValidation] = [new CNativeEvent(keyCodes.ArrowBottom, false, false, true, false)];
tableEvents[tableHotkeyTypes.increaseFontSize] = [new CNativeEvent(keyCodes.BracketRight, true, false, false, false)];
tableEvents[tableHotkeyTypes.decreaseFontSize] = [new CNativeEvent(keyCodes.BracketLeft, true, false, false, false)];

Expand Down
Loading

0 comments on commit 657d900

Please sign in to comment.