Skip to content

Commit

Permalink
Merge pull request #1342 from AyushAgrawal-A2/ayush/1337
Browse files Browse the repository at this point in the history
fix: ctrl+b shortcut should not trigger browser native actions
  • Loading branch information
davidkircos committed May 22, 2024
2 parents 8402ced + 0eb2f68 commit a3dae12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { pythonWebWorker } from '../../../web-workers/pythonWebWorker/pythonWebW
import { zoomIn, zoomOut, zoomTo100, zoomToFit, zoomToSelection } from '../../helpers/zoom';
import { pixiApp } from '../../pixiApp/PixiApp';

export async function keyboardViewport(options: {
export function keyboardViewport(options: {
event: KeyboardEvent;
editorInteractionState: EditorInteractionState;
setEditorInteractionState: React.Dispatch<React.SetStateAction<EditorInteractionState>>;
presentationMode: boolean;
setPresentationMode: Function;
}): Promise<boolean> {
}): boolean {
const { event, editorInteractionState, setEditorInteractionState, presentationMode, setPresentationMode } = options;
const { pointer } = pixiApp;

Expand Down Expand Up @@ -101,14 +101,16 @@ export async function keyboardViewport(options: {
}

if ((event.metaKey || event.ctrlKey) && event.key === 'b') {
const formatPrimaryCell = await sheets.sheet.getFormatPrimaryCell();
setBold(!(formatPrimaryCell ? formatPrimaryCell.bold === true : true));
sheets.sheet
.getFormatPrimaryCell()
.then((formatPrimaryCell) => setBold(!(formatPrimaryCell ? formatPrimaryCell.bold === true : true)));
return true;
}

if ((event.metaKey || event.ctrlKey) && event.key === 'i') {
const formatPrimaryCell = await sheets.sheet.getFormatPrimaryCell();
setItalic(!(formatPrimaryCell ? formatPrimaryCell.italic === true : true));
sheets.sheet
.getFormatPrimaryCell()
.then((formatPrimaryCell) => setItalic(!(formatPrimaryCell ? formatPrimaryCell.italic === true : true)));
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export const useKeyboard = (props: IProps): { onKeyDown: (event: React.KeyboardE
if (pixiAppSettings.input.show || inlineEditorHandler.isOpen()) return;

if (
(await keyboardViewport({
keyboardViewport({
event,
editorInteractionState,
setEditorInteractionState,
presentationMode,
setPresentationMode,
})) ||
}) ||
keyboardSearch(event, editorInteractionState, setEditorInteractionState)
) {
event.stopPropagation();
Expand Down

0 comments on commit a3dae12

Please sign in to comment.