context_drop 0.1.2 → 0.1.3
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/app/assets/javascripts/context_drop/context_drop.js +1109 -570
- data/app/javascript/context_drop/__tests__/widget.test.ts +158 -3
- data/app/javascript/context_drop/element-picker.ts +894 -485
- 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 +147 -61
- data/lib/context_drop/version.rb +1 -1
- metadata +1 -1
|
@@ -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,26 +1601,66 @@
|
|
|
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 ;
|
|
@@ -1581,7 +1677,7 @@
|
|
|
1581
1677
|
this.boundPointerCapture = this.handlePointerSuppression.bind(this);
|
|
1582
1678
|
this.boundWheelCapture = this.handleWheelCapture.bind(this);
|
|
1583
1679
|
this.boundKeyDown = this.handleKeyDown.bind(this);
|
|
1584
|
-
this.boundScrollOrResize = this.
|
|
1680
|
+
this.boundScrollOrResize = this.handleViewportScrollOrResize.bind(this);
|
|
1585
1681
|
}
|
|
1586
1682
|
|
|
1587
1683
|
isActive() {
|
|
@@ -1589,7 +1685,11 @@
|
|
|
1589
1685
|
}
|
|
1590
1686
|
|
|
1591
1687
|
isAnchored() {
|
|
1592
|
-
return
|
|
1688
|
+
return false;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
isScrubbing() {
|
|
1692
|
+
return this.isScrubbingLayers;
|
|
1593
1693
|
}
|
|
1594
1694
|
|
|
1595
1695
|
getActiveCandidate() {
|
|
@@ -1605,10 +1705,13 @@
|
|
|
1605
1705
|
return;
|
|
1606
1706
|
}
|
|
1607
1707
|
this.active = true;
|
|
1608
|
-
this.
|
|
1708
|
+
this.isScrubbingLayers = false;
|
|
1709
|
+
this.wheelAccumulator = 0;
|
|
1710
|
+
this.lastWheelStepAt = 0;
|
|
1609
1711
|
this.candidateStack = [];
|
|
1610
1712
|
this.activeCandidateIndex = 0;
|
|
1611
1713
|
this.leafElement = null;
|
|
1714
|
+
this.lastAction = null;
|
|
1612
1715
|
|
|
1613
1716
|
this.hideExternalPreview();
|
|
1614
1717
|
|
|
@@ -1618,6 +1721,7 @@
|
|
|
1618
1721
|
}
|
|
1619
1722
|
|
|
1620
1723
|
this.mountSelectionUi();
|
|
1724
|
+
this.refreshPinnedMarkers();
|
|
1621
1725
|
this.notifyStateChange();
|
|
1622
1726
|
|
|
1623
1727
|
window.addEventListener("mousemove", this.boundMouseMove, { capture: true, passive: true });
|
|
@@ -1634,10 +1738,13 @@
|
|
|
1634
1738
|
stop() {
|
|
1635
1739
|
if (!this.active) return;
|
|
1636
1740
|
this.active = false;
|
|
1637
|
-
this.
|
|
1741
|
+
this.isScrubbingLayers = false;
|
|
1742
|
+
this.wheelAccumulator = 0;
|
|
1638
1743
|
this.candidateStack = [];
|
|
1639
1744
|
this.activeCandidateIndex = 0;
|
|
1640
1745
|
this.leafElement = null;
|
|
1746
|
+
this.lastAction = null;
|
|
1747
|
+
this.clearTimers();
|
|
1641
1748
|
|
|
1642
1749
|
if (typeof document !== "undefined" && document.body) {
|
|
1643
1750
|
document.body.style.cursor = this.previousCursor;
|
|
@@ -1660,9 +1767,6 @@
|
|
|
1660
1767
|
this.callbacks.onExit();
|
|
1661
1768
|
}
|
|
1662
1769
|
|
|
1663
|
-
/**
|
|
1664
|
-
* Allows the widget or breadcrumb bar to select or preview a specific DOM element directly.
|
|
1665
|
-
*/
|
|
1666
1770
|
focusCandidateElement(el ) {
|
|
1667
1771
|
if (!this.active) return;
|
|
1668
1772
|
const excluded = this.callbacks.getExcludedSelectors();
|
|
@@ -1677,10 +1781,10 @@
|
|
|
1677
1781
|
this.activeCandidateIndex = this.candidateStack.length - 1;
|
|
1678
1782
|
}
|
|
1679
1783
|
|
|
1784
|
+
this.isScrubbingLayers = this.candidateStack.length > 1;
|
|
1785
|
+
this.scrubOriginX = this.lastPointerX;
|
|
1786
|
+
this.scrubOriginY = this.lastPointerY;
|
|
1680
1787
|
this.updateOverlayPosition();
|
|
1681
|
-
if (this.anchored) {
|
|
1682
|
-
this.renderLayerPopover();
|
|
1683
|
-
}
|
|
1684
1788
|
this.notifyStateChange();
|
|
1685
1789
|
}
|
|
1686
1790
|
|
|
@@ -1690,16 +1794,75 @@
|
|
|
1690
1794
|
if (!snapshot) return false;
|
|
1691
1795
|
|
|
1692
1796
|
this.callbacks.onSelect(snapshot, el);
|
|
1693
|
-
this.
|
|
1797
|
+
this.lastAction = { kind: "pinned", selector: snapshot.selector };
|
|
1798
|
+
this.isScrubbingLayers = false;
|
|
1799
|
+
this.refreshPinnedMarkers();
|
|
1694
1800
|
|
|
1695
1801
|
if (!this.callbacks.canSelectMore()) {
|
|
1696
1802
|
this.stop();
|
|
1697
1803
|
} else {
|
|
1804
|
+
this.updateOverlayPosition();
|
|
1698
1805
|
this.notifyStateChange();
|
|
1699
1806
|
}
|
|
1700
1807
|
return true;
|
|
1701
1808
|
}
|
|
1702
1809
|
|
|
1810
|
+
refreshPinnedMarkers() {
|
|
1811
|
+
if (!this.active || !this.pinnedMarkersContainerEl) return;
|
|
1812
|
+
this.pinnedMarkersContainerEl.innerHTML = "";
|
|
1813
|
+
|
|
1814
|
+
const pinnedEntries = this.callbacks.getPinnedElements ? this.callbacks.getPinnedElements() : [];
|
|
1815
|
+
pinnedEntries.forEach((entry, index) => {
|
|
1816
|
+
if (!entry.element || typeof entry.element.getBoundingClientRect !== "function") return;
|
|
1817
|
+
const rect = entry.element.getBoundingClientRect();
|
|
1818
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
1819
|
+
|
|
1820
|
+
const markerFrame = document.createElement("div");
|
|
1821
|
+
markerFrame.setAttribute("data-context-drop-ui", "pinned-badge");
|
|
1822
|
+
markerFrame.style.cssText = [
|
|
1823
|
+
"position: fixed",
|
|
1824
|
+
"pointer-events: none",
|
|
1825
|
+
`left: ${rect.left}px`,
|
|
1826
|
+
`top: ${rect.top}px`,
|
|
1827
|
+
`width: ${rect.width}px`,
|
|
1828
|
+
`height: ${rect.height}px`,
|
|
1829
|
+
"border: 1.5px dashed rgba(194, 65, 12, 0.72)",
|
|
1830
|
+
"background: rgba(194, 65, 12, 0.04)",
|
|
1831
|
+
"border-radius: 6px"
|
|
1832
|
+
].join(";");
|
|
1833
|
+
|
|
1834
|
+
const badge = document.createElement("div");
|
|
1835
|
+
const badgeTop = rect.top < 26 ? "4px" : "-22px";
|
|
1836
|
+
badge.style.cssText = [
|
|
1837
|
+
"position: absolute",
|
|
1838
|
+
`top: ${badgeTop}`,
|
|
1839
|
+
"right: -1px",
|
|
1840
|
+
"display: inline-flex",
|
|
1841
|
+
"align-items: center",
|
|
1842
|
+
"gap: 4px",
|
|
1843
|
+
"padding: 2px 6px",
|
|
1844
|
+
"border-radius: 9999px",
|
|
1845
|
+
"background: #c2410c",
|
|
1846
|
+
"color: #faf9f6",
|
|
1847
|
+
"border: 1px solid #faf9f6",
|
|
1848
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1849
|
+
"font-size: 10px",
|
|
1850
|
+
"font-weight: 700",
|
|
1851
|
+
"font-variant-numeric: tabular-nums",
|
|
1852
|
+
"line-height: 1.2",
|
|
1853
|
+
"max-width: 160px",
|
|
1854
|
+
"overflow: hidden",
|
|
1855
|
+
"text-overflow: ellipsis",
|
|
1856
|
+
"white-space: nowrap",
|
|
1857
|
+
"box-shadow: 0 4px 10px -2px rgba(17, 19, 24, 0.25)"
|
|
1858
|
+
].join(";");
|
|
1859
|
+
badge.textContent = `#${index + 1} ${entry.selector}`;
|
|
1860
|
+
|
|
1861
|
+
markerFrame.appendChild(badge);
|
|
1862
|
+
this.pinnedMarkersContainerEl?.appendChild(markerFrame);
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1703
1866
|
showExternalPreview(el ) {
|
|
1704
1867
|
if (typeof document === "undefined" || !document.body) return;
|
|
1705
1868
|
if (!el || this.active) {
|
|
@@ -1743,20 +1906,58 @@
|
|
|
1743
1906
|
this.previewOverlayEl = null;
|
|
1744
1907
|
}
|
|
1745
1908
|
|
|
1746
|
-
cycleDepth(delta ) {
|
|
1909
|
+
cycleDepth(delta , revealStack = true) {
|
|
1747
1910
|
if (!this.active || this.candidateStack.length <= 1) return;
|
|
1911
|
+
|
|
1912
|
+
const wasScrubbing = this.isScrubbingLayers;
|
|
1913
|
+
if (revealStack) {
|
|
1914
|
+
this.isScrubbingLayers = true;
|
|
1915
|
+
this.scrubOriginX = this.lastPointerX;
|
|
1916
|
+
this.scrubOriginY = this.lastPointerY;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1748
1919
|
const next = Math.max(
|
|
1749
1920
|
0,
|
|
1750
1921
|
Math.min(this.candidateStack.length - 1, this.activeCandidateIndex + delta)
|
|
1751
1922
|
);
|
|
1923
|
+
|
|
1752
1924
|
if (next !== this.activeCandidateIndex) {
|
|
1753
1925
|
this.activeCandidateIndex = next;
|
|
1754
1926
|
this.updateOverlayPosition();
|
|
1755
|
-
if (this.anchored) {
|
|
1756
|
-
this.renderLayerPopover();
|
|
1757
|
-
}
|
|
1758
1927
|
this.notifyStateChange();
|
|
1928
|
+
} else if (!wasScrubbing && this.isScrubbingLayers) {
|
|
1929
|
+
this.updateOverlayPosition();
|
|
1930
|
+
this.triggerHudBoundaryNudge(delta < 0 ? -3 : 3);
|
|
1931
|
+
this.notifyStateChange();
|
|
1932
|
+
} else {
|
|
1933
|
+
this.triggerHudBoundaryNudge(delta < 0 ? -3 : 3);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
clearTimers() {
|
|
1938
|
+
if (this.pulseTimer !== null) {
|
|
1939
|
+
clearTimeout(this.pulseTimer);
|
|
1940
|
+
this.pulseTimer = null;
|
|
1941
|
+
}
|
|
1942
|
+
if (this.nudgeTimer !== null) {
|
|
1943
|
+
clearTimeout(this.nudgeTimer);
|
|
1944
|
+
this.nudgeTimer = null;
|
|
1945
|
+
}
|
|
1946
|
+
if (this.toastTimer !== null) {
|
|
1947
|
+
clearTimeout(this.toastTimer);
|
|
1948
|
+
this.toastTimer = null;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
findPinnedIndex(el ) {
|
|
1953
|
+
if (!this.callbacks.getPinnedElements) return null;
|
|
1954
|
+
const pinned = this.callbacks.getPinnedElements();
|
|
1955
|
+
for (let i = 0; i < pinned.length; i += 1) {
|
|
1956
|
+
if (pinned[i].element === el) {
|
|
1957
|
+
return { index: i, entry: pinned[i] };
|
|
1958
|
+
}
|
|
1759
1959
|
}
|
|
1960
|
+
return null;
|
|
1760
1961
|
}
|
|
1761
1962
|
|
|
1762
1963
|
notifyStateChange() {
|
|
@@ -1767,16 +1968,27 @@
|
|
|
1767
1968
|
: [];
|
|
1768
1969
|
this.callbacks.onStateChange({
|
|
1769
1970
|
active: this.active,
|
|
1770
|
-
anchored:
|
|
1971
|
+
anchored: false,
|
|
1972
|
+
scrubbing: this.isScrubbingLayers,
|
|
1771
1973
|
activeCandidate,
|
|
1772
1974
|
candidateStack: [...this.candidateStack],
|
|
1773
|
-
ancestors
|
|
1975
|
+
ancestors,
|
|
1976
|
+
lastAction: this.lastAction
|
|
1774
1977
|
});
|
|
1775
1978
|
}
|
|
1776
1979
|
|
|
1777
1980
|
mountSelectionUi() {
|
|
1778
1981
|
if (typeof document === "undefined" || !document.body) return;
|
|
1779
1982
|
|
|
1983
|
+
const pinnedMarkers = document.createElement("div");
|
|
1984
|
+
pinnedMarkers.setAttribute("data-context-drop-ui", "pinned-markers");
|
|
1985
|
+
pinnedMarkers.style.cssText = [
|
|
1986
|
+
"position: fixed",
|
|
1987
|
+
"inset: 0",
|
|
1988
|
+
"pointer-events: none",
|
|
1989
|
+
"z-index: 2147483643"
|
|
1990
|
+
].join(";");
|
|
1991
|
+
|
|
1780
1992
|
// Secondary ghost outline showing the innermost leaf element when cycling up to parent/overlapping layers
|
|
1781
1993
|
const leafOutline = document.createElement("div");
|
|
1782
1994
|
leafOutline.setAttribute("data-context-drop-ui", "leaf-outline");
|
|
@@ -1801,40 +2013,36 @@
|
|
|
1801
2013
|
"background: rgba(29, 78, 216, 0.10)",
|
|
1802
2014
|
"border-radius: 6px",
|
|
1803
2015
|
"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)"
|
|
2016
|
+
"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
2017
|
].join(";");
|
|
1806
2018
|
|
|
1807
|
-
// Floating HUD
|
|
1808
|
-
const
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
"position:
|
|
1812
|
-
"
|
|
1813
|
-
"left: -2px",
|
|
2019
|
+
// Viewport-clamped Floating HUD (Compact 2-line coach on hover, inline 5-row wheel-scrubbed stack on scroll)
|
|
2020
|
+
const hud = document.createElement("div");
|
|
2021
|
+
hud.setAttribute("data-context-drop-ui", "label");
|
|
2022
|
+
hud.style.cssText = [
|
|
2023
|
+
"position: fixed",
|
|
2024
|
+
"z-index: 2147483646",
|
|
1814
2025
|
"background: #111318",
|
|
1815
2026
|
"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",
|
|
2027
|
+
"border: 1px solid rgba(250, 249, 246, 0.16)",
|
|
2028
|
+
"border-radius: 10px",
|
|
1823
2029
|
"pointer-events: none",
|
|
1824
|
-
"display:
|
|
1825
|
-
"
|
|
1826
|
-
"
|
|
1827
|
-
"
|
|
2030
|
+
"display: none",
|
|
2031
|
+
"overflow: hidden",
|
|
2032
|
+
"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
2033
|
+
"font-size: 11.5px",
|
|
2034
|
+
"line-height: 1.35",
|
|
2035
|
+
"box-shadow: 0 16px 34px -8px rgba(17, 19, 24, 0.40), 0 6px 14px -4px rgba(17, 19, 24, 0.22)",
|
|
2036
|
+
"transition: transform 0.12s cubic-bezier(0.22, 1, 0.36, 1)"
|
|
1828
2037
|
].join(";");
|
|
1829
|
-
overlay.appendChild(label);
|
|
1830
2038
|
|
|
1831
|
-
// Floating Pin marker that follows the pointer
|
|
2039
|
+
// Floating Pin marker that follows the pointer
|
|
1832
2040
|
const pinMarker = document.createElement("div");
|
|
1833
2041
|
pinMarker.setAttribute("data-context-drop-ui", "pin-marker");
|
|
1834
2042
|
pinMarker.style.cssText = [
|
|
1835
2043
|
"position: fixed",
|
|
1836
2044
|
"pointer-events: none",
|
|
1837
|
-
"z-index:
|
|
2045
|
+
"z-index: 2147483647",
|
|
1838
2046
|
"width: 28px",
|
|
1839
2047
|
"height: 28px",
|
|
1840
2048
|
"margin-left: -6px",
|
|
@@ -1851,55 +2059,68 @@
|
|
|
1851
2059
|
].join(";");
|
|
1852
2060
|
pinMarker.innerHTML = ICON_PIN;
|
|
1853
2061
|
|
|
1854
|
-
//
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1857
|
-
|
|
2062
|
+
// Tactile floating confirmation pill near cursor on pin / unpin
|
|
2063
|
+
const toast = document.createElement("div");
|
|
2064
|
+
toast.setAttribute("data-context-drop-ui", "pin-toast");
|
|
2065
|
+
toast.style.cssText = [
|
|
1858
2066
|
"position: fixed",
|
|
2067
|
+
"pointer-events: none",
|
|
1859
2068
|
"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
2069
|
"display: none",
|
|
1870
|
-
"
|
|
1871
|
-
"
|
|
2070
|
+
"align-items: center",
|
|
2071
|
+
"gap: 6px",
|
|
2072
|
+
"padding: 6px 10px",
|
|
2073
|
+
"border-radius: 9999px",
|
|
2074
|
+
"background: #111318",
|
|
2075
|
+
"color: #faf9f6",
|
|
2076
|
+
"border: 1px solid rgba(250, 249, 246, 0.18)",
|
|
2077
|
+
"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
2078
|
+
"font-size: 11.5px",
|
|
2079
|
+
"font-weight: 500",
|
|
2080
|
+
"white-space: nowrap",
|
|
2081
|
+
"box-shadow: 0 12px 24px -6px rgba(17, 19, 24, 0.34)"
|
|
1872
2082
|
].join(";");
|
|
1873
2083
|
|
|
2084
|
+
document.body.appendChild(pinnedMarkers);
|
|
1874
2085
|
document.body.appendChild(leafOutline);
|
|
1875
2086
|
document.body.appendChild(overlay);
|
|
2087
|
+
document.body.appendChild(hud);
|
|
1876
2088
|
document.body.appendChild(pinMarker);
|
|
1877
|
-
document.body.appendChild(
|
|
2089
|
+
document.body.appendChild(toast);
|
|
1878
2090
|
|
|
2091
|
+
this.pinnedMarkersContainerEl = pinnedMarkers;
|
|
1879
2092
|
this.leafOutlineEl = leafOutline;
|
|
1880
2093
|
this.overlayEl = overlay;
|
|
1881
|
-
this.
|
|
2094
|
+
this.hudEl = hud;
|
|
1882
2095
|
this.pinMarkerEl = pinMarker;
|
|
1883
|
-
this.
|
|
2096
|
+
this.toastEl = toast;
|
|
1884
2097
|
}
|
|
1885
2098
|
|
|
1886
2099
|
unmountSelectionUi() {
|
|
1887
|
-
for (const el of [
|
|
2100
|
+
for (const el of [
|
|
2101
|
+
this.pinnedMarkersContainerEl,
|
|
2102
|
+
this.leafOutlineEl,
|
|
2103
|
+
this.overlayEl,
|
|
2104
|
+
this.hudEl,
|
|
2105
|
+
this.pinMarkerEl,
|
|
2106
|
+
this.toastEl
|
|
2107
|
+
]) {
|
|
1888
2108
|
if (el && el.parentNode) {
|
|
1889
2109
|
el.parentNode.removeChild(el);
|
|
1890
2110
|
}
|
|
1891
2111
|
}
|
|
2112
|
+
this.pinnedMarkersContainerEl = null;
|
|
1892
2113
|
this.leafOutlineEl = null;
|
|
1893
2114
|
this.overlayEl = null;
|
|
1894
|
-
this.
|
|
2115
|
+
this.hudEl = null;
|
|
1895
2116
|
this.pinMarkerEl = null;
|
|
1896
|
-
this.
|
|
2117
|
+
this.toastEl = null;
|
|
1897
2118
|
}
|
|
1898
2119
|
|
|
1899
2120
|
isInternalUiEvent(event ) {
|
|
1900
2121
|
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
1901
2122
|
for (const node of path) {
|
|
1902
|
-
if (node
|
|
2123
|
+
if (isDomElementNode(node)) {
|
|
1903
2124
|
if (
|
|
1904
2125
|
node.tagName.toLowerCase() === "context-drop-widget" ||
|
|
1905
2126
|
node.hasAttribute("data-context-drop-ui") ||
|
|
@@ -1910,7 +2131,7 @@
|
|
|
1910
2131
|
}
|
|
1911
2132
|
}
|
|
1912
2133
|
}
|
|
1913
|
-
const rawTarget = event.target
|
|
2134
|
+
const rawTarget = isDomElementNode(event.target) ? event.target : null;
|
|
1914
2135
|
if (
|
|
1915
2136
|
rawTarget &&
|
|
1916
2137
|
typeof rawTarget.closest === "function" &&
|
|
@@ -1927,7 +2148,7 @@
|
|
|
1927
2148
|
try {
|
|
1928
2149
|
const fromPoint = document.elementsFromPoint(clientX, clientY);
|
|
1929
2150
|
for (const el of fromPoint) {
|
|
1930
|
-
if (el
|
|
2151
|
+
if (isDomElementNode(el)) {
|
|
1931
2152
|
results.push(el);
|
|
1932
2153
|
}
|
|
1933
2154
|
}
|
|
@@ -1937,12 +2158,12 @@
|
|
|
1937
2158
|
}
|
|
1938
2159
|
if (event && typeof event.composedPath === "function") {
|
|
1939
2160
|
for (const node of event.composedPath()) {
|
|
1940
|
-
if (node
|
|
2161
|
+
if (isDomElementNode(node) && !results.includes(node)) {
|
|
1941
2162
|
results.push(node);
|
|
1942
2163
|
}
|
|
1943
2164
|
}
|
|
1944
2165
|
}
|
|
1945
|
-
if (event && event.target
|
|
2166
|
+
if (event && isDomElementNode(event.target) && !results.includes(event.target)) {
|
|
1946
2167
|
results.unshift(event.target);
|
|
1947
2168
|
}
|
|
1948
2169
|
return results;
|
|
@@ -1957,17 +2178,39 @@
|
|
|
1957
2178
|
this.leafElement = null;
|
|
1958
2179
|
this.candidateStack = [];
|
|
1959
2180
|
this.activeCandidateIndex = 0;
|
|
2181
|
+
this.isScrubbingLayers = false;
|
|
1960
2182
|
return;
|
|
1961
2183
|
}
|
|
1962
2184
|
|
|
1963
|
-
// Preserve depth
|
|
2185
|
+
// Preserve depth & inline stack when pointer stays inside the exact same primary leaf element
|
|
1964
2186
|
if (this.leafElement === primary && this.candidateStack.length > 0) {
|
|
1965
2187
|
return;
|
|
1966
2188
|
}
|
|
1967
2189
|
|
|
2190
|
+
// Pointer-jitter lock: if user scrubbed to a specific layer and nudges the mouse slightly (<=28px)
|
|
2191
|
+
// across child boundaries inside that selected element right before clicking, keep it locked.
|
|
2192
|
+
if (this.isScrubbingLayers && this.candidateStack.length > 0) {
|
|
2193
|
+
const lockedCandidate = this.getActiveCandidate();
|
|
2194
|
+
const travel = Math.hypot(clientX - this.scrubOriginX, clientY - this.scrubOriginY);
|
|
2195
|
+
if (
|
|
2196
|
+
lockedCandidate &&
|
|
2197
|
+
travel <= SCRUB_JITTER_LOCK_PX &&
|
|
2198
|
+
(pointElements.includes(lockedCandidate.element) ||
|
|
2199
|
+
isPointInsideRect(clientX, clientY, lockedCandidate.element.getBoundingClientRect()))
|
|
2200
|
+
) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
|
|
1968
2205
|
this.leafElement = primary;
|
|
1969
2206
|
this.candidateStack = resolveCandidateStack(primary, pointElements, excluded, 10);
|
|
1970
2207
|
this.activeCandidateIndex = 0;
|
|
2208
|
+
this.isScrubbingLayers = false;
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
handleViewportScrollOrResize() {
|
|
2212
|
+
this.refreshPinnedMarkers();
|
|
2213
|
+
this.updateOverlayPosition();
|
|
1971
2214
|
}
|
|
1972
2215
|
|
|
1973
2216
|
handleMouseMove(event ) {
|
|
@@ -1976,12 +2219,9 @@
|
|
|
1976
2219
|
this.lastPointerX = event.clientX;
|
|
1977
2220
|
this.lastPointerY = event.clientY;
|
|
1978
2221
|
|
|
1979
|
-
if (this.anchored) {
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
2222
|
if (this.isInternalUiEvent(event)) {
|
|
1984
2223
|
if (this.overlayEl) this.overlayEl.style.display = "none";
|
|
2224
|
+
if (this.hudEl) this.hudEl.style.display = "none";
|
|
1985
2225
|
if (this.leafOutlineEl) this.leafOutlineEl.style.display = "none";
|
|
1986
2226
|
if (this.pinMarkerEl) this.pinMarkerEl.style.display = "none";
|
|
1987
2227
|
return;
|
|
@@ -1998,484 +2238,697 @@
|
|
|
1998
2238
|
this.notifyStateChange();
|
|
1999
2239
|
}
|
|
2000
2240
|
|
|
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
|
-
}
|
|
2241
|
+
createSpanEl(text ) {
|
|
2242
|
+
const span = document.createElement("span");
|
|
2243
|
+
span.textContent = text;
|
|
2244
|
+
return span;
|
|
2245
|
+
}
|
|
2016
2246
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2247
|
+
createKbdEl(text ) {
|
|
2248
|
+
const kbd = document.createElement("kbd");
|
|
2249
|
+
kbd.textContent = text;
|
|
2250
|
+
kbd.style.cssText = [
|
|
2251
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2252
|
+
"font-size: 10px",
|
|
2253
|
+
"font-weight: 600",
|
|
2254
|
+
"line-height: 1.1",
|
|
2255
|
+
"padding: 1px 4px",
|
|
2256
|
+
"border-radius: 4px",
|
|
2257
|
+
"background: rgba(250, 249, 246, 0.14)",
|
|
2258
|
+
"border: 1px solid rgba(250, 249, 246, 0.24)",
|
|
2259
|
+
"color: #faf9f6"
|
|
2260
|
+
].join(";");
|
|
2261
|
+
return kbd;
|
|
2262
|
+
}
|
|
2022
2263
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2264
|
+
renderCompactHudContent(
|
|
2265
|
+
currentCandidate ,
|
|
2266
|
+
rect
|
|
2267
|
+
) {
|
|
2268
|
+
if (!this.hudEl) return;
|
|
2269
|
+
this.hudEl.innerHTML = "";
|
|
2270
|
+
this.hudEl.style.width = "auto";
|
|
2271
|
+
this.hudEl.style.maxWidth = "min(440px, calc(100vw - 20px))";
|
|
2031
2272
|
|
|
2032
2273
|
const total = this.candidateStack.length;
|
|
2033
2274
|
const pos = this.activeCandidateIndex + 1;
|
|
2034
2275
|
const dims = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2276
|
+
const pinnedInfo = this.findPinnedIndex(currentCandidate.element);
|
|
2277
|
+
const hasOverlap = this.candidateStack.some((c) => c.relation === "overlap");
|
|
2037
2278
|
|
|
2038
|
-
//
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2279
|
+
// Top Row: Identity + Dimensions + Layer Count
|
|
2280
|
+
const topRow = document.createElement("div");
|
|
2281
|
+
topRow.style.cssText = [
|
|
2282
|
+
"display: flex",
|
|
2283
|
+
"align-items: center",
|
|
2284
|
+
"gap: 6px",
|
|
2285
|
+
"padding: 6px 9px 5px",
|
|
2286
|
+
"white-space: nowrap"
|
|
2287
|
+
].join(";");
|
|
2288
|
+
|
|
2289
|
+
if (pinnedInfo) {
|
|
2290
|
+
const pinnedPill = document.createElement("span");
|
|
2291
|
+
pinnedPill.textContent = `#${pinnedInfo.index + 1} Pinned`;
|
|
2292
|
+
pinnedPill.style.cssText = [
|
|
2293
|
+
"padding: 1px 5px",
|
|
2294
|
+
"border-radius: 4px",
|
|
2295
|
+
"background: #c2410c",
|
|
2296
|
+
"color: #faf9f6",
|
|
2297
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2298
|
+
"font-size: 10px",
|
|
2299
|
+
"font-weight: 700",
|
|
2300
|
+
"font-variant-numeric: tabular-nums",
|
|
2301
|
+
"flex-shrink: 0"
|
|
2302
|
+
].join(";");
|
|
2303
|
+
topRow.appendChild(pinnedPill);
|
|
2050
2304
|
}
|
|
2051
|
-
}
|
|
2052
2305
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2306
|
+
const selectorSpan = document.createElement("span");
|
|
2307
|
+
selectorSpan.textContent = formatCandidateLabel(
|
|
2308
|
+
currentCandidate.tagName,
|
|
2309
|
+
currentCandidate.selector
|
|
2310
|
+
);
|
|
2311
|
+
selectorSpan.style.cssText = [
|
|
2312
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2313
|
+
"font-size: 11.5px",
|
|
2314
|
+
"font-weight: 600",
|
|
2315
|
+
"color: #faf9f6",
|
|
2316
|
+
"max-width: 230px",
|
|
2317
|
+
"overflow: hidden",
|
|
2318
|
+
"text-overflow: ellipsis",
|
|
2319
|
+
"white-space: nowrap"
|
|
2320
|
+
].join(";");
|
|
2321
|
+
topRow.appendChild(selectorSpan);
|
|
2055
2322
|
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2323
|
+
const dimsSpan = document.createElement("span");
|
|
2324
|
+
dimsSpan.textContent = dims;
|
|
2325
|
+
dimsSpan.style.cssText = [
|
|
2326
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2327
|
+
"font-size: 10.5px",
|
|
2328
|
+
"font-variant-numeric: tabular-nums",
|
|
2329
|
+
"color: #cbd5e1",
|
|
2330
|
+
"flex-shrink: 0"
|
|
2331
|
+
].join(";");
|
|
2332
|
+
topRow.appendChild(dimsSpan);
|
|
2060
2333
|
|
|
2061
|
-
if (
|
|
2062
|
-
|
|
2334
|
+
if (total > 1) {
|
|
2335
|
+
const layerPill = document.createElement("span");
|
|
2336
|
+
layerPill.style.cssText = [
|
|
2337
|
+
"display: inline-flex",
|
|
2338
|
+
"align-items: center",
|
|
2339
|
+
"gap: 3px",
|
|
2340
|
+
"padding: 1px 6px",
|
|
2341
|
+
"border-radius: 9999px",
|
|
2342
|
+
"background: rgba(29, 78, 216, 0.36)",
|
|
2343
|
+
"border: 1px solid rgba(96, 165, 250, 0.45)",
|
|
2344
|
+
"color: #dbeafe",
|
|
2345
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2346
|
+
"font-size: 10px",
|
|
2347
|
+
"font-weight: 600",
|
|
2348
|
+
"font-variant-numeric: tabular-nums",
|
|
2349
|
+
"flex-shrink: 0"
|
|
2350
|
+
].join(";");
|
|
2351
|
+
const iconWrap = document.createElement("span");
|
|
2352
|
+
iconWrap.style.cssText = "display: inline-flex; width: 11px; height: 11px; align-items: center;";
|
|
2353
|
+
iconWrap.innerHTML = ICON_LAYERS;
|
|
2354
|
+
const countText = document.createElement("span");
|
|
2355
|
+
countText.textContent = `${pos}/${total}`;
|
|
2356
|
+
layerPill.appendChild(iconWrap);
|
|
2357
|
+
layerPill.appendChild(countText);
|
|
2358
|
+
topRow.appendChild(layerPill);
|
|
2063
2359
|
}
|
|
2064
2360
|
|
|
2065
|
-
|
|
2066
|
-
event.stopPropagation();
|
|
2361
|
+
this.hudEl.appendChild(topRow);
|
|
2067
2362
|
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2363
|
+
// Bottom Row: Action Coaching Strip
|
|
2364
|
+
const coachRow = document.createElement("div");
|
|
2365
|
+
coachRow.style.cssText = [
|
|
2366
|
+
"display: flex",
|
|
2367
|
+
"align-items: center",
|
|
2368
|
+
"gap: 8px",
|
|
2369
|
+
"padding: 4px 9px 5px",
|
|
2370
|
+
"background: rgba(250, 249, 246, 0.05)",
|
|
2371
|
+
"border-top: 1px solid rgba(250, 249, 246, 0.10)",
|
|
2372
|
+
"font-size: 10.5px",
|
|
2373
|
+
"color: #cbd5e1",
|
|
2374
|
+
"white-space: nowrap"
|
|
2375
|
+
].join(";");
|
|
2376
|
+
|
|
2377
|
+
const clickHint = document.createElement("span");
|
|
2378
|
+
const clickStrong = document.createElement("strong");
|
|
2379
|
+
clickStrong.style.cssText = pinnedInfo
|
|
2380
|
+
? "color: #ffedd5; font-weight: 600;"
|
|
2381
|
+
: "color: #faf9f6; font-weight: 600;";
|
|
2382
|
+
clickStrong.textContent = "Click";
|
|
2383
|
+
clickHint.appendChild(clickStrong);
|
|
2384
|
+
clickHint.appendChild(this.createSpanEl(pinnedInfo ? " to unpin" : " to pin"));
|
|
2385
|
+
coachRow.appendChild(clickHint);
|
|
2386
|
+
|
|
2387
|
+
if (total > 1) {
|
|
2388
|
+
const scrollHint = document.createElement("span");
|
|
2389
|
+
scrollHint.style.cssText = "display: inline-flex; align-items: center; gap: 3px;";
|
|
2390
|
+
const wheelIcon = document.createElement("span");
|
|
2391
|
+
wheelIcon.style.cssText = "display: inline-flex; color: #dbeafe;";
|
|
2392
|
+
wheelIcon.innerHTML = ICON_SCROLL_VERTICAL;
|
|
2393
|
+
const scrollStrong = document.createElement("strong");
|
|
2394
|
+
scrollStrong.style.cssText = hasOverlap
|
|
2395
|
+
? "color: #dbeafe; font-weight: 600;"
|
|
2396
|
+
: "color: #faf9f6; font-weight: 600;";
|
|
2397
|
+
scrollStrong.textContent = "Scroll wheel";
|
|
2398
|
+
scrollHint.appendChild(wheelIcon);
|
|
2399
|
+
scrollHint.appendChild(scrollStrong);
|
|
2400
|
+
scrollHint.appendChild(
|
|
2401
|
+
this.createSpanEl(hasOverlap ? " for element behind" : ` for ${total} layers`)
|
|
2402
|
+
);
|
|
2403
|
+
coachRow.appendChild(scrollHint);
|
|
2073
2404
|
}
|
|
2074
|
-
}
|
|
2075
2405
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
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);
|
|
2106
|
-
|
|
2107
|
-
const activeCandidate = this.getActiveCandidate();
|
|
2108
|
-
if (!activeCandidate) return;
|
|
2109
|
-
|
|
2110
|
-
// Fast-path: Shift+Click or single-layer target pins immediately
|
|
2111
|
-
if (event.shiftKey || this.candidateStack.length === 1) {
|
|
2112
|
-
this.selectElementDirectly(activeCandidate.element);
|
|
2113
|
-
return;
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
// Otherwise anchor the floating pin and open the Layer & Hierarchy Disambiguation Popover
|
|
2117
|
-
this.anchored = true;
|
|
2118
|
-
if (this.pinMarkerEl) {
|
|
2119
|
-
this.pinMarkerEl.style.display = "inline-flex";
|
|
2120
|
-
this.pinMarkerEl.style.left = `${this.anchorX}px`;
|
|
2121
|
-
this.pinMarkerEl.style.top = `${this.anchorY}px`;
|
|
2122
|
-
this.pinMarkerEl.style.transform = "scale(1.08)";
|
|
2123
|
-
}
|
|
2124
|
-
this.updateOverlayPosition();
|
|
2125
|
-
this.renderLayerPopover();
|
|
2126
|
-
this.notifyStateChange();
|
|
2127
|
-
}
|
|
2406
|
+
const escHint = document.createElement("span");
|
|
2407
|
+
escHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2408
|
+
escHint.appendChild(this.createKbdEl("Esc"));
|
|
2409
|
+
escHint.appendChild(this.createSpanEl("done"));
|
|
2410
|
+
coachRow.appendChild(escHint);
|
|
2128
2411
|
|
|
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();
|
|
2412
|
+
this.hudEl.appendChild(coachRow);
|
|
2141
2413
|
}
|
|
2142
2414
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2415
|
+
renderScrubbingHudContent(
|
|
2416
|
+
currentCandidate ,
|
|
2417
|
+
rect
|
|
2418
|
+
) {
|
|
2419
|
+
if (!this.hudEl) return;
|
|
2420
|
+
this.hudEl.innerHTML = "";
|
|
2421
|
+
this.hudEl.style.width = "320px";
|
|
2422
|
+
this.hudEl.style.maxWidth = "calc(100vw - 20px)";
|
|
2147
2423
|
|
|
2148
|
-
this.
|
|
2149
|
-
this.
|
|
2424
|
+
const total = this.candidateStack.length;
|
|
2425
|
+
const pos = this.activeCandidateIndex + 1;
|
|
2150
2426
|
|
|
2151
|
-
// Header
|
|
2427
|
+
// Header Strip
|
|
2152
2428
|
const header = document.createElement("div");
|
|
2153
2429
|
header.style.cssText = [
|
|
2154
2430
|
"display: flex",
|
|
2155
2431
|
"align-items: center",
|
|
2156
2432
|
"justify-content: space-between",
|
|
2157
2433
|
"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"
|
|
2191
|
-
].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"
|
|
2434
|
+
"padding: 6px 10px",
|
|
2435
|
+
"background: rgba(250, 249, 246, 0.05)",
|
|
2436
|
+
"border-bottom: 1px solid rgba(250, 249, 246, 0.12)"
|
|
2226
2437
|
].join(";");
|
|
2227
|
-
closeBtn.innerHTML = ICON_CLOSE;
|
|
2228
|
-
closeBtn.addEventListener("click", (ev) => {
|
|
2229
|
-
ev.stopPropagation();
|
|
2230
|
-
this.closeLayerPopover();
|
|
2231
|
-
});
|
|
2232
|
-
|
|
2233
|
-
headerActions.appendChild(stepDownBtn);
|
|
2234
|
-
headerActions.appendChild(stepUpBtn);
|
|
2235
|
-
headerActions.appendChild(closeBtn);
|
|
2236
|
-
header.appendChild(titleGroup);
|
|
2237
|
-
header.appendChild(headerActions);
|
|
2238
|
-
this.popoverEl.appendChild(header);
|
|
2239
|
-
|
|
2240
|
-
// Interactive DOM Breadcrumb Bar
|
|
2241
|
-
const ancestors = resolveAncestorChain(
|
|
2242
|
-
activeCandidate.element,
|
|
2243
|
-
this.callbacks.getExcludedSelectors(),
|
|
2244
|
-
6
|
|
2245
|
-
);
|
|
2246
|
-
if (ancestors.length > 0) {
|
|
2247
|
-
const breadcrumbBar = document.createElement("div");
|
|
2248
|
-
breadcrumbBar.setAttribute("data-context-drop-ui", "breadcrumb-bar");
|
|
2249
|
-
breadcrumbBar.style.cssText = [
|
|
2250
|
-
"display: flex",
|
|
2251
|
-
"align-items: center",
|
|
2252
|
-
"flex-wrap: wrap",
|
|
2253
|
-
"gap: 3px",
|
|
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
2438
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2439
|
+
const headerLeft = document.createElement("div");
|
|
2440
|
+
headerLeft.style.cssText =
|
|
2441
|
+
"display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: #faf9f6;";
|
|
2442
|
+
const layersIcon = document.createElement("span");
|
|
2443
|
+
layersIcon.style.cssText = "display: inline-flex; color: #60a5fa;";
|
|
2444
|
+
layersIcon.innerHTML = ICON_LAYERS;
|
|
2445
|
+
const headerTitle = document.createElement("span");
|
|
2446
|
+
headerTitle.textContent = "Select Layer";
|
|
2447
|
+
headerLeft.appendChild(layersIcon);
|
|
2448
|
+
headerLeft.appendChild(headerTitle);
|
|
2449
|
+
|
|
2450
|
+
const headerRight = document.createElement("div");
|
|
2451
|
+
headerRight.style.cssText =
|
|
2452
|
+
"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;";
|
|
2453
|
+
const wheelSpan = document.createElement("span");
|
|
2454
|
+
wheelSpan.style.cssText = "display: inline-flex; color: #dbeafe;";
|
|
2455
|
+
wheelSpan.innerHTML = ICON_SCROLL_VERTICAL;
|
|
2456
|
+
const ratioSpan = document.createElement("span");
|
|
2457
|
+
ratioSpan.textContent = `${pos}/${total}`;
|
|
2458
|
+
headerRight.appendChild(wheelSpan);
|
|
2459
|
+
headerRight.appendChild(ratioSpan);
|
|
2303
2460
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2461
|
+
header.appendChild(headerLeft);
|
|
2462
|
+
header.appendChild(headerRight);
|
|
2463
|
+
this.hudEl.appendChild(header);
|
|
2464
|
+
|
|
2465
|
+
// Non-scrolling Sliding Window of Layers (max 5 rows)
|
|
2466
|
+
const start =
|
|
2467
|
+
total <= MAX_VISIBLE_STACK_ROWS
|
|
2468
|
+
? 0
|
|
2469
|
+
: Math.max(0, Math.min(this.activeCandidateIndex - 2, total - MAX_VISIBLE_STACK_ROWS));
|
|
2470
|
+
const end = Math.min(total, start + MAX_VISIBLE_STACK_ROWS);
|
|
2471
|
+
|
|
2472
|
+
const listWrap = document.createElement("div");
|
|
2473
|
+
listWrap.setAttribute("data-context-drop-ui", "hud-layer-list");
|
|
2474
|
+
listWrap.style.cssText = [
|
|
2310
2475
|
"display: flex",
|
|
2311
2476
|
"flex-direction: column",
|
|
2312
|
-
"gap:
|
|
2477
|
+
"gap: 2px",
|
|
2478
|
+
"padding: 5px"
|
|
2313
2479
|
].join(";");
|
|
2314
2480
|
|
|
2481
|
+
if (start > 0) {
|
|
2482
|
+
const aboveHint = document.createElement("div");
|
|
2483
|
+
aboveHint.textContent = `${start} inner layer${start > 1 ? "s" : ""} above`;
|
|
2484
|
+
aboveHint.style.cssText =
|
|
2485
|
+
"font-size: 10px; color: #cbd5e1; padding: 1px 7px; font-variant-numeric: tabular-nums;";
|
|
2486
|
+
listWrap.appendChild(aboveHint);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2315
2489
|
const relationLabels = {
|
|
2316
2490
|
target: "Topmost",
|
|
2317
|
-
overlap: "
|
|
2491
|
+
overlap: "Behind",
|
|
2318
2492
|
child: "Child",
|
|
2319
2493
|
ancestor: "Parent"
|
|
2320
2494
|
};
|
|
2321
2495
|
|
|
2322
|
-
|
|
2496
|
+
for (let idx = start; idx < end; idx += 1) {
|
|
2497
|
+
const candidate = this.candidateStack[idx];
|
|
2323
2498
|
const isSelected = idx === this.activeCandidateIndex;
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2499
|
+
const candPinned = this.findPinnedIndex(candidate.element);
|
|
2500
|
+
|
|
2501
|
+
const row = document.createElement("div");
|
|
2326
2502
|
row.setAttribute("data-context-drop-layer-index", String(idx));
|
|
2503
|
+
if (isSelected) {
|
|
2504
|
+
row.setAttribute("data-selected", "true");
|
|
2505
|
+
}
|
|
2327
2506
|
row.style.cssText = [
|
|
2328
|
-
"appearance: none",
|
|
2329
|
-
"width: 100%",
|
|
2330
|
-
"text-align: left",
|
|
2331
2507
|
"display: flex",
|
|
2332
|
-
"
|
|
2333
|
-
"
|
|
2334
|
-
"
|
|
2335
|
-
"
|
|
2336
|
-
"border:
|
|
2337
|
-
"
|
|
2338
|
-
"
|
|
2339
|
-
"cursor: pointer",
|
|
2340
|
-
"transition: background-color 0.1s ease"
|
|
2508
|
+
"align-items: center",
|
|
2509
|
+
"justify-content: space-between",
|
|
2510
|
+
"gap: 6px",
|
|
2511
|
+
"padding: " + (isSelected ? "5px 7px" : "4px 7px"),
|
|
2512
|
+
"border-radius: 7px",
|
|
2513
|
+
"border: 1px solid " + (isSelected ? "#60a5fa" : "transparent"),
|
|
2514
|
+
"background: " + (isSelected ? "rgba(29, 78, 216, 0.34)" : "transparent")
|
|
2341
2515
|
].join(";");
|
|
2342
2516
|
|
|
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
2517
|
const leftGroup = document.createElement("div");
|
|
2347
|
-
leftGroup.style.cssText = "display: flex; align-items: center; gap:
|
|
2518
|
+
leftGroup.style.cssText = "display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1;";
|
|
2348
2519
|
|
|
2349
2520
|
const relBadge = document.createElement("span");
|
|
2350
2521
|
relBadge.textContent = relationLabels[candidate.relation] || "Layer";
|
|
2522
|
+
const relBg =
|
|
2523
|
+
candidate.relation === "target"
|
|
2524
|
+
? "rgba(255, 237, 213, 0.16)"
|
|
2525
|
+
: candidate.relation === "overlap"
|
|
2526
|
+
? "rgba(252, 231, 243, 0.20)"
|
|
2527
|
+
: "rgba(226, 232, 240, 0.14)";
|
|
2528
|
+
const relColor =
|
|
2529
|
+
candidate.relation === "target"
|
|
2530
|
+
? "#ffedd5"
|
|
2531
|
+
: candidate.relation === "overlap"
|
|
2532
|
+
? "#fee2e2"
|
|
2533
|
+
: "#cbd5e1";
|
|
2351
2534
|
relBadge.style.cssText = [
|
|
2352
|
-
"font-size:
|
|
2535
|
+
"font-size: 9.5px",
|
|
2353
2536
|
"font-weight: 600",
|
|
2354
2537
|
"padding: 1px 5px",
|
|
2355
2538
|
"border-radius: 4px",
|
|
2356
|
-
|
|
2357
|
-
|
|
2539
|
+
`background: ${relBg}`,
|
|
2540
|
+
`color: ${relColor}`,
|
|
2358
2541
|
"flex-shrink: 0"
|
|
2359
2542
|
].join(";");
|
|
2360
2543
|
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2544
|
+
const selText = document.createElement("span");
|
|
2545
|
+
selText.textContent = formatCandidateLabel(candidate.tagName, candidate.selector);
|
|
2546
|
+
selText.style.cssText = [
|
|
2364
2547
|
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2365
|
-
"font-size:
|
|
2366
|
-
"font-weight: 600",
|
|
2367
|
-
"color: #
|
|
2548
|
+
"font-size: 11px",
|
|
2549
|
+
"font-weight: " + (isSelected ? "600" : "500"),
|
|
2550
|
+
"color: " + (isSelected ? "#faf9f6" : "#e2e8f0"),
|
|
2368
2551
|
"overflow: hidden",
|
|
2369
2552
|
"text-overflow: ellipsis",
|
|
2370
2553
|
"white-space: nowrap"
|
|
2371
2554
|
].join(";");
|
|
2372
2555
|
|
|
2373
2556
|
leftGroup.appendChild(relBadge);
|
|
2374
|
-
leftGroup.appendChild(
|
|
2375
|
-
|
|
2376
|
-
const dimsSpan = document.createElement("span");
|
|
2377
|
-
dimsSpan.textContent = `${Math.round(candidate.rect.width)}×${Math.round(candidate.rect.height)}`;
|
|
2378
|
-
dimsSpan.style.cssText = [
|
|
2379
|
-
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2380
|
-
"font-size: 10.5px",
|
|
2381
|
-
"font-variant-numeric: tabular-nums",
|
|
2382
|
-
"color: #4b5262",
|
|
2383
|
-
"flex-shrink: 0"
|
|
2384
|
-
].join(";");
|
|
2557
|
+
leftGroup.appendChild(selText);
|
|
2385
2558
|
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
"font-
|
|
2395
|
-
"
|
|
2396
|
-
"
|
|
2397
|
-
"
|
|
2398
|
-
"white-space: nowrap",
|
|
2399
|
-
"padding-left: 2px"
|
|
2559
|
+
if (candPinned) {
|
|
2560
|
+
const pinTag = document.createElement("span");
|
|
2561
|
+
pinTag.textContent = `#${candPinned.index + 1}`;
|
|
2562
|
+
pinTag.style.cssText = [
|
|
2563
|
+
"padding: 0 4px",
|
|
2564
|
+
"border-radius: 4px",
|
|
2565
|
+
"background: #c2410c",
|
|
2566
|
+
"color: #faf9f6",
|
|
2567
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2568
|
+
"font-size: 9.5px",
|
|
2569
|
+
"font-weight: 700",
|
|
2570
|
+
"flex-shrink: 0"
|
|
2400
2571
|
].join(";");
|
|
2401
|
-
|
|
2572
|
+
leftGroup.appendChild(pinTag);
|
|
2402
2573
|
}
|
|
2403
2574
|
|
|
2404
|
-
row.
|
|
2405
|
-
if (this.activeCandidateIndex !== idx) {
|
|
2406
|
-
this.activeCandidateIndex = idx;
|
|
2407
|
-
this.updateOverlayPosition();
|
|
2408
|
-
this.notifyStateChange();
|
|
2409
|
-
}
|
|
2410
|
-
});
|
|
2575
|
+
row.appendChild(leftGroup);
|
|
2411
2576
|
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2577
|
+
if (isSelected) {
|
|
2578
|
+
const actionBadge = document.createElement("span");
|
|
2579
|
+
actionBadge.textContent = candPinned ? "Click unpin" : "Click to pin";
|
|
2580
|
+
actionBadge.style.cssText = [
|
|
2581
|
+
"padding: 1px 6px",
|
|
2582
|
+
"border-radius: 4px",
|
|
2583
|
+
"background: " + (candPinned ? "rgba(250, 249, 246, 0.18)" : "#c2410c"),
|
|
2584
|
+
"color: #faf9f6",
|
|
2585
|
+
"font-size: 10px",
|
|
2586
|
+
"font-weight: 600",
|
|
2587
|
+
"flex-shrink: 0"
|
|
2588
|
+
].join(";");
|
|
2589
|
+
row.appendChild(actionBadge);
|
|
2590
|
+
} else {
|
|
2591
|
+
const rowDims = document.createElement("span");
|
|
2592
|
+
rowDims.textContent = `${Math.round(candidate.rect.width)}×${Math.round(candidate.rect.height)}`;
|
|
2593
|
+
rowDims.style.cssText = [
|
|
2594
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
2595
|
+
"font-size: 10px",
|
|
2596
|
+
"font-variant-numeric: tabular-nums",
|
|
2597
|
+
"color: #cbd5e1",
|
|
2598
|
+
"flex-shrink: 0"
|
|
2599
|
+
].join(";");
|
|
2600
|
+
row.appendChild(rowDims);
|
|
2601
|
+
}
|
|
2416
2602
|
|
|
2417
|
-
|
|
2418
|
-
}
|
|
2603
|
+
listWrap.appendChild(row);
|
|
2604
|
+
}
|
|
2419
2605
|
|
|
2420
|
-
|
|
2606
|
+
if (end < total) {
|
|
2607
|
+
const belowHint = document.createElement("div");
|
|
2608
|
+
belowHint.textContent = `${total - end} parent layer${total - end > 1 ? "s" : ""} below`;
|
|
2609
|
+
belowHint.style.cssText =
|
|
2610
|
+
"font-size: 10px; color: #cbd5e1; padding: 1px 7px; font-variant-numeric: tabular-nums;";
|
|
2611
|
+
listWrap.appendChild(belowHint);
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
this.hudEl.appendChild(listWrap);
|
|
2421
2615
|
|
|
2422
|
-
// Footer
|
|
2616
|
+
// Footer Strip
|
|
2423
2617
|
const footer = document.createElement("div");
|
|
2424
2618
|
footer.style.cssText = [
|
|
2425
2619
|
"display: flex",
|
|
2426
2620
|
"align-items: center",
|
|
2427
2621
|
"justify-content: space-between",
|
|
2428
|
-
"
|
|
2429
|
-
"
|
|
2430
|
-
"
|
|
2622
|
+
"gap: 8px",
|
|
2623
|
+
"padding: 5px 10px",
|
|
2624
|
+
"background: rgba(250, 249, 246, 0.04)",
|
|
2625
|
+
"border-top: 1px solid rgba(250, 249, 246, 0.10)",
|
|
2626
|
+
"font-size: 10.5px",
|
|
2627
|
+
"color: #cbd5e1"
|
|
2431
2628
|
].join(";");
|
|
2432
2629
|
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2630
|
+
const dimsLabel = document.createElement("span");
|
|
2631
|
+
dimsLabel.textContent = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
|
|
2632
|
+
dimsLabel.style.cssText =
|
|
2633
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-variant-numeric: tabular-nums;";
|
|
2634
|
+
|
|
2635
|
+
const keysHint = document.createElement("span");
|
|
2636
|
+
keysHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2637
|
+
keysHint.appendChild(this.createKbdEl("Enter"));
|
|
2638
|
+
keysHint.appendChild(this.createSpanEl("pin · "));
|
|
2639
|
+
keysHint.appendChild(this.createKbdEl("Esc"));
|
|
2640
|
+
keysHint.appendChild(this.createSpanEl("done"));
|
|
2641
|
+
|
|
2642
|
+
footer.appendChild(dimsLabel);
|
|
2643
|
+
footer.appendChild(keysHint);
|
|
2644
|
+
this.hudEl.appendChild(footer);
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
positionHudElement(rect ) {
|
|
2648
|
+
if (!this.hudEl || typeof window === "undefined") return;
|
|
2649
|
+
|
|
2650
|
+
const vw = window.innerWidth || 1024;
|
|
2651
|
+
const vh = window.innerHeight || 768;
|
|
2652
|
+
const fallbackWidth = this.isScrubbingLayers ? 320 : 300;
|
|
2653
|
+
const visibleRows = Math.min(this.candidateStack.length, MAX_VISIBLE_STACK_ROWS);
|
|
2654
|
+
const fallbackHeight = this.isScrubbingLayers ? 66 + visibleRows * 30 : 54;
|
|
2655
|
+
|
|
2656
|
+
const hudWidth = (this.hudEl ).offsetWidth || fallbackWidth;
|
|
2657
|
+
const hudHeight = (this.hudEl ).offsetHeight || fallbackHeight;
|
|
2658
|
+
|
|
2659
|
+
const clampedLeft = Math.max(10, Math.min(rect.left, vw - hudWidth - 10));
|
|
2660
|
+
let top = rect.top - hudHeight - 8;
|
|
2661
|
+
|
|
2662
|
+
if (top < 10) {
|
|
2663
|
+
const belowTop = rect.top + rect.height + 8;
|
|
2664
|
+
if (belowTop + hudHeight <= vh - 10) {
|
|
2665
|
+
top = belowTop;
|
|
2666
|
+
} else {
|
|
2667
|
+
// Large container spanning viewport: place near top-left of visible area, stepping below cursor if close
|
|
2668
|
+
const insideTop = Math.max(10, rect.top + 8);
|
|
2669
|
+
if (
|
|
2670
|
+
Math.abs(this.lastPointerY - insideTop) < hudHeight + 18 &&
|
|
2671
|
+
this.lastPointerX < clampedLeft + hudWidth + 24
|
|
2672
|
+
) {
|
|
2673
|
+
top = Math.min(vh - hudHeight - 10, this.lastPointerY + 22);
|
|
2674
|
+
} else {
|
|
2675
|
+
top = insideTop;
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
this.hudEl.style.left = `${Math.round(clampedLeft)}px`;
|
|
2681
|
+
this.hudEl.style.top = `${Math.round(Math.max(10, top))}px`;
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
updateOverlayPosition() {
|
|
2685
|
+
if (!this.overlayEl || !this.hudEl) return;
|
|
2686
|
+
|
|
2687
|
+
const currentCandidate = this.getActiveCandidate();
|
|
2688
|
+
if (!currentCandidate) {
|
|
2689
|
+
this.overlayEl.style.display = "none";
|
|
2690
|
+
this.hudEl.style.display = "none";
|
|
2691
|
+
if (this.leafOutlineEl) this.leafOutlineEl.style.display = "none";
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
const rect = currentCandidate.element.getBoundingClientRect();
|
|
2696
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
2697
|
+
this.overlayEl.style.display = "none";
|
|
2698
|
+
this.hudEl.style.display = "none";
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
this.overlayEl.style.display = "block";
|
|
2703
|
+
this.overlayEl.style.left = `${rect.left}px`;
|
|
2704
|
+
this.overlayEl.style.top = `${rect.top}px`;
|
|
2705
|
+
this.overlayEl.style.width = `${rect.width}px`;
|
|
2706
|
+
this.overlayEl.style.height = `${rect.height}px`;
|
|
2707
|
+
|
|
2708
|
+
this.hudEl.style.display = "block";
|
|
2709
|
+
if (this.isScrubbingLayers && this.candidateStack.length > 1) {
|
|
2710
|
+
this.renderScrubbingHudContent(currentCandidate, rect);
|
|
2711
|
+
} else {
|
|
2712
|
+
this.renderCompactHudContent(currentCandidate, rect);
|
|
2713
|
+
}
|
|
2714
|
+
this.positionHudElement(rect);
|
|
2715
|
+
|
|
2716
|
+
// Show ghost leaf outline when inspecting an ancestor or overlapping layer
|
|
2717
|
+
if (this.leafOutlineEl) {
|
|
2718
|
+
if (
|
|
2719
|
+
this.activeCandidateIndex > 0 &&
|
|
2720
|
+
this.leafElement &&
|
|
2721
|
+
this.leafElement !== currentCandidate.element
|
|
2722
|
+
) {
|
|
2723
|
+
const leafRect = this.leafElement.getBoundingClientRect();
|
|
2724
|
+
this.leafOutlineEl.style.display = "block";
|
|
2725
|
+
this.leafOutlineEl.style.left = `${leafRect.left}px`;
|
|
2726
|
+
this.leafOutlineEl.style.top = `${leafRect.top}px`;
|
|
2727
|
+
this.leafOutlineEl.style.width = `${leafRect.width}px`;
|
|
2728
|
+
this.leafOutlineEl.style.height = `${leafRect.height}px`;
|
|
2729
|
+
} else {
|
|
2730
|
+
this.leafOutlineEl.style.display = "none";
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
triggerHudBoundaryNudge(offsetY ) {
|
|
2736
|
+
if (!this.hudEl) return;
|
|
2737
|
+
this.hudEl.style.transform = `translateY(${offsetY}px)`;
|
|
2738
|
+
if (this.nudgeTimer !== null) {
|
|
2739
|
+
clearTimeout(this.nudgeTimer);
|
|
2740
|
+
}
|
|
2741
|
+
this.nudgeTimer = setTimeout(() => {
|
|
2742
|
+
if (this.hudEl) {
|
|
2743
|
+
this.hudEl.style.transform = "translateY(0)";
|
|
2744
|
+
}
|
|
2745
|
+
this.nudgeTimer = null;
|
|
2746
|
+
}, 120);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
flashSelectionPulse(kind ) {
|
|
2750
|
+
if (!this.overlayEl) return;
|
|
2751
|
+
if (kind === "pinned") {
|
|
2752
|
+
this.overlayEl.style.borderColor = "#15803d";
|
|
2753
|
+
this.overlayEl.style.background = "rgba(21, 128, 61, 0.14)";
|
|
2754
|
+
} else {
|
|
2755
|
+
this.overlayEl.style.borderColor = "#c2410c";
|
|
2756
|
+
this.overlayEl.style.background = "rgba(194, 65, 12, 0.12)";
|
|
2757
|
+
}
|
|
2758
|
+
if (this.pulseTimer !== null) {
|
|
2759
|
+
clearTimeout(this.pulseTimer);
|
|
2760
|
+
}
|
|
2761
|
+
this.pulseTimer = setTimeout(() => {
|
|
2762
|
+
if (this.overlayEl) {
|
|
2763
|
+
this.overlayEl.style.borderColor = "#1d4ed8";
|
|
2764
|
+
this.overlayEl.style.background = "rgba(29, 78, 216, 0.10)";
|
|
2765
|
+
}
|
|
2766
|
+
this.pulseTimer = null;
|
|
2767
|
+
}, 280);
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
showCursorToast(selector , kind , x , y ) {
|
|
2771
|
+
if (!this.toastEl || typeof window === "undefined") return;
|
|
2772
|
+
this.toastEl.innerHTML = "";
|
|
2436
2773
|
|
|
2437
|
-
const
|
|
2438
|
-
|
|
2439
|
-
pinNowBtn.setAttribute("data-context-drop-ui", "confirm-pin-btn");
|
|
2440
|
-
pinNowBtn.style.cssText = [
|
|
2774
|
+
const iconBadge = document.createElement("span");
|
|
2775
|
+
iconBadge.style.cssText = [
|
|
2441
2776
|
"display: inline-flex",
|
|
2442
2777
|
"align-items: center",
|
|
2443
|
-
"
|
|
2444
|
-
"
|
|
2445
|
-
"
|
|
2446
|
-
"border:
|
|
2447
|
-
"background: #
|
|
2778
|
+
"justify-content: center",
|
|
2779
|
+
"width: 16px",
|
|
2780
|
+
"height: 16px",
|
|
2781
|
+
"border-radius: 9999px",
|
|
2782
|
+
"background: " + (kind === "pinned" ? "#15803d" : "#4b5262"),
|
|
2448
2783
|
"color: #faf9f6",
|
|
2449
|
-
"
|
|
2450
|
-
"font-weight: 600",
|
|
2451
|
-
"cursor: pointer"
|
|
2784
|
+
"flex-shrink: 0"
|
|
2452
2785
|
].join(";");
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
this.
|
|
2786
|
+
iconBadge.innerHTML = ICON_CHECK;
|
|
2787
|
+
this.toastEl.appendChild(iconBadge);
|
|
2788
|
+
|
|
2789
|
+
const primaryText = document.createElement("span");
|
|
2790
|
+
primaryText.textContent = kind === "pinned" ? "Pinned " : "Removed ";
|
|
2791
|
+
this.toastEl.appendChild(primaryText);
|
|
2792
|
+
|
|
2793
|
+
const monoSel = document.createElement("span");
|
|
2794
|
+
monoSel.textContent = selector;
|
|
2795
|
+
monoSel.style.cssText =
|
|
2796
|
+
"font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600; color: #faf9f6; max-width: 160px; overflow: hidden; text-overflow: ellipsis;";
|
|
2797
|
+
this.toastEl.appendChild(monoSel);
|
|
2798
|
+
|
|
2799
|
+
if (kind === "pinned") {
|
|
2800
|
+
const nextHint = document.createElement("span");
|
|
2801
|
+
nextHint.style.cssText =
|
|
2802
|
+
"display: inline-flex; align-items: center; gap: 4px; color: #cbd5e1; font-size: 10.5px; margin-left: 2px;";
|
|
2803
|
+
nextHint.appendChild(this.createSpanEl("· Click more or"));
|
|
2804
|
+
nextHint.appendChild(this.createKbdEl("Esc"));
|
|
2805
|
+
this.toastEl.appendChild(nextHint);
|
|
2806
|
+
}
|
|
2465
2807
|
|
|
2466
|
-
|
|
2808
|
+
this.toastEl.style.display = "inline-flex";
|
|
2467
2809
|
const vw = window.innerWidth || 1024;
|
|
2468
2810
|
const vh = window.innerHeight || 768;
|
|
2469
|
-
const
|
|
2470
|
-
const
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2811
|
+
const left = Math.max(10, Math.min(x + 14, vw - 310));
|
|
2812
|
+
const top = Math.max(10, Math.min(y + 16, vh - 44));
|
|
2813
|
+
this.toastEl.style.left = `${Math.round(left)}px`;
|
|
2814
|
+
this.toastEl.style.top = `${Math.round(top)}px`;
|
|
2815
|
+
|
|
2816
|
+
if (this.toastTimer !== null) {
|
|
2817
|
+
clearTimeout(this.toastTimer);
|
|
2818
|
+
}
|
|
2819
|
+
this.toastTimer = setTimeout(() => {
|
|
2820
|
+
if (this.toastEl) {
|
|
2821
|
+
this.toastEl.style.display = "none";
|
|
2822
|
+
}
|
|
2823
|
+
this.toastTimer = null;
|
|
2824
|
+
}, 1450);
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
commitCandidateSelection(el , x , y ) {
|
|
2828
|
+
const existingPinned = this.findPinnedIndex(el);
|
|
2829
|
+
if (existingPinned && this.callbacks.onUnselect) {
|
|
2830
|
+
this.callbacks.onUnselect(existingPinned.entry.clientRef, el);
|
|
2831
|
+
this.lastAction = { kind: "unpinned", selector: existingPinned.entry.selector };
|
|
2832
|
+
this.isScrubbingLayers = false;
|
|
2833
|
+
this.refreshPinnedMarkers();
|
|
2834
|
+
this.flashSelectionPulse("unpinned");
|
|
2835
|
+
this.showCursorToast(existingPinned.entry.selector, "unpinned", x, y);
|
|
2836
|
+
this.updateOverlayPosition();
|
|
2837
|
+
this.notifyStateChange();
|
|
2838
|
+
return;
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
const excluded = this.callbacks.getExcludedSelectors();
|
|
2842
|
+
const snapshot = captureElementSnapshot(el, excluded);
|
|
2843
|
+
if (!snapshot) return;
|
|
2844
|
+
|
|
2845
|
+
this.callbacks.onSelect(snapshot, el);
|
|
2846
|
+
this.lastAction = { kind: "pinned", selector: snapshot.selector };
|
|
2847
|
+
this.isScrubbingLayers = false;
|
|
2848
|
+
this.refreshPinnedMarkers();
|
|
2849
|
+
|
|
2850
|
+
if (!this.callbacks.canSelectMore()) {
|
|
2851
|
+
this.stop();
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
this.flashSelectionPulse("pinned");
|
|
2856
|
+
this.showCursorToast(snapshot.selector, "pinned", x, y);
|
|
2857
|
+
this.updateOverlayPosition();
|
|
2858
|
+
this.notifyStateChange();
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
handleWheelCapture(event ) {
|
|
2862
|
+
if (!this.active) return;
|
|
2863
|
+
if (this.isInternalUiEvent(event)) return;
|
|
2864
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
2865
|
+
|
|
2866
|
+
if (this.candidateStack.length <= 1) {
|
|
2867
|
+
return;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
event.preventDefault();
|
|
2871
|
+
event.stopPropagation();
|
|
2872
|
+
|
|
2873
|
+
const normalizedDelta = event.deltaMode === 1 ? event.deltaY * 32 : event.deltaY;
|
|
2874
|
+
if (normalizedDelta === 0) return;
|
|
2875
|
+
|
|
2876
|
+
// Reset accumulator immediately when the user reverses scroll direction
|
|
2877
|
+
if (this.wheelAccumulator * normalizedDelta < 0) {
|
|
2878
|
+
this.wheelAccumulator = 0;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
this.wheelAccumulator += normalizedDelta;
|
|
2882
|
+
if (Math.abs(this.wheelAccumulator) < WHEEL_STEP_THRESHOLD) {
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
const now = Date.now();
|
|
2887
|
+
if (now - this.lastWheelStepAt < WHEEL_STEP_COOLDOWN_MS) {
|
|
2888
|
+
this.wheelAccumulator = 0;
|
|
2889
|
+
return;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
const step = this.wheelAccumulator > 0 ? 1 : -1;
|
|
2893
|
+
this.wheelAccumulator = 0;
|
|
2894
|
+
this.lastWheelStepAt = now;
|
|
2895
|
+
this.cycleDepth(step, true);
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
handlePointerSuppression(event ) {
|
|
2899
|
+
if (!this.active) return;
|
|
2900
|
+
if (this.isInternalUiEvent(event)) {
|
|
2901
|
+
return;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
// Intercept host page pointer events in capture phase so links/buttons do not fire
|
|
2905
|
+
event.preventDefault();
|
|
2906
|
+
event.stopPropagation();
|
|
2907
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2908
|
+
event.stopImmediatePropagation();
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
handleClickCapture(event ) {
|
|
2913
|
+
if (!this.active) return;
|
|
2914
|
+
if (this.isInternalUiEvent(event)) {
|
|
2915
|
+
return;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
event.preventDefault();
|
|
2919
|
+
event.stopPropagation();
|
|
2920
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2921
|
+
event.stopImmediatePropagation();
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
this.lastPointerX = event.clientX;
|
|
2925
|
+
this.lastPointerY = event.clientY;
|
|
2926
|
+
this.updateCandidatesFromPoint(event.clientX, event.clientY, event);
|
|
2927
|
+
|
|
2928
|
+
const activeCandidate = this.getActiveCandidate();
|
|
2929
|
+
if (!activeCandidate) return;
|
|
2476
2930
|
|
|
2477
|
-
this.
|
|
2478
|
-
this.popoverEl.style.top = `${top}px`;
|
|
2931
|
+
this.commitCandidateSelection(activeCandidate.element, event.clientX, event.clientY);
|
|
2479
2932
|
}
|
|
2480
2933
|
|
|
2481
2934
|
handleKeyDown(event ) {
|
|
@@ -2484,25 +2937,21 @@
|
|
|
2484
2937
|
if (event.key === "Escape") {
|
|
2485
2938
|
event.preventDefault();
|
|
2486
2939
|
event.stopPropagation();
|
|
2487
|
-
|
|
2488
|
-
this.closeLayerPopover();
|
|
2489
|
-
} else {
|
|
2490
|
-
this.stop();
|
|
2491
|
-
}
|
|
2940
|
+
this.stop();
|
|
2492
2941
|
return;
|
|
2493
2942
|
}
|
|
2494
2943
|
|
|
2495
2944
|
if (event.key === "ArrowUp" || event.key === "[") {
|
|
2496
2945
|
event.preventDefault();
|
|
2497
2946
|
event.stopPropagation();
|
|
2498
|
-
this.cycleDepth(1);
|
|
2947
|
+
this.cycleDepth(1, true);
|
|
2499
2948
|
return;
|
|
2500
2949
|
}
|
|
2501
2950
|
|
|
2502
2951
|
if (event.key === "ArrowDown" || event.key === "]") {
|
|
2503
2952
|
event.preventDefault();
|
|
2504
2953
|
event.stopPropagation();
|
|
2505
|
-
this.cycleDepth(-1);
|
|
2954
|
+
this.cycleDepth(-1, true);
|
|
2506
2955
|
return;
|
|
2507
2956
|
}
|
|
2508
2957
|
|
|
@@ -2511,7 +2960,11 @@
|
|
|
2511
2960
|
if (candidate) {
|
|
2512
2961
|
event.preventDefault();
|
|
2513
2962
|
event.stopPropagation();
|
|
2514
|
-
this.
|
|
2963
|
+
this.commitCandidateSelection(
|
|
2964
|
+
candidate.element,
|
|
2965
|
+
this.lastPointerX || 80,
|
|
2966
|
+
this.lastPointerY || 80
|
|
2967
|
+
);
|
|
2515
2968
|
}
|
|
2516
2969
|
}
|
|
2517
2970
|
}
|
|
@@ -2563,7 +3016,11 @@
|
|
|
2563
3016
|
rootContainer = null;
|
|
2564
3017
|
composerEl = null;
|
|
2565
3018
|
compactBarEl = null;
|
|
2566
|
-
|
|
3019
|
+
compactStatusEl = null;
|
|
3020
|
+
compactStepGroupEl = null;
|
|
3021
|
+
compactLayerUpBtn = null;
|
|
3022
|
+
compactLayerDownBtn = null;
|
|
3023
|
+
compactDoneBtn = null;
|
|
2567
3024
|
compactPinBtn = null;
|
|
2568
3025
|
pinDockEl = null;
|
|
2569
3026
|
floatingPinBtn = null;
|
|
@@ -2587,10 +3044,19 @@
|
|
|
2587
3044
|
onSelect: (snapshot, el) => {
|
|
2588
3045
|
const added = this.addElementReference(snapshot, el);
|
|
2589
3046
|
if (added) {
|
|
2590
|
-
this.
|
|
3047
|
+
const count = this.elementReferences.length;
|
|
3048
|
+
this.showStatus(
|
|
3049
|
+
count === 1
|
|
3050
|
+
? `Pinned ${snapshot.selector}`
|
|
3051
|
+
: `Pinned ${count} elements (latest: ${snapshot.selector})`,
|
|
3052
|
+
"success"
|
|
3053
|
+
);
|
|
2591
3054
|
}
|
|
2592
3055
|
this.syncUiStates();
|
|
2593
3056
|
},
|
|
3057
|
+
onUnselect: (clientRef) => {
|
|
3058
|
+
this.removeElementReference(clientRef);
|
|
3059
|
+
},
|
|
2594
3060
|
onExit: () => {
|
|
2595
3061
|
this.isMinimized = false;
|
|
2596
3062
|
this.openComposer();
|
|
@@ -2598,9 +3064,21 @@
|
|
|
2598
3064
|
},
|
|
2599
3065
|
canSelectMore: () => this.elementReferences.length < this.config.limits.max_element_references,
|
|
2600
3066
|
getExcludedSelectors: () => this.config.privacy.excluded_selectors,
|
|
3067
|
+
getPinnedElements: () =>
|
|
3068
|
+
this.elementReferences
|
|
3069
|
+
.map((ref) => {
|
|
3070
|
+
const node = this.elementDomNodes.get(ref.client_ref);
|
|
3071
|
+
return node
|
|
3072
|
+
? { clientRef: ref.client_ref, selector: ref.selector, element: node }
|
|
3073
|
+
: null;
|
|
3074
|
+
})
|
|
3075
|
+
.filter(
|
|
3076
|
+
(item) =>
|
|
3077
|
+
item !== null
|
|
3078
|
+
),
|
|
2601
3079
|
onStateChange: (state) => {
|
|
2602
|
-
this.renderCompactBreadcrumbs(state.activeCandidate, state.ancestors);
|
|
2603
3080
|
this.syncPinActiveIndicators(state.active);
|
|
3081
|
+
this.renderCompactCoachBar(state.active, state.candidateStack.length);
|
|
2604
3082
|
}
|
|
2605
3083
|
});
|
|
2606
3084
|
}
|
|
@@ -2717,6 +3195,7 @@
|
|
|
2717
3195
|
if (elementNode) {
|
|
2718
3196
|
this.elementDomNodes.set(snapshot.client_ref, elementNode);
|
|
2719
3197
|
}
|
|
3198
|
+
this.picker?.refreshPinnedMarkers();
|
|
2720
3199
|
this.renderTray();
|
|
2721
3200
|
this.syncUiStates();
|
|
2722
3201
|
return true;
|
|
@@ -2726,6 +3205,7 @@
|
|
|
2726
3205
|
this.elementReferences = this.elementReferences.filter((el) => el.client_ref !== clientRef);
|
|
2727
3206
|
this.elementDomNodes.delete(clientRef);
|
|
2728
3207
|
this.picker?.hideExternalPreview();
|
|
3208
|
+
this.picker?.refreshPinnedMarkers();
|
|
2729
3209
|
this.renderTray();
|
|
2730
3210
|
this.syncUiStates();
|
|
2731
3211
|
}
|
|
@@ -2920,20 +3400,12 @@
|
|
|
2920
3400
|
|
|
2921
3401
|
const compactStatus = document.createElement("div");
|
|
2922
3402
|
compactStatus.className = "cd-compact-status";
|
|
2923
|
-
|
|
2924
|
-
breadcrumbScroll.className = "cd-breadcrumb-scroll";
|
|
2925
|
-
this.compactBreadcrumbEl = breadcrumbScroll;
|
|
2926
|
-
compactStatus.appendChild(breadcrumbScroll);
|
|
3403
|
+
this.compactStatusEl = compactStatus;
|
|
2927
3404
|
compactBar.appendChild(compactStatus);
|
|
2928
3405
|
|
|
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);
|
|
3406
|
+
const compactStepGroup = document.createElement("div");
|
|
3407
|
+
compactStepGroup.className = "cd-compact-step-group";
|
|
3408
|
+
this.compactStepGroupEl = compactStepGroup;
|
|
2937
3409
|
|
|
2938
3410
|
const compactLayerDown = document.createElement("button");
|
|
2939
3411
|
compactLayerDown.type = "button";
|
|
@@ -2941,15 +3413,29 @@
|
|
|
2941
3413
|
compactLayerDown.title = "Step to inner/child element (Down arrow)";
|
|
2942
3414
|
compactLayerDown.setAttribute("aria-label", "Step to child element");
|
|
2943
3415
|
compactLayerDown.innerHTML = ICON_CHEVRON_DOWN;
|
|
2944
|
-
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1));
|
|
2945
|
-
|
|
3416
|
+
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1, true));
|
|
3417
|
+
this.compactLayerDownBtn = compactLayerDown;
|
|
3418
|
+
compactStepGroup.appendChild(compactLayerDown);
|
|
3419
|
+
|
|
3420
|
+
const compactLayerUp = document.createElement("button");
|
|
3421
|
+
compactLayerUp.type = "button";
|
|
3422
|
+
compactLayerUp.className = "cd-icon-btn";
|
|
3423
|
+
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
3424
|
+
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
3425
|
+
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
3426
|
+
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1, true));
|
|
3427
|
+
this.compactLayerUpBtn = compactLayerUp;
|
|
3428
|
+
compactStepGroup.appendChild(compactLayerUp);
|
|
3429
|
+
|
|
3430
|
+
compactBar.appendChild(compactStepGroup);
|
|
2946
3431
|
|
|
2947
3432
|
const expandBtn = document.createElement("button");
|
|
2948
3433
|
expandBtn.type = "button";
|
|
2949
|
-
expandBtn.className = "cd-btn
|
|
2950
|
-
expandBtn.setAttribute("aria-label", "
|
|
2951
|
-
expandBtn.innerHTML =
|
|
3434
|
+
expandBtn.className = "cd-btn";
|
|
3435
|
+
expandBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
3436
|
+
expandBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
2952
3437
|
expandBtn.addEventListener("click", () => this.expandFromCompactBar());
|
|
3438
|
+
this.compactDoneBtn = expandBtn;
|
|
2953
3439
|
compactBar.appendChild(expandBtn);
|
|
2954
3440
|
|
|
2955
3441
|
// 2. Main Floating Chatbox Composer Window
|
|
@@ -3177,7 +3663,6 @@
|
|
|
3177
3663
|
root.appendChild(pinDock);
|
|
3178
3664
|
this.shadow.appendChild(root);
|
|
3179
3665
|
|
|
3180
|
-
this.renderCompactBreadcrumbs(null, []);
|
|
3181
3666
|
this.syncUiStates();
|
|
3182
3667
|
}
|
|
3183
3668
|
|
|
@@ -3228,48 +3713,102 @@
|
|
|
3228
3713
|
}
|
|
3229
3714
|
|
|
3230
3715
|
this.syncPinActiveIndicators(pickerActive);
|
|
3716
|
+
this.renderCompactCoachBar(
|
|
3717
|
+
pickerActive,
|
|
3718
|
+
this.picker ? this.picker.getCandidateStack().length : 0
|
|
3719
|
+
);
|
|
3231
3720
|
}
|
|
3232
3721
|
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
) {
|
|
3237
|
-
if (!this.compactBreadcrumbEl) return;
|
|
3238
|
-
this.compactBreadcrumbEl.innerHTML = "";
|
|
3722
|
+
renderCompactCoachBar(pickerActive , candidateCount = 0) {
|
|
3723
|
+
if (!this.compactStatusEl) return;
|
|
3724
|
+
this.compactStatusEl.innerHTML = "";
|
|
3239
3725
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
this.
|
|
3248
|
-
return;
|
|
3726
|
+
const pinnedCount = this.elementReferences.length;
|
|
3727
|
+
const totalContextCount = pinnedCount + this.attachments.length;
|
|
3728
|
+
|
|
3729
|
+
if (this.compactStepGroupEl) {
|
|
3730
|
+
this.compactStepGroupEl.hidden = !pickerActive;
|
|
3731
|
+
}
|
|
3732
|
+
if (this.compactLayerUpBtn) {
|
|
3733
|
+
this.compactLayerUpBtn.disabled = candidateCount <= 1;
|
|
3249
3734
|
}
|
|
3735
|
+
if (this.compactLayerDownBtn) {
|
|
3736
|
+
this.compactLayerDownBtn.disabled = candidateCount <= 1;
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
if (pickerActive) {
|
|
3740
|
+
if (pinnedCount === 0) {
|
|
3741
|
+
const coach = document.createElement("span");
|
|
3742
|
+
coach.className = "cd-compact-coach-text";
|
|
3743
|
+
coach.innerHTML = `<strong>Click</strong><span>element to pin</span><span>·</span><span class="cd-compact-wheel-icon">${ICON_SCROLL_VERTICAL}</span><strong>Scroll</strong><span>layers</span>`;
|
|
3744
|
+
this.compactStatusEl.appendChild(coach);
|
|
3745
|
+
} else {
|
|
3746
|
+
const latest = this.elementReferences[pinnedCount - 1];
|
|
3747
|
+
const pill = document.createElement("div");
|
|
3748
|
+
pill.className = "cd-compact-pinned-pill";
|
|
3749
|
+
|
|
3750
|
+
const countSpan = document.createElement("span");
|
|
3751
|
+
countSpan.className = "cd-compact-pinned-count";
|
|
3752
|
+
countSpan.textContent = `${pinnedCount} pinned`;
|
|
3753
|
+
|
|
3754
|
+
const selSpan = document.createElement("span");
|
|
3755
|
+
selSpan.className = "cd-compact-pinned-selector";
|
|
3756
|
+
selSpan.textContent = latest.selector;
|
|
3757
|
+
selSpan.title = latest.dom_path || latest.selector;
|
|
3758
|
+
|
|
3759
|
+
const undoBtn = document.createElement("button");
|
|
3760
|
+
undoBtn.type = "button";
|
|
3761
|
+
undoBtn.className = "cd-chip-remove";
|
|
3762
|
+
undoBtn.title = `Remove ${latest.selector}`;
|
|
3763
|
+
undoBtn.setAttribute("aria-label", `Undo pin ${latest.selector}`);
|
|
3764
|
+
undoBtn.innerHTML = ICON_CLOSE;
|
|
3765
|
+
undoBtn.addEventListener("click", (ev) => {
|
|
3766
|
+
ev.stopPropagation();
|
|
3767
|
+
this.removeElementReference(latest.client_ref);
|
|
3768
|
+
});
|
|
3250
3769
|
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3770
|
+
pill.appendChild(countSpan);
|
|
3771
|
+
pill.appendChild(selSpan);
|
|
3772
|
+
pill.appendChild(undoBtn);
|
|
3773
|
+
this.compactStatusEl.appendChild(pill);
|
|
3774
|
+
|
|
3775
|
+
const addMore = document.createElement("span");
|
|
3776
|
+
addMore.className = "cd-compact-coach-text";
|
|
3777
|
+
addMore.textContent = "Click another to add";
|
|
3778
|
+
this.compactStatusEl.appendChild(addMore);
|
|
3257
3779
|
}
|
|
3258
3780
|
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3781
|
+
if (this.compactDoneBtn) {
|
|
3782
|
+
if (pinnedCount > 0) {
|
|
3783
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
3784
|
+
this.compactDoneBtn.setAttribute(
|
|
3785
|
+
"aria-label",
|
|
3786
|
+
"Finish pinning elements and return to chatbox"
|
|
3787
|
+
);
|
|
3788
|
+
this.compactDoneBtn.innerHTML = `${ICON_CHECK}<span>Done (${pinnedCount})</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
3789
|
+
} else {
|
|
3790
|
+
this.compactDoneBtn.className = "cd-btn";
|
|
3791
|
+
this.compactDoneBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
3792
|
+
this.compactDoneBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
return;
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
// Minimized while not actively in Pin Mode
|
|
3799
|
+
const summary = document.createElement("span");
|
|
3800
|
+
summary.className = "cd-compact-coach-text";
|
|
3801
|
+
summary.textContent =
|
|
3802
|
+
totalContextCount > 0
|
|
3803
|
+
? `${totalContextCount} context item${totalContextCount > 1 ? "s" : ""} attached`
|
|
3804
|
+
: "Chatbox minimized";
|
|
3805
|
+
this.compactStatusEl.appendChild(summary);
|
|
3806
|
+
|
|
3807
|
+
if (this.compactDoneBtn) {
|
|
3808
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
3809
|
+
this.compactDoneBtn.setAttribute("aria-label", "Return to chatbox");
|
|
3810
|
+
this.compactDoneBtn.innerHTML = `${ICON_EXPAND}<span>Chat</span>`;
|
|
3811
|
+
}
|
|
3273
3812
|
}
|
|
3274
3813
|
|
|
3275
3814
|
renderChatThread() {
|
|
@@ -3287,7 +3826,7 @@
|
|
|
3287
3826
|
const p2 = document.createElement("p");
|
|
3288
3827
|
p2.className = "cd-chat-empty-hint";
|
|
3289
3828
|
p2.textContent =
|
|
3290
|
-
"
|
|
3829
|
+
"Click Pin Element, scroll the wheel to step through overlapping layers, click once to pin, and press Esc when done.";
|
|
3291
3830
|
|
|
3292
3831
|
emptyBox.appendChild(p1);
|
|
3293
3832
|
emptyBox.appendChild(p2);
|