context_drop 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +101 -9
- data/app/assets/javascripts/context_drop/context_drop.js +1219 -575
- data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +62 -2
- data/app/helpers/context_drop/dashboard_helper.rb +52 -0
- data/app/javascript/context_drop/__tests__/widget.test.ts +225 -3
- data/app/javascript/context_drop/element-picker.ts +958 -484
- data/app/javascript/context_drop/icons.ts +2 -0
- data/app/javascript/context_drop/screenshot.ts +7 -1
- data/app/javascript/context_drop/styles.ts +88 -39
- data/app/javascript/context_drop/widget.ts +195 -69
- data/app/models/context_drop/feedback.rb +11 -5
- data/app/views/context_drop/dashboard/feedbacks/index.html.erb +161 -60
- data/app/views/context_drop/dashboard/feedbacks/show.html.erb +168 -47
- data/app/views/layouts/context_drop/application.html.erb +415 -70
- data/lib/context_drop/version.rb +1 -1
- metadata +3 -2
|
@@ -15,6 +15,8 @@ export const ICON_CHEVRON_DOWN = `<svg viewBox="0 0 16 16" width="12" height="12
|
|
|
15
15
|
|
|
16
16
|
export 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>`;
|
|
17
17
|
|
|
18
|
+
export 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>`;
|
|
19
|
+
|
|
18
20
|
export 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>`;
|
|
19
21
|
|
|
20
22
|
export 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>`;
|
|
@@ -119,7 +119,13 @@ export async function captureViewportScreenshot(
|
|
|
119
119
|
// Paint visible non-excluded DOM elements approximation onto canvas
|
|
120
120
|
const visibleNodes = document.body ? Array.from(document.body.querySelectorAll("*")) : [];
|
|
121
121
|
for (const node of visibleNodes) {
|
|
122
|
-
if (
|
|
122
|
+
if (
|
|
123
|
+
node.closest("context-drop-widget") ||
|
|
124
|
+
node.hasAttribute("data-context-drop-ui") ||
|
|
125
|
+
node.closest("[data-context-drop-ui]")
|
|
126
|
+
) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
123
129
|
if (isElementExcluded(node, customExcludedSelectors)) continue;
|
|
124
130
|
|
|
125
131
|
const r = node.getBoundingClientRect();
|
|
@@ -92,21 +92,18 @@ textarea:focus-visible {
|
|
|
92
92
|
|
|
93
93
|
/* Custom themed scrollbars */
|
|
94
94
|
.cd-chat-thread::-webkit-scrollbar,
|
|
95
|
-
.cd-tray::-webkit-scrollbar
|
|
96
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar {
|
|
95
|
+
.cd-tray::-webkit-scrollbar {
|
|
97
96
|
width: 6px;
|
|
98
97
|
height: 6px;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
.cd-chat-thread::-webkit-scrollbar-track,
|
|
102
|
-
.cd-tray::-webkit-scrollbar-track
|
|
103
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar-track {
|
|
101
|
+
.cd-tray::-webkit-scrollbar-track {
|
|
104
102
|
background: transparent;
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
.cd-chat-thread::-webkit-scrollbar-thumb,
|
|
108
|
-
.cd-tray::-webkit-scrollbar-thumb
|
|
109
|
-
.cd-breadcrumb-scroll::-webkit-scrollbar-thumb {
|
|
106
|
+
.cd-tray::-webkit-scrollbar-thumb {
|
|
110
107
|
background: var(--cd-border);
|
|
111
108
|
border-radius: 9999px;
|
|
112
109
|
}
|
|
@@ -211,14 +208,15 @@ textarea:focus-visible {
|
|
|
211
208
|
font-variant-numeric: tabular-nums;
|
|
212
209
|
}
|
|
213
210
|
|
|
214
|
-
/* Compact Minimized Bar (active while pinning elements or minimized) */
|
|
211
|
+
/* Compact Minimized Session Coach Bar (active while pinning elements or minimized) */
|
|
215
212
|
.cd-compact-bar {
|
|
216
213
|
pointer-events: auto;
|
|
217
214
|
display: flex;
|
|
218
215
|
align-items: center;
|
|
219
216
|
gap: 8px;
|
|
220
|
-
width:
|
|
221
|
-
|
|
217
|
+
width: max-content;
|
|
218
|
+
min-width: 390px;
|
|
219
|
+
max-width: min(560px, calc(100vw - 24px));
|
|
222
220
|
padding: 7px 10px;
|
|
223
221
|
background: var(--cd-surface);
|
|
224
222
|
color: var(--cd-ink);
|
|
@@ -237,52 +235,93 @@ textarea:focus-visible {
|
|
|
237
235
|
.cd-compact-status {
|
|
238
236
|
display: flex;
|
|
239
237
|
align-items: center;
|
|
240
|
-
gap:
|
|
238
|
+
gap: 7px;
|
|
241
239
|
flex: 1;
|
|
242
240
|
min-width: 0;
|
|
241
|
+
overflow: hidden;
|
|
243
242
|
}
|
|
244
243
|
|
|
245
|
-
.cd-
|
|
246
|
-
display: flex;
|
|
244
|
+
.cd-compact-coach-text {
|
|
245
|
+
display: inline-flex;
|
|
247
246
|
align-items: center;
|
|
248
|
-
gap:
|
|
249
|
-
|
|
247
|
+
gap: 5px;
|
|
248
|
+
font-size: 12px;
|
|
249
|
+
color: var(--cd-ink-secondary);
|
|
250
250
|
white-space: nowrap;
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
overflow: hidden;
|
|
252
|
+
text-overflow: ellipsis;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.cd-compact-coach-text strong {
|
|
256
|
+
color: var(--cd-ink);
|
|
257
|
+
font-weight: 600;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.cd-compact-wheel-icon {
|
|
261
|
+
display: inline-flex;
|
|
262
|
+
align-items: center;
|
|
263
|
+
color: var(--cd-accent);
|
|
264
|
+
flex-shrink: 0;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.cd-compact-pinned-pill {
|
|
268
|
+
display: inline-flex;
|
|
269
|
+
align-items: center;
|
|
270
|
+
gap: 5px;
|
|
271
|
+
padding: 2px 5px 2px 6px;
|
|
272
|
+
background: var(--cd-surface-elevated);
|
|
273
|
+
border: 1px solid var(--cd-border);
|
|
274
|
+
border-radius: 7px;
|
|
253
275
|
min-width: 0;
|
|
254
|
-
|
|
276
|
+
max-width: 220px;
|
|
255
277
|
}
|
|
256
278
|
|
|
257
|
-
.cd-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
border-radius: 5px;
|
|
266
|
-
cursor: pointer;
|
|
279
|
+
.cd-compact-pinned-count {
|
|
280
|
+
font-size: 10.5px;
|
|
281
|
+
font-weight: 700;
|
|
282
|
+
font-variant-numeric: tabular-nums;
|
|
283
|
+
padding: 1px 5px;
|
|
284
|
+
border-radius: 4px;
|
|
285
|
+
background: var(--cd-pin-soft);
|
|
286
|
+
color: var(--cd-pin-hover);
|
|
267
287
|
flex-shrink: 0;
|
|
268
288
|
}
|
|
269
289
|
|
|
270
|
-
.cd-
|
|
271
|
-
|
|
290
|
+
.cd-compact-pinned-selector {
|
|
291
|
+
font-family: var(--cd-mono);
|
|
292
|
+
font-size: 11px;
|
|
272
293
|
color: var(--cd-ink);
|
|
294
|
+
overflow: hidden;
|
|
295
|
+
text-overflow: ellipsis;
|
|
296
|
+
white-space: nowrap;
|
|
273
297
|
}
|
|
274
298
|
|
|
275
|
-
.cd-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
299
|
+
.cd-compact-step-group {
|
|
300
|
+
display: inline-flex;
|
|
301
|
+
align-items: center;
|
|
302
|
+
gap: 2px;
|
|
303
|
+
flex-shrink: 0;
|
|
280
304
|
}
|
|
281
305
|
|
|
282
|
-
.cd-
|
|
306
|
+
.cd-kbd {
|
|
283
307
|
display: inline-flex;
|
|
284
|
-
|
|
285
|
-
|
|
308
|
+
align-items: center;
|
|
309
|
+
justify-content: center;
|
|
310
|
+
font-family: var(--cd-mono);
|
|
311
|
+
font-size: 10px;
|
|
312
|
+
font-weight: 600;
|
|
313
|
+
line-height: 1.1;
|
|
314
|
+
padding: 2px 5px;
|
|
315
|
+
border-radius: 4px;
|
|
316
|
+
background: var(--cd-surface-recessed);
|
|
317
|
+
border: 1px solid var(--cd-border);
|
|
318
|
+
color: var(--cd-ink-secondary);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.cd-btn-primary .cd-kbd {
|
|
322
|
+
background: rgba(250, 249, 246, 0.16);
|
|
323
|
+
border-color: rgba(250, 249, 246, 0.26);
|
|
324
|
+
color: var(--cd-surface);
|
|
286
325
|
}
|
|
287
326
|
|
|
288
327
|
/* Main Floating Chatbox Composer Window */
|
|
@@ -395,11 +434,16 @@ textarea:focus-visible {
|
|
|
395
434
|
transition: background-color 0.12s ease, color 0.12s ease;
|
|
396
435
|
}
|
|
397
436
|
|
|
398
|
-
.cd-icon-btn:hover {
|
|
437
|
+
.cd-icon-btn:hover:not(:disabled) {
|
|
399
438
|
background: rgba(17, 19, 24, 0.06);
|
|
400
439
|
color: var(--cd-ink);
|
|
401
440
|
}
|
|
402
441
|
|
|
442
|
+
.cd-icon-btn:disabled {
|
|
443
|
+
opacity: 0.36;
|
|
444
|
+
cursor: not-allowed;
|
|
445
|
+
}
|
|
446
|
+
|
|
403
447
|
/* Conversational Chat Thread */
|
|
404
448
|
.cd-chat-thread {
|
|
405
449
|
display: flex;
|
|
@@ -681,10 +725,15 @@ textarea:focus-visible {
|
|
|
681
725
|
border-color: #252a34;
|
|
682
726
|
}
|
|
683
727
|
|
|
684
|
-
@media (max-width:
|
|
728
|
+
@media (max-width: 520px) {
|
|
685
729
|
.cd-composer,
|
|
686
730
|
.cd-compact-bar {
|
|
687
731
|
width: calc(100vw - 20px);
|
|
732
|
+
min-width: 0;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.cd-compact-bar {
|
|
736
|
+
flex-wrap: wrap;
|
|
688
737
|
}
|
|
689
738
|
}
|
|
690
739
|
`;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ElementCandidateInfo,
|
|
3
2
|
ElementReferenceSnapshot,
|
|
4
3
|
FeedbackSubmissionPayload,
|
|
5
4
|
PendingAttachmentItem,
|
|
@@ -7,12 +6,12 @@ import type {
|
|
|
7
6
|
WidgetConfig,
|
|
8
7
|
WidgetPosition
|
|
9
8
|
} from "./types.ts";
|
|
10
|
-
import {
|
|
9
|
+
import { MANDATORY_EXCLUDED_SELECTORS } from "./sanitizer.ts";
|
|
11
10
|
import {
|
|
12
11
|
ICON_CAMERA,
|
|
13
12
|
ICON_CHAT,
|
|
13
|
+
ICON_CHECK,
|
|
14
14
|
ICON_CHEVRON_DOWN,
|
|
15
|
-
ICON_CHEVRON_RIGHT,
|
|
16
15
|
ICON_CHEVRON_UP,
|
|
17
16
|
ICON_CLOSE,
|
|
18
17
|
ICON_EXPAND,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
ICON_IMAGE,
|
|
21
20
|
ICON_MINIMIZE,
|
|
22
21
|
ICON_PIN,
|
|
22
|
+
ICON_SCROLL_VERTICAL,
|
|
23
23
|
ICON_SEND
|
|
24
24
|
} from "./icons.ts";
|
|
25
25
|
import { WIDGET_SHADOW_STYLES } from "./styles.ts";
|
|
@@ -73,7 +73,11 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
73
73
|
private rootContainer: HTMLDivElement | null = null;
|
|
74
74
|
private composerEl: HTMLDivElement | null = null;
|
|
75
75
|
private compactBarEl: HTMLDivElement | null = null;
|
|
76
|
-
private
|
|
76
|
+
private compactStatusEl: HTMLDivElement | null = null;
|
|
77
|
+
private compactStepGroupEl: HTMLDivElement | null = null;
|
|
78
|
+
private compactLayerUpBtn: HTMLButtonElement | null = null;
|
|
79
|
+
private compactLayerDownBtn: HTMLButtonElement | null = null;
|
|
80
|
+
private compactDoneBtn: HTMLButtonElement | null = null;
|
|
77
81
|
private compactPinBtn: HTMLButtonElement | null = null;
|
|
78
82
|
private pinDockEl: HTMLDivElement | null = null;
|
|
79
83
|
private floatingPinBtn: HTMLButtonElement | null = null;
|
|
@@ -85,6 +89,10 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
85
89
|
private statusEl: HTMLDivElement | null = null;
|
|
86
90
|
private fileInputEl: HTMLInputElement | null = null;
|
|
87
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;
|
|
88
96
|
|
|
89
97
|
public connectedCallback(): void {
|
|
90
98
|
if (!this.shadow) {
|
|
@@ -93,14 +101,49 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
93
101
|
this.readDataAttributes();
|
|
94
102
|
this.renderShadowDom();
|
|
95
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
|
+
|
|
96
130
|
this.picker = new ElementPicker({
|
|
97
131
|
onSelect: (snapshot, el) => {
|
|
98
132
|
const added = this.addElementReference(snapshot, el);
|
|
99
133
|
if (added) {
|
|
100
|
-
this.
|
|
134
|
+
const count = this.elementReferences.length;
|
|
135
|
+
this.showStatus(
|
|
136
|
+
count === 1
|
|
137
|
+
? `Pinned ${snapshot.selector}`
|
|
138
|
+
: `Pinned ${count} elements (latest: ${snapshot.selector})`,
|
|
139
|
+
"success"
|
|
140
|
+
);
|
|
101
141
|
}
|
|
102
142
|
this.syncUiStates();
|
|
103
143
|
},
|
|
144
|
+
onUnselect: (clientRef) => {
|
|
145
|
+
this.removeElementReference(clientRef);
|
|
146
|
+
},
|
|
104
147
|
onExit: () => {
|
|
105
148
|
this.isMinimized = false;
|
|
106
149
|
this.openComposer();
|
|
@@ -108,9 +151,21 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
108
151
|
},
|
|
109
152
|
canSelectMore: () => this.elementReferences.length < this.config.limits.max_element_references,
|
|
110
153
|
getExcludedSelectors: () => this.config.privacy.excluded_selectors,
|
|
154
|
+
getPinnedElements: () =>
|
|
155
|
+
this.elementReferences
|
|
156
|
+
.map((ref) => {
|
|
157
|
+
const node = this.elementDomNodes.get(ref.client_ref);
|
|
158
|
+
return node
|
|
159
|
+
? { clientRef: ref.client_ref, selector: ref.selector, element: node }
|
|
160
|
+
: null;
|
|
161
|
+
})
|
|
162
|
+
.filter(
|
|
163
|
+
(item): item is { clientRef: string; selector: string; element: Element } =>
|
|
164
|
+
item !== null
|
|
165
|
+
),
|
|
111
166
|
onStateChange: (state) => {
|
|
112
|
-
this.renderCompactBreadcrumbs(state.activeCandidate, state.ancestors);
|
|
113
167
|
this.syncPinActiveIndicators(state.active);
|
|
168
|
+
this.renderCompactCoachBar(state.active, state.candidateStack.length);
|
|
114
169
|
}
|
|
115
170
|
});
|
|
116
171
|
}
|
|
@@ -120,6 +175,11 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
120
175
|
this.picker.stop();
|
|
121
176
|
}
|
|
122
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
|
+
}
|
|
123
183
|
}
|
|
124
184
|
|
|
125
185
|
public getConfig(): WidgetConfig {
|
|
@@ -191,6 +251,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
191
251
|
}
|
|
192
252
|
this.minimizeToCompactBar();
|
|
193
253
|
this.picker.start();
|
|
254
|
+
if (this.lastPointerX > 0 && this.lastPointerY > 0) {
|
|
255
|
+
this.picker.highlightAtPoint(this.lastPointerX, this.lastPointerY);
|
|
256
|
+
}
|
|
194
257
|
this.syncUiStates();
|
|
195
258
|
}
|
|
196
259
|
|
|
@@ -227,6 +290,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
227
290
|
if (elementNode) {
|
|
228
291
|
this.elementDomNodes.set(snapshot.client_ref, elementNode);
|
|
229
292
|
}
|
|
293
|
+
this.picker?.refreshPinnedMarkers();
|
|
230
294
|
this.renderTray();
|
|
231
295
|
this.syncUiStates();
|
|
232
296
|
return true;
|
|
@@ -236,6 +300,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
236
300
|
this.elementReferences = this.elementReferences.filter((el) => el.client_ref !== clientRef);
|
|
237
301
|
this.elementDomNodes.delete(clientRef);
|
|
238
302
|
this.picker?.hideExternalPreview();
|
|
303
|
+
this.picker?.refreshPinnedMarkers();
|
|
239
304
|
this.renderTray();
|
|
240
305
|
this.syncUiStates();
|
|
241
306
|
}
|
|
@@ -422,7 +487,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
422
487
|
const compactPinBtn = document.createElement("button");
|
|
423
488
|
compactPinBtn.type = "button";
|
|
424
489
|
compactPinBtn.className = "cd-pin-corner-btn is-active";
|
|
425
|
-
compactPinBtn.
|
|
490
|
+
compactPinBtn.title = "Toggle Freeze & Pin (⌥⇧P)";
|
|
491
|
+
compactPinBtn.setAttribute("aria-label", "Toggle element pin mode (Option+Shift+P)");
|
|
426
492
|
compactPinBtn.innerHTML = `${ICON_PIN}<span>Pinning</span>`;
|
|
427
493
|
compactPinBtn.addEventListener("click", () => this.togglePinSelection());
|
|
428
494
|
this.compactPinBtn = compactPinBtn;
|
|
@@ -430,20 +496,12 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
430
496
|
|
|
431
497
|
const compactStatus = document.createElement("div");
|
|
432
498
|
compactStatus.className = "cd-compact-status";
|
|
433
|
-
|
|
434
|
-
breadcrumbScroll.className = "cd-breadcrumb-scroll";
|
|
435
|
-
this.compactBreadcrumbEl = breadcrumbScroll;
|
|
436
|
-
compactStatus.appendChild(breadcrumbScroll);
|
|
499
|
+
this.compactStatusEl = compactStatus;
|
|
437
500
|
compactBar.appendChild(compactStatus);
|
|
438
501
|
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
443
|
-
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
444
|
-
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
445
|
-
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1));
|
|
446
|
-
compactBar.appendChild(compactLayerUp);
|
|
502
|
+
const compactStepGroup = document.createElement("div");
|
|
503
|
+
compactStepGroup.className = "cd-compact-step-group";
|
|
504
|
+
this.compactStepGroupEl = compactStepGroup;
|
|
447
505
|
|
|
448
506
|
const compactLayerDown = document.createElement("button");
|
|
449
507
|
compactLayerDown.type = "button";
|
|
@@ -451,15 +509,29 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
451
509
|
compactLayerDown.title = "Step to inner/child element (Down arrow)";
|
|
452
510
|
compactLayerDown.setAttribute("aria-label", "Step to child element");
|
|
453
511
|
compactLayerDown.innerHTML = ICON_CHEVRON_DOWN;
|
|
454
|
-
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1));
|
|
455
|
-
|
|
512
|
+
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1, true));
|
|
513
|
+
this.compactLayerDownBtn = compactLayerDown;
|
|
514
|
+
compactStepGroup.appendChild(compactLayerDown);
|
|
515
|
+
|
|
516
|
+
const compactLayerUp = document.createElement("button");
|
|
517
|
+
compactLayerUp.type = "button";
|
|
518
|
+
compactLayerUp.className = "cd-icon-btn";
|
|
519
|
+
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
520
|
+
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
521
|
+
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
522
|
+
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1, true));
|
|
523
|
+
this.compactLayerUpBtn = compactLayerUp;
|
|
524
|
+
compactStepGroup.appendChild(compactLayerUp);
|
|
525
|
+
|
|
526
|
+
compactBar.appendChild(compactStepGroup);
|
|
456
527
|
|
|
457
528
|
const expandBtn = document.createElement("button");
|
|
458
529
|
expandBtn.type = "button";
|
|
459
|
-
expandBtn.className = "cd-btn
|
|
460
|
-
expandBtn.setAttribute("aria-label", "
|
|
461
|
-
expandBtn.innerHTML =
|
|
530
|
+
expandBtn.className = "cd-btn";
|
|
531
|
+
expandBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
532
|
+
expandBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
462
533
|
expandBtn.addEventListener("click", () => this.expandFromCompactBar());
|
|
534
|
+
this.compactDoneBtn = expandBtn;
|
|
463
535
|
compactBar.appendChild(expandBtn);
|
|
464
536
|
|
|
465
537
|
// 2. Main Floating Chatbox Composer Window
|
|
@@ -499,8 +571,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
499
571
|
const cornerPinBtn = document.createElement("button");
|
|
500
572
|
cornerPinBtn.type = "button";
|
|
501
573
|
cornerPinBtn.className = "cd-pin-corner-btn";
|
|
502
|
-
cornerPinBtn.title = "
|
|
503
|
-
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)");
|
|
504
576
|
cornerPinBtn.innerHTML = `${ICON_PIN}<span>Pin Element</span>`;
|
|
505
577
|
cornerPinBtn.addEventListener("click", () => this.startPinSelection());
|
|
506
578
|
this.cornerPinBtn = cornerPinBtn;
|
|
@@ -607,8 +679,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
607
679
|
const pickBtn = document.createElement("button");
|
|
608
680
|
pickBtn.type = "button";
|
|
609
681
|
pickBtn.className = "cd-btn";
|
|
610
|
-
pickBtn.
|
|
611
|
-
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>`;
|
|
612
685
|
pickBtn.addEventListener("click", () => this.startPinSelection());
|
|
613
686
|
actions.appendChild(pickBtn);
|
|
614
687
|
}
|
|
@@ -664,8 +737,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
664
737
|
const floatingPinBtn = document.createElement("button");
|
|
665
738
|
floatingPinBtn.type = "button";
|
|
666
739
|
floatingPinBtn.className = "cd-floating-pin-btn";
|
|
667
|
-
floatingPinBtn.title = "Pin
|
|
668
|
-
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)");
|
|
669
742
|
floatingPinBtn.innerHTML = `${ICON_PIN}<span>Pin</span>`;
|
|
670
743
|
this.attachDragHandle(floatingPinBtn, () => this.startPinSelection());
|
|
671
744
|
this.floatingPinBtn = floatingPinBtn;
|
|
@@ -687,7 +760,6 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
687
760
|
root.appendChild(pinDock);
|
|
688
761
|
this.shadow.appendChild(root);
|
|
689
762
|
|
|
690
|
-
this.renderCompactBreadcrumbs(null, []);
|
|
691
763
|
this.syncUiStates();
|
|
692
764
|
}
|
|
693
765
|
|
|
@@ -738,48 +810,102 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
738
810
|
}
|
|
739
811
|
|
|
740
812
|
this.syncPinActiveIndicators(pickerActive);
|
|
813
|
+
this.renderCompactCoachBar(
|
|
814
|
+
pickerActive,
|
|
815
|
+
this.picker ? this.picker.getCandidateStack().length : 0
|
|
816
|
+
);
|
|
741
817
|
}
|
|
742
818
|
|
|
743
|
-
private
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
this.
|
|
749
|
-
|
|
750
|
-
if (
|
|
751
|
-
|
|
752
|
-
hint.style.cssText = "font-size: 11.5px; color: #4b5262;";
|
|
753
|
-
hint.textContent =
|
|
754
|
-
this.elementReferences.length > 0
|
|
755
|
-
? `${this.elementReferences.length} pinned · Hover or click any element (scroll ↕ for layers)`
|
|
756
|
-
: "Hover any element · Scroll ↕ for layers · Click to inspect stack";
|
|
757
|
-
this.compactBreadcrumbEl.appendChild(hint);
|
|
758
|
-
return;
|
|
819
|
+
private renderCompactCoachBar(pickerActive: boolean, candidateCount: number = 0): void {
|
|
820
|
+
if (!this.compactStatusEl) return;
|
|
821
|
+
this.compactStatusEl.innerHTML = "";
|
|
822
|
+
|
|
823
|
+
const pinnedCount = this.elementReferences.length;
|
|
824
|
+
const totalContextCount = pinnedCount + this.attachments.length;
|
|
825
|
+
|
|
826
|
+
if (this.compactStepGroupEl) {
|
|
827
|
+
this.compactStepGroupEl.hidden = !pickerActive;
|
|
759
828
|
}
|
|
829
|
+
if (this.compactLayerUpBtn) {
|
|
830
|
+
this.compactLayerUpBtn.disabled = candidateCount <= 1;
|
|
831
|
+
}
|
|
832
|
+
if (this.compactLayerDownBtn) {
|
|
833
|
+
this.compactLayerDownBtn.disabled = candidateCount <= 1;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (pickerActive) {
|
|
837
|
+
if (pinnedCount === 0) {
|
|
838
|
+
const coach = document.createElement("span");
|
|
839
|
+
coach.className = "cd-compact-coach-text";
|
|
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>`;
|
|
841
|
+
this.compactStatusEl.appendChild(coach);
|
|
842
|
+
} else {
|
|
843
|
+
const latest = this.elementReferences[pinnedCount - 1];
|
|
844
|
+
const pill = document.createElement("div");
|
|
845
|
+
pill.className = "cd-compact-pinned-pill";
|
|
846
|
+
|
|
847
|
+
const countSpan = document.createElement("span");
|
|
848
|
+
countSpan.className = "cd-compact-pinned-count";
|
|
849
|
+
countSpan.textContent = `${pinnedCount} pinned`;
|
|
850
|
+
|
|
851
|
+
const selSpan = document.createElement("span");
|
|
852
|
+
selSpan.className = "cd-compact-pinned-selector";
|
|
853
|
+
selSpan.textContent = latest.selector;
|
|
854
|
+
selSpan.title = latest.dom_path || latest.selector;
|
|
855
|
+
|
|
856
|
+
const undoBtn = document.createElement("button");
|
|
857
|
+
undoBtn.type = "button";
|
|
858
|
+
undoBtn.className = "cd-chip-remove";
|
|
859
|
+
undoBtn.title = `Remove ${latest.selector}`;
|
|
860
|
+
undoBtn.setAttribute("aria-label", `Undo pin ${latest.selector}`);
|
|
861
|
+
undoBtn.innerHTML = ICON_CLOSE;
|
|
862
|
+
undoBtn.addEventListener("click", (ev) => {
|
|
863
|
+
ev.stopPropagation();
|
|
864
|
+
this.removeElementReference(latest.client_ref);
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
pill.appendChild(countSpan);
|
|
868
|
+
pill.appendChild(selSpan);
|
|
869
|
+
pill.appendChild(undoBtn);
|
|
870
|
+
this.compactStatusEl.appendChild(pill);
|
|
760
871
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
sep.innerHTML = ICON_CHEVRON_RIGHT;
|
|
766
|
-
this.compactBreadcrumbEl?.appendChild(sep);
|
|
872
|
+
const addMore = document.createElement("span");
|
|
873
|
+
addMore.className = "cd-compact-coach-text";
|
|
874
|
+
addMore.innerHTML = `<strong>Space</strong><span>or click to add more</span>`;
|
|
875
|
+
this.compactStatusEl.appendChild(addMore);
|
|
767
876
|
}
|
|
768
877
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
878
|
+
if (this.compactDoneBtn) {
|
|
879
|
+
if (pinnedCount > 0) {
|
|
880
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
881
|
+
this.compactDoneBtn.setAttribute(
|
|
882
|
+
"aria-label",
|
|
883
|
+
"Finish pinning elements and return to chatbox"
|
|
884
|
+
);
|
|
885
|
+
this.compactDoneBtn.innerHTML = `${ICON_CHECK}<span>Done (${pinnedCount})</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
886
|
+
} else {
|
|
887
|
+
this.compactDoneBtn.className = "cd-btn";
|
|
888
|
+
this.compactDoneBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
889
|
+
this.compactDoneBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// Minimized while not actively in Pin Mode
|
|
896
|
+
const summary = document.createElement("span");
|
|
897
|
+
summary.className = "cd-compact-coach-text";
|
|
898
|
+
summary.textContent =
|
|
899
|
+
totalContextCount > 0
|
|
900
|
+
? `${totalContextCount} context item${totalContextCount > 1 ? "s" : ""} attached`
|
|
901
|
+
: "Chatbox minimized";
|
|
902
|
+
this.compactStatusEl.appendChild(summary);
|
|
903
|
+
|
|
904
|
+
if (this.compactDoneBtn) {
|
|
905
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
906
|
+
this.compactDoneBtn.setAttribute("aria-label", "Return to chatbox");
|
|
907
|
+
this.compactDoneBtn.innerHTML = `${ICON_EXPAND}<span>Chat</span>`;
|
|
908
|
+
}
|
|
783
909
|
}
|
|
784
910
|
|
|
785
911
|
private renderChatThread(): void {
|
|
@@ -796,8 +922,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
796
922
|
|
|
797
923
|
const p2 = document.createElement("p");
|
|
798
924
|
p2.className = "cd-chat-empty-hint";
|
|
799
|
-
p2.
|
|
800
|
-
"
|
|
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.";
|
|
801
927
|
|
|
802
928
|
emptyBox.appendChild(p1);
|
|
803
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
|