excalidraw/src/tests/data/__snapshots__/restore.test.ts.snap
Aakansha Doshi 9659254fd6
feat: improve text measurements in bound containers (#6187)
* feat: move to canvas measureText

* calcualte height with better heuristic

* improve heuristic more

* remove vertical offset as its not needed

* lint

* calculate width of individual char and ceil to calculate width and remove adjustment factor

* push the word if equal to max width

* update height when text overflows for vertical alignment top/bottom

* remove the hack of updating height when line mismatch as its not needed

* remove scroll height and calculate the height instead

* remove unused code

* fix

* remove

* use math.ceil for whole width instead of individual chars

* fix tests

* fix

* fix

* redraw text bounding box instead when font loaded to fix alignment as well

* fix

* fix

* fix

* Add a 0.05px extra only for firefox

* Add spec

* stop taking ceil and increase firefox editor width by 0.05px

* Ad 0.05px in safari too

* lint

* lint

* remove baseline from measureFontSizeFromWH

* don't redraw on font load

* lint

* refactor name and signature
2023-02-23 16:33:10 +05:30

356 lines
6.6 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`restoreElements should restore arrow element correctly 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 100,
"id": "id-arrow01",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"locked": false,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
100,
100,
],
],
"roughness": 1,
"roundness": Object {
"type": 2,
},
"seed": Any<Number>,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "arrow",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 0,
"y": 0,
}
`;
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 1`] = `
Object {
"angle": 0,
"backgroundColor": "blue",
"boundElements": Array [],
"fillStyle": "cross-hatch",
"groupIds": Array [
"1",
"2",
"3",
],
"height": 200,
"id": "1",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 10,
"roughness": 2,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"strokeColor": "red",
"strokeStyle": "dashed",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 10,
"y": 20,
}
`;
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 2`] = `
Object {
"angle": 0,
"backgroundColor": "blue",
"boundElements": Array [],
"fillStyle": "cross-hatch",
"groupIds": Array [
"1",
"2",
"3",
],
"height": 200,
"id": "2",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 10,
"roughness": 2,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"strokeColor": "red",
"strokeStyle": "dashed",
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 10,
"y": 20,
}
`;
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 3`] = `
Object {
"angle": 0,
"backgroundColor": "blue",
"boundElements": Array [],
"fillStyle": "cross-hatch",
"groupIds": Array [
"1",
"2",
"3",
],
"height": 200,
"id": "3",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 10,
"roughness": 2,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"strokeColor": "red",
"strokeStyle": "dashed",
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 10,
"y": 20,
}
`;
exports[`restoreElements should restore freedraw element correctly 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id-freedraw01",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"locked": false,
"opacity": 100,
"points": Array [],
"pressures": Array [],
"roughness": 1,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"simulatePressure": true,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "freedraw",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 0,
"x": 0,
"y": 0,
}
`;
exports[`restoreElements should restore line and draw elements correctly 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 100,
"id": "id-line01",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"locked": false,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
100,
100,
],
],
"roughness": 1,
"roundness": Object {
"type": 2,
},
"seed": Any<Number>,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "line",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 0,
"y": 0,
}
`;
exports[`restoreElements should restore line and draw elements correctly 2`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 100,
"id": "id-draw01",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"locked": false,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
100,
100,
],
],
"roughness": 1,
"roundness": Object {
"type": 2,
},
"seed": Any<Number>,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "line",
"updated": 1,
"version": 1,
"versionNonce": 0,
"width": 100,
"x": 0,
"y": 0,
}
`;
exports[`restoreElements should restore text element correctly passing value for each attribute 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"containerId": null,
"fillStyle": "hachure",
"fontFamily": 1,
"fontSize": 14,
"groupIds": Array [],
"height": 100,
"id": "id-text01",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"originalText": "text",
"roughness": 1,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"text": "text",
"textAlign": "center",
"type": "text",
"updated": 1,
"version": 1,
"versionNonce": 0,
"verticalAlign": "middle",
"width": 100,
"x": -20,
"y": -8.4,
}
`;
exports[`restoreElements should restore text element correctly with unknown font family, null text and undefined alignment 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": Array [],
"containerId": null,
"fillStyle": "hachure",
"fontFamily": 1,
"fontSize": 10,
"groupIds": Array [],
"height": 100,
"id": "id-text01",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"originalText": "test",
"roughness": 1,
"roundness": Object {
"type": 3,
},
"seed": Any<Number>,
"strokeColor": "#000000",
"strokeStyle": "solid",
"strokeWidth": 1,
"text": "",
"textAlign": "left",
"type": "text",
"updated": 1,
"version": 1,
"versionNonce": 0,
"verticalAlign": "top",
"width": 100,
"x": 0,
"y": 0,
}
`;