context_drop 0.1.3 → 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 +117 -12
- 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 +70 -3
- data/app/javascript/context_drop/element-picker.ts +66 -1
- data/app/javascript/context_drop/widget.ts +51 -11
- 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
|
@@ -349,7 +349,11 @@ class MockUiEvent {
|
|
|
349
349
|
deltaY?: number;
|
|
350
350
|
deltaMode?: number;
|
|
351
351
|
key?: string;
|
|
352
|
+
code?: string;
|
|
352
353
|
shiftKey?: boolean;
|
|
354
|
+
altKey?: boolean;
|
|
355
|
+
ctrlKey?: boolean;
|
|
356
|
+
metaKey?: boolean;
|
|
353
357
|
} = {}
|
|
354
358
|
) {
|
|
355
359
|
this.type = type;
|
|
@@ -359,10 +363,11 @@ class MockUiEvent {
|
|
|
359
363
|
this.deltaY = init.deltaY ?? 0;
|
|
360
364
|
this.deltaMode = init.deltaMode ?? 0;
|
|
361
365
|
this.key = init.key ?? "";
|
|
366
|
+
this.code = init.code ?? "";
|
|
362
367
|
this.shiftKey = init.shiftKey ?? false;
|
|
363
|
-
this.altKey = false;
|
|
364
|
-
this.ctrlKey = false;
|
|
365
|
-
this.metaKey = false;
|
|
368
|
+
this.altKey = init.altKey ?? false;
|
|
369
|
+
this.ctrlKey = init.ctrlKey ?? false;
|
|
370
|
+
this.metaKey = init.metaKey ?? false;
|
|
366
371
|
}
|
|
367
372
|
|
|
368
373
|
public preventDefault(): void {
|
|
@@ -970,4 +975,66 @@ describe("ContextDrop Floating Dock & Drag Handle Interactions", () => {
|
|
|
970
975
|
assert.equal(mockBody.querySelector("[data-context-drop-ui='pinned-badge']"), null);
|
|
971
976
|
});
|
|
972
977
|
});
|
|
978
|
+
|
|
979
|
+
it("activates Freeze & Pin via Alt+Shift+P, pins candidate on Space, and suppresses blur events", async () => {
|
|
980
|
+
await withMountedWidget(({ widget, shadowRoot, mockBody, mockDocument, mockWindow }) => {
|
|
981
|
+
const compactBar = shadowRoot.querySelector(".cd-compact-bar");
|
|
982
|
+
const composer = shadowRoot.querySelector(".cd-composer");
|
|
983
|
+
assert.ok(compactBar && composer);
|
|
984
|
+
|
|
985
|
+
const navMenu = new MockDomElement("nav");
|
|
986
|
+
navMenu.setAttribute("id", "transient-dropdown");
|
|
987
|
+
const menuItem = new MockDomElement("a");
|
|
988
|
+
menuItem.setAttribute("id", "dimensions-link");
|
|
989
|
+
menuItem.textContent = "Dimensions";
|
|
990
|
+
menuItem.setRect({ left: 100, top: 60, width: 140, height: 32 });
|
|
991
|
+
navMenu.appendChild(menuItem);
|
|
992
|
+
mockBody.appendChild(navMenu);
|
|
993
|
+
|
|
994
|
+
const pointNodes = [menuItem, navMenu];
|
|
995
|
+
mockDocument.elementsFromPoint = () => pointNodes;
|
|
996
|
+
|
|
997
|
+
// Track pointer at (150, 80)
|
|
998
|
+
mockWindow.dispatchEvent(new MockUiEvent("mousemove", { clientX: 150, clientY: 80 }));
|
|
999
|
+
|
|
1000
|
+
// Press Alt+Shift+P to trigger Freeze & Pin globally
|
|
1001
|
+
const freezeKeyEv = new MockUiEvent("keydown", {
|
|
1002
|
+
key: "p",
|
|
1003
|
+
code: "KeyP",
|
|
1004
|
+
altKey: true,
|
|
1005
|
+
shiftKey: true
|
|
1006
|
+
});
|
|
1007
|
+
mockWindow.dispatchEvent(freezeKeyEv);
|
|
1008
|
+
assert.equal(freezeKeyEv.defaultPrevented, true);
|
|
1009
|
+
assert.equal(compactBar.hidden, false);
|
|
1010
|
+
|
|
1011
|
+
// Verify blur event suppression: blur on host element should be stopped
|
|
1012
|
+
const blurEv = new MockUiEvent("blur", {});
|
|
1013
|
+
mockWindow.dispatchEvent(blurEv);
|
|
1014
|
+
assert.equal(blurEv.propagationStopped, true);
|
|
1015
|
+
|
|
1016
|
+
// Verify Spacebar commits the candidate without firing mouse click
|
|
1017
|
+
const spaceKeyEv = new MockUiEvent("keydown", {
|
|
1018
|
+
key: " ",
|
|
1019
|
+
code: "Space"
|
|
1020
|
+
});
|
|
1021
|
+
mockWindow.dispatchEvent(spaceKeyEv);
|
|
1022
|
+
assert.equal(spaceKeyEv.defaultPrevented, true);
|
|
1023
|
+
|
|
1024
|
+
// Pinned elements list should now contain the candidate
|
|
1025
|
+
assert.equal(widget.getElementReferences().length, 1);
|
|
1026
|
+
assert.equal(widget.getElementReferences()[0].selector, "#dimensions-link");
|
|
1027
|
+
|
|
1028
|
+
// Press Alt+Shift+P again to exit Freeze & Pin mode
|
|
1029
|
+
const exitKeyEv = new MockUiEvent("keydown", {
|
|
1030
|
+
key: "p",
|
|
1031
|
+
code: "KeyP",
|
|
1032
|
+
altKey: true,
|
|
1033
|
+
shiftKey: true
|
|
1034
|
+
});
|
|
1035
|
+
mockWindow.dispatchEvent(exitKeyEv);
|
|
1036
|
+
assert.equal(compactBar.hidden, true);
|
|
1037
|
+
assert.equal(composer.hidden, false);
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
973
1040
|
});
|
|
@@ -108,6 +108,7 @@ export class ElementPicker {
|
|
|
108
108
|
private boundMouseMove: (e: MouseEvent) => void;
|
|
109
109
|
private boundClickCapture: (e: MouseEvent) => void;
|
|
110
110
|
private boundPointerCapture: (e: Event) => void;
|
|
111
|
+
private boundBlurSuppression: (e: Event) => void;
|
|
111
112
|
private boundWheelCapture: (e: WheelEvent) => void;
|
|
112
113
|
private boundKeyDown: (e: KeyboardEvent) => void;
|
|
113
114
|
private boundScrollOrResize: () => void;
|
|
@@ -117,6 +118,7 @@ export class ElementPicker {
|
|
|
117
118
|
this.boundMouseMove = this.handleMouseMove.bind(this);
|
|
118
119
|
this.boundClickCapture = this.handleClickCapture.bind(this);
|
|
119
120
|
this.boundPointerCapture = this.handlePointerSuppression.bind(this);
|
|
121
|
+
this.boundBlurSuppression = this.handleBlurSuppression.bind(this);
|
|
120
122
|
this.boundWheelCapture = this.handleWheelCapture.bind(this);
|
|
121
123
|
this.boundKeyDown = this.handleKeyDown.bind(this);
|
|
122
124
|
this.boundScrollOrResize = this.handleViewportScrollOrResize.bind(this);
|
|
@@ -171,6 +173,8 @@ export class ElementPicker {
|
|
|
171
173
|
window.addEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
172
174
|
window.addEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
173
175
|
window.addEventListener("click", this.boundClickCapture, { capture: true });
|
|
176
|
+
window.addEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
177
|
+
window.addEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
174
178
|
window.addEventListener("wheel", this.boundWheelCapture, { capture: true, passive: false });
|
|
175
179
|
window.addEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
176
180
|
window.addEventListener("scroll", this.boundScrollOrResize, { capture: true, passive: true });
|
|
@@ -198,6 +202,8 @@ export class ElementPicker {
|
|
|
198
202
|
window.removeEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
199
203
|
window.removeEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
200
204
|
window.removeEventListener("click", this.boundClickCapture, { capture: true });
|
|
205
|
+
window.removeEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
206
|
+
window.removeEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
201
207
|
window.removeEventListener("wheel", this.boundWheelCapture, { capture: true });
|
|
202
208
|
window.removeEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
203
209
|
window.removeEventListener("scroll", this.boundScrollOrResize, { capture: true });
|
|
@@ -209,6 +215,13 @@ export class ElementPicker {
|
|
|
209
215
|
this.callbacks.onExit();
|
|
210
216
|
}
|
|
211
217
|
|
|
218
|
+
public highlightAtPoint(x: number, y: number): void {
|
|
219
|
+
if (!this.active || typeof document === "undefined") return;
|
|
220
|
+
this.lastPointerX = x;
|
|
221
|
+
this.lastPointerY = y;
|
|
222
|
+
this.updateCandidatesFromPoint(x, y);
|
|
223
|
+
}
|
|
224
|
+
|
|
212
225
|
public focusCandidateElement(el: Element): void {
|
|
213
226
|
if (!this.active) return;
|
|
214
227
|
const excluded = this.callbacks.getExcludedSelectors();
|
|
@@ -817,6 +830,9 @@ export class ElementPicker {
|
|
|
817
830
|
].join(";");
|
|
818
831
|
|
|
819
832
|
const clickHint = document.createElement("span");
|
|
833
|
+
clickHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
834
|
+
clickHint.appendChild(this.createKbdEl("Space"));
|
|
835
|
+
clickHint.appendChild(this.createSpanEl("or"));
|
|
820
836
|
const clickStrong = document.createElement("strong");
|
|
821
837
|
clickStrong.style.cssText = pinnedInfo
|
|
822
838
|
? "color: #ffedd5; font-weight: 600;"
|
|
@@ -847,6 +863,8 @@ export class ElementPicker {
|
|
|
847
863
|
|
|
848
864
|
const escHint = document.createElement("span");
|
|
849
865
|
escHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
866
|
+
escHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
867
|
+
escHint.appendChild(this.createSpanEl("freeze · "));
|
|
850
868
|
escHint.appendChild(this.createKbdEl("Esc"));
|
|
851
869
|
escHint.appendChild(this.createSpanEl("done"));
|
|
852
870
|
coachRow.appendChild(escHint);
|
|
@@ -1076,8 +1094,10 @@ export class ElementPicker {
|
|
|
1076
1094
|
|
|
1077
1095
|
const keysHint = document.createElement("span");
|
|
1078
1096
|
keysHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
1079
|
-
keysHint.appendChild(this.createKbdEl("
|
|
1097
|
+
keysHint.appendChild(this.createKbdEl("Space"));
|
|
1080
1098
|
keysHint.appendChild(this.createSpanEl("pin · "));
|
|
1099
|
+
keysHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
1100
|
+
keysHint.appendChild(this.createSpanEl("freeze · "));
|
|
1081
1101
|
keysHint.appendChild(this.createKbdEl("Esc"));
|
|
1082
1102
|
keysHint.appendChild(this.createSpanEl("done"));
|
|
1083
1103
|
|
|
@@ -1351,6 +1371,20 @@ export class ElementPicker {
|
|
|
1351
1371
|
}
|
|
1352
1372
|
}
|
|
1353
1373
|
|
|
1374
|
+
private handleBlurSuppression(event: Event): void {
|
|
1375
|
+
if (!this.active) return;
|
|
1376
|
+
if (this.isInternalUiEvent(event)) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// Freeze DOM states: suppress blur / focusout on host elements while picker is active
|
|
1381
|
+
// so transient popovers, tooltips, flyout menus, and modals remain open
|
|
1382
|
+
event.stopPropagation();
|
|
1383
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
1384
|
+
event.stopImmediatePropagation();
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1354
1388
|
private handleClickCapture(event: MouseEvent): void {
|
|
1355
1389
|
if (!this.active) return;
|
|
1356
1390
|
if (this.isInternalUiEvent(event)) {
|
|
@@ -1383,6 +1417,37 @@ export class ElementPicker {
|
|
|
1383
1417
|
return;
|
|
1384
1418
|
}
|
|
1385
1419
|
|
|
1420
|
+
// Alt+Shift+P / Option+Shift+P toggle / exit Freeze & Pin mode
|
|
1421
|
+
if (
|
|
1422
|
+
event.altKey &&
|
|
1423
|
+
event.shiftKey &&
|
|
1424
|
+
(event.code === "KeyP" || event.key.toLowerCase() === "p")
|
|
1425
|
+
) {
|
|
1426
|
+
event.preventDefault();
|
|
1427
|
+
event.stopPropagation();
|
|
1428
|
+
this.stop();
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
// Space key freezes & pins the currently hovered element without triggering mouse clicks
|
|
1433
|
+
if (event.key === " " || event.key === "Spacebar" || event.code === "Space") {
|
|
1434
|
+
if (this.isInternalUiEvent(event)) return;
|
|
1435
|
+
const candidate = this.getActiveCandidate();
|
|
1436
|
+
if (candidate) {
|
|
1437
|
+
event.preventDefault();
|
|
1438
|
+
event.stopPropagation();
|
|
1439
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
1440
|
+
event.stopImmediatePropagation();
|
|
1441
|
+
}
|
|
1442
|
+
this.commitCandidateSelection(
|
|
1443
|
+
candidate.element,
|
|
1444
|
+
this.lastPointerX || 80,
|
|
1445
|
+
this.lastPointerY || 80
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1386
1451
|
if (event.key === "ArrowUp" || event.key === "[") {
|
|
1387
1452
|
event.preventDefault();
|
|
1388
1453
|
event.stopPropagation();
|
|
@@ -89,6 +89,10 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
89
89
|
private statusEl: HTMLDivElement | null = null;
|
|
90
90
|
private fileInputEl: HTMLInputElement | null = null;
|
|
91
91
|
private submitBtn: HTMLButtonElement | null = null;
|
|
92
|
+
private lastPointerX: number = 0;
|
|
93
|
+
private lastPointerY: number = 0;
|
|
94
|
+
private boundTrackPointer: (ev: MouseEvent) => void;
|
|
95
|
+
private boundGlobalKeyDown: (ev: KeyboardEvent) => void;
|
|
92
96
|
|
|
93
97
|
public connectedCallback(): void {
|
|
94
98
|
if (!this.shadow) {
|
|
@@ -97,6 +101,32 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
97
101
|
this.readDataAttributes();
|
|
98
102
|
this.renderShadowDom();
|
|
99
103
|
|
|
104
|
+
this.boundTrackPointer = (ev: MouseEvent) => {
|
|
105
|
+
this.lastPointerX = ev.clientX;
|
|
106
|
+
this.lastPointerY = ev.clientY;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
this.boundGlobalKeyDown = (ev: KeyboardEvent) => {
|
|
110
|
+
// Alt+Shift+P / Option+Shift+P toggles Freeze & Pin mode from anywhere on the host page
|
|
111
|
+
if (
|
|
112
|
+
ev.altKey &&
|
|
113
|
+
ev.shiftKey &&
|
|
114
|
+
(ev.code === "KeyP" || (typeof ev.key === "string" && ev.key.toLowerCase() === "p"))
|
|
115
|
+
) {
|
|
116
|
+
ev.preventDefault();
|
|
117
|
+
ev.stopPropagation();
|
|
118
|
+
if (typeof ev.stopImmediatePropagation === "function") {
|
|
119
|
+
ev.stopImmediatePropagation();
|
|
120
|
+
}
|
|
121
|
+
this.togglePinSelection();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (typeof window !== "undefined") {
|
|
126
|
+
window.addEventListener("mousemove", this.boundTrackPointer, { capture: true, passive: true });
|
|
127
|
+
window.addEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
128
|
+
}
|
|
129
|
+
|
|
100
130
|
this.picker = new ElementPicker({
|
|
101
131
|
onSelect: (snapshot, el) => {
|
|
102
132
|
const added = this.addElementReference(snapshot, el);
|
|
@@ -145,6 +175,11 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
145
175
|
this.picker.stop();
|
|
146
176
|
}
|
|
147
177
|
this.picker?.hideExternalPreview();
|
|
178
|
+
|
|
179
|
+
if (typeof window !== "undefined") {
|
|
180
|
+
window.removeEventListener("mousemove", this.boundTrackPointer, { capture: true });
|
|
181
|
+
window.removeEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
182
|
+
}
|
|
148
183
|
}
|
|
149
184
|
|
|
150
185
|
public getConfig(): WidgetConfig {
|
|
@@ -216,6 +251,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
216
251
|
}
|
|
217
252
|
this.minimizeToCompactBar();
|
|
218
253
|
this.picker.start();
|
|
254
|
+
if (this.lastPointerX > 0 && this.lastPointerY > 0) {
|
|
255
|
+
this.picker.highlightAtPoint(this.lastPointerX, this.lastPointerY);
|
|
256
|
+
}
|
|
219
257
|
this.syncUiStates();
|
|
220
258
|
}
|
|
221
259
|
|
|
@@ -449,7 +487,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
449
487
|
const compactPinBtn = document.createElement("button");
|
|
450
488
|
compactPinBtn.type = "button";
|
|
451
489
|
compactPinBtn.className = "cd-pin-corner-btn is-active";
|
|
452
|
-
compactPinBtn.
|
|
490
|
+
compactPinBtn.title = "Toggle Freeze & Pin (⌥⇧P)";
|
|
491
|
+
compactPinBtn.setAttribute("aria-label", "Toggle element pin mode (Option+Shift+P)");
|
|
453
492
|
compactPinBtn.innerHTML = `${ICON_PIN}<span>Pinning</span>`;
|
|
454
493
|
compactPinBtn.addEventListener("click", () => this.togglePinSelection());
|
|
455
494
|
this.compactPinBtn = compactPinBtn;
|
|
@@ -532,8 +571,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
532
571
|
const cornerPinBtn = document.createElement("button");
|
|
533
572
|
cornerPinBtn.type = "button";
|
|
534
573
|
cornerPinBtn.className = "cd-pin-corner-btn";
|
|
535
|
-
cornerPinBtn.title = "
|
|
536
|
-
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page");
|
|
574
|
+
cornerPinBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
575
|
+
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page (Option+Shift+P)");
|
|
537
576
|
cornerPinBtn.innerHTML = `${ICON_PIN}<span>Pin Element</span>`;
|
|
538
577
|
cornerPinBtn.addEventListener("click", () => this.startPinSelection());
|
|
539
578
|
this.cornerPinBtn = cornerPinBtn;
|
|
@@ -640,8 +679,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
640
679
|
const pickBtn = document.createElement("button");
|
|
641
680
|
pickBtn.type = "button";
|
|
642
681
|
pickBtn.className = "cd-btn";
|
|
643
|
-
pickBtn.
|
|
644
|
-
pickBtn.
|
|
682
|
+
pickBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
683
|
+
pickBtn.setAttribute("aria-label", "Pin HTML element as context (Option+Shift+P)");
|
|
684
|
+
pickBtn.innerHTML = `${ICON_PIN}<span>Pin</span><kbd class="cd-kbd">⌥⇧P</kbd>`;
|
|
645
685
|
pickBtn.addEventListener("click", () => this.startPinSelection());
|
|
646
686
|
actions.appendChild(pickBtn);
|
|
647
687
|
}
|
|
@@ -697,8 +737,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
697
737
|
const floatingPinBtn = document.createElement("button");
|
|
698
738
|
floatingPinBtn.type = "button";
|
|
699
739
|
floatingPinBtn.className = "cd-floating-pin-btn";
|
|
700
|
-
floatingPinBtn.title = "Pin
|
|
701
|
-
floatingPinBtn.setAttribute("aria-label", "Pin element on page");
|
|
740
|
+
floatingPinBtn.title = "Freeze & Pin element (⌥⇧P, or drag to move)";
|
|
741
|
+
floatingPinBtn.setAttribute("aria-label", "Freeze & Pin element on page (Option+Shift+P)");
|
|
702
742
|
floatingPinBtn.innerHTML = `${ICON_PIN}<span>Pin</span>`;
|
|
703
743
|
this.attachDragHandle(floatingPinBtn, () => this.startPinSelection());
|
|
704
744
|
this.floatingPinBtn = floatingPinBtn;
|
|
@@ -797,7 +837,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
797
837
|
if (pinnedCount === 0) {
|
|
798
838
|
const coach = document.createElement("span");
|
|
799
839
|
coach.className = "cd-compact-coach-text";
|
|
800
|
-
coach.innerHTML = `<strong>
|
|
840
|
+
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>`;
|
|
801
841
|
this.compactStatusEl.appendChild(coach);
|
|
802
842
|
} else {
|
|
803
843
|
const latest = this.elementReferences[pinnedCount - 1];
|
|
@@ -831,7 +871,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
831
871
|
|
|
832
872
|
const addMore = document.createElement("span");
|
|
833
873
|
addMore.className = "cd-compact-coach-text";
|
|
834
|
-
addMore.
|
|
874
|
+
addMore.innerHTML = `<strong>Space</strong><span>or click to add more</span>`;
|
|
835
875
|
this.compactStatusEl.appendChild(addMore);
|
|
836
876
|
}
|
|
837
877
|
|
|
@@ -882,8 +922,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
882
922
|
|
|
883
923
|
const p2 = document.createElement("p");
|
|
884
924
|
p2.className = "cd-chat-empty-hint";
|
|
885
|
-
p2.
|
|
886
|
-
"
|
|
925
|
+
p2.innerHTML =
|
|
926
|
+
"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.";
|
|
887
927
|
|
|
888
928
|
emptyBox.appendChild(p1);
|
|
889
929
|
emptyBox.appendChild(p2);
|
|
@@ -48,11 +48,17 @@ module ContextDrop
|
|
|
48
48
|
def submitter_label
|
|
49
49
|
return "Anonymous" if submitter_type.blank? && submitter_id.blank?
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
target_submitter = begin
|
|
52
|
+
submitter
|
|
53
|
+
rescue NameError
|
|
54
|
+
nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if target_submitter
|
|
58
|
+
if target_submitter.respond_to?(:email) && target_submitter.email.present?
|
|
59
|
+
"#{submitter_type}##{submitter_id} (#{target_submitter.email})"
|
|
60
|
+
elsif target_submitter.respond_to?(:name) && target_submitter.name.present?
|
|
61
|
+
"#{submitter_type}##{submitter_id} (#{target_submitter.name})"
|
|
56
62
|
else
|
|
57
63
|
"#{submitter_type}##{submitter_id}"
|
|
58
64
|
end
|
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
<div class="cd-tabs" role="tablist" aria-label="Filter feedback by status">
|
|
2
2
|
<a href="<%= dashboard_feedbacks_path(q: @search_query.presence, page_url: @page_url_filter.presence) %>"
|
|
3
3
|
class="cd-tab <%= 'active' if @current_status.blank? %>">
|
|
4
|
-
All
|
|
4
|
+
<span>All</span>
|
|
5
|
+
<span class="cd-tab-count"><%= @status_counts["all"] || 0 %></span>
|
|
5
6
|
</a>
|
|
6
7
|
<% ContextDrop::Feedback::STATUSES.each do |status_name| %>
|
|
7
8
|
<a href="<%= dashboard_feedbacks_path(status: status_name, q: @search_query.presence, page_url: @page_url_filter.presence) %>"
|
|
8
9
|
class="cd-tab <%= 'active' if @current_status == status_name %>">
|
|
9
|
-
|
|
10
|
+
<span><%= status_name.capitalize %></span>
|
|
11
|
+
<span class="cd-tab-count"><%= @status_counts[status_name] || 0 %></span>
|
|
10
12
|
</a>
|
|
11
13
|
<% end %>
|
|
12
14
|
</div>
|
|
13
15
|
|
|
14
|
-
<div class="cd-card">
|
|
16
|
+
<div class="cd-card cd-card-tight">
|
|
15
17
|
<form method="get" action="<%= dashboard_feedbacks_path %>" class="cd-filter-bar">
|
|
16
18
|
<% if @current_status.present? %>
|
|
17
19
|
<input type="hidden" name="status" value="<%= @current_status %>">
|
|
18
20
|
<% end %>
|
|
19
|
-
<input
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
<div class="cd-input-wrap" style="flex: 1 1 260px;">
|
|
22
|
+
<span class="cd-input-icon"><%= cd_icon_search(size: 14) %></span>
|
|
23
|
+
<input type="search"
|
|
24
|
+
name="q"
|
|
25
|
+
value="<%= @search_query %>"
|
|
26
|
+
placeholder="Search message, selector, or DOM text..."
|
|
27
|
+
class="cd-input"
|
|
28
|
+
style="width: 100%;"
|
|
29
|
+
aria-label="Search feedback">
|
|
30
|
+
</div>
|
|
31
|
+
<div class="cd-input-wrap" style="flex: 1 1 220px;">
|
|
32
|
+
<span class="cd-input-icon"><%= cd_icon_link(size: 14) %></span>
|
|
33
|
+
<input type="text"
|
|
34
|
+
name="page_url"
|
|
35
|
+
value="<%= @page_url_filter %>"
|
|
36
|
+
placeholder="Filter by page URL (e.g. /checkout)"
|
|
37
|
+
class="cd-input"
|
|
38
|
+
style="width: 100%;"
|
|
39
|
+
aria-label="Filter by page URL">
|
|
40
|
+
</div>
|
|
31
41
|
<button type="submit" class="cd-btn cd-btn-primary">Filter</button>
|
|
32
42
|
<% if @search_query.present? || @page_url_filter.present? || @current_status.present? %>
|
|
33
43
|
<a href="<%= dashboard_feedbacks_path %>" class="cd-btn">Reset</a>
|
|
@@ -35,52 +45,143 @@
|
|
|
35
45
|
</form>
|
|
36
46
|
|
|
37
47
|
<% if @feedbacks.empty? %>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
<div style="color: var(--cd-muted); padding: 3rem 1.5rem; text-align: center;">
|
|
49
|
+
<p style="margin: 0 0 0.5rem 0; font-size: 0.9375rem; font-weight: 500; color: var(--cd-text);">No feedback matches current filters</p>
|
|
50
|
+
<p style="margin: 0; font-size: 0.8125rem;">Try adjusting your search terms or clearing status filters.</p>
|
|
51
|
+
</div>
|
|
41
52
|
<% else %>
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
</
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
</
|
|
61
|
-
<
|
|
62
|
-
<div style="font-weight: 500; margin-bottom: 0.25rem;">
|
|
63
|
-
<%= fb.message.present? ? truncate(fb.message, length: 120) : "(No text message)" %>
|
|
64
|
-
</div>
|
|
65
|
-
<div style="display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.75rem; color: var(--cd-muted);">
|
|
66
|
-
<span>Attachments: <strong><%= fb.attachments.size %></strong></span>
|
|
67
|
-
<span>Elements: <strong><%= fb.element_references.size %></strong></span>
|
|
68
|
-
<% fb.element_references.first(2).each do |el| %>
|
|
69
|
-
<code class="cd-mono"><%= el.selector %></code>
|
|
70
|
-
<% end %>
|
|
71
|
-
</div>
|
|
72
|
-
</td>
|
|
73
|
-
<td><code class="cd-mono"><%= fb.page_url %></code></td>
|
|
74
|
-
<td><%= fb.submitter_label %></td>
|
|
75
|
-
<td style="white-space: nowrap; color: var(--cd-muted);">
|
|
76
|
-
<%= fb.created_at&.strftime("%Y-%m-%d %H:%M UTC") %>
|
|
77
|
-
</td>
|
|
78
|
-
<td>
|
|
79
|
-
<a href="<%= dashboard_feedback_path(fb) %>" class="cd-btn">Inspect</a>
|
|
80
|
-
</td>
|
|
53
|
+
<div class="cd-table-wrap">
|
|
54
|
+
<table class="cd-table">
|
|
55
|
+
<colgroup>
|
|
56
|
+
<col style="width: 68px;">
|
|
57
|
+
<col style="width: 104px;">
|
|
58
|
+
<col style="width: 36%;">
|
|
59
|
+
<col style="width: 28%;">
|
|
60
|
+
<col style="width: 120px;">
|
|
61
|
+
<col style="width: 140px;">
|
|
62
|
+
<col style="width: 88px;">
|
|
63
|
+
</colgroup>
|
|
64
|
+
<thead>
|
|
65
|
+
<tr>
|
|
66
|
+
<th>ID</th>
|
|
67
|
+
<th>Status</th>
|
|
68
|
+
<th>Message & Context</th>
|
|
69
|
+
<th>Page URL</th>
|
|
70
|
+
<th>Submitter</th>
|
|
71
|
+
<th>Created</th>
|
|
72
|
+
<th>Actions</th>
|
|
81
73
|
</tr>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
</thead>
|
|
75
|
+
<tbody>
|
|
76
|
+
<% @feedbacks.each do |fb| %>
|
|
77
|
+
<tr id="feedback-row-<%= fb.id %>">
|
|
78
|
+
<td>
|
|
79
|
+
<a href="<%= dashboard_feedback_path(fb) %>" class="cd-mono-id">#<%= fb.id %></a>
|
|
80
|
+
</td>
|
|
81
|
+
<td>
|
|
82
|
+
<span class="cd-badge cd-badge-<%= fb.status %>"><%= fb.status %></span>
|
|
83
|
+
</td>
|
|
84
|
+
<td>
|
|
85
|
+
<div style="font-weight: 500; color: var(--cd-text); margin-bottom: 0.25rem; line-height: 1.4;">
|
|
86
|
+
<%= fb.message.present? ? truncate(fb.message, length: 120) : content_tag(:span, "(No text message)", style: "color: var(--cd-muted); font-style: italic;") %>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="cd-context-chips">
|
|
89
|
+
<% if fb.attachments.size > 0 %>
|
|
90
|
+
<span class="cd-context-chip" title="<%= fb.attachments.size %> attachment(s)">
|
|
91
|
+
<%= cd_icon_attachment(size: 11) %>
|
|
92
|
+
<span><%= fb.attachments.size %></span>
|
|
93
|
+
</span>
|
|
94
|
+
<% end %>
|
|
95
|
+
<% if fb.element_references.size > 0 %>
|
|
96
|
+
<span class="cd-context-chip" title="<%= fb.element_references.size %> element reference(s)">
|
|
97
|
+
<%= cd_icon_pin(size: 11) %>
|
|
98
|
+
<span><%= fb.element_references.size %></span>
|
|
99
|
+
</span>
|
|
100
|
+
<% end %>
|
|
101
|
+
<% fb.element_references.first(2).each do |el| %>
|
|
102
|
+
<code class="cd-selector-chip" title="<%= el.selector %>"><%= el.selector %></code>
|
|
103
|
+
<% end %>
|
|
104
|
+
<% if fb.element_references.size > 2 %>
|
|
105
|
+
<span style="font-size: 0.6875rem; color: var(--cd-muted); font-variant-numeric: tabular-nums;">
|
|
106
|
+
+<%= fb.element_references.size - 2 %> more
|
|
107
|
+
</span>
|
|
108
|
+
<% end %>
|
|
109
|
+
</div>
|
|
110
|
+
</td>
|
|
111
|
+
<td>
|
|
112
|
+
<% path, host = url_path_and_host(fb.page_url) %>
|
|
113
|
+
<div class="cd-url-box" title="<%= fb.page_url %>">
|
|
114
|
+
<div class="cd-url-top">
|
|
115
|
+
<span class="cd-url-path"><%= path %></span>
|
|
116
|
+
<% if fb.page_url.present? %>
|
|
117
|
+
<a href="<%= fb.page_url %>"
|
|
118
|
+
target="_blank"
|
|
119
|
+
rel="noopener noreferrer"
|
|
120
|
+
class="cd-icon-link"
|
|
121
|
+
title="Open <%= fb.page_url %> in new tab">
|
|
122
|
+
<%= cd_icon_external_link(size: 12) %>
|
|
123
|
+
</a>
|
|
124
|
+
<% end %>
|
|
125
|
+
</div>
|
|
126
|
+
<% if host.present? %>
|
|
127
|
+
<span class="cd-url-host"><%= host %></span>
|
|
128
|
+
<% end %>
|
|
129
|
+
</div>
|
|
130
|
+
</td>
|
|
131
|
+
<td>
|
|
132
|
+
<div style="display: flex; align-items: center; gap: 0.35rem; color: var(--cd-text-secondary); font-size: 0.8125rem;">
|
|
133
|
+
<%= cd_icon_user(size: 12) %>
|
|
134
|
+
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="<%= fb.submitter_label %>"><%= fb.submitter_label %></span>
|
|
135
|
+
</div>
|
|
136
|
+
</td>
|
|
137
|
+
<td style="white-space: nowrap; color: var(--cd-muted); font-size: 0.75rem; font-family: var(--cd-font-mono); font-variant-numeric: tabular-nums;">
|
|
138
|
+
<%= fb.created_at&.strftime("%Y-%m-%d %H:%M UTC") %>
|
|
139
|
+
</td>
|
|
140
|
+
<td>
|
|
141
|
+
<a href="<%= dashboard_feedback_path(fb) %>" class="cd-btn cd-btn-sm">Inspect</a>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
<% end %>
|
|
145
|
+
</tbody>
|
|
146
|
+
</table>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<%
|
|
150
|
+
per_page = ContextDrop::Dashboard::FeedbacksController::PER_PAGE
|
|
151
|
+
start_idx = @total_filtered.zero? ? 0 : ((@page - 1) * per_page) + 1
|
|
152
|
+
end_idx = [@page * per_page, @total_filtered].min
|
|
153
|
+
%>
|
|
154
|
+
<div class="cd-pagination-bar">
|
|
155
|
+
<div class="cd-pagination-info">
|
|
156
|
+
Showing <strong><%= start_idx %>–<%= end_idx %></strong> of <strong><%= @total_filtered %></strong> feedback<%= @total_filtered == 1 ? '' : 's' %>
|
|
157
|
+
</div>
|
|
158
|
+
<% if @total_pages > 1 %>
|
|
159
|
+
<div class="cd-pagination-nav">
|
|
160
|
+
<% if @page > 1 %>
|
|
161
|
+
<a href="<%= dashboard_feedbacks_path(page: @page - 1, status: @current_status.presence, q: @search_query.presence, page_url: @page_url_filter.presence) %>"
|
|
162
|
+
class="cd-btn cd-btn-sm">
|
|
163
|
+
<%= cd_icon_arrow_left(size: 12) %> Previous
|
|
164
|
+
</a>
|
|
165
|
+
<% else %>
|
|
166
|
+
<button class="cd-btn cd-btn-sm" disabled style="opacity: 0.4; cursor: not-allowed;">
|
|
167
|
+
<%= cd_icon_arrow_left(size: 12) %> Previous
|
|
168
|
+
</button>
|
|
169
|
+
<% end %>
|
|
170
|
+
<span style="font-size: 0.75rem; padding: 0 0.35rem; font-variant-numeric: tabular-nums;">
|
|
171
|
+
Page <strong><%= @page %></strong> of <strong><%= @total_pages %></strong>
|
|
172
|
+
</span>
|
|
173
|
+
<% if @page < @total_pages %>
|
|
174
|
+
<a href="<%= dashboard_feedbacks_path(page: @page + 1, status: @current_status.presence, q: @search_query.presence, page_url: @page_url_filter.presence) %>"
|
|
175
|
+
class="cd-btn cd-btn-sm">
|
|
176
|
+
Next <%= cd_icon_arrow_right(size: 12) %>
|
|
177
|
+
</a>
|
|
178
|
+
<% else %>
|
|
179
|
+
<button class="cd-btn cd-btn-sm" disabled style="opacity: 0.4; cursor: not-allowed;">
|
|
180
|
+
Next <%= cd_icon_arrow_right(size: 12) %>
|
|
181
|
+
</button>
|
|
182
|
+
<% end %>
|
|
183
|
+
</div>
|
|
184
|
+
<% end %>
|
|
185
|
+
</div>
|
|
85
186
|
<% end %>
|
|
86
187
|
</div>
|