fix: keyboard-zooming in wysiwyg should zoom canvas (#4676)

This commit is contained in:
David Luzar 2022-01-31 10:43:03 +01:00 committed by GitHub
parent dcee594b66
commit 4b5270ab12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 5 deletions

View file

@ -25,6 +25,7 @@ import {
actionDecreaseFontSize,
actionIncreaseFontSize,
} from "../actions/actionProperties";
import { actionZoomIn, actionZoomOut } from "../actions/actionCanvas";
import App from "../components/App";
const normalizeText = (text: string) => {
@ -60,7 +61,6 @@ const getTransform = (
export const textWysiwyg = ({
id,
appState,
onChange,
onSubmit,
getViewportCoords,
@ -70,7 +70,6 @@ export const textWysiwyg = ({
app,
}: {
id: ExcalidrawElement["id"];
appState: AppState;
onChange?: (text: string) => void;
onSubmit: (data: {
text: string;
@ -102,6 +101,7 @@ export const textWysiwyg = ({
let originalContainerHeight: number;
const updateWysiwygStyle = () => {
const appState = app.state;
const updatedElement = Scene.getScene(element)?.getElement(
id,
) as ExcalidrawTextElement;
@ -291,7 +291,15 @@ export const textWysiwyg = ({
editable.onkeydown = (event) => {
event.stopPropagation();
if (actionDecreaseFontSize.keyTest(event)) {
if (actionZoomIn.keyTest(event)) {
event.preventDefault();
app.actionManager.executeAction(actionZoomIn);
updateWysiwygStyle();
} else if (actionZoomOut.keyTest(event)) {
event.preventDefault();
app.actionManager.executeAction(actionZoomOut);
updateWysiwygStyle();
} else if (actionDecreaseFontSize.keyTest(event)) {
app.actionManager.executeAction(actionDecreaseFontSize);
} else if (actionIncreaseFontSize.keyTest(event)) {
app.actionManager.executeAction(actionIncreaseFontSize);