mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: cmd/ctrl native browser behavior blocked in inputs (#4589)
* fix: cmd/ctrl native browser behavior blocked in inputs * add basic test for fontSize increase/decrease via keyboard * add tests for fontSize resizing via keyboard outside wysiwyg * Update src/element/textWysiwyg.test.tsx Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> * Update src/tests/resize.test.tsx Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> * Update src/tests/resize.test.tsx Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com> Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
dba71e358d
commit
1fd2fe56ee
6 changed files with 83 additions and 17 deletions
|
@ -17,6 +17,11 @@ import {
|
|||
getContainerElement,
|
||||
wrapText,
|
||||
} from "./textElement";
|
||||
import {
|
||||
actionDecreaseFontSize,
|
||||
actionIncreaseFontSize,
|
||||
} from "../actions/actionProperties";
|
||||
import App from "../components/App";
|
||||
|
||||
const normalizeText = (text: string) => {
|
||||
return (
|
||||
|
@ -60,6 +65,7 @@ export const textWysiwyg = ({
|
|||
element,
|
||||
canvas,
|
||||
excalidrawContainer,
|
||||
app,
|
||||
}: {
|
||||
id: ExcalidrawElement["id"];
|
||||
appState: AppState;
|
||||
|
@ -73,6 +79,7 @@ export const textWysiwyg = ({
|
|||
element: ExcalidrawTextElement;
|
||||
canvas: HTMLCanvasElement | null;
|
||||
excalidrawContainer: HTMLDivElement | null;
|
||||
app: App;
|
||||
}) => {
|
||||
const textPropertiesUpdated = (
|
||||
updatedElement: ExcalidrawTextElement,
|
||||
|
@ -293,16 +300,18 @@ export const textWysiwyg = ({
|
|||
}
|
||||
|
||||
editable.onkeydown = (event) => {
|
||||
if (!event[KEYS.CTRL_OR_CMD]) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
if (event.key === KEYS.ESCAPE) {
|
||||
event.stopPropagation();
|
||||
|
||||
if (actionDecreaseFontSize.keyTest(event)) {
|
||||
app.actionManager.executeAction(actionDecreaseFontSize);
|
||||
} else if (actionIncreaseFontSize.keyTest(event)) {
|
||||
app.actionManager.executeAction(actionIncreaseFontSize);
|
||||
} else if (event.key === KEYS.ESCAPE) {
|
||||
event.preventDefault();
|
||||
submittedViaKeyboard = true;
|
||||
handleSubmit();
|
||||
} else if (event.key === KEYS.ENTER && event[KEYS.CTRL_OR_CMD]) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (event.isComposing || event.keyCode === 229) {
|
||||
return;
|
||||
}
|
||||
|
@ -315,7 +324,6 @@ export const textWysiwyg = ({
|
|||
event.code === CODES.BRACKET_RIGHT))
|
||||
) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (event.shiftKey || event.code === CODES.BRACKET_LEFT) {
|
||||
outdent();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue