@teachinglab/omd 0.7.9 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -445,13 +445,64 @@ export class ResizeHandleManager {
445
445
  if (!this.selectedElement) return { x: 0, y: 0, width: 0, height: 0 };
446
446
 
447
447
  try {
448
- // Get bounding box of the content inside the wrapper
448
+ // Get the content inside the wrapper (usually an SVG element)
449
449
  const content = this.selectedElement.firstElementChild;
450
- if (content) {
451
- return content.getBBox();
452
- } else {
450
+ if (!content) {
453
451
  return this.selectedElement.getBBox();
454
452
  }
453
+
454
+ // For elements with clip paths (like coordinate planes),
455
+ // the graph lines extend beyond the visible area causing getBBox() to be too large.
456
+ // We need to find the clip rect to get the actual visible bounds.
457
+ const clipPaths = content.querySelectorAll('clipPath');
458
+
459
+ if (clipPaths.length > 0) {
460
+ let maxArea = 0;
461
+ let clipBounds = null;
462
+
463
+ for (const clipPath of clipPaths) {
464
+ const rect = clipPath.querySelector('rect');
465
+ if (rect) {
466
+ const w = parseFloat(rect.getAttribute('width')) || 0;
467
+ const h = parseFloat(rect.getAttribute('height')) || 0;
468
+ const x = parseFloat(rect.getAttribute('x')) || 0;
469
+ const y = parseFloat(rect.getAttribute('y')) || 0;
470
+
471
+ const area = w * h;
472
+ if (area > maxArea) {
473
+ maxArea = area;
474
+
475
+ // Find the transform on the content group
476
+ const contentGroup = content.firstElementChild;
477
+ let tx = 0, ty = 0;
478
+ if (contentGroup) {
479
+ const transform = contentGroup.getAttribute('transform');
480
+ if (transform) {
481
+ const translateMatch = transform.match(/translate\(\s*([^,]+)(?:,\s*([^)]+))?\s*\)/);
482
+ if (translateMatch) {
483
+ tx = parseFloat(translateMatch[1]) || 0;
484
+ ty = parseFloat(translateMatch[2]) || 0;
485
+ }
486
+ }
487
+ }
488
+
489
+ clipBounds = {
490
+ x: x + tx,
491
+ y: y + ty,
492
+ width: w,
493
+ height: h
494
+ };
495
+ }
496
+ }
497
+ }
498
+
499
+ if (clipBounds) {
500
+ return clipBounds;
501
+ }
502
+ }
503
+
504
+ // Fallback to getBBox if no clip path found
505
+ return content.getBBox();
455
506
  } catch (error) {
456
507
  // Fallback if getBBox fails
457
508
  return { x: 0, y: 0, width: 100, height: 100 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teachinglab/omd",
3
- "version": "0.7.9",
3
+ "version": "0.7.10",
4
4
  "description": "omd",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",