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 <luzar.david@gmail.com>
This commit is contained in:
Aakansha Doshi 2022-06-14 16:27:41 +05:30 committed by GitHub
parent f1bc90e08a
commit 5daff2d3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;