mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
use Object.assign instead of mutateElement
This commit is contained in:
parent
06dd6de0af
commit
e463d2f51b
2 changed files with 22 additions and 22 deletions
|
@ -250,7 +250,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
|
||||||
"textAlign": "left",
|
"textAlign": "left",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"verticalAlign": "top",
|
"verticalAlign": "top",
|
||||||
"width": 70,
|
"width": 70,
|
||||||
|
@ -294,7 +294,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
|
||||||
"textAlign": "left",
|
"textAlign": "left",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"verticalAlign": "top",
|
"verticalAlign": "top",
|
||||||
"width": 100,
|
"width": 100,
|
||||||
|
@ -353,7 +353,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 4,
|
"version": 3,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 255,
|
"x": 255,
|
||||||
|
@ -450,7 +450,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 4,
|
"version": 3,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 255,
|
"x": 255,
|
||||||
|
@ -617,7 +617,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 4,
|
"version": 3,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 255,
|
"x": 255,
|
||||||
|
@ -699,7 +699,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
|
||||||
"textAlign": "left",
|
"textAlign": "left",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"verticalAlign": "top",
|
"verticalAlign": "top",
|
||||||
"width": 70,
|
"width": 70,
|
||||||
|
@ -743,7 +743,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
|
||||||
"textAlign": "left",
|
"textAlign": "left",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"verticalAlign": "top",
|
"verticalAlign": "top",
|
||||||
"width": 100,
|
"width": 100,
|
||||||
|
@ -1087,7 +1087,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 2,
|
"version": 1,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1176,7 +1176,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 2,
|
"version": 1,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1265,7 +1265,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1355,7 +1355,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
"type": "arrow",
|
"type": "arrow",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1430,7 +1430,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "rectangle",
|
"type": "rectangle",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 4,
|
"version": 3,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 250,
|
"width": 250,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1504,7 +1504,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "ellipse",
|
"type": "ellipse",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 200,
|
"width": 200,
|
||||||
"x": 500,
|
"x": 500,
|
||||||
|
@ -1579,7 +1579,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "diamond",
|
"type": "diamond",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 280,
|
"width": 280,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1656,7 +1656,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
"type": "diamond",
|
"type": "diamond",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 300,
|
"width": 300,
|
||||||
"x": 100,
|
"x": 100,
|
||||||
|
@ -1731,7 +1731,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "rectangle",
|
"type": "rectangle",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 200,
|
"width": 200,
|
||||||
"x": 500,
|
"x": 500,
|
||||||
|
@ -1807,7 +1807,7 @@ exports[`Test Transform > should transform to text containers when label provide
|
||||||
"strokeWidth": 1,
|
"strokeWidth": 1,
|
||||||
"type": "ellipse",
|
"type": "ellipse",
|
||||||
"updated": 1,
|
"updated": 1,
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"versionNonce": Any<Number>,
|
"versionNonce": Any<Number>,
|
||||||
"width": 200,
|
"width": 200,
|
||||||
"x": 500,
|
"x": 500,
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
redrawTextBoundingBox,
|
redrawTextBoundingBox,
|
||||||
} from "../element";
|
} from "../element";
|
||||||
import { bindLinearElement } from "../element/binding";
|
import { bindLinearElement } from "../element/binding";
|
||||||
import { mutateElement } from "../element/mutateElement";
|
|
||||||
import {
|
import {
|
||||||
ElementConstructorOpts,
|
ElementConstructorOpts,
|
||||||
newImageElement,
|
newImageElement,
|
||||||
|
@ -211,7 +210,7 @@ const bindTextToContainer = (
|
||||||
strokeColor: textProps.strokeColor || container.strokeColor,
|
strokeColor: textProps.strokeColor || container.strokeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
mutateElement(container, {
|
Object.assign(container, {
|
||||||
boundElements: (container.boundElements || []).concat({
|
boundElements: (container.boundElements || []).concat({
|
||||||
type: "text",
|
type: "text",
|
||||||
id: textElement.id,
|
id: textElement.id,
|
||||||
|
@ -254,7 +253,7 @@ const bindLinearElementToElement = (
|
||||||
let startBoundElement;
|
let startBoundElement;
|
||||||
let endBoundElement;
|
let endBoundElement;
|
||||||
|
|
||||||
mutateElement(excliadrawLinearElement, {
|
Object.assign(excliadrawLinearElement, {
|
||||||
startBinding: linearElement?.startBinding || null,
|
startBinding: linearElement?.startBinding || null,
|
||||||
endBinding: linearElement.endBinding || null,
|
endBinding: linearElement.endBinding || null,
|
||||||
});
|
});
|
||||||
|
@ -302,7 +301,7 @@ const bindLinearElementToElement = (
|
||||||
text,
|
text,
|
||||||
});
|
});
|
||||||
// to position the text correctly when coordinates not provided
|
// to position the text correctly when coordinates not provided
|
||||||
mutateElement(startBoundElement, {
|
Object.assign(startBoundElement, {
|
||||||
x: start.x || excliadrawLinearElement.x - startBoundElement.width,
|
x: start.x || excliadrawLinearElement.x - startBoundElement.width,
|
||||||
y:
|
y:
|
||||||
start.y || excliadrawLinearElement.y - startBoundElement.height / 2,
|
start.y || excliadrawLinearElement.y - startBoundElement.height / 2,
|
||||||
|
@ -370,7 +369,7 @@ const bindLinearElementToElement = (
|
||||||
text,
|
text,
|
||||||
});
|
});
|
||||||
// to position the text correctly when coordinates not provided
|
// to position the text correctly when coordinates not provided
|
||||||
mutateElement(endBoundElement, {
|
Object.assign(endBoundElement, {
|
||||||
y: end.y || excliadrawLinearElement.y - endBoundElement.height / 2,
|
y: end.y || excliadrawLinearElement.y - endBoundElement.height / 2,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -551,5 +550,6 @@ export const convertToExcalidrawElements = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log(excalidrawElements.get());
|
||||||
return excalidrawElements.get();
|
return excalidrawElements.get();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue