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
|
@@ -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;
|
|
@@ -97,10 +101,19 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
97
101
|
onSelect: (snapshot, el) => {
|
|
98
102
|
const added = this.addElementReference(snapshot, el);
|
|
99
103
|
if (added) {
|
|
100
|
-
this.
|
|
104
|
+
const count = this.elementReferences.length;
|
|
105
|
+
this.showStatus(
|
|
106
|
+
count === 1
|
|
107
|
+
? `Pinned ${snapshot.selector}`
|
|
108
|
+
: `Pinned ${count} elements (latest: ${snapshot.selector})`,
|
|
109
|
+
"success"
|
|
110
|
+
);
|
|
101
111
|
}
|
|
102
112
|
this.syncUiStates();
|
|
103
113
|
},
|
|
114
|
+
onUnselect: (clientRef) => {
|
|
115
|
+
this.removeElementReference(clientRef);
|
|
116
|
+
},
|
|
104
117
|
onExit: () => {
|
|
105
118
|
this.isMinimized = false;
|
|
106
119
|
this.openComposer();
|
|
@@ -108,9 +121,21 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
108
121
|
},
|
|
109
122
|
canSelectMore: () => this.elementReferences.length < this.config.limits.max_element_references,
|
|
110
123
|
getExcludedSelectors: () => this.config.privacy.excluded_selectors,
|
|
124
|
+
getPinnedElements: () =>
|
|
125
|
+
this.elementReferences
|
|
126
|
+
.map((ref) => {
|
|
127
|
+
const node = this.elementDomNodes.get(ref.client_ref);
|
|
128
|
+
return node
|
|
129
|
+
? { clientRef: ref.client_ref, selector: ref.selector, element: node }
|
|
130
|
+
: null;
|
|
131
|
+
})
|
|
132
|
+
.filter(
|
|
133
|
+
(item): item is { clientRef: string; selector: string; element: Element } =>
|
|
134
|
+
item !== null
|
|
135
|
+
),
|
|
111
136
|
onStateChange: (state) => {
|
|
112
|
-
this.renderCompactBreadcrumbs(state.activeCandidate, state.ancestors);
|
|
113
137
|
this.syncPinActiveIndicators(state.active);
|
|
138
|
+
this.renderCompactCoachBar(state.active, state.candidateStack.length);
|
|
114
139
|
}
|
|
115
140
|
});
|
|
116
141
|
}
|
|
@@ -227,6 +252,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
227
252
|
if (elementNode) {
|
|
228
253
|
this.elementDomNodes.set(snapshot.client_ref, elementNode);
|
|
229
254
|
}
|
|
255
|
+
this.picker?.refreshPinnedMarkers();
|
|
230
256
|
this.renderTray();
|
|
231
257
|
this.syncUiStates();
|
|
232
258
|
return true;
|
|
@@ -236,6 +262,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
236
262
|
this.elementReferences = this.elementReferences.filter((el) => el.client_ref !== clientRef);
|
|
237
263
|
this.elementDomNodes.delete(clientRef);
|
|
238
264
|
this.picker?.hideExternalPreview();
|
|
265
|
+
this.picker?.refreshPinnedMarkers();
|
|
239
266
|
this.renderTray();
|
|
240
267
|
this.syncUiStates();
|
|
241
268
|
}
|
|
@@ -430,20 +457,12 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
430
457
|
|
|
431
458
|
const compactStatus = document.createElement("div");
|
|
432
459
|
compactStatus.className = "cd-compact-status";
|
|
433
|
-
|
|
434
|
-
breadcrumbScroll.className = "cd-breadcrumb-scroll";
|
|
435
|
-
this.compactBreadcrumbEl = breadcrumbScroll;
|
|
436
|
-
compactStatus.appendChild(breadcrumbScroll);
|
|
460
|
+
this.compactStatusEl = compactStatus;
|
|
437
461
|
compactBar.appendChild(compactStatus);
|
|
438
462
|
|
|
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);
|
|
463
|
+
const compactStepGroup = document.createElement("div");
|
|
464
|
+
compactStepGroup.className = "cd-compact-step-group";
|
|
465
|
+
this.compactStepGroupEl = compactStepGroup;
|
|
447
466
|
|
|
448
467
|
const compactLayerDown = document.createElement("button");
|
|
449
468
|
compactLayerDown.type = "button";
|
|
@@ -451,15 +470,29 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
451
470
|
compactLayerDown.title = "Step to inner/child element (Down arrow)";
|
|
452
471
|
compactLayerDown.setAttribute("aria-label", "Step to child element");
|
|
453
472
|
compactLayerDown.innerHTML = ICON_CHEVRON_DOWN;
|
|
454
|
-
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1));
|
|
455
|
-
|
|
473
|
+
compactLayerDown.addEventListener("click", () => this.picker?.cycleDepth(-1, true));
|
|
474
|
+
this.compactLayerDownBtn = compactLayerDown;
|
|
475
|
+
compactStepGroup.appendChild(compactLayerDown);
|
|
476
|
+
|
|
477
|
+
const compactLayerUp = document.createElement("button");
|
|
478
|
+
compactLayerUp.type = "button";
|
|
479
|
+
compactLayerUp.className = "cd-icon-btn";
|
|
480
|
+
compactLayerUp.title = "Step to outer/parent element (Up arrow)";
|
|
481
|
+
compactLayerUp.setAttribute("aria-label", "Step to parent element");
|
|
482
|
+
compactLayerUp.innerHTML = ICON_CHEVRON_UP;
|
|
483
|
+
compactLayerUp.addEventListener("click", () => this.picker?.cycleDepth(1, true));
|
|
484
|
+
this.compactLayerUpBtn = compactLayerUp;
|
|
485
|
+
compactStepGroup.appendChild(compactLayerUp);
|
|
486
|
+
|
|
487
|
+
compactBar.appendChild(compactStepGroup);
|
|
456
488
|
|
|
457
489
|
const expandBtn = document.createElement("button");
|
|
458
490
|
expandBtn.type = "button";
|
|
459
|
-
expandBtn.className = "cd-btn
|
|
460
|
-
expandBtn.setAttribute("aria-label", "
|
|
461
|
-
expandBtn.innerHTML =
|
|
491
|
+
expandBtn.className = "cd-btn";
|
|
492
|
+
expandBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
493
|
+
expandBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
462
494
|
expandBtn.addEventListener("click", () => this.expandFromCompactBar());
|
|
495
|
+
this.compactDoneBtn = expandBtn;
|
|
463
496
|
compactBar.appendChild(expandBtn);
|
|
464
497
|
|
|
465
498
|
// 2. Main Floating Chatbox Composer Window
|
|
@@ -687,7 +720,6 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
687
720
|
root.appendChild(pinDock);
|
|
688
721
|
this.shadow.appendChild(root);
|
|
689
722
|
|
|
690
|
-
this.renderCompactBreadcrumbs(null, []);
|
|
691
723
|
this.syncUiStates();
|
|
692
724
|
}
|
|
693
725
|
|
|
@@ -738,48 +770,102 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
738
770
|
}
|
|
739
771
|
|
|
740
772
|
this.syncPinActiveIndicators(pickerActive);
|
|
773
|
+
this.renderCompactCoachBar(
|
|
774
|
+
pickerActive,
|
|
775
|
+
this.picker ? this.picker.getCandidateStack().length : 0
|
|
776
|
+
);
|
|
741
777
|
}
|
|
742
778
|
|
|
743
|
-
private
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
this.
|
|
749
|
-
|
|
750
|
-
if (
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
this.
|
|
758
|
-
return;
|
|
779
|
+
private renderCompactCoachBar(pickerActive: boolean, candidateCount: number = 0): void {
|
|
780
|
+
if (!this.compactStatusEl) return;
|
|
781
|
+
this.compactStatusEl.innerHTML = "";
|
|
782
|
+
|
|
783
|
+
const pinnedCount = this.elementReferences.length;
|
|
784
|
+
const totalContextCount = pinnedCount + this.attachments.length;
|
|
785
|
+
|
|
786
|
+
if (this.compactStepGroupEl) {
|
|
787
|
+
this.compactStepGroupEl.hidden = !pickerActive;
|
|
788
|
+
}
|
|
789
|
+
if (this.compactLayerUpBtn) {
|
|
790
|
+
this.compactLayerUpBtn.disabled = candidateCount <= 1;
|
|
791
|
+
}
|
|
792
|
+
if (this.compactLayerDownBtn) {
|
|
793
|
+
this.compactLayerDownBtn.disabled = candidateCount <= 1;
|
|
759
794
|
}
|
|
760
795
|
|
|
761
|
-
|
|
762
|
-
if (
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
this.
|
|
796
|
+
if (pickerActive) {
|
|
797
|
+
if (pinnedCount === 0) {
|
|
798
|
+
const coach = document.createElement("span");
|
|
799
|
+
coach.className = "cd-compact-coach-text";
|
|
800
|
+
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>`;
|
|
801
|
+
this.compactStatusEl.appendChild(coach);
|
|
802
|
+
} else {
|
|
803
|
+
const latest = this.elementReferences[pinnedCount - 1];
|
|
804
|
+
const pill = document.createElement("div");
|
|
805
|
+
pill.className = "cd-compact-pinned-pill";
|
|
806
|
+
|
|
807
|
+
const countSpan = document.createElement("span");
|
|
808
|
+
countSpan.className = "cd-compact-pinned-count";
|
|
809
|
+
countSpan.textContent = `${pinnedCount} pinned`;
|
|
810
|
+
|
|
811
|
+
const selSpan = document.createElement("span");
|
|
812
|
+
selSpan.className = "cd-compact-pinned-selector";
|
|
813
|
+
selSpan.textContent = latest.selector;
|
|
814
|
+
selSpan.title = latest.dom_path || latest.selector;
|
|
815
|
+
|
|
816
|
+
const undoBtn = document.createElement("button");
|
|
817
|
+
undoBtn.type = "button";
|
|
818
|
+
undoBtn.className = "cd-chip-remove";
|
|
819
|
+
undoBtn.title = `Remove ${latest.selector}`;
|
|
820
|
+
undoBtn.setAttribute("aria-label", `Undo pin ${latest.selector}`);
|
|
821
|
+
undoBtn.innerHTML = ICON_CLOSE;
|
|
822
|
+
undoBtn.addEventListener("click", (ev) => {
|
|
823
|
+
ev.stopPropagation();
|
|
824
|
+
this.removeElementReference(latest.client_ref);
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
pill.appendChild(countSpan);
|
|
828
|
+
pill.appendChild(selSpan);
|
|
829
|
+
pill.appendChild(undoBtn);
|
|
830
|
+
this.compactStatusEl.appendChild(pill);
|
|
831
|
+
|
|
832
|
+
const addMore = document.createElement("span");
|
|
833
|
+
addMore.className = "cd-compact-coach-text";
|
|
834
|
+
addMore.textContent = "Click another to add";
|
|
835
|
+
this.compactStatusEl.appendChild(addMore);
|
|
767
836
|
}
|
|
768
837
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
838
|
+
if (this.compactDoneBtn) {
|
|
839
|
+
if (pinnedCount > 0) {
|
|
840
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
841
|
+
this.compactDoneBtn.setAttribute(
|
|
842
|
+
"aria-label",
|
|
843
|
+
"Finish pinning elements and return to chatbox"
|
|
844
|
+
);
|
|
845
|
+
this.compactDoneBtn.innerHTML = `${ICON_CHECK}<span>Done (${pinnedCount})</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
846
|
+
} else {
|
|
847
|
+
this.compactDoneBtn.className = "cd-btn";
|
|
848
|
+
this.compactDoneBtn.setAttribute("aria-label", "Cancel pinning and return to chatbox");
|
|
849
|
+
this.compactDoneBtn.innerHTML = `<span>Cancel</span><kbd class="cd-kbd">Esc</kbd>`;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Minimized while not actively in Pin Mode
|
|
856
|
+
const summary = document.createElement("span");
|
|
857
|
+
summary.className = "cd-compact-coach-text";
|
|
858
|
+
summary.textContent =
|
|
859
|
+
totalContextCount > 0
|
|
860
|
+
? `${totalContextCount} context item${totalContextCount > 1 ? "s" : ""} attached`
|
|
861
|
+
: "Chatbox minimized";
|
|
862
|
+
this.compactStatusEl.appendChild(summary);
|
|
863
|
+
|
|
864
|
+
if (this.compactDoneBtn) {
|
|
865
|
+
this.compactDoneBtn.className = "cd-btn cd-btn-primary";
|
|
866
|
+
this.compactDoneBtn.setAttribute("aria-label", "Return to chatbox");
|
|
867
|
+
this.compactDoneBtn.innerHTML = `${ICON_EXPAND}<span>Chat</span>`;
|
|
868
|
+
}
|
|
783
869
|
}
|
|
784
870
|
|
|
785
871
|
private renderChatThread(): void {
|
|
@@ -797,7 +883,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
797
883
|
const p2 = document.createElement("p");
|
|
798
884
|
p2.className = "cd-chat-empty-hint";
|
|
799
885
|
p2.textContent =
|
|
800
|
-
"
|
|
886
|
+
"Click Pin Element, scroll the wheel to step through overlapping layers, click once to pin, and press Esc when done.";
|
|
801
887
|
|
|
802
888
|
emptyBox.appendChild(p1);
|
|
803
889
|
emptyBox.appendChild(p2);
|
data/lib/context_drop/version.rb
CHANGED