Skip to content

Conversation

@mtolmacs
Copy link
Collaborator

Currently manual stats updates do not respect already bound linear elements.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
@mtolmacs mtolmacs added the stats label Jun 26, 2024
@mtolmacs mtolmacs requested a review from ryan-di June 26, 2024 17:46
@vercel
Copy link

vercel bot commented Jun 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview Jul 1, 2024 7:42am
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Jul 1, 2024 7:42am
excalidraw-package-example-with-nextjs ✅ Ready (Inspect) Visit Preview Jul 1, 2024 7:42am
1 Ignored Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jul 1, 2024 7:42am

@github-actions
Copy link

github-actions bot commented Jun 26, 2024

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 66.18% (🎯 70%) 53484 / 80811
🔴 Statements 66.18% (🎯 70%) 53484 / 80811
🔴 Functions 67.29% (🎯 68%) 1611 / 2394
🟢 Branches 80.86% (🎯 70%) 6521 / 8064
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/excalidraw/shapes.tsx 95.65% 96% 100% 95.65% 140-146
packages/excalidraw/types.ts 100% 100% 100% 100%
packages/excalidraw/actions/actionFinalize.tsx 86.75% 90% 66.66% 86.75% 46, 63, 66-67, 112-121, 153-158, 209-217
packages/excalidraw/actions/actionFlip.ts 100% 86.66% 100% 100%
packages/excalidraw/components/App.tsx 69.74% 76.39% 68.22% 69.74% 473-474, 581-590, 689-690, 708-709, 730-790, 793-799, 802-805, 808-884, 887-906, 909-914, 922-932, 934-935, 940-941, 945-947, 961, 968-1229, 1289-1290, 1301-1302, 1330-1332, 1342-1387, 1413, 1423, 1430-1433, 1442-1446, 1477-1478, 1562-1572, 1577-1592, 1596-1643, 1716-1721, 1750-1755, 1758-1788, 1796-1821, 1824-1833, 1836-1948, 1951-1959, 1968-1981, 1984-2010, 2013-2084, 2087-2128, 2176-2177, 2191-2192, 2224-2225, 2229-2230, 2250-2258, 2263-2276, 2282-2283, 2287, 2292-2300, 2302-2310, 2322, 2363-2364, 2386-2387, 2394, 2463-2465, 2468-2473, 2478-2479, 2518-2526, 2531-2540, 2578-2579, 2666-2667, 2671, 2674-2675, 2683-2686, 2695-2708, 2714-2717, 2720, 2722-2723, 2730-2731, 2737-2738, 2741-2742, 2750-2751, 2754-2755, 2758-2761, 2772-2780, 2785-2786, 2836-2837, 2851-2857, 2863-2871, 2875-2883, 2887-2888, 2891-2924, 2927-2939, 2950-2951, 2962-2963, 2980-2984, 2988-2991, 2998-3000, 3018-3025, 3028, 3030-3035, 3039-3041, 3089-3090, 3097-3099, 3101-3124, 3150, 3156, 3212-3213, 3230-3232, 3254-3255, 3261-3264, 3270-3351, 3405, 3409, 3444-3445, 3504, 3514-3532, 3535-3541, 3544-3545, 3551-3564, 3650-3651, 3653-3654, 3659-3661, 3669-3670, 3693-3707, 3712-3731, 3783-3784, 3863, 3872-3873, 3875-3882, 3897-3901, 3912-3913, 3916-3920, 3922-3923, 3925-3928, 3953-3954, 3963-3965, 3967, 4050-4053, 4075-4077, 4087-4088, 4090-4110, 4113-4119, 4136-4139, 4145-4148, 4158-4165, 4205-4209, 4213, 4218-4219, 4224-4228, 4261-4262, 4265-4266, 4278-4282, 4287-4288, 4294-4304, 4309-4336, 4341-4352, 4416, 4442-4443, 4558, 4583, 4609-4611, 4678-4679, 4697-4698, 4873-4874, 4877-4878, 4886, 4935-4939, 4993-5000, 5006-5072, 5116, 5168, 5195, 5202-5203, 5212-5215, 5246, 5294-5297, 5300-5306, 5308-5311, 5326-5335, 5338-5339, 5439-5440, 5443, 5445-5450, 5456-5458, 5460, 5469, 5491-5496, 5498-5501, 5505-5506, 5516-5616, 5620-5621, 5636-5637, 5673-5674, 5701-5702, 5735-5762, 5769-5770, 5792-5793, 5812, 5814-5857, 5862-5863, 5865-5866, 5882-5883, 5889-5890, 5894-5897, 5900-5901, 5915-5942, 5950-5951, 5955-5958, 5960-5964, 5982-5986, 6033-6038, 6040-6042, 6058, 6060-6073, 6098-6101, 6145, 6162-6163, 6165-6188, 6203-6204, 6315-6343, 6449-6450, 6470-6471, 6565, 6571-6572, 6595-6614, 6629, 6758, 6780-6818, 6822-6872, 6887, 6896, 6930-6936, 6951-6953, 7095-7098, 7122-7153, 7166, 7168-7176, 7190, 7192-7200, 7207-7210, 7218-7223, 7250-7251, 7256-7258, 7261-7262, 7287-7288, 7319-7320, 7403-7404, 7453-7466, 7532-7535, 7561-7562, 7598-7599, 7612, 7630-7636, 7643-7646, 7669-7675, 7747, 7753, 7768-7775, 7778-7785, 7841, 7918-7919, 7940-7942, 7945, 7959-7983, 8111-8135, 8145-8184, 8197-8198, 8207-8214, 8228-8241, 8254-8261, 8315-8341, 8343-8344, 8418-8419, 8426, 8428-8464, 8493, 8557, 8589-8591, 8616-8621, 8623-8624, 8629-8631, 8634-8654, 8668-8669, 8675-8684, 8689, 8693-8697, 8706-8710, 8713-8718, 8722-8729, 8759, 8761-8765, 8767-8777, 8793-8795, 8806-8814, 8818-8862, 8865-8936, 8944, 8962-8969, 8971-8987, 9002-9024, 9043-9045, 9090-9091, 9205-9209, 9211-9227, 9229-9233, 9245-9246, 9256-9272, 9291-9310, 9312-9313, 9340-9341, 9345-9346, 9356, 9358-9361, 9363-9364, 9404, 9425-9426, 9453, 9456, 9497, 9510-9518, 9535-9536, 9568-9571, 9664-9671, 9697-9698, 9741-9795, 9843-9844, 9853-9856, 9861-9862, 9883-9885, 9887-9891, 9929
packages/excalidraw/components/Stats/Angle.tsx 82.79% 22.22% 100% 82.79% 34-35, 46-47, 51-60, 72-73
packages/excalidraw/components/Stats/MultiDimension.tsx 71.2% 80.43% 100% 71.2% 55, 78-98, 203, 215, 240, 245-329
packages/excalidraw/components/Stats/MultiPosition.tsx 70.65% 72.72% 75% 70.65% 29-67, 86-87, 157-187, 193-196
packages/excalidraw/components/Stats/utils.ts 83.38% 78.78% 100% 83.38% 131-132, 137-147, 175-194, 197-200, 214-215, 254-264
packages/excalidraw/element/binding.ts 96.98% 90.29% 100% 96.98% 232, 246, 269, 278, 316-317, 525-526, 600, 602-603, 623, 633-635, 730-731, 739-740, 745-746, 787, 799-800, 827-828, 1184-1186, 1224-1229, 1275-1276, 1298-1299, 1351-1353, 1528-1529, 1640-1641, 1673-1677
packages/excalidraw/element/linearElementEditor.ts 78.09% 83.24% 89.18% 78.09% 134, 138-190, 206-207, 211-212, 222-223, 225-245, 271-274, 345-346, 369, 386, 404-412, 500-501, 517-518, 625-626, 639, 663-664, 670-671, 688-726, 821-822, 826-827, 834-835, 841-843, 845-882, 1032-1097, 1111-1118, 1133-1142, 1211-1212, 1253-1254, 1318-1344, 1460-1492
Generated in workflow #2753

@ryan-di
Copy link
Member

ryan-di commented Jun 27, 2024

What about the other direction, when it is the arrow (bound to some elements) that we're updating through stats panel? Should we update the bindings? For instance, the arrow is moved to a different location

image

@mtolmacs
Copy link
Collaborator Author

@dwelle Should we update the arrow bindings if manually update via the stats panel? It would make sense that if you move an arrow close to a bindable it would bind.

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
@mtolmacs
Copy link
Collaborator Author

I merged in the master branch and added in functionality to keep linear elements bound if they were previously bound and the manual changes don't remove them from their original binding area. Otherwise the linear element disconnects.

Previously it never disconnected the original binding, no matter how far it was moved via stats edits. Consequently it never bound to any shape either when moved within the binding area.

@dwelle
Copy link
Member

dwelle commented Jun 27, 2024

Should we update the arrow bindings if manually update via the stats panel? It would make sense that if you move an arrow close to a bindable it would bind.

I merged in the master branch and added in functionality to keep linear elements bound if they were previously bound and the manual changes don't remove them from their original binding area. Otherwise the linear element disconnects.

Previously it never disconnected the original binding, no matter how far it was moved via stats edits. Consequently it never bound to any shape either when moved within the binding area.

yeah, sounds good!

@mtolmacs
Copy link
Collaborator Author

Okay, if @ryan-di if you're okay with this, no more edge cases come to mind, then give me the go-ahead and I merge this.

…ioning

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
mtolmacs added 2 commits June 28, 2024 13:59
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
@mtolmacs
Copy link
Collaborator Author

@ryan-di added tests and fixed a small bug. Let me know.

mtolmacs added 2 commits June 28, 2024 17:09
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
@mtolmacs
Copy link
Collaborator Author

Removed import reordering as per @dwelle's request.

@ryan-di
Copy link
Member

ryan-di commented Jul 1, 2024

Hey @mtolmacs, I've gone through the code and if you could take some time to go over the two comments, we're good to go 🙂

interface AngleProps {
element: ExcalidrawElement;
elementsMap: ElementsMap;
scene: Scene;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of using scene here?

): boolean => {
const threshold = maxBindingGap(element, element.width, element.height);
const shape = app.getElementShape(element);
const shape = getElementShape(element, elementsMap);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the inclusion of the getElementShape refactor intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately yes, because the getElementShape() was an instance method on App and the binding code uses getElementShape(), therefore an app instance must be provided to the linear binding functions used this PR. Since it was a fairly self-contained instance method, I opted to extract it from App and not add an app instance to all functions all the way down to the stats editor. I also bring this refactor in another PR, so this is a refactor which should happen anyway.

I believe the code and responsibilities are clearer this way.

angle: nextAngle,
});

if (isLinearElement(latestElement)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably put this in a function in Stats/utilts 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Copy link
Collaborator Author

@mtolmacs mtolmacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered and completed

): boolean => {
const threshold = maxBindingGap(element, element.width, element.height);
const shape = app.getElementShape(element);
const shape = getElementShape(element, elementsMap);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately yes, because the getElementShape() was an instance method on App and the binding code uses getElementShape(), therefore an app instance must be provided to the linear binding functions used this PR. Since it was a fairly self-contained instance method, I opted to extract it from App and not add an app instance to all functions all the way down to the stats editor. I also bring this refactor in another PR, so this is a refactor which should happen anyway.

I believe the code and responsibilities are clearer this way.

angle: nextAngle,
});

if (isLinearElement(latestElement)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@ryan-di ryan-di left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mtolmacs mtolmacs merged commit 66a2f24 into master Jul 1, 2024
@mtolmacs mtolmacs deleted the fix/stats-editor-binding branch July 1, 2024 07:45
Jauhen pushed a commit to Jauhen/excalidraw that referenced this pull request Nov 7, 2024
Manual stats changes now respect previous element bindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants