added loopLock to newElement, updated test snapshots
This commit is contained in:
parent
9dc588efa2
commit
3ee5e62c0e
@ -45,7 +45,9 @@ import type {
|
||||
ElementsMap,
|
||||
ExcalidrawArrowElement,
|
||||
ExcalidrawElbowArrowElement,
|
||||
ExcalidrawLineElement,
|
||||
} from "./types";
|
||||
import { isLineElement } from "./typeChecks";
|
||||
|
||||
export type ElementConstructorOpts = MarkOptional<
|
||||
Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">,
|
||||
@ -459,7 +461,7 @@ export const newLinearElement = (
|
||||
points?: ExcalidrawLinearElement["points"];
|
||||
} & ElementConstructorOpts,
|
||||
): NonDeleted<ExcalidrawLinearElement> => {
|
||||
return {
|
||||
const element = {
|
||||
..._newElementBase<ExcalidrawLinearElement>(opts.type, opts),
|
||||
points: opts.points || [],
|
||||
lastCommittedPoint: null,
|
||||
@ -468,6 +470,15 @@ export const newLinearElement = (
|
||||
startArrowhead: null,
|
||||
endArrowhead: null,
|
||||
};
|
||||
|
||||
if (isLineElement(element)) {
|
||||
return {
|
||||
...element,
|
||||
loopLock: false,
|
||||
} as NonDeleted<ExcalidrawLineElement>;
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
export const newArrowElement = <T extends boolean>(
|
||||
|
@ -937,6 +937,7 @@ exports[`Test Transform > should transform linear elements 3`] = `
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
@ -984,6 +985,7 @@ exports[`Test Transform > should transform linear elements 4`] = `
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
@ -142,6 +142,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
@ -78,6 +78,7 @@ exports[`multi point mode in linear elements > line 3`] = `
|
||||
],
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
@ -6410,6 +6410,7 @@ History {
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
@ -6630,6 +6631,7 @@ History {
|
||||
],
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
@ -8864,6 +8866,7 @@ History {
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
@ -9687,6 +9690,7 @@ History {
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
@ -68,6 +68,7 @@ exports[`select single element on the scene > arrow escape 1`] = `
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
@ -229,6 +229,7 @@ exports[`restoreElements > should restore line and draw elements correctly 1`] =
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
@ -278,6 +279,7 @@ exports[`restoreElements > should restore line and draw elements correctly 2`] =
|
||||
"lastCommittedPoint": null,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"loopLock": false,
|
||||
"opacity": 100,
|
||||
"points": [
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user