@@ -28,6 +28,7 @@ import {
28
28
import type { CanvasPoint , CanvasRectangle , LocalRectangle } from '../../../core/shared/math-utils'
29
29
import {
30
30
canvasPoint ,
31
+ canvasRectangle ,
31
32
isFiniteRectangle ,
32
33
isInfinityRectangle ,
33
34
nullIfInfinity ,
@@ -2160,6 +2161,8 @@ const rulerMarkerIconSize = 12 // px
2160
2161
2161
2162
type RulerMarkerData = {
2162
2163
parentGrid : GridContainerProperties
2164
+ cellRect : CanvasRectangle
2165
+ gridRect : CanvasRectangle
2163
2166
columnStart : RulerMarkerPositionData
2164
2167
columnEnd : RulerMarkerPositionData
2165
2168
rowStart : RulerMarkerPositionData
@@ -2243,8 +2246,18 @@ const RulerMarkers = React.memo((props: { path: ElementPath }) => {
2243
2246
store . editor . jsxMetadata ,
2244
2247
)
2245
2248
2249
+ const cellRect = parentGridCellGlobalFrames [ cellBounds . row - 1 ] [ cellBounds . column - 1 ]
2250
+ const cellRectResized = canvasRectangle ( {
2251
+ x : cellRect . x ,
2252
+ y : cellRect . y ,
2253
+ width : width ,
2254
+ height : height ,
2255
+ } )
2256
+
2246
2257
return {
2247
2258
parentGrid : parentGrid ,
2259
+ cellRect : cellRectResized ,
2260
+ gridRect : gridRect ,
2248
2261
columnStart : {
2249
2262
top : gridRect . y ,
2250
2263
left : left ,
@@ -2280,6 +2293,7 @@ const RulerMarkers = React.memo((props: { path: ElementPath }) => {
2280
2293
2281
2294
return (
2282
2295
< React . Fragment >
2296
+ { /* Indicators */ }
2283
2297
< RulerMarkerIndicator
2284
2298
parentGrid = { markers . parentGrid }
2285
2299
marker = { markers . columnStart }
@@ -2296,6 +2310,38 @@ const RulerMarkers = React.memo((props: { path: ElementPath }) => {
2296
2310
axis = { 'row' }
2297
2311
/>
2298
2312
< RulerMarkerIndicator parentGrid = { markers . parentGrid } marker = { markers . rowEnd } axis = { 'row' } />
2313
+ { /* Offset lines */ }
2314
+ < GridCellOffsetLine
2315
+ top = { markers . columnStart . top }
2316
+ left = { markers . columnStart . left }
2317
+ size = { markers . cellRect . y - markers . gridRect . y }
2318
+ orientation = 'vertical'
2319
+ />
2320
+ < GridCellOffsetLine
2321
+ top = { markers . columnEnd . top }
2322
+ left = { markers . columnEnd . left }
2323
+ size = { markers . cellRect . y - markers . gridRect . y }
2324
+ orientation = 'vertical'
2325
+ />
2326
+ < GridCellOffsetLine
2327
+ top = { markers . rowStart . top }
2328
+ left = { markers . rowStart . left }
2329
+ size = { markers . cellRect . x - markers . gridRect . x }
2330
+ orientation = 'horizontal'
2331
+ />
2332
+ < GridCellOffsetLine
2333
+ top = { markers . rowEnd . top }
2334
+ left = { markers . rowEnd . left }
2335
+ size = { markers . cellRect . x - markers . gridRect . x }
2336
+ orientation = 'horizontal'
2337
+ />
2338
+ { /* Cell outline */ }
2339
+ < GridCellOutline
2340
+ top = { markers . cellRect . y }
2341
+ left = { markers . cellRect . x }
2342
+ width = { markers . cellRect . width + 1 }
2343
+ height = { markers . cellRect . height + 1 }
2344
+ />
2299
2345
</ React . Fragment >
2300
2346
)
2301
2347
} )
@@ -2496,16 +2542,17 @@ function skewMarkerPosition(
2496
2542
// span-end triangle, on the column
2497
2543
const spanEndColumn = axis === 'column' && markerType === 'span-end'
2498
2544
if ( spanEndColumn ) {
2499
- return 10
2545
+ return 9
2500
2546
}
2501
- const pinnedEndColumn = axis === 'column' && markerType === 'pinned'
2547
+ // pinned triangle, on the column
2548
+ const pinnedEndColumn = axis === 'column' && markerType === 'pinned' && bound === 'end'
2502
2549
if ( pinnedEndColumn ) {
2503
2550
return 5
2504
2551
}
2505
2552
// any other ending marker, on the column
2506
2553
const endColumn = bound === 'end' && axis === 'column'
2507
2554
if ( endColumn ) {
2508
- return 2
2555
+ return 1
2509
2556
}
2510
2557
2511
2558
// span-end triangle, on the row
@@ -2516,18 +2563,22 @@ function skewMarkerPosition(
2516
2563
// any other ending marker, on the row
2517
2564
const endRow = bound === 'end' && axis === 'row'
2518
2565
if ( endRow ) {
2519
- return 6
2566
+ return 4
2520
2567
}
2521
2568
2522
2569
// span-start triangle, on the column
2523
2570
const spanStartColumn = axis === 'column' && markerType === 'span-start'
2524
2571
if ( spanStartColumn ) {
2525
2572
return 0
2526
2573
}
2574
+ const pinnedStartColumn = axis === 'column' && markerType === 'pinned' && bound === 'start'
2575
+ if ( pinnedStartColumn ) {
2576
+ return 5
2577
+ }
2527
2578
// any starting marker, on the column
2528
2579
const startColumn = bound === 'start' && axis === 'column'
2529
2580
if ( startColumn ) {
2530
- return 5
2581
+ return 1
2531
2582
}
2532
2583
2533
2584
// span-start starting triangle, on the row
@@ -2543,3 +2594,50 @@ function skewMarkerPosition(
2543
2594
2544
2595
return 0
2545
2596
}
2597
+
2598
+ const GridCellOffsetLine = React . memo (
2599
+ ( props : { top : number ; left : number ; size : number ; orientation : 'vertical' | 'horizontal' } ) => {
2600
+ const colorTheme = useColorTheme ( )
2601
+
2602
+ return (
2603
+ < div
2604
+ style = { {
2605
+ position : 'absolute' ,
2606
+ top : props . top ,
2607
+ left : props . left ,
2608
+ width : props . orientation === 'horizontal' ? props . size : 1 ,
2609
+ height : props . orientation === 'vertical' ? props . size : 1 ,
2610
+ borderLeft :
2611
+ props . orientation === 'vertical' ? `1px dashed ${ colorTheme . primary . value } ` : undefined ,
2612
+ borderTop :
2613
+ props . orientation === 'horizontal'
2614
+ ? `1px dashed ${ colorTheme . primary . value } `
2615
+ : undefined ,
2616
+ pointerEvents : 'none' ,
2617
+ } }
2618
+ />
2619
+ )
2620
+ } ,
2621
+ )
2622
+ GridCellOffsetLine . displayName = 'GridCellOffsetLine'
2623
+
2624
+ const GridCellOutline = React . memo (
2625
+ ( props : { top : number ; left : number ; width : number ; height : number } ) => {
2626
+ const colorTheme = useColorTheme ( )
2627
+
2628
+ return (
2629
+ < div
2630
+ style = { {
2631
+ position : 'absolute' ,
2632
+ top : props . top ,
2633
+ left : props . left ,
2634
+ width : props . width ,
2635
+ height : props . height ,
2636
+ border : `1px dashed ${ colorTheme . primary . value } ` ,
2637
+ pointerEvents : 'none' ,
2638
+ } }
2639
+ />
2640
+ )
2641
+ } ,
2642
+ )
2643
+ GridCellOutline . displayName = 'GridCellOutline'
0 commit comments