Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: copy arrow head when using copy styles #5303

Merged
merged 3 commits into from Jun 14, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/actions/actionStyles.ts
Expand Up @@ -13,6 +13,7 @@ import {
DEFAULT_TEXT_ALIGN,
} from "../constants";
import { getContainerElement } from "../element/textElement";
import { isLinearElement } from "../element/typeChecks";

// `copiedStyles` is exported only for tests.
export let copiedStyles: string = "{}";
Expand Down Expand Up @@ -49,7 +50,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,
Expand All @@ -58,15 +59,24 @@ 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,
});

redrawTextBoundingBox(newElement, getContainerElement(newElement));
}

if (newElement.type === "arrow") {
newElement = newElementWith(newElement, {
startArrowhead: pastedElement.startArrowhead,
endArrowhead: pastedElement.endArrowhead,
});
}

return newElement;
}
return element;
Expand Down