context_drop 0.1.2 → 0.1.4
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.
- checksums.yaml +4 -4
- data/README.md +101 -9
- data/app/assets/javascripts/context_drop/context_drop.js +1219 -575
- data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +62 -2
- data/app/helpers/context_drop/dashboard_helper.rb +52 -0
- data/app/javascript/context_drop/__tests__/widget.test.ts +225 -3
- data/app/javascript/context_drop/element-picker.ts +958 -484
- data/app/javascript/context_drop/icons.ts +2 -0
- data/app/javascript/context_drop/screenshot.ts +7 -1
- data/app/javascript/context_drop/styles.ts +88 -39
- data/app/javascript/context_drop/widget.ts +195 -69
- data/app/models/context_drop/feedback.rb +11 -5
- data/app/views/context_drop/dashboard/feedbacks/index.html.erb +161 -60
- data/app/views/context_drop/dashboard/feedbacks/show.html.erb +168 -47
- data/app/views/layouts/context_drop/application.html.erb +415 -70
- data/lib/context_drop/version.rb +1 -1
- metadata +3 -2
|
@@ -452,6 +452,7 @@
|
|
|
452
452
|
const ICON_CHEVRON_UP = `<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3.5 10 8 5.5 12.5 10"/></svg>`;
|
|
453
453
|
const ICON_CHEVRON_DOWN = `<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3.5 6 8 10.5 12.5 6"/></svg>`;
|
|
454
454
|
const ICON_CHEVRON_RIGHT = `<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 3.5 10.5 8 6 12.5"/></svg>`;
|
|
455
|
+
const ICON_SCROLL_VERTICAL = `<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="5.25 5.75 8 3 10.75 5.75"/><polyline points="5.25 10.25 8 13 10.75 10.25"/></svg>`;
|
|
455
456
|
const ICON_CAMERA = `<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6.5h2.5l1.4-2h6.2l1.4 2H17a1.5 1.5 0 0 1 1.5 1.5v7.5A1.5 1.5 0 0 1 17 17H3a1.5 1.5 0 0 1-1.5-1.5V8A1.5 1.5 0 0 1 3 6.5z"/><circle cx="10" cy="11.5" r="2.75"/></svg>`;
|
|
456
457
|
const ICON_IMAGE = `<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="3.5" width="15" height="13" rx="2"/><circle cx="7" cy="8" r="1.3"/><path d="M17.5 13.2l-3.8-3.7L6 16.5"/></svg>`;
|
|
457
458
|
const ICON_SEND = `<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 16V4"/><polyline points="5 9 10 4 15 9"/></svg>`;
|
|
@@ -557,21 +558,18 @@
|
|
|
557
558
|
|
|
558
559
|
/* Custom themed scrollbars */
|
|
559
560
|
.cd-chat-thread::-webkit-scrollbar,
|
|
560
|
-
.cd-tray::-webkit-scrollbar
|
|
561
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar {
|
|
561
|
+
.cd-tray::-webkit-scrollbar {
|
|
562
562
|
width: 6px;
|
|
563
563
|
height: 6px;
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
.cd-chat-thread::-webkit-scrollbar-track,
|
|
567
|
-
.cd-tray::-webkit-scrollbar-track
|
|
568
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar-track {
|
|
567
|
+
.cd-tray::-webkit-scrollbar-track {
|
|
569
568
|
background: transparent;
|
|
570
569
|
}
|
|
571
570
|
|
|
572
571
|
.cd-chat-thread::-webkit-scrollbar-thumb,
|
|
573
|
-
.cd-tray::-webkit-scrollbar-thumb
|
|
574
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar-thumb {
|
|
572
|
+
.cd-tray::-webkit-scrollbar-thumb {
|
|
575
573
|
background: var(--cd-border);
|
|
576
574
|
border-radius: 9999px;
|
|
577
575
|
}
|
|
@@ -676,14 +674,15 @@
|
|
|
676
674
|
font-variant-numeric: tabular-nums;
|
|
677
675
|
}
|
|
678
676
|
|
|
679
|
-
/* Compact Minimized Bar (active while pinning elements or minimized) */
|
|
677
|
+
/* Compact Minimized Session Coach Bar (active while pinning elements or minimized) */
|
|
680
678
|
.cd-compact-bar {
|
|
681
679
|
pointer-events: auto;
|
|
682
680
|
display: flex;
|
|
683
681
|
align-items: center;
|
|
684
682
|
gap: 8px;
|
|
685
|
-
width:
|
|
686
|
-
|
|
683
|
+
width: max-content;
|
|
684
|
+
min-width: 390px;
|
|
685
|
+
max-width: min(560px, calc(100vw - 24px));
|
|
687
686
|
padding: 7px 10px;
|
|
688
687
|
background: var(--cd-surface);
|
|
689
688
|
color: var(--cd-ink);
|
|
@@ -702,52 +701,93 @@
|
|
|
702
701
|
.cd-compact-status {
|
|
703
702
|
display: flex;
|
|
704
703
|
align-items: center;
|
|
705
|
-
gap:
|
|
704
|
+
gap: 7px;
|
|
706
705
|
flex: 1;
|
|
707
706
|
min-width: 0;
|
|
707
|
+
overflow: hidden;
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
.cd-
|
|
711
|
-
display: flex;
|
|
710
|
+
.cd-compact-coach-text {
|
|
711
|
+
display: inline-flex;
|
|
712
712
|
align-items: center;
|
|
713
|
-
gap:
|
|
714
|
-
|
|
713
|
+
gap: 5px;
|
|
714
|
+
font-size: 12px;
|
|
715
|
+
color: var(--cd-ink-secondary);
|
|
715
716
|
white-space: nowrap;
|
|
716
|
-
|
|
717
|
-
|
|
717
|
+
overflow: hidden;
|
|
718
|
+
text-overflow: ellipsis;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
.cd-compact-coach-text strong {
|
|
722
|
+
color: var(--cd-ink);
|
|
723
|
+
font-weight: 600;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.cd-compact-wheel-icon {
|
|
727
|
+
display: inline-flex;
|
|
728
|
+
align-items: center;
|
|
729
|
+
color: var(--cd-accent);
|
|
730
|
+
flex-shrink: 0;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.cd-compact-pinned-pill {
|
|
734
|
+
display: inline-flex;
|
|
735
|
+
align-items: center;
|
|
736
|
+
gap: 5px;
|
|
737
|
+
padding: 2px 5px 2px 6px;
|
|
738
|
+
background: var(--cd-surface-elevated);
|
|
739
|
+
border: 1px solid var(--cd-border);
|
|
740
|
+
border-radius: 7px;
|
|
718
741
|
min-width: 0;
|
|
719
|
-
|
|
742
|
+
max-width: 220px;
|
|
720
743
|
}
|
|
721
744
|
|
|
722
|
-
.cd-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
border-radius: 5px;
|
|
731
|
-
cursor: pointer;
|
|
745
|
+
.cd-compact-pinned-count {
|
|
746
|
+
font-size: 10.5px;
|
|
747
|
+
font-weight: 700;
|
|
748
|
+
font-variant-numeric: tabular-nums;
|
|
749
|
+
padding: 1px 5px;
|
|
750
|
+
border-radius: 4px;
|
|
751
|
+
background: var(--cd-pin-soft);
|
|
752
|
+
color: var(--cd-pin-hover);
|
|
732
753
|
flex-shrink: 0;
|
|
733
754
|
}
|
|
734
755
|
|
|
735
|
-
.cd-
|
|
736
|
-
|
|
756
|
+
.cd-compact-pinned-selector {
|
|
757
|
+
font-family: var(--cd-mono);
|
|
758
|
+
font-size: 11px;
|
|
737
759
|
color: var(--cd-ink);
|
|
760
|
+
overflow: hidden;
|
|
761
|
+
text-overflow: ellipsis;
|
|
762
|
+
white-space: nowrap;
|
|
738
763
|
}
|
|
739
764
|
|
|
740
|
-
.cd-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
765
|
+
.cd-compact-step-group {
|
|
766
|
+
display: inline-flex;
|
|
767
|
+
align-items: center;
|
|
768
|
+
gap: 2px;
|
|
769
|
+
flex-shrink: 0;
|
|
745
770
|
}
|
|
746
771
|
|
|
747
|
-
.cd-
|
|
772
|
+
.cd-kbd {
|
|
748
773
|
display: inline-flex;
|
|
749
|
-
|
|
750
|
-
|
|
774
|
+
align-items: center;
|
|
775
|
+
justify-content: center;
|
|
776
|
+
font-family: var(--cd-mono);
|
|
777
|
+
font-size: 10px;
|
|
778
|
+
font-weight: 600;
|
|
779
|
+
line-height: 1.1;
|
|
780
|
+
padding: 2px 5px;
|
|
781
|
+
border-radius: 4px;
|
|
782
|
+
background: var(--cd-surface-recessed);
|
|
783
|
+
border: 1px solid var(--cd-border);
|
|
784
|
+
color: var(--cd-ink-secondary);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.cd-btn-primary .cd-kbd {
|
|
788
|
+
background: rgba(250, 249, 246, 0.16);
|
|
789
|
+
border-color: rgba(250, 249, 246, 0.26);
|
|
790
|
+
color: var(--cd-surface);
|
|
751
791
|
}
|
|
752
792
|
|
|
753
793
|
/* Main Floating Chatbox Composer Window */
|
|
@@ -860,11 +900,16 @@
|
|
|
860
900
|
transition: background-color 0.12s ease, color 0.12s ease;
|
|
861
901
|
}
|
|
862
902
|
|
|
863
|
-
.cd-icon-btn:hover {
|
|
903
|
+
.cd-icon-btn:hover:not(:disabled) {
|
|
864
904
|
background: rgba(17, 19, 24, 0.06);
|
|
865
905
|
color: var(--cd-ink);
|
|
866
906
|
}
|
|
867
907
|
|
|
908
|
+
.cd-icon-btn:disabled {
|
|
909
|
+
opacity: 0.36;
|
|
910
|
+
cursor: not-allowed;
|
|
911
|
+
}
|
|
912
|
+
|
|
868
913
|
/* Conversational Chat Thread */
|
|
869
914
|
.cd-chat-thread {
|
|
870
915
|
display: flex;
|
|
@@ -1146,10 +1191,15 @@
|
|
|
1146
1191
|
border-color: #252a34;
|
|
1147
1192
|
}
|
|
1148
1193
|
|
|
1149
|
-
@media (max-width:
|
|
1194
|
+
@media (max-width: 520px) {
|
|
1150
1195
|
.cd-composer,
|
|
1151
1196
|
.cd-compact-bar {
|
|
1152
1197
|
width: calc(100vw - 20px);
|
|
1198
|
+
min-width: 0;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
.cd-compact-bar {
|
|
1202
|
+
flex-wrap: wrap;
|
|
1153
1203
|
}
|
|
1154
1204
|
}
|
|
1155
1205
|
`;
|
|
@@ -1451,7 +1501,13 @@
|
|
|
1451
1501
|
// Paint visible non-excluded DOM elements approximation onto canvas
|
|
1452
1502
|
const visibleNodes = document.body ? Array.from(document.body.querySelectorAll("*")) : [];
|
|
1453
1503
|
for (const node of visibleNodes) {
|
|
1454
|
-
if (
|
|
1504
|
+
if (
|
|
1505
|
+
node.closest("context-drop-widget") ||
|
|
1506
|
+
node.hasAttribute("data-context-drop-ui") ||
|
|
1507
|
+
node.closest("[data-context-drop-ui]")
|
|
1508
|
+
) {
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1455
1511
|
if (isElementExcluded(node, customExcludedSelectors)) continue;
|
|
1456
1512
|
|
|
1457
1513
|
const r = node.getBoundingClientRect();
|
|
@@ -1545,31 +1601,72 @@
|
|
|
1545
1601
|
}
|
|
1546
1602
|
|
|
1547
1603
|
// --- Module: element-picker.ts ---
|
|
1604
|
+
const WHEEL_STEP_THRESHOLD = 26;
|
|
1605
|
+
const WHEEL_STEP_COOLDOWN_MS = 80;
|
|
1606
|
+
const SCRUB_JITTER_LOCK_PX = 28;
|
|
1607
|
+
const MAX_VISIBLE_STACK_ROWS = 5;
|
|
1608
|
+
|
|
1609
|
+
function isDomElementNode(node ) {
|
|
1610
|
+
if (!node || typeof node !== "object") return false;
|
|
1611
|
+
if (typeof window !== "undefined" && node === window) return false;
|
|
1612
|
+
if ((node ).nodeType !== 1) return false;
|
|
1613
|
+
const tag = ((node ).tagName || "").toUpperCase();
|
|
1614
|
+
return tag.length > 0 && tag !== "WINDOW";
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
function formatCandidateLabel(tagName , selector ) {
|
|
1618
|
+
if (selector.startsWith(tagName)) {
|
|
1619
|
+
return selector;
|
|
1620
|
+
}
|
|
1621
|
+
if (selector.startsWith("#") || selector.startsWith(".")) {
|
|
1622
|
+
return `${tagName}${selector}`;
|
|
1623
|
+
}
|
|
1624
|
+
return selector;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
function isPointInsideRect(
|
|
1628
|
+
x ,
|
|
1629
|
+
y ,
|
|
1630
|
+
rect ,
|
|
1631
|
+
tolerance = 2
|
|
1632
|
+
) {
|
|
1633
|
+
const left = (rect.left ?? rect.x ?? 0) - tolerance;
|
|
1634
|
+
const top = (rect.top ?? rect.y ?? 0) - tolerance;
|
|
1635
|
+
return x >= left && x <= left + rect.width + tolerance * 2 && y >= top && y <= top + rect.height + tolerance * 2;
|
|
1636
|
+
}
|
|
1548
1637
|
class ElementPicker {
|
|
1549
1638
|
active = false;
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1639
|
+
isScrubbingLayers = false;
|
|
1640
|
+
scrubOriginX = 0;
|
|
1641
|
+
scrubOriginY = 0;
|
|
1553
1642
|
lastPointerX = 0;
|
|
1554
1643
|
lastPointerY = 0;
|
|
1555
1644
|
wheelAccumulator = 0;
|
|
1645
|
+
lastWheelStepAt = 0;
|
|
1556
1646
|
|
|
1557
1647
|
callbacks ;
|
|
1558
1648
|
overlayEl = null;
|
|
1559
1649
|
leafOutlineEl = null;
|
|
1560
|
-
|
|
1650
|
+
hudEl = null;
|
|
1561
1651
|
pinMarkerEl = null;
|
|
1562
|
-
|
|
1652
|
+
pinnedMarkersContainerEl = null;
|
|
1653
|
+
toastEl = null;
|
|
1563
1654
|
previewOverlayEl = null;
|
|
1564
1655
|
|
|
1656
|
+
pulseTimer = null;
|
|
1657
|
+
nudgeTimer = null;
|
|
1658
|
+
toastTimer = null;
|
|
1659
|
+
|
|
1565
1660
|
candidateStack = [];
|
|
1566
1661
|
activeCandidateIndex = 0;
|
|
1567
1662
|
leafElement = null;
|
|
1663
|
+
lastAction = null;
|
|
1568
1664
|
previousCursor = "";
|
|
1569
1665
|
|
|
1570
1666
|
boundMouseMove ;
|
|
1571
1667
|
boundClickCapture ;
|
|
1572
1668
|
boundPointerCapture ;
|
|
1669
|
+
boundBlurSuppression ;
|
|
1573
1670
|
boundWheelCapture ;
|
|
1574
1671
|
boundKeyDown ;
|
|
1575
1672
|
boundScrollOrResize ;
|
|
@@ -1579,9 +1676,10 @@
|
|
|
1579
1676
|
this.boundMouseMove = this.handleMouseMove.bind(this);
|
|
1580
1677
|
this.boundClickCapture = this.handleClickCapture.bind(this);
|
|
1581
1678
|
this.boundPointerCapture = this.handlePointerSuppression.bind(this);
|
|
1679
|
+
this.boundBlurSuppression = this.handleBlurSuppression.bind(this);
|
|
1582
1680
|
this.boundWheelCapture = this.handleWheelCapture.bind(this);
|
|
1583
1681
|
this.boundKeyDown = this.handleKeyDown.bind(this);
|
|
1584
|
-
this.boundScrollOrResize = this.
|
|
1682
|
+
this.boundScrollOrResize = this.handleViewportScrollOrResize.bind(this);
|
|
1585
1683
|
}
|
|
1586
1684
|
|
|
1587
1685
|
isActive() {
|
|
@@ -1589,7 +1687,11 @@
|
|
|
1589
1687
|
}
|
|
1590
1688
|
|
|
1591
1689
|
isAnchored() {
|
|
1592
|
-
return
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
isScrubbing() {
|
|
1694
|
+
return this.isScrubbingLayers;
|
|
1593
1695
|
}
|
|
1594
1696
|
|
|
1595
1697
|
getActiveCandidate() {
|
|
@@ -1605,10 +1707,13 @@
|
|
|
1605
1707
|
return;
|
|
1606
1708
|
}
|
|
1607
1709
|
this.active = true;
|
|
1608
|
-
this.
|
|
1710
|
+
this.isScrubbingLayers = false;
|
|
1711
|
+
this.wheelAccumulator = 0;
|
|
1712
|
+
this.lastWheelStepAt = 0;
|
|
1609
1713
|
this.candidateStack = [];
|
|
1610
1714
|
this.activeCandidateIndex = 0;
|
|
1611
1715
|
this.leafElement = null;
|
|
1716
|
+
this.lastAction = null;
|
|
1612
1717
|
|
|
1613
1718
|
this.hideExternalPreview();
|
|
1614
1719
|
|
|
@@ -1618,6 +1723,7 @@
|
|
|
1618
1723
|
}
|
|
1619
1724
|
|
|
1620
1725
|
this.mountSelectionUi();
|
|
1726
|
+
this.refreshPinnedMarkers();
|
|
1621
1727
|
this.notifyStateChange();
|
|
1622
1728
|
|
|
1623
1729
|
window.addEventListener("mousemove", this.boundMouseMove, { capture: true, passive: true });
|
|
@@ -1625,6 +1731,8 @@
|
|
|
1625
1731
|
window.addEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
1626
1732
|
window.addEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
1627
1733
|
window.addEventListener("click", this.boundClickCapture, { capture: true });
|
|
1734
|
+
window.addEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
1735
|
+
window.addEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
1628
1736
|
window.addEventListener("wheel", this.boundWheelCapture, { capture: true, passive: false });
|
|
1629
1737
|
window.addEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
1630
1738
|
window.addEventListener("scroll", this.boundScrollOrResize, { capture: true, passive: true });
|
|
@@ -1634,10 +1742,13 @@
|
|
|
1634
1742
|
stop() {
|
|
1635
1743
|
if (!this.active) return;
|
|
1636
1744
|
this.active = false;
|
|
1637
|
-
this.
|
|
1745
|
+
this.isScrubbingLayers = false;
|
|
1746
|
+
this.wheelAccumulator = 0;
|
|
1638
1747
|
this.candidateStack = [];
|
|
1639
1748
|
this.activeCandidateIndex = 0;
|
|
1640
1749
|
this.leafElement = null;
|
|
1750
|
+
this.lastAction = null;
|
|
1751
|
+
this.clearTimers();
|
|
1641
1752
|
|
|
1642
1753
|
if (typeof document !== "undefined" && document.body) {
|
|
1643
1754
|
document.body.style.cursor = this.previousCursor;
|
|
@@ -1649,6 +1760,8 @@
|
|
|
1649
1760
|
window.removeEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
1650
1761
|
window.removeEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
1651
1762
|
window.removeEventListener("click", this.boundClickCapture, { capture: true });
|
|
1763
|
+
window.removeEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
1764
|
+
window.removeEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
1652
1765
|
window.removeEventListener("wheel", this.boundWheelCapture, { capture: true });
|
|
1653
1766
|
window.removeEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
1654
1767
|
window.removeEventListener("scroll", this.boundScrollOrResize, { capture: true });
|
|
@@ -1660,9 +1773,13 @@
|
|
|
1660
1773
|
this.callbacks.onExit();
|
|
1661
1774
|
}
|
|
1662
1775
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1776
|
+
highlightAtPoint(x , y ) {
|
|
1777
|
+
if (!this.active || typeof document === "undefined") return;
|
|
1778
|
+
this.lastPointerX = x;
|
|
1779
|
+
this.lastPointerY = y;
|
|
1780
|
+
this.updateCandidatesFromPoint(x, y);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1666
1783
|
focusCandidateElement(el ) {
|
|
1667
1784
|
if (!this.active) return;
|
|
1668
1785
|
const excluded = this.callbacks.getExcludedSelectors();
|
|
@@ -1677,10 +1794,10 @@
|
|
|
1677
1794
|
this.activeCandidateIndex = this.candidateStack.length - 1;
|
|
1678
1795
|
}
|
|
1679
1796
|
|
|
1797
|
+
this.isScrubbingLayers = this.candidateStack.length > 1;
|
|
1798
|
+
this.scrubOriginX = this.lastPointerX;
|
|
1799
|
+
this.scrubOriginY = this.lastPointerY;
|
|
1680
1800
|
this.updateOverlayPosition();
|
|
1681
|
-
if (this.anchored) {
|
|
1682
|
-
this.renderLayerPopover();
|
|
1683
|
-
}
|
|
1684
1801
|
this.notifyStateChange();
|
|
1685
1802
|
}
|
|
1686
1803
|
|
|
@@ -1690,16 +1807,75 @@
|
|
|
1690
1807
|
if (!snapshot) return false;
|
|
1691
1808
|
|
|
1692
1809
|
this.callbacks.onSelect(snapshot, el);
|
|
1693
|
-
this.
|
|
1810
|
+
this.lastAction = { kind: "pinned", selector: snapshot.selector };
|
|
1811
|
+
this.isScrubbingLayers = false;
|
|
1812
|
+
this.refreshPinnedMarkers();
|
|
1694
1813
|
|
|
1695
1814
|
if (!this.callbacks.canSelectMore()) {
|
|
1696
1815
|
this.stop();
|
|
1697
1816
|
} else {
|
|
1817
|
+
this.updateOverlayPosition();
|
|
1698
1818
|
this.notifyStateChange();
|
|
1699
1819
|
}
|
|
1700
1820
|
return true;
|
|
1701
1821
|
}
|
|
1702
1822
|
|
|
1823
|
+
refreshPinnedMarkers() {
|
|
1824
|
+
if (!this.active || !this.pinnedMarkersContainerEl) return;
|
|
1825
|
+
this.pinnedMarkersContainerEl.innerHTML = "";
|
|
1826
|
+
|
|
1827
|
+
const pinnedEntries = this.callbacks.getPinnedElements ? this.callbacks.getPinnedElements() : [];
|
|
1828
|
+
pinnedEntries.forEach((entry, index) => {
|
|
1829
|
+
if (!entry.element || typeof entry.element.getBoundingClientRect !== "function") return;
|
|
1830
|
+
const rect = entry.element.getBoundingClientRect();
|
|
1831
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
1832
|
+
|
|
1833
|
+
const markerFrame = document.createElement("div");
|
|
1834
|
+
markerFrame.setAttribute("data-context-drop-ui", "pinned-badge");
|
|
1835
|
+
markerFrame.style.cssText = [
|
|
1836
|
+
"position: fixed",
|
|
1837
|
+
"pointer-events: none",
|
|
1838
|
+
`left: ${rect.left}px`,
|
|
1839
|
+
`top: ${rect.top}px`,
|
|
1840
|
+
`width: ${rect.width}px`,
|
|
1841
|
+
`height: ${rect.height}px`,
|
|
1842
|
+
"border: 1.5px dashed rgba(194, 65, 12, 0.72)",
|
|
1843
|
+
"background: rgba(194, 65, 12, 0.04)",
|
|
1844
|
+
"border-radius: 6px"
|
|
1845
|
+
].join(";");
|
|
1846
|
+
|
|
1847
|
+
const badge = document.createElement("div");
|
|
1848
|
+
const badgeTop = rect.top < 26 ? "4px" : "-22px";
|
|
1849
|
+
badge.style.cssText = [
|
|
1850
|
+
"position: absolute",
|
|
1851
|
+
`top: ${badgeTop}`,
|
|
1852
|
+
"right: -1px",
|
|
1853
|
+
"display: inline-flex",
|
|
1854
|
+
"align-items: center",
|
|
1855
|
+
"gap: 4px",
|
|
1856
|
+
"padding: 2px 6px",
|
|
1857
|
+
"border-radius: 9999px",
|
|
1858
|
+
"background: #c2410c",
|
|
1859
|
+
"color: #faf9f6",
|
|
1860
|
+
"border: 1px solid #faf9f6",
|
|
1861
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1862
|
+
"font-size: 10px",
|
|
1863
|
+
"font-weight: 700",
|
|
1864
|
+
"font-variant-numeric: tabular-nums",
|
|
1865
|
+
"line-height: 1.2",
|
|
1866
|
+
"max-width: 160px",
|
|
1867
|
+
"overflow: hidden",
|
|
1868
|
+
"text-overflow: ellipsis",
|
|
1869
|
+
"white-space: nowrap",
|
|
1870
|
+
"box-shadow: 0 4px 10px -2px rgba(17, 19, 24, 0.25)"
|
|
1871
|
+
].join(";");
|
|
1872
|
+
badge.textContent = `#${index + 1} ${entry.selector}`;
|
|
1873
|
+
|
|
1874
|
+
markerFrame.appendChild(badge);
|
|
1875
|
+
this.pinnedMarkersContainerEl?.appendChild(markerFrame);
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1703
1879
|
showExternalPreview(el ) {
|
|
1704
1880
|
if (typeof document === "undefined" || !document.body) return;
|
|
1705
1881
|
if (!el || this.active) {
|
|
@@ -1743,20 +1919,58 @@
|
|
|
1743
1919
|
this.previewOverlayEl = null;
|
|
1744
1920
|
}
|
|
1745
1921
|
|
|
1746
|
-
cycleDepth(delta ) {
|
|
1922
|
+
cycleDepth(delta , revealStack = true) {
|
|
1747
1923
|
if (!this.active || this.candidateStack.length <= 1) return;
|
|
1924
|
+
|
|
1925
|
+
const wasScrubbing = this.isScrubbingLayers;
|
|
1926
|
+
if (revealStack) {
|
|
1927
|
+
this.isScrubbingLayers = true;
|
|
1928
|
+
this.scrubOriginX = this.lastPointerX;
|
|
1929
|
+
this.scrubOriginY = this.lastPointerY;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1748
1932
|
const next = Math.max(
|
|
1749
1933
|
0,
|
|
1750
1934
|
Math.min(this.candidateStack.length - 1, this.activeCandidateIndex + delta)
|
|
1751
1935
|
);
|
|
1936
|
+
|
|
1752
1937
|
if (next !== this.activeCandidateIndex) {
|
|
1753
1938
|
this.activeCandidateIndex = next;
|
|
1754
1939
|
this.updateOverlayPosition();
|
|
1755
|
-
if (this.anchored) {
|
|
1756
|
-
this.renderLayerPopover();
|
|
1757
|
-
}
|
|
1758
1940
|
this.notifyStateChange();
|
|
1941
|
+
} else if (!wasScrubbing && this.isScrubbingLayers) {
|
|
1942
|
+
this.updateOverlayPosition();
|
|
1943
|
+
this.triggerHudBoundaryNudge(delta < 0 ? -3 : 3);
|
|
1944
|
+
this.notifyStateChange();
|
|
1945
|
+
} else {
|
|
1946
|
+
this.triggerHudBoundaryNudge(delta < 0 ? -3 : 3);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
clearTimers() {
|
|
1951
|
+
if (this.pulseTimer !== null) {
|
|
1952
|
+
clearTimeout(this.pulseTimer);
|
|
1953
|
+
this.pulseTimer = null;
|
|
1954
|
+
}
|
|
1955
|
+
if (this.nudgeTimer !== null) {
|
|
1956
|
+
clearTimeout(this.nudgeTimer);
|
|
1957
|
+
this.nudgeTimer = null;
|
|
1958
|
+
}
|
|
1959
|
+
if (this.toastTimer !== null) {
|
|
1960
|
+
clearTimeout(this.toastTimer);
|
|
1961
|
+
this.toastTimer = null;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
findPinnedIndex(el ) {
|
|
1966
|
+
if (!this.callbacks.getPinnedElements) return null;
|
|
1967
|
+
const pinned = this.callbacks.getPinnedElements();
|
|
1968
|
+
for (let i = 0; i < pinned.length; i += 1) {
|
|
1969
|
+
if (pinned[i].element === el) {
|
|
1970
|
+
return { index: i, entry: pinned[i] };
|
|
1971
|
+
}
|
|
1759
1972
|
}
|
|
1973
|
+
return null;
|
|
1760
1974
|
}
|
|
1761
1975
|
|
|
1762
1976
|
notifyStateChange() {
|
|
@@ -1767,16 +1981,27 @@
|
|
|
1767
1981
|
: [];
|
|
1768
1982
|
this.callbacks.onStateChange({
|
|
1769
1983
|
active: this.active,
|
|
1770
|
-
anchored:
|
|
1984
|
+
anchored: false,
|
|
1985
|
+
scrubbing: this.isScrubbingLayers,
|
|
1771
1986
|
activeCandidate,
|
|
1772
1987
|
candidateStack: [...this.candidateStack],
|
|
1773
|
-
ancestors
|
|
1988
|
+
ancestors,
|
|
1989
|
+
lastAction: this.lastAction
|
|
1774
1990
|
});
|
|
1775
1991
|
}
|
|
1776
1992
|
|
|
1777
1993
|
mountSelectionUi() {
|
|
1778
1994
|
if (typeof document === "undefined" || !document.body) return;
|
|
1779
1995
|
|
|
1996
|
+
const pinnedMarkers = document.createElement("div");
|
|
1997
|
+
pinnedMarkers.setAttribute("data-context-drop-ui", "pinned-markers");
|
|
1998
|
+
pinnedMarkers.style.cssText = [
|
|
1999
|
+
"position: fixed",
|
|
2000
|
+
"inset: 0",
|
|
2001
|
+
"pointer-events: none",
|
|
2002
|
+
"z-index: 2147483643"
|
|
2003
|
+
].join(";");
|
|
2004
|
+
|
|
1780
2005
|
// Secondary ghost outline showing the innermost leaf element when cycling up to parent/overlapping layers
|
|
1781
2006
|
const leafOutline = document.createElement("div");
|
|
1782
2007
|
leafOutline.setAttribute("data-context-drop-ui", "leaf-outline");
|
|
@@ -1801,40 +2026,36 @@
|
|
|
1801
2026
|
"background: rgba(29, 78, 216, 0.10)",
|
|
1802
2027
|
"border-radius: 6px",
|
|
1803
2028
|
"display: none",
|
|
1804
|
-
"transition: left 0.06s cubic-bezier(0.22, 1, 0.36, 1), top 0.06s cubic-bezier(0.22, 1, 0.36, 1), width 0.06s cubic-bezier(0.22, 1, 0.36, 1), height 0.06s cubic-bezier(0.22, 1, 0.36, 1)"
|
|
2029
|
+
"transition: left 0.06s cubic-bezier(0.22, 1, 0.36, 1), top 0.06s cubic-bezier(0.22, 1, 0.36, 1), width 0.06s cubic-bezier(0.22, 1, 0.36, 1), height 0.06s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.16s ease, background-color 0.16s ease"
|
|
1805
2030
|
].join(";");
|
|
1806
2031
|
|
|
1807
|
-
// Floating HUD
|
|
1808
|
-
const
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
"position:
|
|
1812
|
-
"
|
|
1813
|
-
"left: -2px",
|
|
2032
|
+
// Viewport-clamped Floating HUD (Compact 2-line coach on hover, inline 5-row wheel-scrubbed stack on scroll)
|
|
2033
|
+
const hud = document.createElement("div");
|
|
2034
|
+
hud.setAttribute("data-context-drop-ui", "label");
|
|
2035
|
+
hud.style.cssText = [
|
|
2036
|
+
"position: fixed",
|
|
2037
|
+
"z-index: 2147483646",
|
|
1814
2038
|
"background: #111318",
|
|
1815
2039
|
"color: #faf9f6",
|
|
1816
|
-
"
|
|
1817
|
-
"
|
|
1818
|
-
"font-variant-numeric: tabular-nums",
|
|
1819
|
-
"line-height: 1.3",
|
|
1820
|
-
"padding: 4px 8px",
|
|
1821
|
-
"border-radius: 6px",
|
|
1822
|
-
"white-space: nowrap",
|
|
2040
|
+
"border: 1px solid rgba(250, 249, 246, 0.16)",
|
|
2041
|
+
"border-radius: 10px",
|
|
1823
2042
|
"pointer-events: none",
|
|
1824
|
-
"display:
|
|
1825
|
-
"
|
|
1826
|
-
"
|
|
1827
|
-
"
|
|
2043
|
+
"display: none",
|
|
2044
|
+
"overflow: hidden",
|
|
2045
|
+
"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
2046
|
+
"font-size: 11.5px",
|
|
2047
|
+
"line-height: 1.35",
|
|
2048
|
+
"box-shadow: 0 16px 34px -8px rgba(17, 19, 24, 0.40), 0 6px 14px -4px rgba(17, 19, 24, 0.22)",
|
|
2049
|
+
"transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1)"
|
|
1828
2050
|
].join(";");
|
|
1829
|
-
overlay.appendChild(label);
|
|
1830
2051
|
|
|
1831
|
-
// Floating Pin marker that follows the pointer
|
|
2052
|
+
// Floating Pin marker that follows the pointer
|
|
1832
2053
|
const pinMarker = document.createElement("div");
|
|
1833
2054
|
pinMarker.setAttribute("data-context-drop-ui", "pin-marker");
|
|
1834
2055
|
pinMarker.style.cssText = [
|
|
1835
2056
|
"position: fixed",
|
|
1836
2057
|
"pointer-events: none",
|
|
1837
|
-
"z-index:
|
|
2058
|
+
"z-index: 2147483647",
|
|
1838
2059
|
"width: 28px",
|
|
1839
2060
|
"height: 28px",
|
|
1840
2061
|
"margin-left: -6px",
|
|
@@ -1851,55 +2072,68 @@
|
|
|
1851
2072
|
].join(";");
|
|
1852
2073
|
pinMarker.innerHTML = ICON_PIN;
|
|
1853
2074
|
|
|
1854
|
-
//
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1857
|
-
|
|
2075
|
+
// Tactile floating confirmation pill near cursor on pin / unpin
|
|
2076
|
+
const toast = document.createElement("div");
|
|
2077
|
+
toast.setAttribute("data-context-drop-ui", "pin-toast");
|
|
2078
|
+
toast.style.cssText = [
|
|
1858
2079
|
"position: fixed",
|
|
2080
|
+
"pointer-events: none",
|
|
1859
2081
|
"z-index: 2147483647",
|
|
1860
|
-
"width: 348px",
|
|
1861
|
-
"max-width: calc(100vw - 24px)",
|
|
1862
|
-
"background: #faf9f6",
|
|
1863
|
-
"color: #111318",
|
|
1864
|
-
"border: 1px solid #d6d3cd",
|
|
1865
|
-
"border-radius: 12px",
|
|
1866
|
-
"box-shadow: 0 22px 44px -12px rgba(17, 19, 24, 0.26), 0 6px 14px -4px rgba(17, 19, 24, 0.10)",
|
|
1867
|
-
"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
1868
|
-
"font-size: 12px",
|
|
1869
2082
|
"display: none",
|
|
1870
|
-
"
|
|
1871
|
-
"
|
|
2083
|
+
"align-items: center",
|
|
2084
|
+
"gap: 6px",
|
|
2085
|
+
"padding: 6px 10px",
|
|
2086
|
+
"border-radius: 9999px",
|
|
2087
|
+
"background: #111318",
|
|
2088
|
+
"color: #faf9f6",
|
|
2089
|
+
"border: 1px solid rgba(250, 249, 246, 0.18)",
|
|
2090
|
+
"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
2091
|
+
"font-size: 11.5px",
|
|
2092
|
+
"font-weight: 500",
|
|
2093
|
+
"white-space: nowrap",
|
|
2094
|
+
"box-shadow: 0 12px 24px -6px rgba(17, 19, 24, 0.34)"
|
|
1872
2095
|
].join(";");
|
|
1873
2096
|
|
|
2097
|
+
document.body.appendChild(pinnedMarkers);
|
|
1874
2098
|
document.body.appendChild(leafOutline);
|
|
1875
2099
|
document.body.appendChild(overlay);
|
|
2100
|
+
document.body.appendChild(hud);
|
|
1876
2101
|
document.body.appendChild(pinMarker);
|
|
1877
|
-
document.body.appendChild(
|
|
2102
|
+
document.body.appendChild(toast);
|
|
1878
2103
|
|
|
2104
|
+
this.pinnedMarkersContainerEl = pinnedMarkers;
|
|
1879
2105
|
this.leafOutlineEl = leafOutline;
|
|
1880
2106
|
this.overlayEl = overlay;
|
|
1881
|
-
this.
|
|
2107
|
+
this.hudEl = hud;
|
|
1882
2108
|
this.pinMarkerEl = pinMarker;
|
|
1883
|
-
this.
|
|
2109
|
+
this.toastEl = toast;
|
|
1884
2110
|
}
|
|
1885
2111
|
|
|
1886
2112
|
unmountSelectionUi() {
|
|
1887
|
-
for (const el of [
|
|
2113
|
+
for (const el of [
|
|
2114
|
+
this.pinnedMarkersContainerEl,
|
|
2115
|
+
this.leafOutlineEl,
|
|
2116
|
+
this.overlayEl,
|
|
2117
|
+
this.hudEl,
|
|
2118
|
+
this.pinMarkerEl,
|
|
2119
|
+
this.toastEl
|
|
2120
|
+
]) {
|
|
1888
2121
|
if (el && el.parentNode) {
|
|
1889
2122
|
el.parentNode.removeChild(el);
|
|
1890
2123
|
}
|
|
1891
2124
|
}
|
|
2125
|
+
this.pinnedMarkersContainerEl = null;
|
|
1892
2126
|
this.leafOutlineEl = null;
|
|
1893
2127
|
this.overlayEl = null;
|
|
1894
|
-
this.
|
|
2128
|
+
this.hudEl = null;
|
|
1895
2129
|
this.pinMarkerEl = null;
|
|
1896
|
-
this.
|
|
2130
|
+
this.toastEl = null;
|
|
1897
2131
|
}
|
|
1898
2132
|
|
|
1899
2133
|
isInternalUiEvent(event ) {
|
|
1900
2134
|
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
1901
2135
|
for (const node of path) {
|
|
1902
|
-
if (node
|
|
2136
|
+
if (isDomElementNode(node)) {
|
|
1903
2137
|
if (
|
|
1904
2138
|
node.tagName.toLowerCase() === "context-drop-widget" ||
|
|
1905
2139
|
node.hasAttribute("data-context-drop-ui") ||
|
|
@@ -1910,7 +2144,7 @@
|
|
|
1910
2144
|
}
|
|
1911
2145
|
}
|
|
1912
2146
|
}
|
|
1913
|
-
const rawTarget = event.target
|
|
2147
|
+
const rawTarget = isDomElementNode(event.target) ? event.target : null;
|
|
1914
2148
|
if (
|
|
1915
2149
|
rawTarget &&
|
|
1916
2150
|
typeof rawTarget.closest === "function" &&
|
|
@@ -1927,7 +2161,7 @@
|
|
|
1927
2161
|
try {
|
|
1928
2162
|
const fromPoint = document.elementsFromPoint(clientX, clientY);
|
|
1929
2163
|
for (const el of fromPoint) {
|
|
1930
|
-
if (el
|
|
2164
|
+
if (isDomElementNode(el)) {
|
|
1931
2165
|
results.push(el);
|
|
1932
2166
|
}
|
|
1933
2167
|
}
|
|
@@ -1937,12 +2171,12 @@
|
|
|
1937
2171
|
}
|
|
1938
2172
|
if (event && typeof event.composedPath === "function") {
|
|
1939
2173
|
for (const node of event.composedPath()) {
|
|
1940
|
-
if (node
|
|
2174
|
+
if (isDomElementNode(node) && !results.includes(node)) {
|
|
1941
2175
|
results.push(node);
|
|
1942
2176
|
}
|
|
1943
2177
|
}
|
|
1944
2178
|
}
|
|
1945
|
-
if (event && event.target
|
|
2179
|
+
if (event && isDomElementNode(event.target) && !results.includes(event.target)) {
|
|
1946
2180
|
results.unshift(event.target);
|
|
1947
2181
|
}
|
|
1948
2182
|
return results;
|
|
@@ -1957,17 +2191,39 @@
|
|
|
1957
2191
|
this.leafElement = null;
|
|
1958
2192
|
this.candidateStack = [];
|
|
1959
2193
|
this.activeCandidateIndex = 0;
|
|
2194
|
+
this.isScrubbingLayers = false;
|
|
1960
2195
|
return;
|
|
1961
2196
|
}
|
|
1962
2197
|
|
|
1963
|
-
// Preserve depth
|
|
2198
|
+
// Preserve depth & inline stack when pointer stays inside the exact same primary leaf element
|
|
1964
2199
|
if (this.leafElement === primary && this.candidateStack.length > 0) {
|
|
1965
2200
|
return;
|
|
1966
2201
|
}
|
|
1967
2202
|
|
|
2203
|
+
// Pointer-jitter lock: if user scrubbed to a specific layer and nudges the mouse slightly (<=28px)
|
|
2204
|
+
// across child boundaries inside that selected element right before clicking, keep it locked.
|
|
2205
|
+
if (this.isScrubbingLayers && this.candidateStack.length > 0) {
|
|
2206
|
+
const lockedCandidate = this.getActiveCandidate();
|
|
2207
|
+
const travel = Math.hypot(clientX - this.scrubOriginX, clientY - this.scrubOriginY);
|
|
2208
|
+
if (
|
|
2209
|
+
lockedCandidate &&
|
|
2210
|
+
travel <= SCRUB_JITTER_LOCK_PX &&
|
|
2211
|
+
(pointElements.includes(lockedCandidate.element) ||
|
|
2212
|
+
isPointInsideRect(clientX, clientY, lockedCandidate.element.getBoundingClientRect()))
|
|
2213
|
+
) {
|
|
2214
|
+
return;
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
|
|
1968
2218
|
this.leafElement = primary;
|
|
1969
2219
|
this.candidateStack = resolveCandidateStack(primary, pointElements, excluded, 10);
|
|
1970
2220
|
this.activeCandidateIndex = 0;
|
|
2221
|
+
this.isScrubbingLayers = false;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
handleViewportScrollOrResize() {
|
|
2225
|
+
this.refreshPinnedMarkers();
|
|
2226
|
+
this.updateOverlayPosition();
|
|
1971
2227
|
}
|
|
1972
2228
|
|
|
1973
2229
|
handleMouseMove(event ) {
|
|
@@ -1976,12 +2232,9 @@
|
|
|
1976
2232
|
this.lastPointerX = event.clientX;
|
|
1977
2233
|
this.lastPointerY = event.clientY;
|
|
1978
2234
|
|
|
1979
|
-
if (this.anchored) {
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
2235
|
if (this.isInternalUiEvent(event)) {
|
|
1984
2236
|
if (this.overlayEl) this.overlayEl.style.display = "none";
|
|
2237
|
+
if (this.hudEl) this.hudEl.style.display = "none";
|
|
1985
2238
|
if (this.leafOutlineEl) this.leafOutlineEl.style.display = "none";
|
|
1986
2239
|
if (this.pinMarkerEl) this.pinMarkerEl.style.display = "none";
|
|
1987
2240
|
return;
|
|
@@ -1998,484 +2251,718 @@
|
|
|
1998
2251
|
this.notifyStateChange();
|
|
1999
2252
|
}
|
|
2000
2253
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
this.overlayEl.style.display = "none";
|
|
2007
|
-
if (this.leafOutlineEl) this.leafOutlineEl.style.display = "none";
|
|
2008
|
-
return;
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
const rect = currentCandidate.element.getBoundingClientRect();
|
|
2012
|
-
if (rect.width <= 0 || rect.height <= 0) {
|
|
2013
|
-
this.overlayEl.style.display = "none";
|
|
2014
|
-
return;
|
|
2015
|
-
}
|
|
2254
|
+
createSpanEl(text ) {
|
|
2255
|
+
const span = document.createElement("span");
|
|
2256
|
+
span.textContent = text;
|
|
2257
|
+
return span;
|
|
2258
|
+
}
|
|
2016
2259
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2260
|
+
createKbdEl(text ) {
|
|
2261
|
+
const kbd = document.createElement("kbd");
|
|
2262
|
+
kbd.textContent = text;
|
|
2263
|
+
kbd.style.cssText = [
|
|
2264
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2265
|
+
"font-size: 10px",
|
|
2266
|
+
"font-weight: 600",
|
|
2267
|
+
"line-height: 1.1",
|
|
2268
|
+
"padding: 1px 4px",
|
|
2269
|
+
"border-radius: 4px",
|
|
2270
|
+
"background: rgba(250, 249, 246, 0.14)",
|
|
2271
|
+
"border: 1px solid rgba(250, 249, 246, 0.24)",
|
|
2272
|
+
"color: #faf9f6"
|
|
2273
|
+
].join(";");
|
|
2274
|
+
return kbd;
|
|
2275
|
+
}
|
|
2022
2276
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2277
|
+
renderCompactHudContent(
|
|
2278
|
+
currentCandidate ,
|
|
2279
|
+
rect
|
|
2280
|
+
) {
|
|
2281
|
+
if (!this.hudEl) return;
|
|
2282
|
+
this.hudEl.innerHTML = "";
|
|
2283
|
+
this.hudEl.style.width = "auto";
|
|
2284
|
+
this.hudEl.style.maxWidth = "min(440px, calc(100vw - 20px))";
|
|
2031
2285
|
|
|
2032
2286
|
const total = this.candidateStack.length;
|
|
2033
2287
|
const pos = this.activeCandidateIndex + 1;
|
|
2034
2288
|
const dims = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
// Show ghost leaf outline when inspecting an ancestor or overlapping layer
|
|
2039
|
-
if (this.leafOutlineEl) {
|
|
2040
|
-
if (this.activeCandidateIndex > 0 && this.leafElement && this.leafElement !== currentCandidate.element) {
|
|
2041
|
-
const leafRect = this.leafElement.getBoundingClientRect();
|
|
2042
|
-
this.leafOutlineEl.style.display = "block";
|
|
2043
|
-
this.leafOutlineEl.style.left = `${leafRect.left}px`;
|
|
2044
|
-
this.leafOutlineEl.style.top = `${leafRect.top}px`;
|
|
2045
|
-
this.leafOutlineEl.style.width = `${leafRect.width}px`;
|
|
2046
|
-
this.leafOutlineEl.style.height = `${leafRect.height}px`;
|
|
2047
|
-
} else {
|
|
2048
|
-
this.leafOutlineEl.style.display = "none";
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2289
|
+
const pinnedInfo = this.findPinnedIndex(currentCandidate.element);
|
|
2290
|
+
const hasOverlap = this.candidateStack.some((c) => c.relation === "overlap");
|
|
2052
2291
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2292
|
+
// Top Row: Identity + Dimensions + Layer Count
|
|
2293
|
+
const topRow = document.createElement("div");
|
|
2294
|
+
topRow.style.cssText = [
|
|
2295
|
+
"display: flex",
|
|
2296
|
+
"align-items: center",
|
|
2297
|
+
"gap: 6px",
|
|
2298
|
+
"padding: 6px 9px 5px",
|
|
2299
|
+
"white-space: nowrap"
|
|
2300
|
+
].join(";");
|
|
2055
2301
|
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2302
|
+
if (pinnedInfo) {
|
|
2303
|
+
const pinnedPill = document.createElement("span");
|
|
2304
|
+
pinnedPill.textContent = `#${pinnedInfo.index + 1} Pinned`;
|
|
2305
|
+
pinnedPill.style.cssText = [
|
|
2306
|
+
"padding: 1px 5px",
|
|
2307
|
+
"border-radius: 4px",
|
|
2308
|
+
"background: #c2410c",
|
|
2309
|
+
"color: #faf9f6",
|
|
2310
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2311
|
+
"font-size: 10px",
|
|
2312
|
+
"font-weight: 700",
|
|
2313
|
+
"font-variant-numeric: tabular-nums",
|
|
2314
|
+
"flex-shrink: 0"
|
|
2315
|
+
].join(";");
|
|
2316
|
+
topRow.appendChild(pinnedPill);
|
|
2059
2317
|
}
|
|
2060
2318
|
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2319
|
+
const selectorSpan = document.createElement("span");
|
|
2320
|
+
selectorSpan.textContent = formatCandidateLabel(
|
|
2321
|
+
currentCandidate.tagName,
|
|
2322
|
+
currentCandidate.selector
|
|
2323
|
+
);
|
|
2324
|
+
selectorSpan.style.cssText = [
|
|
2325
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2326
|
+
"font-size: 11.5px",
|
|
2327
|
+
"font-weight: 600",
|
|
2328
|
+
"color: #faf9f6",
|
|
2329
|
+
"max-width: 230px",
|
|
2330
|
+
"overflow: hidden",
|
|
2331
|
+
"text-overflow: ellipsis",
|
|
2332
|
+
"white-space: nowrap"
|
|
2333
|
+
].join(";");
|
|
2334
|
+
topRow.appendChild(selectorSpan);
|
|
2064
2335
|
|
|
2065
|
-
|
|
2066
|
-
|
|
2336
|
+
const dimsSpan = document.createElement("span");
|
|
2337
|
+
dimsSpan.textContent = dims;
|
|
2338
|
+
dimsSpan.style.cssText = [
|
|
2339
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2340
|
+
"font-size: 10.5px",
|
|
2341
|
+
"font-variant-numeric: tabular-nums",
|
|
2342
|
+
"color: #cbd5e1",
|
|
2343
|
+
"flex-shrink: 0"
|
|
2344
|
+
].join(";");
|
|
2345
|
+
topRow.appendChild(dimsSpan);
|
|
2067
2346
|
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2347
|
+
if (total > 1) {
|
|
2348
|
+
const layerPill = document.createElement("span");
|
|
2349
|
+
layerPill.style.cssText = [
|
|
2350
|
+
"display: inline-flex",
|
|
2351
|
+
"align-items: center",
|
|
2352
|
+
"gap: 3px",
|
|
2353
|
+
"padding: 1px 6px",
|
|
2354
|
+
"border-radius: 9999px",
|
|
2355
|
+
"background: rgba(29, 78, 216, 0.36)",
|
|
2356
|
+
"border: 1px solid rgba(96, 165, 250, 0.45)",
|
|
2357
|
+
"color: #dbeafe",
|
|
2358
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2359
|
+
"font-size: 10px",
|
|
2360
|
+
"font-weight: 600",
|
|
2361
|
+
"font-variant-numeric: tabular-nums",
|
|
2362
|
+
"flex-shrink: 0"
|
|
2363
|
+
].join(";");
|
|
2364
|
+
const iconWrap = document.createElement("span");
|
|
2365
|
+
iconWrap.style.cssText = "display: inline-flex; width: 11px; height: 11px; align-items: center;";
|
|
2366
|
+
iconWrap.innerHTML = ICON_LAYERS;
|
|
2367
|
+
const countText = document.createElement("span");
|
|
2368
|
+
countText.textContent = `${pos}/${total}`;
|
|
2369
|
+
layerPill.appendChild(iconWrap);
|
|
2370
|
+
layerPill.appendChild(countText);
|
|
2371
|
+
topRow.appendChild(layerPill);
|
|
2073
2372
|
}
|
|
2074
|
-
}
|
|
2075
2373
|
|
|
2076
|
-
|
|
2077
|
-
if (!this.active) return;
|
|
2078
|
-
if (this.isInternalUiEvent(event)) {
|
|
2079
|
-
return;
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
// Intercept host page pointer events in capture phase so links/buttons do not fire
|
|
2083
|
-
event.preventDefault();
|
|
2084
|
-
event.stopPropagation();
|
|
2085
|
-
if (typeof event.stopImmediatePropagation === "function") {
|
|
2086
|
-
event.stopImmediatePropagation();
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
handleClickCapture(event ) {
|
|
2091
|
-
if (!this.active) return;
|
|
2092
|
-
if (this.isInternalUiEvent(event)) {
|
|
2093
|
-
return;
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
event.preventDefault();
|
|
2097
|
-
event.stopPropagation();
|
|
2098
|
-
if (typeof event.stopImmediatePropagation === "function") {
|
|
2099
|
-
event.stopImmediatePropagation();
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
// If popover was already anchored and user clicked elsewhere on the page, re-evaluate at the new click point
|
|
2103
|
-
this.anchorX = event.clientX;
|
|
2104
|
-
this.anchorY = event.clientY;
|
|
2105
|
-
this.updateCandidatesFromPoint(event.clientX, event.clientY, event);
|
|
2374
|
+
this.hudEl.appendChild(topRow);
|
|
2106
2375
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2376
|
+
// Bottom Row: Action Coaching Strip
|
|
2377
|
+
const coachRow = document.createElement("div");
|
|
2378
|
+
coachRow.style.cssText = [
|
|
2379
|
+
"display: flex",
|
|
2380
|
+
"align-items: center",
|
|
2381
|
+
"gap: 8px",
|
|
2382
|
+
"padding: 4px 9px 5px",
|
|
2383
|
+
"background: rgba(250, 249, 246, 0.05)",
|
|
2384
|
+
"border-top: 1px solid rgba(250, 249, 246, 0.10)",
|
|
2385
|
+
"font-size: 10.5px",
|
|
2386
|
+
"color: #cbd5e1",
|
|
2387
|
+
"white-space: nowrap"
|
|
2388
|
+
].join(";");
|
|
2109
2389
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2390
|
+
const clickHint = document.createElement("span");
|
|
2391
|
+
clickHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2392
|
+
clickHint.appendChild(this.createKbdEl("Space"));
|
|
2393
|
+
clickHint.appendChild(this.createSpanEl("or"));
|
|
2394
|
+
const clickStrong = document.createElement("strong");
|
|
2395
|
+
clickStrong.style.cssText = pinnedInfo
|
|
2396
|
+
? "color: #ffedd5; font-weight: 600;"
|
|
2397
|
+
: "color: #faf9f6; font-weight: 600;";
|
|
2398
|
+
clickStrong.textContent = "Click";
|
|
2399
|
+
clickHint.appendChild(clickStrong);
|
|
2400
|
+
clickHint.appendChild(this.createSpanEl(pinnedInfo ? " to unpin" : " to pin"));
|
|
2401
|
+
coachRow.appendChild(clickHint);
|
|
2402
|
+
|
|
2403
|
+
if (total > 1) {
|
|
2404
|
+
const scrollHint = document.createElement("span");
|
|
2405
|
+
scrollHint.style.cssText = "display: inline-flex; align-items: center; gap: 3px;";
|
|
2406
|
+
const wheelIcon = document.createElement("span");
|
|
2407
|
+
wheelIcon.style.cssText = "display: inline-flex; color: #dbeafe;";
|
|
2408
|
+
wheelIcon.innerHTML = ICON_SCROLL_VERTICAL;
|
|
2409
|
+
const scrollStrong = document.createElement("strong");
|
|
2410
|
+
scrollStrong.style.cssText = hasOverlap
|
|
2411
|
+
? "color: #dbeafe; font-weight: 600;"
|
|
2412
|
+
: "color: #faf9f6; font-weight: 600;";
|
|
2413
|
+
scrollStrong.textContent = "Scroll wheel";
|
|
2414
|
+
scrollHint.appendChild(wheelIcon);
|
|
2415
|
+
scrollHint.appendChild(scrollStrong);
|
|
2416
|
+
scrollHint.appendChild(
|
|
2417
|
+
this.createSpanEl(hasOverlap ? " for element behind" : ` for ${total} layers`)
|
|
2418
|
+
);
|
|
2419
|
+
coachRow.appendChild(scrollHint);
|
|
2114
2420
|
}
|
|
2115
2421
|
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
}
|
|
2124
|
-
this.updateOverlayPosition();
|
|
2125
|
-
this.renderLayerPopover();
|
|
2126
|
-
this.notifyStateChange();
|
|
2127
|
-
}
|
|
2422
|
+
const escHint = document.createElement("span");
|
|
2423
|
+
escHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2424
|
+
escHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
2425
|
+
escHint.appendChild(this.createSpanEl("freeze · "));
|
|
2426
|
+
escHint.appendChild(this.createKbdEl("Esc"));
|
|
2427
|
+
escHint.appendChild(this.createSpanEl("done"));
|
|
2428
|
+
coachRow.appendChild(escHint);
|
|
2128
2429
|
|
|
2129
|
-
|
|
2130
|
-
this.anchored = false;
|
|
2131
|
-
if (this.popoverEl) {
|
|
2132
|
-
this.popoverEl.style.display = "none";
|
|
2133
|
-
this.popoverEl.innerHTML = "";
|
|
2134
|
-
}
|
|
2135
|
-
if (this.pinMarkerEl) {
|
|
2136
|
-
this.pinMarkerEl.style.transform = "scale(1)";
|
|
2137
|
-
this.pinMarkerEl.style.left = `${this.lastPointerX}px`;
|
|
2138
|
-
this.pinMarkerEl.style.top = `${this.lastPointerY}px`;
|
|
2139
|
-
}
|
|
2140
|
-
this.notifyStateChange();
|
|
2430
|
+
this.hudEl.appendChild(coachRow);
|
|
2141
2431
|
}
|
|
2142
2432
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2433
|
+
renderScrubbingHudContent(
|
|
2434
|
+
currentCandidate ,
|
|
2435
|
+
rect
|
|
2436
|
+
) {
|
|
2437
|
+
if (!this.hudEl) return;
|
|
2438
|
+
this.hudEl.innerHTML = "";
|
|
2439
|
+
this.hudEl.style.width = "320px";
|
|
2440
|
+
this.hudEl.style.maxWidth = "calc(100vw - 20px)";
|
|
2147
2441
|
|
|
2148
|
-
this.
|
|
2149
|
-
this.
|
|
2442
|
+
const total = this.candidateStack.length;
|
|
2443
|
+
const pos = this.activeCandidateIndex + 1;
|
|
2150
2444
|
|
|
2151
|
-
// Header
|
|
2445
|
+
// Header Strip
|
|
2152
2446
|
const header = document.createElement("div");
|
|
2153
2447
|
header.style.cssText = [
|
|
2154
2448
|
"display: flex",
|
|
2155
2449
|
"align-items: center",
|
|
2156
2450
|
"justify-content: space-between",
|
|
2157
2451
|
"gap: 8px",
|
|
2158
|
-
"padding: 10px
|
|
2159
|
-
"background:
|
|
2160
|
-
"border-bottom: 1px solid
|
|
2161
|
-
].join(";");
|
|
2162
|
-
|
|
2163
|
-
const titleGroup = document.createElement("div");
|
|
2164
|
-
titleGroup.style.cssText = "display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; color: #111318;";
|
|
2165
|
-
const layersIconSpan = document.createElement("span");
|
|
2166
|
-
layersIconSpan.style.cssText = "display: inline-flex; color: #c2410c;";
|
|
2167
|
-
layersIconSpan.innerHTML = ICON_LAYERS;
|
|
2168
|
-
const titleText = document.createElement("span");
|
|
2169
|
-
titleText.textContent = `Choose Element Layer (${this.candidateStack.length})`;
|
|
2170
|
-
titleGroup.appendChild(layersIconSpan);
|
|
2171
|
-
titleGroup.appendChild(titleText);
|
|
2172
|
-
|
|
2173
|
-
const headerActions = document.createElement("div");
|
|
2174
|
-
headerActions.style.cssText = "display: flex; align-items: center; gap: 4px;";
|
|
2175
|
-
|
|
2176
|
-
const stepUpBtn = document.createElement("button");
|
|
2177
|
-
stepUpBtn.type = "button";
|
|
2178
|
-
stepUpBtn.title = "Step to parent/outer layer (Up arrow)";
|
|
2179
|
-
stepUpBtn.setAttribute("aria-label", "Step to outer layer");
|
|
2180
|
-
stepUpBtn.style.cssText = [
|
|
2181
|
-
"display: inline-flex",
|
|
2182
|
-
"align-items: center",
|
|
2183
|
-
"justify-content: center",
|
|
2184
|
-
"width: 24px",
|
|
2185
|
-
"height: 24px",
|
|
2186
|
-
"border-radius: 6px",
|
|
2187
|
-
"border: 1px solid #d6d3cd",
|
|
2188
|
-
"background: #faf9f6",
|
|
2189
|
-
"color: #111318",
|
|
2190
|
-
"cursor: pointer"
|
|
2452
|
+
"padding: 6px 10px",
|
|
2453
|
+
"background: rgba(250, 249, 246, 0.05)",
|
|
2454
|
+
"border-bottom: 1px solid rgba(250, 249, 246, 0.12)"
|
|
2191
2455
|
].join(";");
|
|
2192
|
-
stepUpBtn.innerHTML = ICON_CHEVRON_UP;
|
|
2193
|
-
stepUpBtn.disabled = this.activeCandidateIndex >= this.candidateStack.length - 1;
|
|
2194
|
-
stepUpBtn.addEventListener("click", (ev) => {
|
|
2195
|
-
ev.stopPropagation();
|
|
2196
|
-
this.cycleDepth(1);
|
|
2197
|
-
});
|
|
2198
|
-
|
|
2199
|
-
const stepDownBtn = document.createElement("button");
|
|
2200
|
-
stepDownBtn.type = "button";
|
|
2201
|
-
stepDownBtn.title = "Step to inner/child layer (Down arrow)";
|
|
2202
|
-
stepDownBtn.setAttribute("aria-label", "Step to inner layer");
|
|
2203
|
-
stepDownBtn.style.cssText = stepUpBtn.style.cssText;
|
|
2204
|
-
stepDownBtn.innerHTML = ICON_CHEVRON_DOWN;
|
|
2205
|
-
stepDownBtn.disabled = this.activeCandidateIndex <= 0;
|
|
2206
|
-
stepDownBtn.addEventListener("click", (ev) => {
|
|
2207
|
-
ev.stopPropagation();
|
|
2208
|
-
this.cycleDepth(-1);
|
|
2209
|
-
});
|
|
2210
|
-
|
|
2211
|
-
const closeBtn = document.createElement("button");
|
|
2212
|
-
closeBtn.type = "button";
|
|
2213
|
-
closeBtn.title = "Resume hover selection (Esc)";
|
|
2214
|
-
closeBtn.setAttribute("aria-label", "Close layer picker");
|
|
2215
|
-
closeBtn.style.cssText = [
|
|
2216
|
-
"display: inline-flex",
|
|
2217
|
-
"align-items: center",
|
|
2218
|
-
"justify-content: center",
|
|
2219
|
-
"width: 24px",
|
|
2220
|
-
"height: 24px",
|
|
2221
|
-
"border-radius: 6px",
|
|
2222
|
-
"border: 0",
|
|
2223
|
-
"background: transparent",
|
|
2224
|
-
"color: #4b5262",
|
|
2225
|
-
"cursor: pointer"
|
|
2226
|
-
].join(";");
|
|
2227
|
-
closeBtn.innerHTML = ICON_CLOSE;
|
|
2228
|
-
closeBtn.addEventListener("click", (ev) => {
|
|
2229
|
-
ev.stopPropagation();
|
|
2230
|
-
this.closeLayerPopover();
|
|
2231
|
-
});
|
|
2232
2456
|
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
"padding: 7px 12px",
|
|
2255
|
-
"background: #f5f3ee",
|
|
2256
|
-
"border-bottom: 1px solid #e4e1da",
|
|
2257
|
-
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2258
|
-
"font-size: 11px"
|
|
2259
|
-
].join(";");
|
|
2260
|
-
|
|
2261
|
-
ancestors.forEach((ancEl, idx) => {
|
|
2262
|
-
if (idx > 0) {
|
|
2263
|
-
const sep = document.createElement("span");
|
|
2264
|
-
sep.style.cssText = "display: inline-flex; color: #687082;";
|
|
2265
|
-
sep.innerHTML = ICON_CHEVRON_RIGHT;
|
|
2266
|
-
breadcrumbBar.appendChild(sep);
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
const isCurrent = ancEl === activeCandidate.element;
|
|
2270
|
-
const crumbBtn = document.createElement("button");
|
|
2271
|
-
crumbBtn.type = "button";
|
|
2272
|
-
crumbBtn.textContent = computeSelector(ancEl);
|
|
2273
|
-
crumbBtn.style.cssText = [
|
|
2274
|
-
"appearance: none",
|
|
2275
|
-
"border: 1px solid " + (isCurrent ? "#1d4ed8" : "transparent"),
|
|
2276
|
-
"background: " + (isCurrent ? "#dbeafe" : "transparent"),
|
|
2277
|
-
"color: " + (isCurrent ? "#1e3a8a" : "#4b5262"),
|
|
2278
|
-
"font-family: inherit",
|
|
2279
|
-
"font-size: 11px",
|
|
2280
|
-
"font-weight: " + (isCurrent ? "600" : "500"),
|
|
2281
|
-
"padding: 2px 5px",
|
|
2282
|
-
"border-radius: 4px",
|
|
2283
|
-
"cursor: pointer",
|
|
2284
|
-
"max-width: 130px",
|
|
2285
|
-
"overflow: hidden",
|
|
2286
|
-
"text-overflow: ellipsis",
|
|
2287
|
-
"white-space: nowrap"
|
|
2288
|
-
].join(";");
|
|
2289
|
-
|
|
2290
|
-
crumbBtn.addEventListener("mouseenter", () => {
|
|
2291
|
-
this.focusCandidateElement(ancEl);
|
|
2292
|
-
});
|
|
2293
|
-
crumbBtn.addEventListener("click", (ev) => {
|
|
2294
|
-
ev.stopPropagation();
|
|
2295
|
-
this.selectElementDirectly(ancEl);
|
|
2296
|
-
});
|
|
2297
|
-
|
|
2298
|
-
breadcrumbBar.appendChild(crumbBtn);
|
|
2299
|
-
});
|
|
2300
|
-
|
|
2301
|
-
this.popoverEl.appendChild(breadcrumbBar);
|
|
2302
|
-
}
|
|
2457
|
+
const headerLeft = document.createElement("div");
|
|
2458
|
+
headerLeft.style.cssText =
|
|
2459
|
+
"display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: #faf9f6;";
|
|
2460
|
+
const layersIcon = document.createElement("span");
|
|
2461
|
+
layersIcon.style.cssText = "display: inline-flex; color: #60a5fa;";
|
|
2462
|
+
layersIcon.innerHTML = ICON_LAYERS;
|
|
2463
|
+
const headerTitle = document.createElement("span");
|
|
2464
|
+
headerTitle.textContent = "Select Layer";
|
|
2465
|
+
headerLeft.appendChild(layersIcon);
|
|
2466
|
+
headerLeft.appendChild(headerTitle);
|
|
2467
|
+
|
|
2468
|
+
const headerRight = document.createElement("div");
|
|
2469
|
+
headerRight.style.cssText =
|
|
2470
|
+
"display: inline-flex; align-items: center; gap: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; font-variant-numeric: tabular-nums; color: #cbd5e1;";
|
|
2471
|
+
const wheelSpan = document.createElement("span");
|
|
2472
|
+
wheelSpan.style.cssText = "display: inline-flex; color: #dbeafe;";
|
|
2473
|
+
wheelSpan.innerHTML = ICON_SCROLL_VERTICAL;
|
|
2474
|
+
const ratioSpan = document.createElement("span");
|
|
2475
|
+
ratioSpan.textContent = `${pos}/${total}`;
|
|
2476
|
+
headerRight.appendChild(wheelSpan);
|
|
2477
|
+
headerRight.appendChild(ratioSpan);
|
|
2303
2478
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2479
|
+
header.appendChild(headerLeft);
|
|
2480
|
+
header.appendChild(headerRight);
|
|
2481
|
+
this.hudEl.appendChild(header);
|
|
2482
|
+
|
|
2483
|
+
// Non-scrolling Sliding Window of Layers (max 5 rows)
|
|
2484
|
+
const start =
|
|
2485
|
+
total <= MAX_VISIBLE_STACK_ROWS
|
|
2486
|
+
? 0
|
|
2487
|
+
: Math.max(0, Math.min(this.activeCandidateIndex - 2, total - MAX_VISIBLE_STACK_ROWS));
|
|
2488
|
+
const end = Math.min(total, start + MAX_VISIBLE_STACK_ROWS);
|
|
2489
|
+
|
|
2490
|
+
const listWrap = document.createElement("div");
|
|
2491
|
+
listWrap.setAttribute("data-context-drop-ui", "hud-layer-list");
|
|
2492
|
+
listWrap.style.cssText = [
|
|
2310
2493
|
"display: flex",
|
|
2311
2494
|
"flex-direction: column",
|
|
2312
|
-
"gap:
|
|
2495
|
+
"gap: 2px",
|
|
2496
|
+
"padding: 5px"
|
|
2313
2497
|
].join(";");
|
|
2314
2498
|
|
|
2499
|
+
if (start > 0) {
|
|
2500
|
+
const aboveHint = document.createElement("div");
|
|
2501
|
+
aboveHint.textContent = `${start} inner layer${start > 1 ? "s" : ""} above`;
|
|
2502
|
+
aboveHint.style.cssText =
|
|
2503
|
+
"font-size: 10px; color: #cbd5e1; padding: 1px 7px; font-variant-numeric: tabular-nums;";
|
|
2504
|
+
listWrap.appendChild(aboveHint);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2315
2507
|
const relationLabels = {
|
|
2316
2508
|
target: "Topmost",
|
|
2317
|
-
overlap: "
|
|
2509
|
+
overlap: "Behind",
|
|
2318
2510
|
child: "Child",
|
|
2319
2511
|
ancestor: "Parent"
|
|
2320
2512
|
};
|
|
2321
2513
|
|
|
2322
|
-
|
|
2514
|
+
for (let idx = start; idx < end; idx += 1) {
|
|
2515
|
+
const candidate = this.candidateStack[idx];
|
|
2323
2516
|
const isSelected = idx === this.activeCandidateIndex;
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2517
|
+
const candPinned = this.findPinnedIndex(candidate.element);
|
|
2518
|
+
|
|
2519
|
+
const row = document.createElement("div");
|
|
2326
2520
|
row.setAttribute("data-context-drop-layer-index", String(idx));
|
|
2521
|
+
if (isSelected) {
|
|
2522
|
+
row.setAttribute("data-selected", "true");
|
|
2523
|
+
}
|
|
2327
2524
|
row.style.cssText = [
|
|
2328
|
-
"appearance: none",
|
|
2329
|
-
"width: 100%",
|
|
2330
|
-
"text-align: left",
|
|
2331
2525
|
"display: flex",
|
|
2332
|
-
"
|
|
2333
|
-
"
|
|
2334
|
-
"
|
|
2335
|
-
"
|
|
2336
|
-
"border:
|
|
2337
|
-
"
|
|
2338
|
-
"
|
|
2339
|
-
"cursor: pointer",
|
|
2340
|
-
"transition: background-color 0.1s ease"
|
|
2526
|
+
"align-items: center",
|
|
2527
|
+
"justify-content: space-between",
|
|
2528
|
+
"gap: 6px",
|
|
2529
|
+
"padding: " + (isSelected ? "5px 7px" : "4px 7px"),
|
|
2530
|
+
"border-radius: 7px",
|
|
2531
|
+
"border: 1px solid " + (isSelected ? "#60a5fa" : "transparent"),
|
|
2532
|
+
"background: " + (isSelected ? "rgba(29, 78, 216, 0.34)" : "transparent")
|
|
2341
2533
|
].join(";");
|
|
2342
2534
|
|
|
2343
|
-
const topLine = document.createElement("div");
|
|
2344
|
-
topLine.style.cssText = "display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;";
|
|
2345
|
-
|
|
2346
2535
|
const leftGroup = document.createElement("div");
|
|
2347
|
-
leftGroup.style.cssText = "display: flex; align-items: center; gap:
|
|
2536
|
+
leftGroup.style.cssText = "display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1;";
|
|
2348
2537
|
|
|
2349
2538
|
const relBadge = document.createElement("span");
|
|
2350
2539
|
relBadge.textContent = relationLabels[candidate.relation] || "Layer";
|
|
2540
|
+
const relBg =
|
|
2541
|
+
candidate.relation === "target"
|
|
2542
|
+
? "rgba(255, 237, 213, 0.16)"
|
|
2543
|
+
: candidate.relation === "overlap"
|
|
2544
|
+
? "rgba(252, 231, 243, 0.20)"
|
|
2545
|
+
: "rgba(226, 232, 240, 0.14)";
|
|
2546
|
+
const relColor =
|
|
2547
|
+
candidate.relation === "target"
|
|
2548
|
+
? "#ffedd5"
|
|
2549
|
+
: candidate.relation === "overlap"
|
|
2550
|
+
? "#fee2e2"
|
|
2551
|
+
: "#cbd5e1";
|
|
2351
2552
|
relBadge.style.cssText = [
|
|
2352
|
-
"font-size:
|
|
2553
|
+
"font-size: 9.5px",
|
|
2353
2554
|
"font-weight: 600",
|
|
2354
2555
|
"padding: 1px 5px",
|
|
2355
2556
|
"border-radius: 4px",
|
|
2356
|
-
|
|
2357
|
-
|
|
2557
|
+
`background: ${relBg}`,
|
|
2558
|
+
`color: ${relColor}`,
|
|
2358
2559
|
"flex-shrink: 0"
|
|
2359
2560
|
].join(";");
|
|
2360
2561
|
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2562
|
+
const selText = document.createElement("span");
|
|
2563
|
+
selText.textContent = formatCandidateLabel(candidate.tagName, candidate.selector);
|
|
2564
|
+
selText.style.cssText = [
|
|
2364
2565
|
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2365
|
-
"font-size:
|
|
2366
|
-
"font-weight: 600",
|
|
2367
|
-
"color: #
|
|
2566
|
+
"font-size: 11px",
|
|
2567
|
+
"font-weight: " + (isSelected ? "600" : "500"),
|
|
2568
|
+
"color: " + (isSelected ? "#faf9f6" : "#e2e8f0"),
|
|
2368
2569
|
"overflow: hidden",
|
|
2369
2570
|
"text-overflow: ellipsis",
|
|
2370
2571
|
"white-space: nowrap"
|
|
2371
2572
|
].join(";");
|
|
2372
2573
|
|
|
2373
2574
|
leftGroup.appendChild(relBadge);
|
|
2374
|
-
leftGroup.appendChild(
|
|
2575
|
+
leftGroup.appendChild(selText);
|
|
2375
2576
|
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
row.appendChild(topLine);
|
|
2389
|
-
|
|
2390
|
-
if (candidate.textPreview) {
|
|
2391
|
-
const previewLine = document.createElement("div");
|
|
2392
|
-
previewLine.textContent = `"${candidate.textPreview}"`;
|
|
2393
|
-
previewLine.style.cssText = [
|
|
2394
|
-
"font-size: 11px",
|
|
2395
|
-
"color: #4b5262",
|
|
2396
|
-
"overflow: hidden",
|
|
2397
|
-
"text-overflow: ellipsis",
|
|
2398
|
-
"white-space: nowrap",
|
|
2399
|
-
"padding-left: 2px"
|
|
2577
|
+
if (candPinned) {
|
|
2578
|
+
const pinTag = document.createElement("span");
|
|
2579
|
+
pinTag.textContent = `#${candPinned.index + 1}`;
|
|
2580
|
+
pinTag.style.cssText = [
|
|
2581
|
+
"padding: 0 4px",
|
|
2582
|
+
"border-radius: 4px",
|
|
2583
|
+
"background: #c2410c",
|
|
2584
|
+
"color: #faf9f6",
|
|
2585
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2586
|
+
"font-size: 9.5px",
|
|
2587
|
+
"font-weight: 700",
|
|
2588
|
+
"flex-shrink: 0"
|
|
2400
2589
|
].join(";");
|
|
2401
|
-
|
|
2590
|
+
leftGroup.appendChild(pinTag);
|
|
2402
2591
|
}
|
|
2403
2592
|
|
|
2404
|
-
row.
|
|
2405
|
-
if (this.activeCandidateIndex !== idx) {
|
|
2406
|
-
this.activeCandidateIndex = idx;
|
|
2407
|
-
this.updateOverlayPosition();
|
|
2408
|
-
this.notifyStateChange();
|
|
2409
|
-
}
|
|
2410
|
-
});
|
|
2593
|
+
row.appendChild(leftGroup);
|
|
2411
2594
|
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2595
|
+
if (isSelected) {
|
|
2596
|
+
const actionBadge = document.createElement("span");
|
|
2597
|
+
actionBadge.textContent = candPinned ? "Click unpin" : "Click to pin";
|
|
2598
|
+
actionBadge.style.cssText = [
|
|
2599
|
+
"padding: 1px 6px",
|
|
2600
|
+
"border-radius: 4px",
|
|
2601
|
+
"background: " + (candPinned ? "rgba(250, 249, 246, 0.18)" : "#c2410c"),
|
|
2602
|
+
"color: #faf9f6",
|
|
2603
|
+
"font-size: 10px",
|
|
2604
|
+
"font-weight: 600",
|
|
2605
|
+
"flex-shrink: 0"
|
|
2606
|
+
].join(";");
|
|
2607
|
+
row.appendChild(actionBadge);
|
|
2608
|
+
} else {
|
|
2609
|
+
const rowDims = document.createElement("span");
|
|
2610
|
+
rowDims.textContent = `${Math.round(candidate.rect.width)}×${Math.round(candidate.rect.height)}`;
|
|
2611
|
+
rowDims.style.cssText = [
|
|
2612
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2613
|
+
"font-size: 10px",
|
|
2614
|
+
"font-variant-numeric: tabular-nums",
|
|
2615
|
+
"color: #cbd5e1",
|
|
2616
|
+
"flex-shrink: 0"
|
|
2617
|
+
].join(";");
|
|
2618
|
+
row.appendChild(rowDims);
|
|
2619
|
+
}
|
|
2416
2620
|
|
|
2417
|
-
|
|
2418
|
-
}
|
|
2621
|
+
listWrap.appendChild(row);
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
if (end < total) {
|
|
2625
|
+
const belowHint = document.createElement("div");
|
|
2626
|
+
belowHint.textContent = `${total - end} parent layer${total - end > 1 ? "s" : ""} below`;
|
|
2627
|
+
belowHint.style.cssText =
|
|
2628
|
+
"font-size: 10px; color: #cbd5e1; padding: 1px 7px; font-variant-numeric: tabular-nums;";
|
|
2629
|
+
listWrap.appendChild(belowHint);
|
|
2630
|
+
}
|
|
2419
2631
|
|
|
2420
|
-
this.
|
|
2632
|
+
this.hudEl.appendChild(listWrap);
|
|
2421
2633
|
|
|
2422
|
-
// Footer
|
|
2634
|
+
// Footer Strip
|
|
2423
2635
|
const footer = document.createElement("div");
|
|
2424
2636
|
footer.style.cssText = [
|
|
2425
2637
|
"display: flex",
|
|
2426
2638
|
"align-items: center",
|
|
2427
2639
|
"justify-content: space-between",
|
|
2428
|
-
"
|
|
2429
|
-
"
|
|
2430
|
-
"
|
|
2640
|
+
"gap: 8px",
|
|
2641
|
+
"padding: 5px 10px",
|
|
2642
|
+
"background: rgba(250, 249, 246, 0.04)",
|
|
2643
|
+
"border-top: 1px solid rgba(250, 249, 246, 0.10)",
|
|
2644
|
+
"font-size: 10.5px",
|
|
2645
|
+
"color: #cbd5e1"
|
|
2431
2646
|
].join(";");
|
|
2432
2647
|
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2648
|
+
const dimsLabel = document.createElement("span");
|
|
2649
|
+
dimsLabel.textContent = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
|
|
2650
|
+
dimsLabel.style.cssText =
|
|
2651
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-variant-numeric: tabular-nums;";
|
|
2652
|
+
|
|
2653
|
+
const keysHint = document.createElement("span");
|
|
2654
|
+
keysHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2655
|
+
keysHint.appendChild(this.createKbdEl("Space"));
|
|
2656
|
+
keysHint.appendChild(this.createSpanEl("pin · "));
|
|
2657
|
+
keysHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
2658
|
+
keysHint.appendChild(this.createSpanEl("freeze · "));
|
|
2659
|
+
keysHint.appendChild(this.createKbdEl("Esc"));
|
|
2660
|
+
keysHint.appendChild(this.createSpanEl("done"));
|
|
2661
|
+
|
|
2662
|
+
footer.appendChild(dimsLabel);
|
|
2663
|
+
footer.appendChild(keysHint);
|
|
2664
|
+
this.hudEl.appendChild(footer);
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
positionHudElement(rect ) {
|
|
2668
|
+
if (!this.hudEl || typeof window === "undefined") return;
|
|
2669
|
+
|
|
2670
|
+
const vw = window.innerWidth || 1024;
|
|
2671
|
+
const vh = window.innerHeight || 768;
|
|
2672
|
+
const fallbackWidth = this.isScrubbingLayers ? 320 : 300;
|
|
2673
|
+
const visibleRows = Math.min(this.candidateStack.length, MAX_VISIBLE_STACK_ROWS);
|
|
2674
|
+
const fallbackHeight = this.isScrubbingLayers ? 66 + visibleRows * 30 : 54;
|
|
2675
|
+
|
|
2676
|
+
const hudWidth = (this.hudEl ).offsetWidth || fallbackWidth;
|
|
2677
|
+
const hudHeight = (this.hudEl ).offsetHeight || fallbackHeight;
|
|
2678
|
+
|
|
2679
|
+
const clampedLeft = Math.max(10, Math.min(rect.left, vw - hudWidth - 10));
|
|
2680
|
+
let top = rect.top - hudHeight - 8;
|
|
2681
|
+
|
|
2682
|
+
if (top < 10) {
|
|
2683
|
+
const belowTop = rect.top + rect.height + 8;
|
|
2684
|
+
if (belowTop + hudHeight <= vh - 10) {
|
|
2685
|
+
top = belowTop;
|
|
2686
|
+
} else {
|
|
2687
|
+
// Large container spanning viewport: place near top-left of visible area, stepping below cursor if close
|
|
2688
|
+
const insideTop = Math.max(10, rect.top + 8);
|
|
2689
|
+
if (
|
|
2690
|
+
Math.abs(this.lastPointerY - insideTop) < hudHeight + 18 &&
|
|
2691
|
+
this.lastPointerX < clampedLeft + hudWidth + 24
|
|
2692
|
+
) {
|
|
2693
|
+
top = Math.min(vh - hudHeight - 10, this.lastPointerY + 22);
|
|
2694
|
+
} else {
|
|
2695
|
+
top = insideTop;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
this.hudEl.style.left = `${Math.round(clampedLeft)}px`;
|
|
2701
|
+
this.hudEl.style.top = `${Math.round(Math.max(10, top))}px`;
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
updateOverlayPosition() {
|
|
2705
|
+
if (!this.overlayEl || !this.hudEl) return;
|
|
2706
|
+
|
|
2707
|
+
const currentCandidate = this.getActiveCandidate();
|
|
2708
|
+
if (!currentCandidate) {
|
|
2709
|
+
this.overlayEl.style.display = "none";
|
|
2710
|
+
this.hudEl.style.display = "none";
|
|
2711
|
+
if (this.leafOutlineEl) this.leafOutlineEl.style.display = "none";
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
const rect = currentCandidate.element.getBoundingClientRect();
|
|
2716
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
2717
|
+
this.overlayEl.style.display = "none";
|
|
2718
|
+
this.hudEl.style.display = "none";
|
|
2719
|
+
return;
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
this.overlayEl.style.display = "block";
|
|
2723
|
+
this.overlayEl.style.left = `${rect.left}px`;
|
|
2724
|
+
this.overlayEl.style.top = `${rect.top}px`;
|
|
2725
|
+
this.overlayEl.style.width = `${rect.width}px`;
|
|
2726
|
+
this.overlayEl.style.height = `${rect.height}px`;
|
|
2727
|
+
|
|
2728
|
+
this.hudEl.style.display = "block";
|
|
2729
|
+
if (this.isScrubbingLayers && this.candidateStack.length > 1) {
|
|
2730
|
+
this.renderScrubbingHudContent(currentCandidate, rect);
|
|
2731
|
+
} else {
|
|
2732
|
+
this.renderCompactHudContent(currentCandidate, rect);
|
|
2733
|
+
}
|
|
2734
|
+
this.positionHudElement(rect);
|
|
2735
|
+
|
|
2736
|
+
// Show ghost leaf outline when inspecting an ancestor or overlapping layer
|
|
2737
|
+
if (this.leafOutlineEl) {
|
|
2738
|
+
if (
|
|
2739
|
+
this.activeCandidateIndex > 0 &&
|
|
2740
|
+
this.leafElement &&
|
|
2741
|
+
this.leafElement !== currentCandidate.element
|
|
2742
|
+
) {
|
|
2743
|
+
const leafRect = this.leafElement.getBoundingClientRect();
|
|
2744
|
+
this.leafOutlineEl.style.display = "block";
|
|
2745
|
+
this.leafOutlineEl.style.left = `${leafRect.left}px`;
|
|
2746
|
+
this.leafOutlineEl.style.top = `${leafRect.top}px`;
|
|
2747
|
+
this.leafOutlineEl.style.width = `${leafRect.width}px`;
|
|
2748
|
+
this.leafOutlineEl.style.height = `${leafRect.height}px`;
|
|
2749
|
+
} else {
|
|
2750
|
+
this.leafOutlineEl.style.display = "none";
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
triggerHudBoundaryNudge(offsetY ) {
|
|
2756
|
+
if (!this.hudEl) return;
|
|
2757
|
+
this.hudEl.style.transform = `translateY(${offsetY}px)`;
|
|
2758
|
+
if (this.nudgeTimer !== null) {
|
|
2759
|
+
clearTimeout(this.nudgeTimer);
|
|
2760
|
+
}
|
|
2761
|
+
this.nudgeTimer = setTimeout(() => {
|
|
2762
|
+
if (this.hudEl) {
|
|
2763
|
+
this.hudEl.style.transform = "translateY(0)";
|
|
2764
|
+
}
|
|
2765
|
+
this.nudgeTimer = null;
|
|
2766
|
+
}, 120);
|
|
2767
|
+
}
|
|
2436
2768
|
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2769
|
+
flashSelectionPulse(kind ) {
|
|
2770
|
+
if (!this.overlayEl) return;
|
|
2771
|
+
if (kind === "pinned") {
|
|
2772
|
+
this.overlayEl.style.borderColor = "#15803d";
|
|
2773
|
+
this.overlayEl.style.background = "rgba(21, 128, 61, 0.14)";
|
|
2774
|
+
} else {
|
|
2775
|
+
this.overlayEl.style.borderColor = "#c2410c";
|
|
2776
|
+
this.overlayEl.style.background = "rgba(194, 65, 12, 0.12)";
|
|
2777
|
+
}
|
|
2778
|
+
if (this.pulseTimer !== null) {
|
|
2779
|
+
clearTimeout(this.pulseTimer);
|
|
2780
|
+
}
|
|
2781
|
+
this.pulseTimer = setTimeout(() => {
|
|
2782
|
+
if (this.overlayEl) {
|
|
2783
|
+
this.overlayEl.style.borderColor = "#1d4ed8";
|
|
2784
|
+
this.overlayEl.style.background = "rgba(29, 78, 216, 0.10)";
|
|
2785
|
+
}
|
|
2786
|
+
this.pulseTimer = null;
|
|
2787
|
+
}, 280);
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
showCursorToast(selector , kind , x , y ) {
|
|
2791
|
+
if (!this.toastEl || typeof window === "undefined") return;
|
|
2792
|
+
this.toastEl.innerHTML = "";
|
|
2793
|
+
|
|
2794
|
+
const iconBadge = document.createElement("span");
|
|
2795
|
+
iconBadge.style.cssText = [
|
|
2441
2796
|
"display: inline-flex",
|
|
2442
2797
|
"align-items: center",
|
|
2443
|
-
"
|
|
2444
|
-
"
|
|
2445
|
-
"
|
|
2446
|
-
"border:
|
|
2447
|
-
"background: #
|
|
2798
|
+
"justify-content: center",
|
|
2799
|
+
"width: 16px",
|
|
2800
|
+
"height: 16px",
|
|
2801
|
+
"border-radius: 9999px",
|
|
2802
|
+
"background: " + (kind === "pinned" ? "#15803d" : "#4b5262"),
|
|
2448
2803
|
"color: #faf9f6",
|
|
2449
|
-
"
|
|
2450
|
-
"font-weight: 600",
|
|
2451
|
-
"cursor: pointer"
|
|
2804
|
+
"flex-shrink: 0"
|
|
2452
2805
|
].join(";");
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
this.
|
|
2806
|
+
iconBadge.innerHTML = ICON_CHECK;
|
|
2807
|
+
this.toastEl.appendChild(iconBadge);
|
|
2808
|
+
|
|
2809
|
+
const primaryText = document.createElement("span");
|
|
2810
|
+
primaryText.textContent = kind === "pinned" ? "Pinned " : "Removed ";
|
|
2811
|
+
this.toastEl.appendChild(primaryText);
|
|
2812
|
+
|
|
2813
|
+
const monoSel = document.createElement("span");
|
|
2814
|
+
monoSel.textContent = selector;
|
|
2815
|
+
monoSel.style.cssText =
|
|
2816
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600; color: #faf9f6; max-width: 160px; overflow: hidden; text-overflow: ellipsis;";
|
|
2817
|
+
this.toastEl.appendChild(monoSel);
|
|
2818
|
+
|
|
2819
|
+
if (kind === "pinned") {
|
|
2820
|
+
const nextHint = document.createElement("span");
|
|
2821
|
+
nextHint.style.cssText =
|
|
2822
|
+
"display: inline-flex; align-items: center; gap: 4px; color: #cbd5e1; font-size: 10.5px; margin-left: 2px;";
|
|
2823
|
+
nextHint.appendChild(this.createSpanEl("· Click more or"));
|
|
2824
|
+
nextHint.appendChild(this.createKbdEl("Esc"));
|
|
2825
|
+
this.toastEl.appendChild(nextHint);
|
|
2826
|
+
}
|
|
2465
2827
|
|
|
2466
|
-
|
|
2828
|
+
this.toastEl.style.display = "inline-flex";
|
|
2467
2829
|
const vw = window.innerWidth || 1024;
|
|
2468
2830
|
const vh = window.innerHeight || 768;
|
|
2469
|
-
const
|
|
2470
|
-
const
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2831
|
+
const left = Math.max(10, Math.min(x + 14, vw - 310));
|
|
2832
|
+
const top = Math.max(10, Math.min(y + 16, vh - 44));
|
|
2833
|
+
this.toastEl.style.left = `${Math.round(left)}px`;
|
|
2834
|
+
this.toastEl.style.top = `${Math.round(top)}px`;
|
|
2835
|
+
|
|
2836
|
+
if (this.toastTimer !== null) {
|
|
2837
|
+
clearTimeout(this.toastTimer);
|
|
2838
|
+
}
|
|
2839
|
+
this.toastTimer = setTimeout(() => {
|
|
2840
|
+
if (this.toastEl) {
|
|
2841
|
+
this.toastEl.style.display = "none";
|
|
2842
|
+
}
|
|
2843
|
+
this.toastTimer = null;
|
|
2844
|
+
}, 1450);
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
commitCandidateSelection(el , x , y ) {
|
|
2848
|
+
const existingPinned = this.findPinnedIndex(el);
|
|
2849
|
+
if (existingPinned && this.callbacks.onUnselect) {
|
|
2850
|
+
this.callbacks.onUnselect(existingPinned.entry.clientRef, el);
|
|
2851
|
+
this.lastAction = { kind: "unpinned", selector: existingPinned.entry.selector };
|
|
2852
|
+
this.isScrubbingLayers = false;
|
|
2853
|
+
this.refreshPinnedMarkers();
|
|
2854
|
+
this.flashSelectionPulse("unpinned");
|
|
2855
|
+
this.showCursorToast(existingPinned.entry.selector, "unpinned", x, y);
|
|
2856
|
+
this.updateOverlayPosition();
|
|
2857
|
+
this.notifyStateChange();
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
const excluded = this.callbacks.getExcludedSelectors();
|
|
2862
|
+
const snapshot = captureElementSnapshot(el, excluded);
|
|
2863
|
+
if (!snapshot) return;
|
|
2864
|
+
|
|
2865
|
+
this.callbacks.onSelect(snapshot, el);
|
|
2866
|
+
this.lastAction = { kind: "pinned", selector: snapshot.selector };
|
|
2867
|
+
this.isScrubbingLayers = false;
|
|
2868
|
+
this.refreshPinnedMarkers();
|
|
2869
|
+
|
|
2870
|
+
if (!this.callbacks.canSelectMore()) {
|
|
2871
|
+
this.stop();
|
|
2872
|
+
return;
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
this.flashSelectionPulse("pinned");
|
|
2876
|
+
this.showCursorToast(snapshot.selector, "pinned", x, y);
|
|
2877
|
+
this.updateOverlayPosition();
|
|
2878
|
+
this.notifyStateChange();
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
handleWheelCapture(event ) {
|
|
2882
|
+
if (!this.active) return;
|
|
2883
|
+
if (this.isInternalUiEvent(event)) return;
|
|
2884
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
2885
|
+
|
|
2886
|
+
if (this.candidateStack.length <= 1) {
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
event.preventDefault();
|
|
2891
|
+
event.stopPropagation();
|
|
2892
|
+
|
|
2893
|
+
const normalizedDelta = event.deltaMode === 1 ? event.deltaY * 32 : event.deltaY;
|
|
2894
|
+
if (normalizedDelta === 0) return;
|
|
2895
|
+
|
|
2896
|
+
// Reset accumulator immediately when the user reverses scroll direction
|
|
2897
|
+
if (this.wheelAccumulator * normalizedDelta < 0) {
|
|
2898
|
+
this.wheelAccumulator = 0;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
this.wheelAccumulator += normalizedDelta;
|
|
2902
|
+
if (Math.abs(this.wheelAccumulator) < WHEEL_STEP_THRESHOLD) {
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
const now = Date.now();
|
|
2907
|
+
if (now - this.lastWheelStepAt < WHEEL_STEP_COOLDOWN_MS) {
|
|
2908
|
+
this.wheelAccumulator = 0;
|
|
2909
|
+
return;
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
const step = this.wheelAccumulator > 0 ? 1 : -1;
|
|
2913
|
+
this.wheelAccumulator = 0;
|
|
2914
|
+
this.lastWheelStepAt = now;
|
|
2915
|
+
this.cycleDepth(step, true);
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
handlePointerSuppression(event ) {
|
|
2919
|
+
if (!this.active) return;
|
|
2920
|
+
if (this.isInternalUiEvent(event)) {
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
// Intercept host page pointer events in capture phase so links/buttons do not fire
|
|
2925
|
+
event.preventDefault();
|
|
2926
|
+
event.stopPropagation();
|
|
2927
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2928
|
+
event.stopImmediatePropagation();
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
handleBlurSuppression(event ) {
|
|
2933
|
+
if (!this.active) return;
|
|
2934
|
+
if (this.isInternalUiEvent(event)) {
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// Freeze DOM states: suppress blur / focusout on host elements while picker is active
|
|
2939
|
+
// so transient popovers, tooltips, flyout menus, and modals remain open
|
|
2940
|
+
event.stopPropagation();
|
|
2941
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2942
|
+
event.stopImmediatePropagation();
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
handleClickCapture(event ) {
|
|
2947
|
+
if (!this.active) return;
|
|
2948
|
+
if (this.isInternalUiEvent(event)) {
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
event.preventDefault();
|
|
2953
|
+
event.stopPropagation();
|
|
2954
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2955
|
+
event.stopImmediatePropagation();
|
|
2956
|
+
}
|
|
2476
2957
|
|
|
2477
|
-
this.
|
|
2478
|
-
this.
|
|
2958
|
+
this.lastPointerX = event.clientX;
|
|
2959
|
+
this.lastPointerY = event.clientY;
|
|
2960
|
+
this.updateCandidatesFromPoint(event.clientX, event.clientY, event);
|
|
2961
|
+
|
|
2962
|
+
const activeCandidate = this.getActiveCandidate();
|
|
2963
|
+
if (!activeCandidate) return;
|
|
2964
|
+
|
|
2965
|
+
this.commitCandidateSelection(activeCandidate.element, event.clientX, event.clientY);
|
|
2479
2966
|
}
|
|
2480
2967
|
|
|
2481
2968
|
handleKeyDown(event ) {
|
|
@@ -2484,10 +2971,37 @@
|
|
|
2484
2971
|
if (event.key === "Escape") {
|
|
2485
2972
|
event.preventDefault();
|
|
2486
2973
|
event.stopPropagation();
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2974
|
+
this.stop();
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
// Alt+Shift+P / Option+Shift+P toggle / exit Freeze & Pin mode
|
|
2979
|
+
if (
|
|
2980
|
+
event.altKey &&
|
|
2981
|
+
event.shiftKey &&
|
|
2982
|
+
(event.code === "KeyP" || event.key.toLowerCase() === "p")
|
|
2983
|
+
) {
|
|
2984
|
+
event.preventDefault();
|
|
2985
|
+
event.stopPropagation();
|
|
2986
|
+
this.stop();
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
// Space key freezes & pins the currently hovered element without triggering mouse clicks
|
|
2991
|
+
if (event.key === " " || event.key === "Spacebar" || event.code === "Space") {
|
|
2992
|
+
if (this.isInternalUiEvent(event)) return;
|
|
2993
|
+
const candidate = this.getActiveCandidate();
|
|
2994
|
+
if (candidate) {
|
|
2995
|
+
event.preventDefault();
|
|
2996
|
+
event.stopPropagation();
|
|
2997
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2998
|
+
event.stopImmediatePropagation();
|
|
2999
|
+
}
|
|
3000
|
+
this.commitCandidateSelection(
|
|
3001
|
+
candidate.element,
|
|
3002
|
+
this.lastPointerX || 80,
|
|
3003
|
+
this.lastPointerY || 80
|
|
3004
|
+
);
|
|
2491
3005
|
}
|
|
2492
3006
|
return;
|
|
2493
3007
|
}
|
|
@@ -2495,14 +3009,14 @@
|
|
|
2495
3009
|
if (event.key === "ArrowUp" || event.key === "[") {
|
|
2496
3010
|
event.preventDefault();
|
|
2497
3011
|
event.stopPropagation();
|
|
2498
|
-
this.cycleDepth(1);
|
|
3012
|
+
this.cycleDepth(1, true);
|
|
2499
3013
|
return;
|
|
2500
3014
|
}
|
|
2501
3015
|
|
|
2502
3016
|
if (event.key === "ArrowDown" || event.key === "]") {
|
|
2503
3017
|
event.preventDefault();
|
|
2504
3018
|
event.stopPropagation();
|
|
2505
|
-
this.cycleDepth(-1);
|
|
3019
|
+
this.cycleDepth(-1, true);
|
|
2506
3020
|
return;
|
|
2507
3021
|
}
|
|
2508
3022
|
|
|
@@ -2511,7 +3025,11 @@
|
|
|
2511
3025
|
if (candidate) {
|
|
2512
3026
|
event.preventDefault();
|
|
2513
3027
|
event.stopPropagation();
|
|
2514
|
-
this.
|
|
3028
|
+
this.commitCandidateSelection(
|
|
3029
|
+
candidate.element,
|
|
3030
|
+
this.lastPointerX || 80,
|
|
3031
|
+
this.lastPointerY || 80
|
|
3032
|
+
);
|
|
2515
3033
|
}
|
|
2516
3034
|
}
|
|
2517
3035
|
}
|
|
@@ -2563,7 +3081,11 @@
|
|
|
2563
3081
|
rootContainer = null;
|
|
2564
3082
|
composerEl = null;
|
|
2565
3083
|
compactBarEl = null;
|
|
2566
|
-
|
|
3084
|
+
compactStatusEl = null;
|
|
3085
|
+
compactStepGroupEl = null;
|
|
3086
|
+
compactLayerUpBtn = null;
|
|
3087
|
+
compactLayerDownBtn = null;
|
|
3088
|
+
compactDoneBtn = null;
|
|
2567
3089
|
compactPinBtn = null;
|
|
2568
3090
|
pinDockEl = null;
|
|
2569
3091
|
floatingPinBtn = null;
|
|
@@ -2575,6 +3097,10 @@
|
|
|
2575
3097
|
statusEl = null;
|
|
2576
3098
|
fileInputEl = null;
|
|
2577
3099
|
submitBtn = null;
|
|
3100
|
+
lastPointerX = 0;
|
|
3101
|
+
lastPointerY = 0;
|
|
3102
|
+
boundTrackPointer ;
|
|
3103
|
+
boundGlobalKeyDown ;
|
|
2578
3104
|
|
|
2579
3105
|
connectedCallback() {
|
|
2580
3106
|
if (!this.shadow) {
|
|
@@ -2583,14 +3109,49 @@
|
|
|
2583
3109
|
this.readDataAttributes();
|
|
2584
3110
|
this.renderShadowDom();
|
|
2585
3111
|
|
|
3112
|
+
this.boundTrackPointer = (ev ) => {
|
|
3113
|
+
this.lastPointerX = ev.clientX;
|
|
3114
|
+
this.lastPointerY = ev.clientY;
|
|
3115
|
+
};
|
|
3116
|
+
|
|
3117
|
+
this.boundGlobalKeyDown = (ev ) => {
|
|
3118
|
+
// Alt+Shift+P / Option+Shift+P toggles Freeze & Pin mode from anywhere on the host page
|
|
3119
|
+
if (
|
|
3120
|
+
ev.altKey &&
|
|
3121
|
+
ev.shiftKey &&
|
|
3122
|
+
(ev.code === "KeyP" || (typeof ev.key === "string" && ev.key.toLowerCase() === "p"))
|
|
3123
|
+
) {
|
|
3124
|
+
ev.preventDefault();
|
|
3125
|
+
ev.stopPropagation();
|
|
3126
|
+
if (typeof ev.stopImmediatePropagation === "function") {
|
|
3127
|
+
ev.stopImmediatePropagation();
|
|
3128
|
+
}
|
|
3129
|
+
this.togglePinSelection();
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
|
|
3133
|
+
if (typeof window !== "undefined") {
|
|
3134
|
+
window.addEventListener("mousemove", this.boundTrackPointer, { capture: true, passive: true });
|
|
3135
|
+
window.addEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
3136
|
+
}
|
|
3137
|
+
|
|
2586
3138
|
this.picker = new ElementPicker({
|
|
2587
3139
|
onSelect: (snapshot, el) => {
|
|
2588
3140
|
const added = this.addElementReference(snapshot, el);
|
|
2589
3141
|
if (added) {
|
|
2590
|
-
this.
|
|
3142
|
+
const count = this.elementReferences.length;
|
|
3143
|
+
this.showStatus(
|
|
3144
|
+
count === 1
|
|
3145
|
+
? `Pinned ${snapshot.selector}`
|
|
3146
|
+
: `Pinned ${count} elements (latest: ${snapshot.selector})`,
|
|
3147
|
+
"success"
|
|
3148
|
+
);
|
|
2591
3149
|
}
|
|
2592
3150
|
this.syncUiStates();
|
|
2593
3151
|
},
|
|
3152
|
+
onUnselect: (clientRef) => {
|
|
3153
|
+
this.removeElementReference(clientRef);
|
|
3154
|
+
},
|
|
2594
3155
|
onExit: () => {
|
|
2595
3156
|
this.isMinimized = false;
|
|
2596
3157
|
this.openComposer();
|
|
@@ -2598,9 +3159,21 @@
|
|
|
2598
3159
|
},
|
|
2599
3160
|
canSelectMore: () => this.elementReferences.length < this.config.limits.max_element_references,
|
|
2600
3161
|
getExcludedSelectors: () => this.config.privacy.excluded_selectors,
|
|
3162
|
+
getPinnedElements: () =>
|
|
3163
|
+
this.elementReferences
|
|
3164
|
+
.map((ref) => {
|
|
3165
|
+
const node = this.elementDomNodes.get(ref.client_ref);
|
|
3166
|
+
return node
|
|
3167
|
+
? { clientRef: ref.client_ref, selector: ref.selector, element: node }
|
|
3168
|
+
: null;
|
|
3169
|
+
})
|
|
3170
|
+
.filter(
|
|
3171
|
+
(item) =>
|
|
3172
|
+
item !== null
|
|
3173
|
+
),
|
|
2601
3174
|
onStateChange: (state) => {
|
|
2602
|
-
this.renderCompactBreadcrumbs(state.activeCandidate, state.ancestors);
|
|
2603
3175
|
this.syncPinActiveIndicators(state.active);
|
|
3176
|
+
this.renderCompactCoachBar(state.active, state.candidateStack.length);
|
|
2604
3177
|
}
|
|
2605
3178
|
});
|
|
2606
3179
|
}
|
|
@@ -2610,6 +3183,11 @@
|
|
|
2610
3183
|
this.picker.stop();
|
|
2611
3184
|
}
|
|
2612
3185
|
this.picker?.hideExternalPreview();
|
|
3186
|
+
|
|
3187
|
+
if (typeof window !== "undefined") {
|
|
3188
|
+
window.removeEventListener("mousemove", this.boundTrackPointer, { capture: true });
|
|
3189
|
+
window.removeEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
3190
|
+
}
|
|
2613
3191
|
}
|
|
2614
3192
|
|
|
2615
3193
|
getConfig() {
|
|
@@ -2681,6 +3259,9 @@
|
|
|
2681
3259
|
}
|
|
2682
3260
|
this.minimizeToCompactBar();
|
|
2683
3261
|
this.picker.start();
|
|
3262
|
+
if (this.lastPointerX > 0 && this.lastPointerY > 0) {
|
|
3263
|
+
this.picker.highlightAtPoint(this.lastPointerX, this.lastPointerY);
|
|
3264
|
+
}
|
|
2684
3265
|
this.syncUiStates();
|
|
2685
3266
|
}
|
|
2686
3267
|
|
|
@@ -2717,6 +3298,7 @@
|
|
|
2717
3298
|
if (elementNode) {
|
|
2718
3299
|
this.elementDomNodes.set(snapshot.client_ref, elementNode);
|
|
2719
3300
|
}
|
|
3301
|
+
this.picker?.refreshPinnedMarkers();
|
|
2720
3302
|
this.renderTray();
|
|
2721
3303
|
this.syncUiStates();
|
|
2722
3304
|
return true;
|
|
@@ -2726,6 +3308,7 @@
|
|
|
2726
3308
|
this.elementReferences = this.elementReferences.filter((el) => el.client_ref !== clientRef);
|
|
2727
3309
|
this.elementDomNodes.delete(clientRef);
|
|
2728
3310
|
this.picker?.hideExternalPreview();
|
|
3311
|
+
this.picker?.refreshPinnedMarkers();
|
|
2729
3312
|
this.renderTray();
|
|
2730
3313
|
this.syncUiStates();
|
|
2731
3314
|
}
|
|
@@ -2912,7 +3495,8 @@
|
|
|
2912
3495
|
const compactPinBtn = document.createElement("button");
|
|
2913
3496
|
compactPinBtn.type = "button";
|
|
2914
3497
|
compactPinBtn.className = "cd-pin-corner-btn is-active";
|
|
2915
|
-
compactPinBtn.
|
|
3498
|
+
compactPinBtn.title = "Toggle Freeze & Pin (⌥⇧P)";
|
|
3499
|
+
compactPinBtn.setAttribute("aria-label", "Toggle element pin mode (Option+Shift+P)");
|
|
2916
3500
|
compactPinBtn.innerHTML = `${ICON_PIN}<span>Pinning</span>`;
|
|
2917
3501
|
compactPinBtn.addEventListener("click", () => this.togglePinSelection());
|
|
2918
3502
|
this.compactPinBtn = compactPinBtn;
|
|
@@ -2920,20 +3504,12 @@
|
|
|
2920
3504
|
|
|
2921
3505
|
const compactStatus = document.createElement("div");
|
|
2922
3506
|
compactStatus.className = "cd-compact-status";
|
|
2923
|
-
|
|
2924
|
-
breadcrumbScroll.className = "cd-breadcrumb-scroll";
|
|
2925
|
-
this.compactBreadcrumbEl = breadcrumbScroll;
|
|
2926
|
-
compactStatus.appendChild(breadcrumbScroll);
|
|
3507
|
+
this.compactStatusEl = compactStatus;
|
|
2927
3508
|
compactBar.appendChild(compactStatus);
|
|
2928
3509
|
|
|
2929
|
-
const
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
2933
|
-
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
2934
|
-
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
2935
|
-
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1));
|
|
2936
|
-
compactBar.appendChild(compactLayerUp);
|
|
3510
|
+
const compactStepGroup = document.createElement("div");
|
|
3511
|
+
compactStepGroup.className = "cd-compact-step-group";
|
|
3512
|
+
this.compactStepGroupEl = compactStepGroup;
|
|
2937
3513
|
|
|
2938
3514
|
const compactLayerDown = document.createElement("button");
|
|
2939
3515
|
compactLayerDown.type = "button";
|
|
@@ -2941,15 +3517,29 @@
|
|
|
2941
3517
|
compactLayerDown.title = "Step to inner/child element (Down arrow)";
|
|
2942
3518
|
compactLayerDown.setAttribute("aria-label", "Step to child element");
|
|
2943
3519
|
compactLayerDown.innerHTML = ICON_CHEVRON_DOWN;
|
|
2944
|
-
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1));
|
|
2945
|
-
|
|
3520
|
+
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1, true));
|
|
3521
|
+
this.compactLayerDownBtn = compactLayerDown;
|
|
3522
|
+
compactStepGroup.appendChild(compactLayerDown);
|
|
3523
|
+
|
|
3524
|
+
const compactLayerUp = document.createElement("button");
|
|
3525
|
+
compactLayerUp.type = "button";
|
|
3526
|
+
compactLayerUp.className = "cd-icon-btn";
|
|
3527
|
+
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
3528
|
+
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
3529
|
+
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
3530
|
+
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1, true));
|
|
3531
|
+
this.compactLayerUpBtn = compactLayerUp;
|
|
3532
|
+
compactStepGroup.appendChild(compactLayerUp);
|
|
3533
|
+
|
|
3534
|
+
compactBar.appendChild(compactStepGroup);
|
|
2946
3535
|
|
|
2947
3536
|
const expandBtn = document.createElement("button");
|
|
2948
3537
|
expandBtn.type = "button";
|
|
2949
|
-
expandBtn.className = "cd-btn
|
|
2950
|
-
expandBtn.setAttribute("aria-label", "
|
|
2951
|
-
expandBtn.innerHTML =
|
|
3538
|
+
expandBtn.className = "cd-btn";
|
|
3539
|
+
expandBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
3540
|
+
expandBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
2952
3541
|
expandBtn.addEventListener("click", () => this.expandFromCompactBar());
|
|
3542
|
+
this.compactDoneBtn = expandBtn;
|
|
2953
3543
|
compactBar.appendChild(expandBtn);
|
|
2954
3544
|
|
|
2955
3545
|
// 2. Main Floating Chatbox Composer Window
|
|
@@ -2989,8 +3579,8 @@
|
|
|
2989
3579
|
const cornerPinBtn = document.createElement("button");
|
|
2990
3580
|
cornerPinBtn.type = "button";
|
|
2991
3581
|
cornerPinBtn.className = "cd-pin-corner-btn";
|
|
2992
|
-
cornerPinBtn.title = "
|
|
2993
|
-
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page");
|
|
3582
|
+
cornerPinBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
3583
|
+
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page (Option+Shift+P)");
|
|
2994
3584
|
cornerPinBtn.innerHTML = `${ICON_PIN}<span>Pin Element</span>`;
|
|
2995
3585
|
cornerPinBtn.addEventListener("click", () => this.startPinSelection());
|
|
2996
3586
|
this.cornerPinBtn = cornerPinBtn;
|
|
@@ -3097,8 +3687,9 @@
|
|
|
3097
3687
|
const pickBtn = document.createElement("button");
|
|
3098
3688
|
pickBtn.type = "button";
|
|
3099
3689
|
pickBtn.className = "cd-btn";
|
|
3100
|
-
pickBtn.
|
|
3101
|
-
pickBtn.
|
|
3690
|
+
pickBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
3691
|
+
pickBtn.setAttribute("aria-label", "Pin HTML element as context (Option+Shift+P)");
|
|
3692
|
+
pickBtn.innerHTML = `${ICON_PIN}<span>Pin</span><kbd class="cd-kbd">⌥⇧P</kbd>`;
|
|
3102
3693
|
pickBtn.addEventListener("click", () => this.startPinSelection());
|
|
3103
3694
|
actions.appendChild(pickBtn);
|
|
3104
3695
|
}
|
|
@@ -3154,8 +3745,8 @@
|
|
|
3154
3745
|
const floatingPinBtn = document.createElement("button");
|
|
3155
3746
|
floatingPinBtn.type = "button";
|
|
3156
3747
|
floatingPinBtn.className = "cd-floating-pin-btn";
|
|
3157
|
-
floatingPinBtn.title = "Pin
|
|
3158
|
-
floatingPinBtn.setAttribute("aria-label", "Pin element on page");
|
|
3748
|
+
floatingPinBtn.title = "Freeze & Pin element (⌥⇧P, or drag to move)";
|
|
3749
|
+
floatingPinBtn.setAttribute("aria-label", "Freeze & Pin element on page (Option+Shift+P)");
|
|
3159
3750
|
floatingPinBtn.innerHTML = `${ICON_PIN}<span>Pin</span>`;
|
|
3160
3751
|
this.attachDragHandle(floatingPinBtn, () => this.startPinSelection());
|
|
3161
3752
|
this.floatingPinBtn = floatingPinBtn;
|
|
@@ -3177,7 +3768,6 @@
|
|
|
3177
3768
|
root.appendChild(pinDock);
|
|
3178
3769
|
this.shadow.appendChild(root);
|
|
3179
3770
|
|
|
3180
|
-
this.renderCompactBreadcrumbs(null, []);
|
|
3181
3771
|
this.syncUiStates();
|
|
3182
3772
|
}
|
|
3183
3773
|
|
|
@@ -3228,48 +3818,102 @@
|
|
|
3228
3818
|
}
|
|
3229
3819
|
|
|
3230
3820
|
this.syncPinActiveIndicators(pickerActive);
|
|
3821
|
+
this.renderCompactCoachBar(
|
|
3822
|
+
pickerActive,
|
|
3823
|
+
this.picker ? this.picker.getCandidateStack().length : 0
|
|
3824
|
+
);
|
|
3231
3825
|
}
|
|
3232
3826
|
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
) {
|
|
3237
|
-
if (!this.compactBreadcrumbEl) return;
|
|
3238
|
-
this.compactBreadcrumbEl.innerHTML = "";
|
|
3827
|
+
renderCompactCoachBar(pickerActive , candidateCount = 0) {
|
|
3828
|
+
if (!this.compactStatusEl) return;
|
|
3829
|
+
this.compactStatusEl.innerHTML = "";
|
|
3239
3830
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
? `${this.elementReferences.length} pinned · Hover or click any element (scroll ↕ for layers)`
|
|
3246
|
-
: "Hover any element · Scroll ↕ for layers · Click to inspect stack";
|
|
3247
|
-
this.compactBreadcrumbEl.appendChild(hint);
|
|
3248
|
-
return;
|
|
3831
|
+
const pinnedCount = this.elementReferences.length;
|
|
3832
|
+
const totalContextCount = pinnedCount + this.attachments.length;
|
|
3833
|
+
|
|
3834
|
+
if (this.compactStepGroupEl) {
|
|
3835
|
+
this.compactStepGroupEl.hidden = !pickerActive;
|
|
3249
3836
|
}
|
|
3837
|
+
if (this.compactLayerUpBtn) {
|
|
3838
|
+
this.compactLayerUpBtn.disabled = candidateCount <= 1;
|
|
3839
|
+
}
|
|
3840
|
+
if (this.compactLayerDownBtn) {
|
|
3841
|
+
this.compactLayerDownBtn.disabled = candidateCount <= 1;
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
if (pickerActive) {
|
|
3845
|
+
if (pinnedCount === 0) {
|
|
3846
|
+
const coach = document.createElement("span");
|
|
3847
|
+
coach.className = "cd-compact-coach-text";
|
|
3848
|
+
coach.innerHTML = `<strong>Space</strong><span>or click to pin</span><span>·</span><span class="cd-compact-wheel-icon">${ICON_SCROLL_VERTICAL}</span><strong>Scroll</strong><span>layers</span><span>·</span><kbd class="cd-kbd">⌥⇧P</kbd><span>freeze</span>`;
|
|
3849
|
+
this.compactStatusEl.appendChild(coach);
|
|
3850
|
+
} else {
|
|
3851
|
+
const latest = this.elementReferences[pinnedCount - 1];
|
|
3852
|
+
const pill = document.createElement("div");
|
|
3853
|
+
pill.className = "cd-compact-pinned-pill";
|
|
3854
|
+
|
|
3855
|
+
const countSpan = document.createElement("span");
|
|
3856
|
+
countSpan.className = "cd-compact-pinned-count";
|
|
3857
|
+
countSpan.textContent = `${pinnedCount} pinned`;
|
|
3858
|
+
|
|
3859
|
+
const selSpan = document.createElement("span");
|
|
3860
|
+
selSpan.className = "cd-compact-pinned-selector";
|
|
3861
|
+
selSpan.textContent = latest.selector;
|
|
3862
|
+
selSpan.title = latest.dom_path || latest.selector;
|
|
3863
|
+
|
|
3864
|
+
const undoBtn = document.createElement("button");
|
|
3865
|
+
undoBtn.type = "button";
|
|
3866
|
+
undoBtn.className = "cd-chip-remove";
|
|
3867
|
+
undoBtn.title = `Remove ${latest.selector}`;
|
|
3868
|
+
undoBtn.setAttribute("aria-label", `Undo pin ${latest.selector}`);
|
|
3869
|
+
undoBtn.innerHTML = ICON_CLOSE;
|
|
3870
|
+
undoBtn.addEventListener("click", (ev) => {
|
|
3871
|
+
ev.stopPropagation();
|
|
3872
|
+
this.removeElementReference(latest.client_ref);
|
|
3873
|
+
});
|
|
3874
|
+
|
|
3875
|
+
pill.appendChild(countSpan);
|
|
3876
|
+
pill.appendChild(selSpan);
|
|
3877
|
+
pill.appendChild(undoBtn);
|
|
3878
|
+
this.compactStatusEl.appendChild(pill);
|
|
3250
3879
|
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
sep.innerHTML = ICON_CHEVRON_RIGHT;
|
|
3256
|
-
this.compactBreadcrumbEl?.appendChild(sep);
|
|
3880
|
+
const addMore = document.createElement("span");
|
|
3881
|
+
addMore.className = "cd-compact-coach-text";
|
|
3882
|
+
addMore.innerHTML = `<strong>Space</strong><span>or click to add more</span>`;
|
|
3883
|
+
this.compactStatusEl.appendChild(addMore);
|
|
3257
3884
|
}
|
|
3258
3885
|
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3886
|
+
if (this.compactDoneBtn) {
|
|
3887
|
+
if (pinnedCount > 0) {
|
|
3888
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
3889
|
+
this.compactDoneBtn.setAttribute(
|
|
3890
|
+
"aria-label",
|
|
3891
|
+
"Finish pinning elements and return to chatbox"
|
|
3892
|
+
);
|
|
3893
|
+
this.compactDoneBtn.innerHTML = `${ICON_CHECK}<span>Done (${pinnedCount})</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
3894
|
+
} else {
|
|
3895
|
+
this.compactDoneBtn.className = "cd-btn";
|
|
3896
|
+
this.compactDoneBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
3897
|
+
this.compactDoneBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
return;
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
// Minimized while not actively in Pin Mode
|
|
3904
|
+
const summary = document.createElement("span");
|
|
3905
|
+
summary.className = "cd-compact-coach-text";
|
|
3906
|
+
summary.textContent =
|
|
3907
|
+
totalContextCount > 0
|
|
3908
|
+
? `${totalContextCount} context item${totalContextCount > 1 ? "s" : ""} attached`
|
|
3909
|
+
: "Chatbox minimized";
|
|
3910
|
+
this.compactStatusEl.appendChild(summary);
|
|
3911
|
+
|
|
3912
|
+
if (this.compactDoneBtn) {
|
|
3913
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
3914
|
+
this.compactDoneBtn.setAttribute("aria-label", "Return to chatbox");
|
|
3915
|
+
this.compactDoneBtn.innerHTML = `${ICON_EXPAND}<span>Chat</span>`;
|
|
3916
|
+
}
|
|
3273
3917
|
}
|
|
3274
3918
|
|
|
3275
3919
|
renderChatThread() {
|
|
@@ -3286,8 +3930,8 @@
|
|
|
3286
3930
|
|
|
3287
3931
|
const p2 = document.createElement("p");
|
|
3288
3932
|
p2.className = "cd-chat-empty-hint";
|
|
3289
|
-
p2.
|
|
3290
|
-
"
|
|
3933
|
+
p2.innerHTML =
|
|
3934
|
+
"Press <kbd class=\"cd-kbd\">⌥⇧P</kbd> anywhere or click Pin to freeze & pin, scroll to cycle layers, and press <kbd class=\"cd-kbd\">Space</kbd> to pin instantly.";
|
|
3291
3935
|
|
|
3292
3936
|
emptyBox.appendChild(p1);
|
|
3293
3937
|
emptyBox.appendChild(p2);
|