@widgetic/creator 0.4.13 → 0.4.14
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.
package/dist/CreatorApp.svelte
CHANGED
|
@@ -3017,7 +3017,8 @@
|
|
|
3017
3017
|
}
|
|
3018
3018
|
const response = await conversationsClient.createConversationForWidgetRaw({
|
|
3019
3019
|
createConversationForWidgetRequest: {
|
|
3020
|
-
|
|
3020
|
+
// The generated client writes `widgetId`. A snake_case key is dropped, and the API then rejects the body.
|
|
3021
|
+
widgetId: contextId,
|
|
3021
3022
|
title,
|
|
3022
3023
|
},
|
|
3023
3024
|
});
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
...data.element,
|
|
147
147
|
id: `sel_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`
|
|
148
148
|
};
|
|
149
|
-
onSelectElement?.(selectedRef);
|
|
149
|
+
onSelectElement?.(rememberFrame(selectedRef));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -167,6 +167,31 @@
|
|
|
167
167
|
return true;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
function rememberFrame(element: SelectedWidgetElementReference): SelectedWidgetElementReference {
|
|
171
|
+
if (viewportWidth <= 0 || viewportHeight <= 0) return element;
|
|
172
|
+
return {
|
|
173
|
+
...element,
|
|
174
|
+
rectFrame: { width: viewportWidth, height: viewportHeight },
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function rectInCurrentFrame(
|
|
179
|
+
rect: NonNullable<SelectedWidgetElementReference['rect']>,
|
|
180
|
+
frame?: SelectedWidgetElementReference['rectFrame'],
|
|
181
|
+
) {
|
|
182
|
+
const sourceWidth = frame?.width ?? viewportWidth;
|
|
183
|
+
const sourceHeight = frame?.height ?? viewportHeight;
|
|
184
|
+
if (sourceWidth <= 0 || sourceHeight <= 0 || viewportWidth <= 0 || viewportHeight <= 0) return rect;
|
|
185
|
+
const scaleX = viewportWidth / sourceWidth;
|
|
186
|
+
const scaleY = viewportHeight / sourceHeight;
|
|
187
|
+
return {
|
|
188
|
+
x: rect.x * scaleX,
|
|
189
|
+
y: rect.y * scaleY,
|
|
190
|
+
width: rect.width * scaleX,
|
|
191
|
+
height: rect.height * scaleY,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
170
195
|
function handlePointerMove(event: PointerEvent) {
|
|
171
196
|
if (!enabled || passthroughHeld) return;
|
|
172
197
|
const surface = event.currentTarget as HTMLElement;
|
|
@@ -207,7 +232,7 @@
|
|
|
207
232
|
}
|
|
208
233
|
if (target) {
|
|
209
234
|
const selectedRef = serializePickedElement(target);
|
|
210
|
-
onSelectElement?.(selectedRef);
|
|
235
|
+
onSelectElement?.(rememberFrame(selectedRef));
|
|
211
236
|
}
|
|
212
237
|
return;
|
|
213
238
|
}
|
|
@@ -217,7 +242,7 @@
|
|
|
217
242
|
...hoveredElement,
|
|
218
243
|
id: `sel_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`
|
|
219
244
|
};
|
|
220
|
-
onSelectElement?.(selectedRef);
|
|
245
|
+
onSelectElement?.(rememberFrame(selectedRef));
|
|
221
246
|
return;
|
|
222
247
|
}
|
|
223
248
|
|
|
@@ -304,7 +329,7 @@
|
|
|
304
329
|
...hoveredElement,
|
|
305
330
|
id: `sel_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`
|
|
306
331
|
};
|
|
307
|
-
onSelectElement?.(selectedRef);
|
|
332
|
+
onSelectElement?.(rememberFrame(selectedRef));
|
|
308
333
|
}
|
|
309
334
|
}
|
|
310
335
|
|
|
@@ -368,10 +393,11 @@
|
|
|
368
393
|
<!-- Persistent highlights for already-selected elements -->
|
|
369
394
|
{#each selectedElements as item, index (item.id)}
|
|
370
395
|
{#if item.rect && item.rect.width > 0 && item.rect.height > 0}
|
|
371
|
-
{@const
|
|
396
|
+
{@const box = rectInCurrentFrame(item.rect, item.rectFrame)}
|
|
397
|
+
{@const chipPos = computeChipPlacement(box, viewportWidth, viewportHeight)}
|
|
372
398
|
<div
|
|
373
399
|
class="pointer-events-none absolute z-[35] rounded-md border-2 border-dashed border-[#6D9A59] bg-[#7BA668]/10 transition-all duration-75"
|
|
374
|
-
style="left: {
|
|
400
|
+
style="left: {box.x}px; top: {box.y}px; width: {box.width}px; height: {box.height}px; /* rtl-ok: DOM element bounding box is measured from the left edge of the widget frame */"
|
|
375
401
|
></div>
|
|
376
402
|
<div
|
|
377
403
|
class="pointer-events-auto absolute z-[38] flex max-w-[340px] items-center gap-1.5 whitespace-nowrap rounded-full border border-[#7BA668]/45 bg-[#0F2010] px-2.5 py-1 font-mono text-[11px] font-medium leading-none text-[#A5CE8F] shadow-md"
|
|
@@ -441,24 +467,6 @@
|
|
|
441
467
|
{/if}
|
|
442
468
|
{/if}
|
|
443
469
|
|
|
444
|
-
<!-- Bottom Hint Pill (matches Chrome Extension overlay hint) -->
|
|
445
|
-
<div
|
|
446
|
-
class="pointer-events-none absolute inset-x-0 bottom-3 z-[40] mx-auto flex w-max items-center gap-1.5 whitespace-nowrap rounded-full border border-white/10 bg-neutral-900/90 px-3.5 py-1.5 font-sans text-[11px] font-medium text-neutral-200 shadow-lg backdrop-blur-md"
|
|
447
|
-
>
|
|
448
|
-
<span class="inline-block h-2 w-2 rounded-full bg-[#7BA668]"></span>
|
|
449
|
-
<span>{$t('creator.elementSelector.clickPartToReference')}</span>
|
|
450
|
-
<span class="text-neutral-500">·</span>
|
|
451
|
-
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">↑</kbd>
|
|
452
|
-
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">↓</kbd>
|
|
453
|
-
<span>{$t('creator.elementSelector.parentChild')}</span>
|
|
454
|
-
<span class="text-neutral-500">·</span>
|
|
455
|
-
<span>{$t('creator.elementSelector.hold')}</span>
|
|
456
|
-
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">{$t('creator.elementSelector.cmdCtrl')}</kbd>
|
|
457
|
-
<span>{$t('creator.elementSelector.toInteract')}</span>
|
|
458
|
-
<span class="text-neutral-500">·</span>
|
|
459
|
-
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">{$t('creator.elementSelector.esc')}</kbd>
|
|
460
|
-
<span>{$t('creator.elementSelector.done')}</span>
|
|
461
|
-
</div>
|
|
462
470
|
</div>
|
|
463
471
|
{/if}
|
|
464
472
|
{/if}
|
|
@@ -1054,6 +1054,28 @@
|
|
|
1054
1054
|
></div>
|
|
1055
1055
|
{/if}
|
|
1056
1056
|
</div>
|
|
1057
|
+
{#if resolveSelectorEnabled?.(overlay.widgetId)}
|
|
1058
|
+
<div
|
|
1059
|
+
class="widget-shape-selector-hint pointer-events-none fixed z-[70] flex justify-center"
|
|
1060
|
+
style="left: {overlay.left}px; top: {overlay.top + (overlay.localHeight ?? overlay.height) + 8}px; width: {chromeWidth}px; /* rtl-ok: centered on the shape, under it, the same way the bar sits above */"
|
|
1061
|
+
>
|
|
1062
|
+
<div class="widget-shape-selector-hint-pill flex w-max items-center gap-1.5 whitespace-nowrap rounded-full border border-white/10 bg-neutral-900/90 px-3.5 py-1.5 font-sans text-[11px] font-medium text-neutral-200 shadow-lg">
|
|
1063
|
+
<span class="inline-block h-2 w-2 rounded-full bg-[#7BA668]"></span>
|
|
1064
|
+
<span>{$t('creator.elementSelector.clickPartToReference')}</span>
|
|
1065
|
+
<span class="text-neutral-500">·</span>
|
|
1066
|
+
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">↑</kbd>
|
|
1067
|
+
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">↓</kbd>
|
|
1068
|
+
<span>{$t('creator.elementSelector.parentChild')}</span>
|
|
1069
|
+
<span class="text-neutral-500">·</span>
|
|
1070
|
+
<span>{$t('creator.elementSelector.hold')}</span>
|
|
1071
|
+
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">{$t('creator.elementSelector.cmdCtrl')}</kbd>
|
|
1072
|
+
<span>{$t('creator.elementSelector.toInteract')}</span>
|
|
1073
|
+
<span class="text-neutral-500">·</span>
|
|
1074
|
+
<kbd class="rounded border border-white/15 bg-white/10 px-1.5 py-0.5 font-mono text-[10px] text-white">{$t('creator.elementSelector.esc')}</kbd>
|
|
1075
|
+
<span>{$t('creator.elementSelector.done')}</span>
|
|
1076
|
+
</div>
|
|
1077
|
+
</div>
|
|
1078
|
+
{/if}
|
|
1057
1079
|
{#if versionMenuOpen && versionMenuBox?.widgetId === overlay.widgetId}
|
|
1058
1080
|
{@const hasScroll = versionOptions.length > 5}
|
|
1059
1081
|
<div
|
|
@@ -36,6 +36,11 @@ export interface SelectedWidgetElementReference {
|
|
|
36
36
|
attributes?: Record<string, string>;
|
|
37
37
|
/** Bounding box inside the widget frame (in unscaled widget CSS pixels) */
|
|
38
38
|
rect?: SelectedElementRect;
|
|
39
|
+
/** Frame size the box was measured in, so a later resize can scale it. */
|
|
40
|
+
rectFrame?: {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
39
44
|
/** Compact human-readable label (`<em> · to shared company work.`) */
|
|
40
45
|
label: string;
|
|
41
46
|
}
|