rename tweak

This commit is contained in:
Aakansha Doshi 2023-07-17 13:10:57 +05:30
parent 562249e981
commit 2359a7a818

View file

@ -448,31 +448,31 @@ export const convertToExcalidrawElements = (
return; return;
} }
const elementWithid = { ...element, id: elementId }; const elementWithId = { ...element, id: elementId };
if ( if (
(elementWithid.type === "rectangle" || (elementWithId.type === "rectangle" ||
elementWithid.type === "ellipse" || elementWithId.type === "ellipse" ||
elementWithid.type === "diamond" || elementWithId.type === "diamond" ||
elementWithid.type === "arrow") && elementWithId.type === "arrow") &&
elementWithid?.label?.text elementWithId?.label?.text
) { ) {
let [container, text] = bindTextToContainer( let [container, text] = bindTextToContainer(
elementWithid as elementWithId as
| ValidContainer | ValidContainer
| ({ | ({
type: "arrow"; type: "arrow";
} & ValidLinearElement), } & ValidLinearElement),
elementWithid?.label, elementWithId?.label,
); );
excalidrawElements.add(container); excalidrawElements.add(container);
excalidrawElements.add(text); excalidrawElements.add(text);
if (container.type === "arrow") { if (container.type === "arrow") {
const originalStart = const originalStart =
elementWithid.type === "arrow" ? elementWithid?.start : undefined; elementWithId.type === "arrow" ? elementWithId?.start : undefined;
const originalEnd = const originalEnd =
elementWithid.type === "arrow" ? elementWithid?.end : undefined; elementWithId.type === "arrow" ? elementWithId?.end : undefined;
const { linearElement, startBoundElement, endBoundElement } = const { linearElement, startBoundElement, endBoundElement } =
bindLinearElementToElement({ bindLinearElementToElement({
...container, ...container,
@ -486,12 +486,12 @@ export const convertToExcalidrawElements = (
} }
} else { } else {
let excalidrawElement; let excalidrawElement;
if (elementWithid.type === "text") { if (elementWithId.type === "text") {
const fontFamily = elementWithid?.fontFamily || DEFAULT_FONT_FAMILY; const fontFamily = elementWithId?.fontFamily || DEFAULT_FONT_FAMILY;
const fontSize = elementWithid?.fontSize || DEFAULT_FONT_SIZE; const fontSize = elementWithId?.fontSize || DEFAULT_FONT_SIZE;
const lineHeight = const lineHeight =
elementWithid?.lineHeight || getDefaultLineHeight(fontFamily); elementWithId?.lineHeight || getDefaultLineHeight(fontFamily);
const text = elementWithid.text ?? ""; const text = elementWithId.text ?? "";
const normalizedText = normalizeText(text); const normalizedText = normalizeText(text);
const metrics = measureText( const metrics = measureText(
normalizedText, normalizedText,
@ -503,20 +503,20 @@ export const convertToExcalidrawElements = (
height: metrics.height, height: metrics.height,
fontFamily, fontFamily,
fontSize, fontSize,
...elementWithid, ...elementWithId,
}; };
excalidrawElements.add(excalidrawElement as ExcalidrawTextElement); excalidrawElements.add(excalidrawElement as ExcalidrawTextElement);
} else if (elementWithid.type === "arrow") { } else if (elementWithId.type === "arrow") {
const { linearElement, startBoundElement, endBoundElement } = const { linearElement, startBoundElement, endBoundElement } =
bindLinearElementToElement(elementWithid); bindLinearElementToElement(elementWithId);
excalidrawElements.add(linearElement); excalidrawElements.add(linearElement);
excalidrawElements.add(startBoundElement); excalidrawElements.add(startBoundElement);
excalidrawElements.add(endBoundElement); excalidrawElements.add(endBoundElement);
} else if (elementWithid.type === "line") { } else if (elementWithId.type === "line") {
const width = elementWithid.width || DEFAULT_LINEAR_ELEMENT_PROPS.width; const width = elementWithId.width || DEFAULT_LINEAR_ELEMENT_PROPS.width;
const height = const height =
elementWithid.height || DEFAULT_LINEAR_ELEMENT_PROPS.height; elementWithId.height || DEFAULT_LINEAR_ELEMENT_PROPS.height;
const lineElement = newLinearElement({ const lineElement = newLinearElement({
width, width,
height, height,
@ -524,14 +524,14 @@ export const convertToExcalidrawElements = (
[0, 0], [0, 0],
[width, height], [width, height],
], ],
...elementWithid, ...elementWithId,
}); });
excalidrawElements.add(lineElement); excalidrawElements.add(lineElement);
} else { } else {
excalidrawElement = { excalidrawElement = {
...elementWithid, ...elementWithId,
width: elementWithid?.width || DEFAULT_DIMENSION, width: elementWithId?.width || DEFAULT_DIMENSION,
height: elementWithid?.height || DEFAULT_DIMENSION, height: elementWithId?.height || DEFAULT_DIMENSION,
} as ExcalidrawGenericElement; } as ExcalidrawGenericElement;
excalidrawElements.add(excalidrawElement); excalidrawElements.add(excalidrawElement);
} }