From 6164b5273c39de875e136aa808f1e8a7ad62ec92 Mon Sep 17 00:00:00 2001 From: Bear <68773271+SnorfYang@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:22:39 +0800 Subject: [PATCH 1/2] fix: center align text when bind to container via context menu (#6451) --- src/actions/actionBoundText.tsx | 8 +++++++- src/element/textWysiwyg.test.tsx | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/actions/actionBoundText.tsx b/src/actions/actionBoundText.tsx index 990f98d41..3f240b5d8 100644 --- a/src/actions/actionBoundText.tsx +++ b/src/actions/actionBoundText.tsx @@ -1,4 +1,9 @@ -import { BOUND_TEXT_PADDING, ROUNDNESS, VERTICAL_ALIGN } from "../constants"; +import { + BOUND_TEXT_PADDING, + ROUNDNESS, + VERTICAL_ALIGN, + TEXT_ALIGN, +} from "../constants"; import { getNonDeletedElements, isTextElement, newElement } from "../element"; import { mutateElement } from "../element/mutateElement"; import { @@ -132,6 +137,7 @@ export const actionBindText = register({ mutateElement(textElement, { containerId: container.id, verticalAlign: VERTICAL_ALIGN.MIDDLE, + textAlign: TEXT_ALIGN.CENTER, }); mutateElement(container, { boundElements: (container.boundElements || []).concat({ diff --git a/src/element/textWysiwyg.test.tsx b/src/element/textWysiwyg.test.tsx index c55a9befa..4ae3f26f9 100644 --- a/src/element/textWysiwyg.test.tsx +++ b/src/element/textWysiwyg.test.tsx @@ -777,6 +777,13 @@ describe("textWysiwyg", () => { ]); expect(text.containerId).toBe(rectangle.id); expect(text.verticalAlign).toBe(VERTICAL_ALIGN.MIDDLE); + expect(text.textAlign).toBe(TEXT_ALIGN.CENTER); + expect(text.x).toBe( + h.elements[0].x + h.elements[0].width / 2 - text.width / 2, + ); + expect(text.y).toBe( + h.elements[0].y + h.elements[0].height / 2 - text.height / 2, + ); }); it("should update font family correctly on undo/redo by selecting bounded text when font family was updated", async () => { From b0b23353cfbb2def4bcceabdfbd2f0f3cf6d7f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie?= <110197391+fouqueta@users.noreply.github.com> Date: Fri, 14 Apr 2023 23:34:26 +0200 Subject: [PATCH 2/2] fix: split "Edit selected shape" shortcut (#6457) Co-authored-by: David Luzar --- src/components/HelpDialog.tsx | 11 ++++++----- src/locales/en.json | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/HelpDialog.tsx b/src/components/HelpDialog.tsx index 8cb775fc5..bd2f38417 100644 --- a/src/components/HelpDialog.tsx +++ b/src/components/HelpDialog.tsx @@ -165,11 +165,12 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => { shortcuts={[KEYS.E, KEYS["0"]]} /> +