From 5daff2d3cd3c049e501cb6bd7cf0810923ba92b3 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 14 Jun 2022 16:27:41 +0530 Subject: [PATCH] fix: copy arrow head when using copy styles (#5303) * fix: copy arrow head when using copy styles * remove mutations & check against `arrow` type * fix lint Co-authored-by: dwelle --- src/actions/actionStyles.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/actions/actionStyles.ts b/src/actions/actionStyles.ts index 0f4aff99..084d74c9 100644 --- a/src/actions/actionStyles.ts +++ b/src/actions/actionStyles.ts @@ -6,7 +6,7 @@ import { import { CODES, KEYS } from "../keys"; import { t } from "../i18n"; import { register } from "./register"; -import { mutateElement, newElementWith } from "../element/mutateElement"; +import { newElementWith } from "../element/mutateElement"; import { DEFAULT_FONT_SIZE, DEFAULT_FONT_FAMILY, @@ -49,7 +49,7 @@ export const actionPasteStyles = register({ return { elements: elements.map((element) => { if (appState.selectedElementIds[element.id]) { - const newElement = newElementWith(element, { + let newElement = newElementWith(element, { backgroundColor: pastedElement?.backgroundColor, strokeWidth: pastedElement?.strokeWidth, strokeColor: pastedElement?.strokeColor, @@ -58,8 +58,9 @@ export const actionPasteStyles = register({ opacity: pastedElement?.opacity, roughness: pastedElement?.roughness, }); - if (isTextElement(newElement) && isTextElement(element)) { - mutateElement(newElement, { + + if (isTextElement(newElement)) { + newElement = newElementWith(newElement, { fontSize: pastedElement?.fontSize || DEFAULT_FONT_SIZE, fontFamily: pastedElement?.fontFamily || DEFAULT_FONT_FAMILY, textAlign: pastedElement?.textAlign || DEFAULT_TEXT_ALIGN, @@ -67,6 +68,14 @@ export const actionPasteStyles = register({ redrawTextBoundingBox(newElement, getContainerElement(newElement)); } + + if (newElement.type === "arrow") { + newElement = newElementWith(newElement, { + startArrowhead: pastedElement.startArrowhead, + endArrowhead: pastedElement.endArrowhead, + }); + } + return newElement; } return element;