Skip to content

Commit

Permalink
Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Coolcooo committed Oct 10, 2023
1 parent 3093b75 commit 5cf12a4
Show file tree
Hide file tree
Showing 7 changed files with 634 additions and 556 deletions.
52 changes: 52 additions & 0 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8911,6 +8911,58 @@ var editor;
return wb.getSpeechDescription(prevState, wb.getSelectionState(), action);
};

spreadsheet_api.prototype.initDefaultShortcuts = function()
{
// [[ActionType, KeyCode, Ctrl, Shift, Alt]]
const aShortcuts =
[
[Asc.c_oAscSpreadsheetShortcutType.RecalculateAll, 120, false, false, false],
[Asc.c_oAscSpreadsheetShortcutType.RecalculateActiveSheet, 120, false, true, false],
[Asc.c_oAscSpreadsheetShortcutType.EditSelectAll, 65, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.Strikeout, 53, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.Bold, 66, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.Italic, 73, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.Underline, 85, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.SpeechWorker, 90, true, false, true],
[Asc.c_oAscSpreadsheetShortcutType.RefreshAllPivots, 116, false, false, true],
[Asc.c_oAscSpreadsheetShortcutType.RefreshSelectedPivots, 116, true, false, true],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertDate, 186, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertTime, 186, true, true, false],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertDate, 59, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertTime, 59, true, true, false],
[Asc.c_oAscSpreadsheetShortcutType.NextWorksheet, 34, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.NextWorksheet, 34, false, false, true],
[Asc.c_oAscSpreadsheetShortcutType.PreviousWorksheet, 33, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.PreviousWorksheet, 33, false, false, true],
[Asc.c_oAscSpreadsheetShortcutType.EditUndo, 90, true, false, false],
[Asc.c_oAscSpreadsheetShortcutType.EditRedo, 89, true, false, false],

];
this.initShortcuts(aShortcuts, false);
};

spreadsheet_api.prototype.initWindowsShortcuts = function ()
{
// [[ActionType, KeyCode, Ctrl, Shift, Alt]]
const aShortcuts =
[
[Asc.c_oAscSpreadsheetShortcutType.CellInsertSumFunction, 61, false, false, true],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertSumFunction, 187, false, false, true],
];
this.initShortcuts(aShortcuts, false);
}
spreadsheet_api.prototype.initMacOsShortcuts = function ()
{
// [[ActionType, KeyCode, Ctrl, Shift, Alt]]
const aShortcuts =
[
[Asc.c_oAscSpreadsheetShortcutType.CellInsertSumFunction, 61, true, false, true],
[Asc.c_oAscSpreadsheetShortcutType.CellInsertSumFunction, 187, true, false, true],
];
this.initShortcuts(aShortcuts, false);
}


/*
* Export
* -----------------------------------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions cell/apiDefines.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,26 @@ var c_oAscPopUpSelectorType = {
dependent: 2
};

var c_oAscSpreadsheetShortcutType = {
RefreshAllPivots: 1,
RefreshSelectedPivots: 2,
EditSelectAll: 3,
RecalculateAll: 4,
RecalculateActiveSheet: 5,
CellInsertDate: 6,
CellInsertTime: 7,
CellInsertSumFunction: 8,
NextWorksheet: 9,
PreviousWorksheet: 10,
Strikeout: 11,
Italic: 12,
Bold: 13,
Underline: 14,
EditUndo: 15,
EditRedo: 16,
SpeechWorker: 17,
};

//----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].c_oAscDrawDepOptions = c_oAscDrawDepOptions;
Expand Down Expand Up @@ -998,5 +1018,9 @@ var c_oAscPopUpSelectorType = {
prot['precedent'] = prot.precedent;
prot['dependent'] = prot.dependent;

window['Asc']['c_oAscSpreadsheetShortcutType'] = window['Asc'].c_oAscSpreadsheetShortcutType = c_oAscSpreadsheetShortcutType;
prot = c_oAscSpreadsheetShortcutType;



})(window);
176 changes: 69 additions & 107 deletions cell/view/CellEditorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,7 @@
var ctrlKey = !AscCommon.getAltGr(event) && (event.metaKey || event.ctrlKey);
const bIsMacOs = AscCommon.AscBrowser.isMacOs;
const bIsWordRemove = bIsMacOs ? event.altKey : ctrlKey;
let nRetValue = keydownresult_PreventKeyPress;

if (this.handlers.trigger('getWizard') || !t.isOpened || (!isInput && !t.enableKeyEvents && event.emulated !== true)) {
return true;
Expand All @@ -2441,6 +2442,72 @@
hieroglyph = true;
}

AscCommon.check_KeyboardEvent(event);
const oEvent = AscCommon.global_keyboardEvent;
const nShortcutAction = t.view.Api.getShortcut(oEvent);
switch (nShortcutAction) {
case Asc.c_oAscSpreadsheetShortcutType.Strikeout:
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("s", null);
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.Bold:
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("b", null);
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.Italic:
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("i", null);
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.Underline:
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("u", null);
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.EditSelectAll:
if (!t.hasFocus) {
t.setFocus(true);
}
if (!t.isTopLineActive) {
nRetValue = keydownresult_PreventAll;
}
t._moveCursor(kBeginOfText);
t._selectChars(kEndOfText);
break;
case Asc.c_oAscSpreadsheetShortcutType.EditUndo:
{
t.undo();
nRetValue = keydownresult_PreventAll;
break;
}
case Asc.c_oAscSpreadsheetShortcutType.EditRedo:
t.redo();
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.CellInsertTime:
var oDate = new Asc.cDate();
t._addChars(oDate.getTimeString(api));
nRetValue = keydownresult_PreventAll;
break;
case Asc.c_oAscSpreadsheetShortcutType.CellInsertDate:
var oDate = new Asc.cDate();
t._addChars(oDate.getDateString(api));
nRetValue = keydownresult_PreventAll;
break;
default:
break;
}

let api = window["Asc"]["editor"];
switch (event.which) {

Expand Down Expand Up @@ -2503,15 +2570,6 @@
t._removeChars(bIsWordRemove ? kPrevWord : kPrevChar);
return false;

case 32: // "space"

t._addChars(String.fromCharCode(32));
event.stopPropagation();
event.preventDefault();

t._setSkipKeyPress(false);
return false;

case 35: // "end"
if (!this.enableKeyEvents) {
break;
Expand Down Expand Up @@ -2648,84 +2706,6 @@
t._removeChars(bIsWordRemove ? kNextWord : kNextChar);
return true;

case 53: // 5
if (ctrlKey) {
// Отключим стандартную обработку браузера нажатия ctrl + 5
event.stopPropagation();
event.preventDefault();
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("s", null);
return true;
}
break;

case 65: // A
if (ctrlKey) {
if (!t.hasFocus) {
t.setFocus(true);
}
// Отключим стандартную обработку браузера нажатия ctrl + a
if (!t.isTopLineActive) {
event.stopPropagation();
event.preventDefault();
}
t._moveCursor(kBeginOfText);
t._selectChars(kEndOfText);
return true;
}
break;

case 66: // B
if (ctrlKey) {
// Отключим стандартную обработку браузера нажатия ctrl + b
event.stopPropagation();
event.preventDefault();
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("b", null);
return true;
}
break;

case 73: // I
if (ctrlKey) {
// Отключим стандартную обработку браузера нажатия ctrl + i
event.stopPropagation();
event.preventDefault();
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("i", null);
return true;
}
break;

/*case 83: // S
if (ctrlKey) {
if (hieroglyph) {t._syncEditors();}
if (false === t.handlers.trigger("isGlobalLockEditCell"))
t._tryCloseEditor(event);
return false;
}
break;*/

case 85: // U
if (ctrlKey) {
// Отключим стандартную обработку браузера нажатия ctrl + u
event.stopPropagation();
event.preventDefault();
if (hieroglyph) {
t._syncEditors();
}
t.setTextStyle("u", null);
return true;
}
break;

case 144://Num Lock
case 145://Scroll Lock
if (AscBrowser.isOpera) {
Expand All @@ -2741,15 +2721,6 @@
return false;
}
break;
case 89: // ctrl + y
case 90: // ctrl + z
if (ctrlKey) {
event.stopPropagation();
event.preventDefault();
event.which === 90 ? t.undo() : t.redo();
return false;
}
break;

case 110: //NumpadDecimal
t._addChars(api.asc_getDecimalSeparator());
Expand All @@ -2775,20 +2746,11 @@
event.stopPropagation();
event.preventDefault();
return false;

case 59:
case 186: // ctrl + (shift) + ;
if (ctrlKey) {
var oDate = new Asc.cDate();
t._addChars(event.shiftKey ? oDate.getTimeString(api) : oDate.getDateString(api));
event.stopPropagation();
event.preventDefault();
}
default:
t._setSkipKeyPress(false);
return false;
break;
}

t._setSkipKeyPress(false);
t.skipTLUpdate = true;
return true;
};
Expand Down
Loading

0 comments on commit 5cf12a4

Please sign in to comment.