@widgetic/editor 4.1.17 → 4.1.19
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/components/PreviewChromeControls.svelte +2 -2
- package/dist/components/WidgetPreview.svelte +79 -16
- package/dist/components/editors/CompositionEditorApp.svelte +71 -35
- package/dist/components/editors/CompositionEditorApp.svelte.d.ts +3 -1
- package/dist/components/editors/ContentTabBulkDrop.svelte +268 -0
- package/dist/components/editors/ContentTabBulkDrop.svelte.d.ts +37 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte +303 -0
- package/dist/components/editors/EmbedAssistantPanel.svelte.d.ts +29 -0
- package/dist/components/editors/EmbedEditor.svelte +221 -15
- package/dist/components/editors/EmbedEditor.svelte.d.ts +31 -3
- package/dist/components/editors/PropsEditor.svelte +326 -37
- package/dist/components/editors/PropsEditor.svelte.d.ts +11 -0
- package/dist/components/editors/propsEditorContentStateFlatten.d.ts +12 -0
- package/dist/components/editors/propsEditorContentStateFlatten.js +40 -0
- package/dist/components/ic/AngleInputController.svelte +9 -5
- package/dist/components/ic/BrowserInputController.svelte +208 -132
- package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
- package/dist/components/ic/CheckboxInputController.svelte +11 -0
- package/dist/components/ic/ColorPickerInputController.svelte +122 -49
- package/dist/components/ic/DatePickerInputController.svelte +23 -13
- package/dist/components/ic/FixedPositionInputController.svelte +1 -1
- package/dist/components/ic/FontInputController.svelte +48 -47
- package/dist/components/ic/InputControllerHeader.svelte +5 -4
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +20 -7
- package/dist/components/ic/NumberControls.svelte +163 -35
- package/dist/components/ic/PositionInputController.svelte +24 -15
- package/dist/components/ic/RadioGroupInputController.svelte +11 -0
- package/dist/components/ic/RangeCalendarInputController.svelte +73 -28
- package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
- package/dist/components/ic/SliderInputController.svelte +11 -4
- package/dist/components/ic/TextAreaInputController.svelte +620 -327
- package/dist/components/ic/TextAreaPreviewInputController.svelte +53 -64
- package/dist/components/ic/TextInputController.svelte +15 -2
- package/dist/components/ic/TimeInputController.svelte +1 -1
- package/dist/components/ic/VectorInputController.svelte +152 -20
- package/dist/components/ic/numberControlsValueArea.d.ts +29 -0
- package/dist/components/ic/numberControlsValueArea.js +51 -0
- package/dist/components/ic/optionGroupCardPointerDown.d.ts +9 -0
- package/dist/components/ic/optionGroupCardPointerDown.js +20 -0
- package/dist/components/ic/shared/DropdownChevron.svelte +2 -2
- package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +1 -1
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +174 -0
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +30 -0
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte +34 -0
- package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte.d.ts +24 -0
- package/dist/components/ic/shared/ItemGrid.svelte +2 -2
- package/dist/components/ic/shared/RecentItemsSection.svelte +6 -6
- package/dist/components/ic/shared/editableFieldClasses.d.ts +15 -0
- package/dist/components/ic/shared/editableFieldClasses.js +15 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.d.ts +29 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -0
- package/dist/components/ic/shared/index.d.ts +1 -0
- package/dist/components/ic/shared/index.js +1 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +41 -9
- package/dist/composition/compositionApi.d.ts +16 -0
- package/dist/composition/compositionApi.js +16 -1
- package/dist/composition/compositionEditorController.d.ts +46 -0
- package/dist/composition/compositionEditorController.js +277 -5
- package/dist/composition/compositionEditorSchemaCache.d.ts +35 -0
- package/dist/composition/compositionEditorSchemaCache.js +82 -0
- package/dist/contentBulkDrop/applyContentPlan.d.ts +18 -0
- package/dist/contentBulkDrop/applyContentPlan.js +55 -0
- package/dist/contentBulkDrop/bulkDropSummary.d.ts +4 -0
- package/dist/contentBulkDrop/bulkDropSummary.js +12 -0
- package/dist/contentBulkDrop/dragIntent.d.ts +7 -0
- package/dist/contentBulkDrop/dragIntent.js +24 -0
- package/dist/contentBulkDrop/filterDropFiles.d.ts +2 -0
- package/dist/contentBulkDrop/filterDropFiles.js +21 -0
- package/dist/contentBulkDrop/formatFileSize.d.ts +2 -0
- package/dist/contentBulkDrop/formatFileSize.js +13 -0
- package/dist/contentBulkDrop/types.d.ts +34 -0
- package/dist/contentBulkDrop/types.js +1 -0
- package/dist/contentBulkDrop/uploadQueue.d.ts +41 -0
- package/dist/contentBulkDrop/uploadQueue.js +114 -0
- package/dist/drafts/compositionDraft.d.ts +65 -0
- package/dist/drafts/compositionDraft.js +136 -0
- package/dist/drafts/compositionEditorViewState.d.ts +9 -0
- package/dist/drafts/compositionEditorViewState.js +33 -0
- package/dist/drafts/draftJournal.d.ts +59 -0
- package/dist/drafts/draftJournal.js +261 -0
- package/dist/embed/__fixtures__/gatewayGeneratedEmbedCodes.json +25 -0
- package/dist/embed/__fixtures__/generatedEmbedCodes.json +320 -0
- package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
- package/dist/embed/parseCompositionEmbedCode.js +376 -0
- package/dist/embedAssistant/embedAssistantEvents.d.ts +22 -0
- package/dist/embedAssistant/embedAssistantEvents.js +39 -0
- package/dist/embedAssistant/embedAssistantStream.d.ts +30 -0
- package/dist/embedAssistant/embedAssistantStream.js +125 -0
- package/dist/embedAssistant/highlightTiming.d.ts +1 -0
- package/dist/embedAssistant/highlightTiming.js +6 -0
- package/dist/embedAssistant/types.d.ts +27 -0
- package/dist/embedAssistant/types.js +1 -0
- package/dist/i18n/labels.js +8 -4
- package/dist/i18n/language.d.ts +297 -3
- package/dist/i18n/messages.d.ts +38 -1
- package/dist/i18n/messages.js +40 -1
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/utils/FontManager.d.ts +2 -0
- package/dist/utils/FontManager.js +16 -1
- package/dist/utils/angleMath.d.ts +2 -0
- package/dist/utils/angleMath.js +6 -0
- package/dist/utils/isEditableEventTarget.d.ts +5 -0
- package/dist/utils/isEditableEventTarget.js +25 -0
- package/dist/utils/linkUrlValidation.d.ts +17 -0
- package/dist/utils/linkUrlValidation.js +120 -0
- package/dist/utils/mediaFileValue.d.ts +12 -0
- package/dist/utils/mediaFileValue.js +24 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.d.ts +11 -0
- package/dist/utils/placeRichTextCaretAtDocumentEnd.js +26 -0
- package/package.json +6 -6
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
17
17
|
import { Portal } from '@widgetic/design-system/components';
|
|
18
|
-
import { IconArrowsDiagonal } from '@widgetic/design-system/icons';
|
|
18
|
+
import { IconArrowsDiagonal, IconX } from '@widgetic/design-system/icons';
|
|
19
19
|
import {
|
|
20
20
|
dirForUserText,
|
|
21
21
|
useTextDirection
|
|
@@ -46,6 +46,40 @@
|
|
|
46
46
|
const placeholder: string = config.placeholder || '';
|
|
47
47
|
|
|
48
48
|
let isShowingTextArea = false;
|
|
49
|
+
let resolvedPortalTarget: string | HTMLElement = portalTarget;
|
|
50
|
+
|
|
51
|
+
/** Props panel may pass the tab root before the scroll viewport is bound; resolve on open. */
|
|
52
|
+
function resolveTextAreaPortalTarget(): string | HTMLElement {
|
|
53
|
+
// Round 26: the scroll viewport is NOT a host for the editor. It is as tall as the whole list of controllers (1,500 px for a long
|
|
54
|
+
// Content tab), so an editor placed in it ran past the bottom edge of the panel and the gap under it sat at the end of the list,
|
|
55
|
+
// out of sight. The tab shell below clips that list: it is exactly the area the person sees under the tabs.
|
|
56
|
+
const tabRoot =
|
|
57
|
+
(portalTarget instanceof HTMLElement
|
|
58
|
+
? portalTarget.closest('.tab-content-container, .tab-design-container')
|
|
59
|
+
: null) ??
|
|
60
|
+
(typeof portalTarget === 'string' ? document.getElementById(portalTarget) : null) ??
|
|
61
|
+
document.querySelector<HTMLElement>(
|
|
62
|
+
'.tab-content-container:not(.hidden), .tab-design-container:not(.hidden)'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (!(tabRoot instanceof HTMLElement)) {
|
|
66
|
+
return portalTarget || 'tab-content-container';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const hasVisibleViewport = [...tabRoot.querySelectorAll<HTMLElement>('.props-editor-scroll-viewport')].some(
|
|
70
|
+
(viewport) => {
|
|
71
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
72
|
+
return viewportRect.width > 0 && viewportRect.height > 0;
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// The inner Radix viewport is as tall as the scroll content; the tab shell clips the visible controller area.
|
|
77
|
+
if (hasVisibleViewport && tabRoot.clientHeight > 0) {
|
|
78
|
+
return tabRoot;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return portalTarget;
|
|
82
|
+
}
|
|
49
83
|
|
|
50
84
|
// Add a computed property to determine if we're showing placeholder
|
|
51
85
|
$: isShowingPlaceholder = !value && placeholder;
|
|
@@ -56,12 +90,6 @@
|
|
|
56
90
|
// Add this to track the current color
|
|
57
91
|
let currentColor = '#1a1a1a'; // Default color
|
|
58
92
|
|
|
59
|
-
// Add this near the top with other state declarations
|
|
60
|
-
let isPortalHovered = false;
|
|
61
|
-
|
|
62
|
-
// Add this to store the background rect ref
|
|
63
|
-
let backgroundRectRef: HTMLDivElement;
|
|
64
|
-
|
|
65
93
|
// The box the text editor is shown in. The editor is found through it: a search of the whole `document` finds nothing
|
|
66
94
|
// inside a module's shadow root, and finds the customer's own text editor (and focuses it) when the page has one.
|
|
67
95
|
let portalContentRef: HTMLDivElement | undefined;
|
|
@@ -91,18 +119,13 @@
|
|
|
91
119
|
}
|
|
92
120
|
|
|
93
121
|
function handleClick() {
|
|
94
|
-
|
|
122
|
+
if (!isShowingTextArea) {
|
|
123
|
+
resolvedPortalTarget = resolveTextAreaPortalTarget();
|
|
124
|
+
}
|
|
95
125
|
isShowingTextArea = !isShowingTextArea;
|
|
96
126
|
}
|
|
97
127
|
|
|
98
|
-
|
|
99
|
-
setTimeout(() => {
|
|
100
|
-
const editor = portalContentRef?.querySelector('.ProseMirror');
|
|
101
|
-
if (editor instanceof HTMLElement) {
|
|
102
|
-
editor.focus();
|
|
103
|
-
}
|
|
104
|
-
}, 100); // Give a bit more time for the portal to mount
|
|
105
|
-
}
|
|
128
|
+
// Initial caret placement and focus are handled inside TextAreaInputController when the portal editor mounts.
|
|
106
129
|
|
|
107
130
|
// Update value reactively to track color changes
|
|
108
131
|
$: {
|
|
@@ -118,31 +141,6 @@
|
|
|
118
141
|
// console.log('[TextAreaPreview] compact preview html', value.slice(0, 180));
|
|
119
142
|
}
|
|
120
143
|
|
|
121
|
-
function handlePortalMouseEnter() {
|
|
122
|
-
// console.log('Portal mouse entered');
|
|
123
|
-
isPortalHovered = true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function handlePortalMouseLeave(event: MouseEvent) {
|
|
127
|
-
// if (!backgroundRectRef) return;
|
|
128
|
-
// console.log('Portal mouse leave: ', event, backgroundRectRef.getBoundingClientRect());
|
|
129
|
-
|
|
130
|
-
// Get mouse position relative to the portal content
|
|
131
|
-
const { offsetX, offsetY } = event;
|
|
132
|
-
const offsetWidth = backgroundRectRef.getBoundingClientRect().width;
|
|
133
|
-
const offsetHeight = backgroundRectRef.getBoundingClientRect().height;
|
|
134
|
-
// console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
|
|
135
|
-
|
|
136
|
-
// Check if cursor is within the background rect boundaries
|
|
137
|
-
if (0 < offsetX && offsetX < offsetWidth && 0 < offsetY && offsetY < offsetHeight) {
|
|
138
|
-
// console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// console.log('Portal mouse leave mousePosition: ', offsetX, offsetY, offsetWidth, offsetHeight);
|
|
143
|
-
isPortalHovered = false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
144
|
// Add keyboard event handler for Escape key
|
|
147
145
|
function handleKeydown(event: KeyboardEvent) {
|
|
148
146
|
if (event.key === 'Escape' && isShowingTextArea) {
|
|
@@ -210,7 +208,7 @@
|
|
|
210
208
|
aria-hidden="true"
|
|
211
209
|
>
|
|
212
210
|
<IconArrowsDiagonal
|
|
213
|
-
class="size-4 stroke-
|
|
211
|
+
class="size-4 stroke-2 text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
|
|
214
212
|
/>
|
|
215
213
|
</div>
|
|
216
214
|
</div>
|
|
@@ -223,36 +221,27 @@
|
|
|
223
221
|
|
|
224
222
|
<!-- Text Area Input Controller in Portal -->
|
|
225
223
|
{#if isShowingTextArea}
|
|
226
|
-
<Portal target={
|
|
227
|
-
<!-- Blocking overlay -->
|
|
224
|
+
<Portal target={resolvedPortalTarget} class="text-area-portal absolute inset-0 z-50 flex max-h-full min-h-0 flex-col overflow-hidden">
|
|
225
|
+
<!-- Blocking overlay: clicks pass through to portalled popovers; only the editor card receives pointer events. -->
|
|
228
226
|
<div
|
|
229
|
-
class="absolute inset-0 bg-background {isClosing
|
|
227
|
+
class="text-area-portal-overlay pointer-events-auto absolute inset-0 z-0 bg-background {isClosing
|
|
230
228
|
? 'fade-out-animation'
|
|
231
229
|
: 'fade-in-animation'}"
|
|
232
|
-
style="
|
|
230
|
+
style="transform: translateZ(0); backface-visibility: hidden;"
|
|
231
|
+
role="presentation"
|
|
233
232
|
></div>
|
|
234
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
235
233
|
<div
|
|
236
234
|
bind:this={portalContentRef}
|
|
237
|
-
class="text-area-portal-content absolute
|
|
235
|
+
class="text-area-portal-content pointer-events-auto absolute inset-x-6 top-0 bottom-6 z-10 flex min-h-0 min-w-0 flex-1 flex-col {isClosing
|
|
238
236
|
? 'scale-out-animation'
|
|
239
237
|
: 'scale-in-animation'}"
|
|
240
|
-
style="
|
|
241
|
-
on:mouseenter={handlePortalMouseEnter}
|
|
242
|
-
on:mouseleave={handlePortalMouseLeave}
|
|
238
|
+
style="transform: translateZ(0); backface-visibility: hidden;"
|
|
243
239
|
>
|
|
244
|
-
<!--
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
bind:this={backgroundRectRef}
|
|
248
|
-
class="portal-background-rect absolute inset-0 bg-transparent pointer-events-none"
|
|
249
|
-
style="border-radius: var(--radius-lg);"
|
|
250
|
-
></div>
|
|
251
|
-
|
|
240
|
+
<!-- The editor fills the controllers area, 24 px in from both sides and 24 px up from the bottom (the same gutter the cards
|
|
241
|
+
have), so it has no hover ring: a ring is drawn outside the box and the panel clips it, which left two dark lines down
|
|
242
|
+
the sides of the editor. The backdrop above covers the whole area, gutters included, so no card shows in the gap. -->
|
|
252
243
|
<TextAreaInputController
|
|
253
|
-
class="text-area w-full h-full transition-colors duration-fast
|
|
254
|
-
? 'ring-2 ring-ring ring-offset-2 ring-offset-background'
|
|
255
|
-
: ''}"
|
|
244
|
+
class="text-area w-full h-full transition-colors duration-fast"
|
|
256
245
|
{label}
|
|
257
246
|
bind:value
|
|
258
247
|
onChange={handleFullEditorChange}
|
|
@@ -390,7 +379,7 @@
|
|
|
390
379
|
|
|
391
380
|
:global(.scale-in-animation) {
|
|
392
381
|
animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
393
|
-
transform-origin:
|
|
382
|
+
transform-origin: top center;
|
|
394
383
|
will-change: transform, opacity;
|
|
395
384
|
backface-visibility: hidden;
|
|
396
385
|
}
|
|
@@ -424,7 +413,7 @@
|
|
|
424
413
|
|
|
425
414
|
:global(.scale-out-animation) {
|
|
426
415
|
animation: scaleOut 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
427
|
-
transform-origin:
|
|
416
|
+
transform-origin: top center;
|
|
428
417
|
will-change: transform, opacity;
|
|
429
418
|
backface-visibility: hidden;
|
|
430
419
|
pointer-events: none;
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
import { useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
22
22
|
import { directionOfFieldValue } from '../../utils/fieldDirection';
|
|
23
23
|
import InputControllerRow from './InputControllerRow.svelte';
|
|
24
|
+
import {
|
|
25
|
+
editableFieldSurfaceClass,
|
|
26
|
+
editableFieldSurfacePadding,
|
|
27
|
+
embeddedInputClass
|
|
28
|
+
} from './shared/editableFieldClasses';
|
|
24
29
|
|
|
25
30
|
// Component props
|
|
26
31
|
import type { InputControllerConfig } from './index';
|
|
@@ -67,9 +72,17 @@
|
|
|
67
72
|
</script>
|
|
68
73
|
|
|
69
74
|
<InputControllerRow {label} {description}>
|
|
75
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
76
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
70
77
|
<div
|
|
71
|
-
class="
|
|
78
|
+
class="{editableFieldSurfaceClass} {editableFieldSurfacePadding}"
|
|
72
79
|
onfocusin={onFocus}
|
|
80
|
+
onclick={(e) => {
|
|
81
|
+
const target = e.currentTarget.querySelector('input');
|
|
82
|
+
if (target instanceof HTMLInputElement && e.target !== target) {
|
|
83
|
+
target.focus();
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
73
86
|
>
|
|
74
87
|
<Input
|
|
75
88
|
id="text-input"
|
|
@@ -85,7 +98,7 @@
|
|
|
85
98
|
onChange(newValue);
|
|
86
99
|
}
|
|
87
100
|
}}
|
|
88
|
-
class=
|
|
101
|
+
class={embeddedInputClass}
|
|
89
102
|
/>
|
|
90
103
|
</div>
|
|
91
104
|
</InputControllerRow>
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
>
|
|
418
418
|
<span class="flex size-4 shrink-0 items-center justify-center">
|
|
419
419
|
{#if timeOption === value}
|
|
420
|
-
<IconCheck class="size-4 stroke-
|
|
420
|
+
<IconCheck class="size-4 stroke-2" aria-hidden="true" />
|
|
421
421
|
{/if}
|
|
422
422
|
</span>
|
|
423
423
|
<span class="min-w-0 flex-1 truncate">{timeOption}</span>
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
/** COMPONENTS IMPORTS */
|
|
44
44
|
// Shadcn UI components imports from design-system
|
|
45
45
|
import { Popover, EmptyState, IconButton } from '@widgetic/design-system/components';
|
|
46
|
+
import { useEditorPickFile } from '../../pickFileContext';
|
|
46
47
|
|
|
47
48
|
import {
|
|
48
49
|
IconCloudUpload,
|
|
@@ -56,12 +57,14 @@
|
|
|
56
57
|
import { SearchInput } from '@widgetic/design-system/components';
|
|
57
58
|
import CategoryTabs from './shared/CategoryTabs.svelte';
|
|
58
59
|
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
60
|
+
import EditorFileBrowserOverlay from './shared/EditorFileBrowserOverlay.svelte';
|
|
59
61
|
import { RecentItemsSection, ItemGrid } from './shared';
|
|
60
62
|
import { useEditorLanguage } from '../../i18n/language';
|
|
61
63
|
import { categoryLabel } from '../../i18n/labels';
|
|
62
64
|
|
|
63
65
|
// The words of the editor in the language of the page.
|
|
64
66
|
const { t } = useEditorLanguage();
|
|
67
|
+
const getEditorPickFile = useEditorPickFile();
|
|
65
68
|
|
|
66
69
|
$: vectorLoadFailedLabel = $t('editor.vector.loadFailed');
|
|
67
70
|
|
|
@@ -125,6 +128,31 @@
|
|
|
125
128
|
let controllerElement: HTMLDivElement | undefined;
|
|
126
129
|
let vectorObserver = new IntersectionObserver(() => {});
|
|
127
130
|
|
|
131
|
+
// The picker is as tall as the room around its trigger allows (560px at most) and opens on the side that has more room,
|
|
132
|
+
// so that its header (the title and the upload button) is never cut off by the top or the bottom of the window.
|
|
133
|
+
let vectorTriggerBox: HTMLDivElement | undefined;
|
|
134
|
+
let vectorPopoverSide: 'top' | 'bottom' = 'bottom';
|
|
135
|
+
let vectorPopoverStyle = '';
|
|
136
|
+
|
|
137
|
+
function updateVectorPopoverBox() {
|
|
138
|
+
try {
|
|
139
|
+
if (!vectorTriggerBox || typeof window === 'undefined') return;
|
|
140
|
+
const triggerRect = vectorTriggerBox.getBoundingClientRect();
|
|
141
|
+
const collisionPadding = 12;
|
|
142
|
+
const sideOffset = 8;
|
|
143
|
+
const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
|
|
144
|
+
const roomBelow = viewportHeight - triggerRect.bottom - collisionPadding - sideOffset;
|
|
145
|
+
const roomAbove = triggerRect.top - collisionPadding - sideOffset;
|
|
146
|
+
const opensAbove = roomAbove > roomBelow;
|
|
147
|
+
vectorPopoverSide = opensAbove ? 'top' : 'bottom';
|
|
148
|
+
const availableHeight = Math.max(0, opensAbove ? roomAbove : roomBelow);
|
|
149
|
+
const desiredHeight = Math.min(560, availableHeight);
|
|
150
|
+
vectorPopoverStyle = `height: ${desiredHeight}px; max-height: ${desiredHeight}px;`;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('❌ [VectorInput] Could not measure the room around the picker:', error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
128
156
|
// Initialize VectorManager instance
|
|
129
157
|
let vectorManagerInstance: VectorManager;
|
|
130
158
|
let buttonWidth = 0;
|
|
@@ -886,6 +914,9 @@
|
|
|
886
914
|
// vector: vectorValue
|
|
887
915
|
// });
|
|
888
916
|
}
|
|
917
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
918
|
+
toggleDropdown(controllerId);
|
|
919
|
+
}
|
|
889
920
|
}
|
|
890
921
|
|
|
891
922
|
/**
|
|
@@ -998,6 +1029,54 @@
|
|
|
998
1029
|
}
|
|
999
1030
|
}
|
|
1000
1031
|
|
|
1032
|
+
// True while `fillVectorListUntilItScrolls` is asking for more vectors, so that two fills never run together
|
|
1033
|
+
let isFillingVectorList = false;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* The first batch is eight vectors, which do not fill the list: the list cannot scroll, the scroll handler never asks
|
|
1037
|
+
* for more, and the user sees eight icons and never reaches the emoji faces. This asks for more, a batch at a time,
|
|
1038
|
+
* until the list is taller than its window (or there is nothing more to show).
|
|
1039
|
+
*/
|
|
1040
|
+
async function fillVectorListUntilItScrolls() {
|
|
1041
|
+
if (isFillingVectorList) return;
|
|
1042
|
+
isFillingVectorList = true;
|
|
1043
|
+
try {
|
|
1044
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
1045
|
+
await tick();
|
|
1046
|
+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
1047
|
+
const listWindow = vectorListContainer;
|
|
1048
|
+
if (!listWindow || !$openDropdowns?.has(controllerId)) return;
|
|
1049
|
+
if (listWindow.scrollHeight > listWindow.clientHeight + 1) return;
|
|
1050
|
+
|
|
1051
|
+
if (searchTerm && currentSearchResults.length > 0) {
|
|
1052
|
+
const nextSearchBatch = currentSearchResults.slice(
|
|
1053
|
+
filteredVectors.length,
|
|
1054
|
+
filteredVectors.length + SEARCH_BATCH_SIZE
|
|
1055
|
+
);
|
|
1056
|
+
if (nextSearchBatch.length === 0) return;
|
|
1057
|
+
filteredVectors = [...filteredVectors, ...nextSearchBatch];
|
|
1058
|
+
} else if (
|
|
1059
|
+
!searchTerm &&
|
|
1060
|
+
!isLoadingBatch &&
|
|
1061
|
+
vectorManagerInstance?.hasMoreVectors(controllerId, currentFilter)
|
|
1062
|
+
) {
|
|
1063
|
+
await loadNextBatch();
|
|
1064
|
+
} else {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
console.error('❌ [VectorInput] Could not fill the vector list:', error);
|
|
1070
|
+
} finally {
|
|
1071
|
+
isFillingVectorList = false;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Whenever the open list changes (a category, a search, a new batch) check that it is still tall enough to scroll
|
|
1076
|
+
$: if ($openDropdowns?.has(controllerId) && filteredVectors.length > 0) {
|
|
1077
|
+
void fillVectorListUntilItScrolls();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1001
1080
|
onDestroy(() => {
|
|
1002
1081
|
stopListeningForScroll();
|
|
1003
1082
|
|
|
@@ -1020,28 +1099,63 @@
|
|
|
1020
1099
|
* Opens the file browser for vector selection
|
|
1021
1100
|
*/
|
|
1022
1101
|
async function openFileBrowser() {
|
|
1023
|
-
//
|
|
1102
|
+
// The picker gives way to the file browser: two layers of choices must never be open on top of each other.
|
|
1103
|
+
if ($openDropdowns?.has(controllerId)) {
|
|
1104
|
+
toggleDropdown(controllerId);
|
|
1105
|
+
}
|
|
1106
|
+
const pickFile = getEditorPickFile();
|
|
1107
|
+
if (pickFile) {
|
|
1108
|
+
try {
|
|
1109
|
+
const picked = await pickFile({
|
|
1110
|
+
accept: ['image/svg+xml', '.svg'],
|
|
1111
|
+
multiple: false,
|
|
1112
|
+
signal: new AbortController().signal
|
|
1113
|
+
});
|
|
1114
|
+
const selectedFile = picked?.[0];
|
|
1115
|
+
if (selectedFile && onChange) {
|
|
1116
|
+
onChange({
|
|
1117
|
+
name: selectedFile.name.replace(/\.svg$/i, '') || selectedFile.name,
|
|
1118
|
+
category: 'Mine',
|
|
1119
|
+
url: selectedFile.url
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
} catch (error) {
|
|
1123
|
+
console.error('❌ [VectorInput] pickFile failed:', error);
|
|
1124
|
+
}
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1024
1127
|
|
|
1025
1128
|
try {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
? vectorManagerInstance
|
|
1029
|
-
?.getCachedVectorList()
|
|
1030
|
-
.find((v) => v.name === value.name && v.category === 'Mine')?.name
|
|
1031
|
-
: undefined;
|
|
1032
|
-
|
|
1033
|
-
// console.log('🔍 [VectorInput] Opening file browser:', {
|
|
1034
|
-
// fileTypes: ['svg'],
|
|
1035
|
-
// selectedId
|
|
1036
|
-
// });
|
|
1037
|
-
|
|
1038
|
-
// TODO: Implement file browser functionality
|
|
1039
|
-
// This will be similar to FontInputController but for SVG files
|
|
1129
|
+
showVectorModal = true;
|
|
1130
|
+
await tick();
|
|
1040
1131
|
} catch (error) {
|
|
1041
1132
|
console.error('❌ [VectorInput] Error opening file browser:', error);
|
|
1042
1133
|
}
|
|
1043
1134
|
}
|
|
1044
1135
|
|
|
1136
|
+
function closeVectorFileBrowser() {
|
|
1137
|
+
showVectorModal = false;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
async function handleVectorFileBrowserSelect(
|
|
1141
|
+
event: CustomEvent<{ files?: Array<{ id: string; name?: string; file?: string; url: string }> }>
|
|
1142
|
+
) {
|
|
1143
|
+
try {
|
|
1144
|
+
const selectedFile = event.detail?.files?.[0];
|
|
1145
|
+
if (!selectedFile?.url || !onChange) return;
|
|
1146
|
+
const displayName =
|
|
1147
|
+
selectedFile.name || selectedFile.file || selectedFile.url.split('/').pop() || 'Custom';
|
|
1148
|
+
onChange({
|
|
1149
|
+
name: displayName.replace(/\.svg$/i, ''),
|
|
1150
|
+
category: 'Mine',
|
|
1151
|
+
url: selectedFile.url
|
|
1152
|
+
});
|
|
1153
|
+
closeVectorFileBrowser();
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
console.error('❌ [VectorInput] File browser selection failed:', error);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1045
1159
|
/**
|
|
1046
1160
|
* Handles category filter changes
|
|
1047
1161
|
*/
|
|
@@ -1412,7 +1526,10 @@
|
|
|
1412
1526
|
}
|
|
1413
1527
|
|
|
1414
1528
|
function isVectorSelected(vector: VectorItem) {
|
|
1415
|
-
return Boolean(
|
|
1529
|
+
return Boolean(
|
|
1530
|
+
value?.name === vector.name &&
|
|
1531
|
+
(value?.url ? value.url === vector.url : true)
|
|
1532
|
+
);
|
|
1416
1533
|
}
|
|
1417
1534
|
|
|
1418
1535
|
function isCustomVector(vector: VectorItem) {
|
|
@@ -1528,12 +1645,13 @@
|
|
|
1528
1645
|
|
|
1529
1646
|
<div bind:this={controllerElement} class="vector-ic flex w-full flex-col">
|
|
1530
1647
|
<InputControllerRow {label} helpText={description}>
|
|
1531
|
-
<div class="vector-input-ct w-full" onfocusin={onFocus}>
|
|
1648
|
+
<div bind:this={vectorTriggerBox} class="vector-input-ct w-full" onfocusin={onFocus}>
|
|
1532
1649
|
<Popover.Root
|
|
1533
1650
|
open={$openDropdowns?.has(controllerId)}
|
|
1534
1651
|
onOpenChange={(isOpen) => {
|
|
1535
1652
|
if (isOpen !== $openDropdowns?.has(controllerId)) {
|
|
1536
1653
|
if (isOpen) {
|
|
1654
|
+
updateVectorPopoverBox();
|
|
1537
1655
|
// Check if the selected vector image is valid
|
|
1538
1656
|
if (value?.name && value.url) {
|
|
1539
1657
|
// Create a temporary image to test if it loads
|
|
@@ -1591,7 +1709,7 @@
|
|
|
1591
1709
|
<div class="flex min-w-0 flex-1 items-center gap-2 truncate">
|
|
1592
1710
|
{#if value?.url}
|
|
1593
1711
|
{#if hasSvgLoadError(value.name)}
|
|
1594
|
-
<IconAlertTriangle class="size-4 shrink-0 stroke-
|
|
1712
|
+
<IconAlertTriangle class="size-4 shrink-0 stroke-2 text-destructive" />
|
|
1595
1713
|
<span class="truncate text-start text-body text-foreground">
|
|
1596
1714
|
{value?.name || $t('editor.vector.select')}
|
|
1597
1715
|
</span>
|
|
@@ -1616,9 +1734,12 @@
|
|
|
1616
1734
|
</Popover.Trigger>
|
|
1617
1735
|
|
|
1618
1736
|
<Popover.Content
|
|
1737
|
+
collisionPadding={12}
|
|
1738
|
+
side={vectorPopoverSide}
|
|
1619
1739
|
align="end"
|
|
1620
1740
|
sideOffset={8}
|
|
1621
|
-
class="vector-input-popover z-50 flex h-[560px] w-picker flex-col overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground outline-none"
|
|
1741
|
+
class="vector-input-popover z-50 flex h-[560px] w-picker max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground outline-none"
|
|
1742
|
+
style={vectorPopoverStyle}
|
|
1622
1743
|
>
|
|
1623
1744
|
<div class="vector-popover-content flex h-full min-h-0 flex-col">
|
|
1624
1745
|
<div class="flex shrink-0 flex-col gap-3 px-4 pt-4 pb-3">
|
|
@@ -1638,7 +1759,7 @@
|
|
|
1638
1759
|
}
|
|
1639
1760
|
}}
|
|
1640
1761
|
>
|
|
1641
|
-
<IconCloudUpload class="size-4 stroke-
|
|
1762
|
+
<IconCloudUpload class="size-4 stroke-2" />
|
|
1642
1763
|
</IconButton>
|
|
1643
1764
|
</div>
|
|
1644
1765
|
<!-- Search input -->
|
|
@@ -1827,6 +1948,17 @@
|
|
|
1827
1948
|
</InputControllerRow>
|
|
1828
1949
|
</div>
|
|
1829
1950
|
|
|
1951
|
+
{#if showVectorModal}
|
|
1952
|
+
<!-- The browser of the editor (shared with the other file fields); the vector field takes SVG files only. -->
|
|
1953
|
+
<EditorFileBrowserOverlay
|
|
1954
|
+
portalTarget="props-editor-file-browser-portal"
|
|
1955
|
+
fileFilter="svg"
|
|
1956
|
+
addToEditorLabel={$t('editor.file.useFile')}
|
|
1957
|
+
onClose={closeVectorFileBrowser}
|
|
1958
|
+
on:select={handleVectorFileBrowserSelect}
|
|
1959
|
+
/>
|
|
1960
|
+
{/if}
|
|
1961
|
+
|
|
1830
1962
|
<style>
|
|
1831
1963
|
:global(.transition-border) {
|
|
1832
1964
|
transition: border-color 0.2s ease-in-out;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pointer routing for the number stepper value hit area (`NumberControls.svelte`).
|
|
3
|
+
* Kept pure so Node can test the rules without mounting Svelte.
|
|
4
|
+
*/
|
|
5
|
+
type TextInputElement = HTMLInputElement | {
|
|
6
|
+
value: string;
|
|
7
|
+
setSelectionRange: (s: number, e: number) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* True when a mousedown on this target should focus the number input instead of letting the
|
|
11
|
+
* browser move focus to `body` or start a document-level selection in dead space beside the digits.
|
|
12
|
+
*/
|
|
13
|
+
export declare function shouldRoutePointerToNumberInput(target: EventTarget | null, inputId: string): boolean;
|
|
14
|
+
/** Caret placement after routing a press into the field. */
|
|
15
|
+
export declare function selectionAfterValueAreaPress(value: string, extendSelection: boolean): {
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* True when the pointer is in the empty stretch of an auto-sized field after the last digit
|
|
21
|
+
* (HTML `size` / average ch-width used to leave this dead band).
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPointerPastTextEnd(text: string, inputLeft: number, clientX: number, textWidth: number): boolean;
|
|
24
|
+
/** While dragging from empty chrome into the digits, select the whole value for the next key. */
|
|
25
|
+
export declare function selectionWhileDraggingFromValueChrome(valueLength: number, pointerPastTextEnd: boolean, extendSelection: boolean): {
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
} | null;
|
|
29
|
+
export type { TextInputElement };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pointer routing for the number stepper value hit area (`NumberControls.svelte`).
|
|
3
|
+
* Kept pure so Node can test the rules without mounting Svelte.
|
|
4
|
+
*/
|
|
5
|
+
function hasClosest(target) {
|
|
6
|
+
return (typeof target === 'object' &&
|
|
7
|
+
target !== null &&
|
|
8
|
+
'closest' in target &&
|
|
9
|
+
typeof target.closest === 'function');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* True when a mousedown on this target should focus the number input instead of letting the
|
|
13
|
+
* browser move focus to `body` or start a document-level selection in dead space beside the digits.
|
|
14
|
+
*/
|
|
15
|
+
export function shouldRoutePointerToNumberInput(target, inputId) {
|
|
16
|
+
if (!hasClosest(target))
|
|
17
|
+
return false;
|
|
18
|
+
if (target.closest('button'))
|
|
19
|
+
return false;
|
|
20
|
+
const input = document.getElementById(inputId);
|
|
21
|
+
if (!input || !('value' in input))
|
|
22
|
+
return false;
|
|
23
|
+
if (target === input)
|
|
24
|
+
return false;
|
|
25
|
+
return Boolean(target.closest('.number-controls-hit-area'));
|
|
26
|
+
}
|
|
27
|
+
/** Caret placement after routing a press into the field. */
|
|
28
|
+
export function selectionAfterValueAreaPress(value, extendSelection) {
|
|
29
|
+
if (extendSelection) {
|
|
30
|
+
return { start: 0, end: value.length };
|
|
31
|
+
}
|
|
32
|
+
const end = value.length;
|
|
33
|
+
return { start: end, end };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* True when the pointer is in the empty stretch of an auto-sized field after the last digit
|
|
37
|
+
* (HTML `size` / average ch-width used to leave this dead band).
|
|
38
|
+
*/
|
|
39
|
+
export function isPointerPastTextEnd(text, inputLeft, clientX, textWidth) {
|
|
40
|
+
return clientX - inputLeft > textWidth + 0.5;
|
|
41
|
+
}
|
|
42
|
+
/** While dragging from empty chrome into the digits, select the whole value for the next key. */
|
|
43
|
+
export function selectionWhileDraggingFromValueChrome(valueLength, pointerPastTextEnd, extendSelection) {
|
|
44
|
+
if (valueLength === 0)
|
|
45
|
+
return null;
|
|
46
|
+
if (extendSelection)
|
|
47
|
+
return { start: 0, end: valueLength };
|
|
48
|
+
if (pointerPastTextEnd)
|
|
49
|
+
return null;
|
|
50
|
+
return { start: 0, end: valueLength };
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox / radio IC cards keep focus (and their ring) when the pointer presses non-control
|
|
3
|
+
* surfaces (label text, row chrome, padding, gaps) instead of blurring to `body`.
|
|
4
|
+
*
|
|
5
|
+
* Only real focusable controls are excluded. `label` is omitted on purpose: pressing label text
|
|
6
|
+
* must not move focus to `body` while the control inside the card stays focused.
|
|
7
|
+
*/
|
|
8
|
+
/** When true, `mousedown` should call `preventDefault()` so the active control stays focused. */
|
|
9
|
+
export declare function shouldPreventOptionGroupBackgroundFocusSteal(target: EventTarget | null): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox / radio IC cards keep focus (and their ring) when the pointer presses non-control
|
|
3
|
+
* surfaces (label text, row chrome, padding, gaps) instead of blurring to `body`.
|
|
4
|
+
*
|
|
5
|
+
* Only real focusable controls are excluded. `label` is omitted on purpose: pressing label text
|
|
6
|
+
* must not move focus to `body` while the control inside the card stays focused.
|
|
7
|
+
*/
|
|
8
|
+
const FOCUSABLE_CONTROL_SELECTOR = 'button,a,input,textarea,select,[role="checkbox"],[role="radio"],[contenteditable="true"]';
|
|
9
|
+
function hasClosest(target) {
|
|
10
|
+
return (typeof target === 'object' &&
|
|
11
|
+
target !== null &&
|
|
12
|
+
'closest' in target &&
|
|
13
|
+
typeof target.closest === 'function');
|
|
14
|
+
}
|
|
15
|
+
/** When true, `mousedown` should call `preventDefault()` so the active control stays focused. */
|
|
16
|
+
export function shouldPreventOptionGroupBackgroundFocusSteal(target) {
|
|
17
|
+
if (!hasClosest(target))
|
|
18
|
+
return false;
|
|
19
|
+
return !target.closest(FOCUSABLE_CONTROL_SELECTOR);
|
|
20
|
+
}
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
let {
|
|
10
10
|
open = false,
|
|
11
|
-
class: className = 'size-
|
|
11
|
+
class: className = 'size-3.5 shrink-0 stroke-[2.286] text-muted-foreground'
|
|
12
12
|
}: {
|
|
13
13
|
/** True while the list the trigger opens is open: the arrow points up. */
|
|
14
14
|
open?: boolean;
|
|
15
|
-
/** The size and colour of the arrow. */
|
|
15
|
+
/** The size and colour of the arrow. The default is the Figma one: 14 px, drawn with the 1.333 px stroke of every icon (`stroke-[2.286]` in the 24-unit viewBox). */
|
|
16
16
|
class?: string;
|
|
17
17
|
} = $props();
|
|
18
18
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type $$ComponentProps = {
|
|
2
2
|
/** True while the list the trigger opens is open: the arrow points up. */
|
|
3
3
|
open?: boolean;
|
|
4
|
-
/** The size and colour of the arrow. */
|
|
4
|
+
/** The size and colour of the arrow. The default is the Figma one: 14 px, drawn with the 1.333 px stroke of every icon (`stroke-[2.286]` in the 24-unit viewBox). */
|
|
5
5
|
class?: string;
|
|
6
6
|
};
|
|
7
7
|
declare const DropdownChevron: import("svelte").Component<$$ComponentProps, {}, "">;
|