Updates tests
This commit is contained in:
parent
f62166adbf
commit
4a492dcefc
5 changed files with 1250 additions and 4455 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"document": {
|
||||
"id": "0001",
|
||||
"id": "home",
|
||||
"name": "My Document",
|
||||
"pages": {
|
||||
"page1": {
|
||||
|
@ -9,74 +9,344 @@
|
|||
"name": "Page 1",
|
||||
"childIndex": 0,
|
||||
"shapes": {
|
||||
"5ca167d7-54de-47c9-aa8f-86affa25e44d": {
|
||||
"id": "5ca167d7-54de-47c9-aa8f-86affa25e44d",
|
||||
"seed": 0.08116783083496548,
|
||||
"e43559cb-6f41-4ae4-9c49-158ed1ad2f72": {
|
||||
"id": "e43559cb-6f41-4ae4-9c49-158ed1ad2f72",
|
||||
"type": "rectangle",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"childIndex": 3,
|
||||
"point": [
|
||||
171.47,
|
||||
288.63
|
||||
],
|
||||
"size": [
|
||||
176.22,
|
||||
192.26
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"13448777-d8f5-46cd-8a70-a4259211902e": {
|
||||
"id": "13448777-d8f5-46cd-8a70-a4259211902e",
|
||||
"type": "rectangle",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"childIndex": 4,
|
||||
"point": [
|
||||
511.7,
|
||||
404.19
|
||||
],
|
||||
"size": [
|
||||
181.08999999999992,
|
||||
150.40999999999997
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"75010635-8dfb-48ea-9250-719e50e58f02": {
|
||||
"id": "75010635-8dfb-48ea-9250-719e50e58f02",
|
||||
"type": "rectangle",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"childIndex": 5,
|
||||
"point": [
|
||||
384.09,
|
||||
378.45
|
||||
],
|
||||
"size": [
|
||||
95.20999999999992,
|
||||
91.1799999999999
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"c892d665-3311-4e25-a0bf-c4632d777f7e": {
|
||||
"id": "c892d665-3311-4e25-a0bf-c4632d777f7e",
|
||||
"type": "ellipse",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"childIndex": 6,
|
||||
"point": [
|
||||
162.45,
|
||||
679.23
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"51641de1-9787-41b8-afcc-2c85fd1b24c7": {
|
||||
"id": "51641de1-9787-41b8-afcc-2c85fd1b24c7",
|
||||
"type": "ellipse",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"childIndex": 7,
|
||||
"point": [
|
||||
517.18,
|
||||
783.54
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"e08c415e-3db3-4d3b-878e-28ce693ec1b0": {
|
||||
"id": "e08c415e-3db3-4d3b-878e-28ce693ec1b0",
|
||||
"type": "ellipse",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"childIndex": 8,
|
||||
"point": [
|
||||
398.99,
|
||||
810.79
|
||||
],
|
||||
"radiusX": 45.484999999999985,
|
||||
"radiusY": 45.48499999999996,
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"fee77127-e779-4576-882b-b1bf7c7e132f": {
|
||||
"id": "fee77127-e779-4576-882b-b1bf7c7e132f",
|
||||
"type": "arrow",
|
||||
"isGenerated": false,
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"childIndex": 16,
|
||||
"point": [100, 100],
|
||||
"rotation": 0,
|
||||
"isAspectRatioLocked": false,
|
||||
"isLocked": false,
|
||||
"isHidden": false,
|
||||
"bend": 0,
|
||||
"points": [
|
||||
[6.503619523263069, 281.09020634582345],
|
||||
[0, 0]
|
||||
"childIndex": 9,
|
||||
"point": [
|
||||
252.85,
|
||||
1057.5
|
||||
],
|
||||
"rotation": 0,
|
||||
"bend": 0,
|
||||
"handles": {
|
||||
"start": {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": [6.503619523263069, 281.09020634582345]
|
||||
"point": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"end": {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": [0, 0]
|
||||
"point": [
|
||||
0.09000000000000341,
|
||||
208
|
||||
]
|
||||
},
|
||||
"bend": {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": [3.2518097616315345, 140.54510317291172]
|
||||
"point": [
|
||||
0.045000000000001705,
|
||||
104
|
||||
]
|
||||
}
|
||||
},
|
||||
"decorations": {
|
||||
"start": null,
|
||||
"end": null,
|
||||
"middle": null
|
||||
"middle": null,
|
||||
"end": "Arrow"
|
||||
},
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Small",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Solid"
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"1f6c251c-e12e-40b4-8dd2-c1847d80b72f": {
|
||||
"id": "1f6c251c-e12e-40b4-8dd2-c1847d80b72f",
|
||||
"seed": 0.6440313303074272,
|
||||
"type": "rectangle",
|
||||
"isGenerated": false,
|
||||
"name": "Rectangle",
|
||||
"2d842ace-ebc5-4e83-acdf-de29352e5e62": {
|
||||
"id": "2d842ace-ebc5-4e83-acdf-de29352e5e62",
|
||||
"type": "arrow",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"childIndex": 24,
|
||||
"point": [0, 0],
|
||||
"size": [67.22075383450237, 72.92795609221832],
|
||||
"radius": 2,
|
||||
"childIndex": 10,
|
||||
"point": [
|
||||
616.9,
|
||||
1124.3
|
||||
],
|
||||
"rotation": 0,
|
||||
"isAspectRatioLocked": false,
|
||||
"isLocked": false,
|
||||
"isHidden": false,
|
||||
"style": {
|
||||
"size": "Small",
|
||||
"color": "Black",
|
||||
"dash": "Solid",
|
||||
"isFilled": false
|
||||
"bend": 0,
|
||||
"handles": {
|
||||
"start": {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"end": {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": [
|
||||
2.4500000000000455,
|
||||
185.20000000000005
|
||||
]
|
||||
},
|
||||
"bend": {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": [
|
||||
1.2250000000000227,
|
||||
92.60000000000002
|
||||
]
|
||||
}
|
||||
},
|
||||
"decorations": {
|
||||
"start": null,
|
||||
"middle": null,
|
||||
"end": "Arrow"
|
||||
},
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"b8e4e2c5-c662-4587-bf80-b9820ad8ad7f": {
|
||||
"id": "b8e4e2c5-c662-4587-bf80-b9820ad8ad7f",
|
||||
"type": "arrow",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"childIndex": 11,
|
||||
"point": [
|
||||
425.18,
|
||||
1143.2
|
||||
],
|
||||
"rotation": 0,
|
||||
"bend": 0,
|
||||
"handles": {
|
||||
"start": {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"end": {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": [
|
||||
1.8500000000000227,
|
||||
95.70000000000005
|
||||
]
|
||||
},
|
||||
"bend": {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": [
|
||||
0.9250000000000114,
|
||||
47.85000000000002
|
||||
]
|
||||
}
|
||||
},
|
||||
"decorations": {
|
||||
"start": null,
|
||||
"middle": null,
|
||||
"end": "Arrow"
|
||||
},
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
}
|
||||
},
|
||||
"38e9e750-16c2-4476-93ab-21aeb5f8858f": {
|
||||
"id": "38e9e750-16c2-4476-93ab-21aeb5f8858f",
|
||||
"type": "text",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"childIndex": 12,
|
||||
"point": [
|
||||
207.16,
|
||||
1422.4
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
},
|
||||
"text": "Hello",
|
||||
"scale": 1
|
||||
},
|
||||
"5ba998df-c036-447a-9b88-d96c71394f52": {
|
||||
"id": "5ba998df-c036-447a-9b88-d96c71394f52",
|
||||
"type": "text",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"childIndex": 13,
|
||||
"point": [
|
||||
389.57,
|
||||
1496.5
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
},
|
||||
"text": "Hello",
|
||||
"scale": 1
|
||||
},
|
||||
"3c688979-b190-4270-915b-7d8dd22a2bb7": {
|
||||
"id": "3c688979-b190-4270-915b-7d8dd22a2bb7",
|
||||
"type": "text",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"childIndex": 14,
|
||||
"point": [
|
||||
564.06,
|
||||
1558.1
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": {
|
||||
"color": "Black",
|
||||
"size": "Medium",
|
||||
"isFilled": false,
|
||||
"dash": "Draw"
|
||||
},
|
||||
"text": "Hello",
|
||||
"scale": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,16 +355,19 @@
|
|||
"file0": {
|
||||
"id": "file0",
|
||||
"name": "index.ts",
|
||||
"code": ""
|
||||
"code": "\nconst draw = new Draw({\n points: [\n ...Utils.getPointsBetween([0, 0], [20, 50]),\n ...Utils.getPointsBetween([20, 50], [100, 20], 3),\n ...Utils.getPointsBetween([100, 20], [100, 100], 10),\n [100, 100],\n ],\n})\n\nconst rectangle = new Rectangle({\n point: [200, 0],\n style: {\n color: ColorStyle.Blue,\n },\n})\n\nconst ellipse = new Ellipse({\n point: [400, 0],\n})\n\nconst arrow = new Arrow({\n start: [600, 0],\n end: [700, 100],\n})\n\nconst radius = 1000\nconst count = 100\nconst center = [350, 50]\n\nfor (let i = 0; i < count; i++) {\n const point = Vec.rotWith(\n Vec.add(center, [radius, 0]),\n center,\n (Math.PI * 2 * i) / count\n )\n\n const dot = new Dot({\n point,\n })\n}\n "
|
||||
}
|
||||
}
|
||||
},
|
||||
"pageState": {
|
||||
"id": "page1",
|
||||
"selectedIds": {},
|
||||
"camera": {
|
||||
"point": [-776.1126994855964, -404.44260065511594],
|
||||
"zoom": 0.260047458798192
|
||||
}
|
||||
"point": [
|
||||
0,
|
||||
-145
|
||||
],
|
||||
"zoom": 1
|
||||
},
|
||||
"selectedIds": {}
|
||||
}
|
||||
}
|
|
@ -4,12 +4,53 @@ exports[`project loads file from json: data after mount from file 1`] = `
|
|||
Object {
|
||||
"code": Object {
|
||||
"file0": Object {
|
||||
"code": "",
|
||||
"code": "
|
||||
const draw = new Draw({
|
||||
points: [
|
||||
...Utils.getPointsBetween([0, 0], [20, 50]),
|
||||
...Utils.getPointsBetween([20, 50], [100, 20], 3),
|
||||
...Utils.getPointsBetween([100, 20], [100, 100], 10),
|
||||
[100, 100],
|
||||
],
|
||||
})
|
||||
|
||||
const rectangle = new Rectangle({
|
||||
point: [200, 0],
|
||||
style: {
|
||||
color: ColorStyle.Blue,
|
||||
},
|
||||
})
|
||||
|
||||
const ellipse = new Ellipse({
|
||||
point: [400, 0],
|
||||
})
|
||||
|
||||
const arrow = new Arrow({
|
||||
start: [600, 0],
|
||||
end: [700, 100],
|
||||
})
|
||||
|
||||
const radius = 1000
|
||||
const count = 100
|
||||
const center = [350, 50]
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const point = Vec.rotWith(
|
||||
Vec.add(center, [radius, 0]),
|
||||
center,
|
||||
(Math.PI * 2 * i) / count
|
||||
)
|
||||
|
||||
const dot = new Dot({
|
||||
point,
|
||||
})
|
||||
}
|
||||
",
|
||||
"id": "file0",
|
||||
"name": "index.ts",
|
||||
},
|
||||
},
|
||||
"id": "0001",
|
||||
"id": "home",
|
||||
"name": "My Document",
|
||||
"pages": Object {
|
||||
"page1": Object {
|
||||
|
@ -17,39 +58,34 @@ Object {
|
|||
"id": "page1",
|
||||
"name": "Page 1",
|
||||
"shapes": Object {
|
||||
"1f6c251c-e12e-40b4-8dd2-c1847d80b72f": Object {
|
||||
"childIndex": 24,
|
||||
"id": "1f6c251c-e12e-40b4-8dd2-c1847d80b72f",
|
||||
"isAspectRatioLocked": false,
|
||||
"isGenerated": false,
|
||||
"isHidden": false,
|
||||
"isLocked": false,
|
||||
"13448777-d8f5-46cd-8a70-a4259211902e": Object {
|
||||
"childIndex": 4,
|
||||
"id": "13448777-d8f5-46cd-8a70-a4259211902e",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
511.7,
|
||||
404.19,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"seed": 0.6440313303074272,
|
||||
"size": Array [
|
||||
67.22075383450237,
|
||||
72.92795609221832,
|
||||
181.08999999999992,
|
||||
150.40999999999997,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Solid",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Small",
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"5ca167d7-54de-47c9-aa8f-86affa25e44d": Object {
|
||||
"2d842ace-ebc5-4e83-acdf-de29352e5e62": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 16,
|
||||
"childIndex": 10,
|
||||
"decorations": Object {
|
||||
"end": null,
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
|
@ -58,55 +94,306 @@ Object {
|
|||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
3.2518097616315345,
|
||||
140.54510317291172,
|
||||
1.2250000000000227,
|
||||
92.60000000000002,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
2.4500000000000455,
|
||||
185.20000000000005,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
6.503619523263069,
|
||||
281.09020634582345,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "5ca167d7-54de-47c9-aa8f-86affa25e44d",
|
||||
"isAspectRatioLocked": false,
|
||||
"isGenerated": false,
|
||||
"isHidden": false,
|
||||
"isLocked": false,
|
||||
"id": "2d842ace-ebc5-4e83-acdf-de29352e5e62",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
100,
|
||||
100,
|
||||
],
|
||||
"points": Array [
|
||||
Array [
|
||||
6.503619523263069,
|
||||
281.09020634582345,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
616.9,
|
||||
1124.3,
|
||||
],
|
||||
"rotation": 0,
|
||||
"seed": 0.08116783083496548,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Solid",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Small",
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
"38e9e750-16c2-4476-93ab-21aeb5f8858f": Object {
|
||||
"childIndex": 12,
|
||||
"id": "38e9e750-16c2-4476-93ab-21aeb5f8858f",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
207.16,
|
||||
1422.4,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"3c688979-b190-4270-915b-7d8dd22a2bb7": Object {
|
||||
"childIndex": 14,
|
||||
"id": "3c688979-b190-4270-915b-7d8dd22a2bb7",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
564.06,
|
||||
1558.1,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"51641de1-9787-41b8-afcc-2c85fd1b24c7": Object {
|
||||
"childIndex": 7,
|
||||
"id": "51641de1-9787-41b8-afcc-2c85fd1b24c7",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
517.18,
|
||||
783.54,
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"5ba998df-c036-447a-9b88-d96c71394f52": Object {
|
||||
"childIndex": 13,
|
||||
"id": "5ba998df-c036-447a-9b88-d96c71394f52",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
389.57,
|
||||
1496.5,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"75010635-8dfb-48ea-9250-719e50e58f02": Object {
|
||||
"childIndex": 5,
|
||||
"id": "75010635-8dfb-48ea-9250-719e50e58f02",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
384.09,
|
||||
378.45,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"size": Array [
|
||||
95.20999999999992,
|
||||
91.1799999999999,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"b8e4e2c5-c662-4587-bf80-b9820ad8ad7f": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 11,
|
||||
"decorations": Object {
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
"handles": Object {
|
||||
"bend": Object {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
0.9250000000000114,
|
||||
47.85000000000002,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
1.8500000000000227,
|
||||
95.70000000000005,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "b8e4e2c5-c662-4587-bf80-b9820ad8ad7f",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
425.18,
|
||||
1143.2,
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
"c892d665-3311-4e25-a0bf-c4632d777f7e": Object {
|
||||
"childIndex": 6,
|
||||
"id": "c892d665-3311-4e25-a0bf-c4632d777f7e",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
162.45,
|
||||
679.23,
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"e08c415e-3db3-4d3b-878e-28ce693ec1b0": Object {
|
||||
"childIndex": 8,
|
||||
"id": "e08c415e-3db3-4d3b-878e-28ce693ec1b0",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
398.99,
|
||||
810.79,
|
||||
],
|
||||
"radiusX": 45.484999999999985,
|
||||
"radiusY": 45.48499999999996,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"e43559cb-6f41-4ae4-9c49-158ed1ad2f72": Object {
|
||||
"childIndex": 3,
|
||||
"id": "e43559cb-6f41-4ae4-9c49-158ed1ad2f72",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
171.47,
|
||||
288.63,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"size": Array [
|
||||
176.22,
|
||||
192.26,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"fee77127-e779-4576-882b-b1bf7c7e132f": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 9,
|
||||
"decorations": Object {
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
"handles": Object {
|
||||
"bend": Object {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
0.045000000000001705,
|
||||
104,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
0.09000000000000341,
|
||||
208,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "fee77127-e779-4576-882b-b1bf7c7e132f",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
252.85,
|
||||
1057.5,
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
|
@ -121,12 +408,53 @@ exports[`restoring project remounts the state after mutating the current state:
|
|||
Object {
|
||||
"code": Object {
|
||||
"file0": Object {
|
||||
"code": "",
|
||||
"code": "
|
||||
const draw = new Draw({
|
||||
points: [
|
||||
...Utils.getPointsBetween([0, 0], [20, 50]),
|
||||
...Utils.getPointsBetween([20, 50], [100, 20], 3),
|
||||
...Utils.getPointsBetween([100, 20], [100, 100], 10),
|
||||
[100, 100],
|
||||
],
|
||||
})
|
||||
|
||||
const rectangle = new Rectangle({
|
||||
point: [200, 0],
|
||||
style: {
|
||||
color: ColorStyle.Blue,
|
||||
},
|
||||
})
|
||||
|
||||
const ellipse = new Ellipse({
|
||||
point: [400, 0],
|
||||
})
|
||||
|
||||
const arrow = new Arrow({
|
||||
start: [600, 0],
|
||||
end: [700, 100],
|
||||
})
|
||||
|
||||
const radius = 1000
|
||||
const count = 100
|
||||
const center = [350, 50]
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const point = Vec.rotWith(
|
||||
Vec.add(center, [radius, 0]),
|
||||
center,
|
||||
(Math.PI * 2 * i) / count
|
||||
)
|
||||
|
||||
const dot = new Dot({
|
||||
point,
|
||||
})
|
||||
}
|
||||
",
|
||||
"id": "file0",
|
||||
"name": "index.ts",
|
||||
},
|
||||
},
|
||||
"id": "0001",
|
||||
"id": "home",
|
||||
"name": "My Document",
|
||||
"pages": Object {
|
||||
"page1": Object {
|
||||
|
@ -134,39 +462,34 @@ Object {
|
|||
"id": "page1",
|
||||
"name": "Page 1",
|
||||
"shapes": Object {
|
||||
"1f6c251c-e12e-40b4-8dd2-c1847d80b72f": Object {
|
||||
"childIndex": 24,
|
||||
"id": "1f6c251c-e12e-40b4-8dd2-c1847d80b72f",
|
||||
"isAspectRatioLocked": false,
|
||||
"isGenerated": false,
|
||||
"isHidden": false,
|
||||
"isLocked": false,
|
||||
"13448777-d8f5-46cd-8a70-a4259211902e": Object {
|
||||
"childIndex": 4,
|
||||
"id": "13448777-d8f5-46cd-8a70-a4259211902e",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
511.7,
|
||||
404.19,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"seed": 0.6440313303074272,
|
||||
"size": Array [
|
||||
67.22075383450237,
|
||||
72.92795609221832,
|
||||
181.08999999999992,
|
||||
150.40999999999997,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Solid",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Small",
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"5ca167d7-54de-47c9-aa8f-86affa25e44d": Object {
|
||||
"2d842ace-ebc5-4e83-acdf-de29352e5e62": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 16,
|
||||
"childIndex": 10,
|
||||
"decorations": Object {
|
||||
"end": null,
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
|
@ -175,55 +498,306 @@ Object {
|
|||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
3.2518097616315345,
|
||||
140.54510317291172,
|
||||
1.2250000000000227,
|
||||
92.60000000000002,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
2.4500000000000455,
|
||||
185.20000000000005,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
6.503619523263069,
|
||||
281.09020634582345,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "5ca167d7-54de-47c9-aa8f-86affa25e44d",
|
||||
"isAspectRatioLocked": false,
|
||||
"isGenerated": false,
|
||||
"isHidden": false,
|
||||
"isLocked": false,
|
||||
"id": "2d842ace-ebc5-4e83-acdf-de29352e5e62",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
100,
|
||||
100,
|
||||
],
|
||||
"points": Array [
|
||||
Array [
|
||||
6.503619523263069,
|
||||
281.09020634582345,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
616.9,
|
||||
1124.3,
|
||||
],
|
||||
"rotation": 0,
|
||||
"seed": 0.08116783083496548,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Solid",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Small",
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
"38e9e750-16c2-4476-93ab-21aeb5f8858f": Object {
|
||||
"childIndex": 12,
|
||||
"id": "38e9e750-16c2-4476-93ab-21aeb5f8858f",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
207.16,
|
||||
1422.4,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"3c688979-b190-4270-915b-7d8dd22a2bb7": Object {
|
||||
"childIndex": 14,
|
||||
"id": "3c688979-b190-4270-915b-7d8dd22a2bb7",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
564.06,
|
||||
1558.1,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"51641de1-9787-41b8-afcc-2c85fd1b24c7": Object {
|
||||
"childIndex": 7,
|
||||
"id": "51641de1-9787-41b8-afcc-2c85fd1b24c7",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
517.18,
|
||||
783.54,
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"5ba998df-c036-447a-9b88-d96c71394f52": Object {
|
||||
"childIndex": 13,
|
||||
"id": "5ba998df-c036-447a-9b88-d96c71394f52",
|
||||
"name": "Text",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
389.57,
|
||||
1496.5,
|
||||
],
|
||||
"rotation": 0,
|
||||
"scale": 1,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"text": "Hello",
|
||||
"type": "text",
|
||||
},
|
||||
"75010635-8dfb-48ea-9250-719e50e58f02": Object {
|
||||
"childIndex": 5,
|
||||
"id": "75010635-8dfb-48ea-9250-719e50e58f02",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
384.09,
|
||||
378.45,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"size": Array [
|
||||
95.20999999999992,
|
||||
91.1799999999999,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"b8e4e2c5-c662-4587-bf80-b9820ad8ad7f": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 11,
|
||||
"decorations": Object {
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
"handles": Object {
|
||||
"bend": Object {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
0.9250000000000114,
|
||||
47.85000000000002,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
1.8500000000000227,
|
||||
95.70000000000005,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "b8e4e2c5-c662-4587-bf80-b9820ad8ad7f",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
425.18,
|
||||
1143.2,
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
"c892d665-3311-4e25-a0bf-c4632d777f7e": Object {
|
||||
"childIndex": 6,
|
||||
"id": "c892d665-3311-4e25-a0bf-c4632d777f7e",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
162.45,
|
||||
679.23,
|
||||
],
|
||||
"radiusX": 102.99999999999997,
|
||||
"radiusY": 102.99999999999994,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"e08c415e-3db3-4d3b-878e-28ce693ec1b0": Object {
|
||||
"childIndex": 8,
|
||||
"id": "e08c415e-3db3-4d3b-878e-28ce693ec1b0",
|
||||
"name": "Ellipse",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
398.99,
|
||||
810.79,
|
||||
],
|
||||
"radiusX": 45.484999999999985,
|
||||
"radiusY": 45.48499999999996,
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "ellipse",
|
||||
},
|
||||
"e43559cb-6f41-4ae4-9c49-158ed1ad2f72": Object {
|
||||
"childIndex": 3,
|
||||
"id": "e43559cb-6f41-4ae4-9c49-158ed1ad2f72",
|
||||
"name": "Rectangle",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
171.47,
|
||||
288.63,
|
||||
],
|
||||
"radius": 2,
|
||||
"rotation": 0,
|
||||
"size": Array [
|
||||
176.22,
|
||||
192.26,
|
||||
],
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "rectangle",
|
||||
},
|
||||
"fee77127-e779-4576-882b-b1bf7c7e132f": Object {
|
||||
"bend": 0,
|
||||
"childIndex": 9,
|
||||
"decorations": Object {
|
||||
"end": "Arrow",
|
||||
"middle": null,
|
||||
"start": null,
|
||||
},
|
||||
"handles": Object {
|
||||
"bend": Object {
|
||||
"id": "bend",
|
||||
"index": 2,
|
||||
"point": Array [
|
||||
0.045000000000001705,
|
||||
104,
|
||||
],
|
||||
},
|
||||
"end": Object {
|
||||
"id": "end",
|
||||
"index": 1,
|
||||
"point": Array [
|
||||
0.09000000000000341,
|
||||
208,
|
||||
],
|
||||
},
|
||||
"start": Object {
|
||||
"id": "start",
|
||||
"index": 0,
|
||||
"point": Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
"id": "fee77127-e779-4576-882b-b1bf7c7e132f",
|
||||
"name": "Arrow",
|
||||
"parentId": "page1",
|
||||
"point": Array [
|
||||
252.85,
|
||||
1057.5,
|
||||
],
|
||||
"rotation": 0,
|
||||
"style": Object {
|
||||
"color": "Black",
|
||||
"dash": "Draw",
|
||||
"isFilled": false,
|
||||
"size": "Medium",
|
||||
},
|
||||
"type": "arrow",
|
||||
},
|
||||
|
|
|
@ -3,13 +3,13 @@ import tld from 'utils/tld'
|
|||
import inputs from 'state/inputs'
|
||||
import { createShape, getShapeUtils } from 'state/shape-utils'
|
||||
import { Data, Shape, ShapeType, ShapeUtility } from 'types'
|
||||
import { deepCompareArrays, uniqueId, vec } from 'utils'
|
||||
import * as json from './__mocks__/document.json'
|
||||
import { deepCompareArrays, setToArray, uniqueId, vec } from 'utils'
|
||||
import * as mockDocument from './__mocks__/document.json'
|
||||
|
||||
type State = typeof _state
|
||||
|
||||
export const rectangleId = '1f6c251c-e12e-40b4-8dd2-c1847d80b72f'
|
||||
export const arrowId = '5ca167d7-54de-47c9-aa8f-86affa25e44d'
|
||||
export const rectangleId = 'e43559cb-6f41-4ae4-9c49-158ed1ad2f72'
|
||||
export const arrowId = 'fee77127-e779-4576-882b-b1bf7c7e132f'
|
||||
|
||||
interface PointerOptions {
|
||||
id?: number
|
||||
|
@ -40,8 +40,9 @@ class TestState {
|
|||
reset(): TestState {
|
||||
this.state.reset()
|
||||
this.state
|
||||
.send('MOUNTED')
|
||||
.send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
|
||||
.send('UNMOUNTED')
|
||||
.send('MOUNTED', { roomId: 'TESTING' })
|
||||
.send('LOADED_FROM_FILE', { json: JSON.stringify(mockDocument) })
|
||||
|
||||
return this
|
||||
}
|
||||
|
@ -126,6 +127,10 @@ class TestState {
|
|||
)
|
||||
}
|
||||
|
||||
get selectedIds(): string[] {
|
||||
return setToArray(tld.getSelectedIds(this.data))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the shape with the provided id has the provided parent id.
|
||||
*
|
||||
|
@ -220,9 +225,15 @@ class TestState {
|
|||
*```
|
||||
*/
|
||||
clickShape(id: string, options: PointerOptions = {}): TestState {
|
||||
this.state
|
||||
.send('POINTED_SHAPE', inputs.pointerDown(TestState.point(options), id))
|
||||
.send('STOPPED_POINTING', inputs.pointerUp(TestState.point(options), id))
|
||||
this.state.send(
|
||||
'POINTED_SHAPE',
|
||||
inputs.pointerDown(TestState.point(options), id)
|
||||
)
|
||||
|
||||
this.state.send(
|
||||
'STOPPED_POINTING',
|
||||
inputs.pointerUp(TestState.point(options), id)
|
||||
)
|
||||
|
||||
return this
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ function storageId(fileId: string, label: string, id?: string) {
|
|||
class Storage {
|
||||
previousSaveHandle?: any // FileSystemHandle
|
||||
|
||||
firstLoad(data: Data, roomId?: string) {
|
||||
firstLoad(data: Data, roomId = 'TESTING') {
|
||||
const lastOpenedFileId =
|
||||
roomId || localStorage.getItem(`${CURRENT_VERSION}_lastOpened`)
|
||||
|
||||
|
@ -88,6 +88,7 @@ class Storage {
|
|||
JSON.parse(json)
|
||||
|
||||
data.document = restoredDocument.document
|
||||
data.pageStates[restoredDocument.pageState.id] = restoredDocument.pageState
|
||||
|
||||
// Save pages to local storage, possibly overwriting unsaved local copies
|
||||
Object.values(data.document.pages).forEach((page) => {
|
||||
|
@ -164,8 +165,6 @@ class Storage {
|
|||
data.pageStates[pageState.id] = pageState
|
||||
data.currentPageId = pageState.id
|
||||
} catch (e) {
|
||||
console.error('Could not restore page state:', e.message)
|
||||
|
||||
data.pageStates[data.currentPageId] = {
|
||||
id: data.currentPageId,
|
||||
selectedIds: new Set([]),
|
||||
|
|
Loading…
Reference in a new issue