@widgetic/editor 4.1.18 → 4.1.20
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/WidgetPreview.svelte +77 -14
- 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 +223 -30
- 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/BrowserInputController.svelte +184 -21
- package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
- package/dist/components/ic/CheckboxInputController.svelte +11 -0
- package/dist/components/ic/ColorPickerInputController.svelte +2 -1
- package/dist/components/ic/DatePickerInputController.svelte +5 -3
- package/dist/components/ic/FontInputController.svelte +9 -4
- package/dist/components/ic/InputControllerHeader.svelte +4 -3
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +13 -0
- package/dist/components/ic/NumberControls.svelte +140 -17
- package/dist/components/ic/RadioGroupInputController.svelte +11 -0
- package/dist/components/ic/RangeCalendarInputController.svelte +38 -13
- package/dist/components/ic/TextAreaInputController.svelte +593 -321
- package/dist/components/ic/TextAreaPreviewInputController.svelte +46 -58
- package/dist/components/ic/VectorInputController.svelte +0 -1
- 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/EditorFileBrowserOverlay.svelte +48 -6
- package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +4 -1
- 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/fileBrowserOverlayEscape.d.ts +29 -0
- package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -0
- 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/embedSchema.json +409 -0
- package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
- package/dist/embed/parseCompositionEmbedCode.js +379 -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 +38 -2
- 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/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 +7 -7
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
id: string;
|
|
6
6
|
file: string;
|
|
7
7
|
url: string;
|
|
8
|
-
hash?: string;
|
|
8
|
+
hash?: string;
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
mimeType?: string;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
/** Declared props contract — export lets below are annotated from it so the
|
|
@@ -52,9 +54,13 @@
|
|
|
52
54
|
} from '@widgetic/design-system/icons';
|
|
53
55
|
import MediaManager from '../../utils/MediaManager';
|
|
54
56
|
import { queryInTreeOf } from '../../utils/shadowDom';
|
|
57
|
+
import { filesFromDataTransfer } from '../../contentBulkDrop/filterDropFiles.js';
|
|
58
|
+
import { dragCarriesFiles } from '../../contentBulkDrop/dragIntent.js';
|
|
55
59
|
|
|
56
60
|
import InputControllerRow from './InputControllerRow.svelte';
|
|
57
61
|
import EditorFileBrowserOverlay from './shared/EditorFileBrowserOverlay.svelte';
|
|
62
|
+
import EditorSelectedFilePreviewOverlay from './shared/EditorSelectedFilePreviewOverlay.svelte';
|
|
63
|
+
import type { FileSystemItem } from '@widgetic/file-browser';
|
|
58
64
|
|
|
59
65
|
// Component props with default values
|
|
60
66
|
export let header: BrowserInputControllerProps['header'] = undefined;
|
|
@@ -71,6 +77,8 @@
|
|
|
71
77
|
const getEditorPickFile = useEditorPickFile();
|
|
72
78
|
const getEditorStoreFileUrl = useEditorStoreFileUrl();
|
|
73
79
|
let pickAbortController: AbortController | null = null;
|
|
80
|
+
let fieldFileDragDepth = 0;
|
|
81
|
+
let fieldFileDragActive = false;
|
|
74
82
|
|
|
75
83
|
// The words of the editor in the language of the page
|
|
76
84
|
const { t } = useEditorLanguage();
|
|
@@ -90,6 +98,8 @@
|
|
|
90
98
|
let isChecking = true;
|
|
91
99
|
let hasError = false;
|
|
92
100
|
let isFileBrowserOpen = false;
|
|
101
|
+
let isSelectedFilePreviewOpen = false;
|
|
102
|
+
let selectedPreviewRestoreFocus: HTMLElement | null = null;
|
|
93
103
|
|
|
94
104
|
let mouseX = 0;
|
|
95
105
|
let mouseY = 0;
|
|
@@ -154,17 +164,92 @@
|
|
|
154
164
|
* @param path - File path to analyze
|
|
155
165
|
* @returns File type category or 'unknown'
|
|
156
166
|
*/
|
|
167
|
+
function extensionFromPath(path: string): string {
|
|
168
|
+
const withoutQuery = path.split('?')[0] || path;
|
|
169
|
+
const fileSegment = withoutQuery.split('/').pop() || withoutQuery;
|
|
170
|
+
const dot = fileSegment.lastIndexOf('.');
|
|
171
|
+
return dot >= 0 ? fileSegment.slice(dot + 1).toLowerCase() : '';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function getFileTypeFromExtension(
|
|
175
|
+
extension: string
|
|
176
|
+
): 'image' | 'video' | 'audio' | 'document' | 'unknown' {
|
|
177
|
+
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'avif', 'heic', 'heif'].includes(extension)) {
|
|
178
|
+
return 'image';
|
|
179
|
+
}
|
|
180
|
+
if (['mp4', 'webm', 'ogg', 'mov'].includes(extension)) return 'video';
|
|
181
|
+
if (['mp3', 'wav', 'ogg', 'aac', 'm4a'].includes(extension)) return 'audio';
|
|
182
|
+
if (['pdf', 'doc', 'docx', 'txt', 'md', 'csv'].includes(extension)) return 'document';
|
|
183
|
+
return 'unknown';
|
|
184
|
+
}
|
|
185
|
+
|
|
157
186
|
function getFileType(
|
|
158
187
|
path: string | null | undefined
|
|
159
188
|
): 'image' | 'video' | 'audio' | 'document' | 'unknown' {
|
|
160
189
|
if (!path || typeof path !== 'string') return 'unknown';
|
|
190
|
+
return getFileTypeFromExtension(extensionFromPath(path));
|
|
191
|
+
}
|
|
161
192
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
if (
|
|
167
|
-
|
|
193
|
+
function resolveMediaKind(
|
|
194
|
+
fileValue: string | FileValue | null | undefined
|
|
195
|
+
): 'image' | 'video' | 'audio' | 'document' | 'unknown' {
|
|
196
|
+
if (!fileValue) return 'unknown';
|
|
197
|
+
if (typeof fileValue === 'object' && fileValue.mimeType) {
|
|
198
|
+
const mime = fileValue.mimeType.toLowerCase();
|
|
199
|
+
if (mime.startsWith('image/')) return 'image';
|
|
200
|
+
if (mime.startsWith('video/')) return 'video';
|
|
201
|
+
if (mime.startsWith('audio/')) return 'audio';
|
|
202
|
+
if (mime === 'application/pdf' || mime.startsWith('text/')) return 'document';
|
|
203
|
+
}
|
|
204
|
+
const name = typeof fileValue === 'object' ? fileValue.file || fileValue.url : fileValue;
|
|
205
|
+
const fromName = getFileType(name);
|
|
206
|
+
if (fromName !== 'unknown') return fromName;
|
|
207
|
+
return getFileType(getPreviewUrl(fileValue));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function thumbnailDisplayUrl(fileValue: string | FileValue | null | undefined): string {
|
|
211
|
+
if (!fileValue) return '';
|
|
212
|
+
if (typeof fileValue === 'object' && fileValue.thumbnail) return fileValue.thumbnail;
|
|
213
|
+
return getPreviewUrl(fileValue);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function valueAsPreviewItem(fileValue: FileValue): FileSystemItem {
|
|
217
|
+
return {
|
|
218
|
+
id: fileValue.id,
|
|
219
|
+
name: fileValue.file,
|
|
220
|
+
type: 'file',
|
|
221
|
+
url: fileValue.url,
|
|
222
|
+
thumbnail: fileValue.thumbnail,
|
|
223
|
+
hash: fileValue.hash,
|
|
224
|
+
mimeType: fileValue.mimeType
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function openSelectedFilePreview(trigger: HTMLElement) {
|
|
229
|
+
if (!value || typeof value !== 'object') return;
|
|
230
|
+
selectedPreviewRestoreFocus = trigger;
|
|
231
|
+
isSelectedFilePreviewOpen = true;
|
|
232
|
+
setPortalHostInteractive(true);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function closeSelectedFilePreview() {
|
|
236
|
+
isSelectedFilePreviewOpen = false;
|
|
237
|
+
if (!isFileBrowserOpen) setPortalHostInteractive(false);
|
|
238
|
+
const restoreTarget = selectedPreviewRestoreFocus;
|
|
239
|
+
selectedPreviewRestoreFocus = null;
|
|
240
|
+
void tick().then(() => restoreTarget?.focus());
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function handleThumbnailClick(event: MouseEvent) {
|
|
244
|
+
event.stopPropagation();
|
|
245
|
+
openSelectedFilePreview(event.currentTarget as HTMLElement);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function handleThumbnailKeydown(event: KeyboardEvent) {
|
|
249
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
event.stopPropagation();
|
|
252
|
+
openSelectedFilePreview(event.currentTarget as HTMLElement);
|
|
168
253
|
}
|
|
169
254
|
|
|
170
255
|
/** Only embedded iframe mode (URL params) sets upload config here; standalone uses parent +page sync. */
|
|
@@ -229,7 +314,9 @@
|
|
|
229
314
|
id: selectedFile.id,
|
|
230
315
|
file: selectedFile.name || '',
|
|
231
316
|
url,
|
|
232
|
-
hash: selectedFile.hash
|
|
317
|
+
hash: selectedFile.hash,
|
|
318
|
+
thumbnail: selectedFile.thumbnail,
|
|
319
|
+
mimeType: selectedFile.mimeType
|
|
233
320
|
};
|
|
234
321
|
value = nextValue;
|
|
235
322
|
onChange(nextValue);
|
|
@@ -296,7 +383,9 @@
|
|
|
296
383
|
id: selectedFile.id,
|
|
297
384
|
name: selectedFile.name || selectedFile.file || '',
|
|
298
385
|
url: selectedFile.url,
|
|
299
|
-
hash: selectedFile.hash
|
|
386
|
+
hash: selectedFile.hash,
|
|
387
|
+
thumbnail: selectedFile.thumbnail,
|
|
388
|
+
mimeType: (selectedFile as { mimeType?: string }).mimeType
|
|
300
389
|
});
|
|
301
390
|
closeFileBrowser();
|
|
302
391
|
} catch (error) {
|
|
@@ -409,6 +498,8 @@
|
|
|
409
498
|
// Update the reactive statement to use trimString
|
|
410
499
|
$: displayLabel = value ? trimString(getFileName(value)) : header?.label || label;
|
|
411
500
|
$: previewUrl = getPreviewUrl(value);
|
|
501
|
+
$: thumbnailUrl = thumbnailDisplayUrl(value);
|
|
502
|
+
$: mediaKind = resolveMediaKind(value);
|
|
412
503
|
|
|
413
504
|
// Add hash extraction helper
|
|
414
505
|
function getThumbHash(value: string | FileValue | null | undefined): string | undefined {
|
|
@@ -550,6 +641,66 @@
|
|
|
550
641
|
if (target.closest('.browser-ic-clear-btn')) return;
|
|
551
642
|
openFileBrowser();
|
|
552
643
|
}
|
|
644
|
+
|
|
645
|
+
function handleFieldFileDragEnter(event: DragEvent) {
|
|
646
|
+
if (!dragCarriesFiles(event.dataTransfer)) return;
|
|
647
|
+
event.preventDefault();
|
|
648
|
+
event.stopPropagation();
|
|
649
|
+
fieldFileDragDepth += 1;
|
|
650
|
+
fieldFileDragActive = true;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function handleFieldFileDragOver(event: DragEvent) {
|
|
654
|
+
if (!dragCarriesFiles(event.dataTransfer)) return;
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
event.stopPropagation();
|
|
657
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy';
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function handleFieldFileDragLeave(event: DragEvent) {
|
|
661
|
+
if (!dragCarriesFiles(event.dataTransfer)) return;
|
|
662
|
+
fieldFileDragDepth = Math.max(0, fieldFileDragDepth - 1);
|
|
663
|
+
if (fieldFileDragDepth === 0) fieldFileDragActive = false;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
async function handleFieldFileDrop(event: DragEvent) {
|
|
667
|
+
if (!dragCarriesFiles(event.dataTransfer)) return;
|
|
668
|
+
event.preventDefault();
|
|
669
|
+
event.stopPropagation();
|
|
670
|
+
fieldFileDragDepth = 0;
|
|
671
|
+
fieldFileDragActive = false;
|
|
672
|
+
const files = filesFromDataTransfer(event.dataTransfer);
|
|
673
|
+
const file = files[0];
|
|
674
|
+
if (!file) return;
|
|
675
|
+
const library = getEditorMediaLibrary();
|
|
676
|
+
if (!library?.upload) {
|
|
677
|
+
showToast('error', $t('editor.file.pickFailed'));
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
pickAbortController?.abort();
|
|
681
|
+
pickAbortController = new AbortController();
|
|
682
|
+
const { signal } = pickAbortController;
|
|
683
|
+
try {
|
|
684
|
+
const uploaded = await library.upload({
|
|
685
|
+
file,
|
|
686
|
+
onProgress: () => {},
|
|
687
|
+
signal
|
|
688
|
+
});
|
|
689
|
+
if (signal.aborted) return;
|
|
690
|
+
await applyPickedFile({
|
|
691
|
+
id: uploaded.id,
|
|
692
|
+
name: uploaded.name,
|
|
693
|
+
url: uploaded.url,
|
|
694
|
+
hash: uploaded.hash,
|
|
695
|
+
thumbnail: uploaded.thumbnail,
|
|
696
|
+
mimeType: uploaded.mimeType
|
|
697
|
+
});
|
|
698
|
+
} catch (error) {
|
|
699
|
+
if (signal.aborted) return;
|
|
700
|
+
console.warn('[BrowserInputController] file drop upload failed:', error);
|
|
701
|
+
showToast('error', $t('editor.file.pickFailed'));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
553
704
|
</script>
|
|
554
705
|
|
|
555
706
|
<!-- IC Browser row: 185×36, one horizontal line (text → thumbnail → remove, or placeholder → browse). -->
|
|
@@ -561,9 +712,14 @@
|
|
|
561
712
|
class="browser-input-controller-field flex h-9 w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg bg-accent ps-3 pe-1 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background {hasError &&
|
|
562
713
|
previewUrl
|
|
563
714
|
? 'border border-destructive'
|
|
564
|
-
: ''}"
|
|
715
|
+
: ''} {fieldFileDragActive ? 'ring-2 ring-primary ring-inset' : ''}"
|
|
716
|
+
data-content-field-file-drop
|
|
565
717
|
on:click={handleControllerClick}
|
|
566
718
|
on:keydown={(e) => e.key === 'Enter' && openFileBrowser()}
|
|
719
|
+
on:dragenter={handleFieldFileDragEnter}
|
|
720
|
+
on:dragover={handleFieldFileDragOver}
|
|
721
|
+
on:dragleave={handleFieldFileDragLeave}
|
|
722
|
+
on:drop={handleFieldFileDrop}
|
|
567
723
|
role="button"
|
|
568
724
|
tabindex={0}
|
|
569
725
|
>
|
|
@@ -582,18 +738,18 @@
|
|
|
582
738
|
<div class="size-7 shrink-0 animate-pulse rounded-lg bg-muted"></div>
|
|
583
739
|
{:else if previewUrl && !hasError}
|
|
584
740
|
<!-- File preview content (28×28 thumbnail) -->
|
|
585
|
-
{#if
|
|
586
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
741
|
+
{#if mediaKind === 'image'}
|
|
587
742
|
<div
|
|
588
743
|
class="browser-input-controller-thumbnail size-7 shrink-0 overflow-hidden rounded-lg border border-border bg-background"
|
|
589
|
-
on:click
|
|
744
|
+
on:click={handleThumbnailClick}
|
|
745
|
+
on:keydown={handleThumbnailKeydown}
|
|
590
746
|
role="button"
|
|
591
747
|
tabindex={0}
|
|
592
748
|
>
|
|
593
749
|
{#if thumbHash}
|
|
594
750
|
<div on:error={() => (hasError = true)}>
|
|
595
751
|
<ThumbHashImage
|
|
596
|
-
src={
|
|
752
|
+
src={thumbnailUrl || previewUrl}
|
|
597
753
|
alt={displayLabel || ''}
|
|
598
754
|
thumbhash={thumbHash}
|
|
599
755
|
class_="size-full object-cover"
|
|
@@ -601,14 +757,14 @@
|
|
|
601
757
|
</div>
|
|
602
758
|
{:else}
|
|
603
759
|
<img
|
|
604
|
-
src={previewUrl}
|
|
760
|
+
src={thumbnailUrl || previewUrl}
|
|
605
761
|
alt={displayLabel || ''}
|
|
606
762
|
class="size-full object-cover"
|
|
607
763
|
on:error={() => (hasError = true)}
|
|
608
764
|
/>
|
|
609
765
|
{/if}
|
|
610
766
|
</div>
|
|
611
|
-
{:else if
|
|
767
|
+
{:else if mediaKind === 'video'}
|
|
612
768
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
613
769
|
<div
|
|
614
770
|
class="browser-input-controller-thumbnail relative flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-background"
|
|
@@ -642,7 +798,7 @@
|
|
|
642
798
|
</span>
|
|
643
799
|
{/if}
|
|
644
800
|
</div>
|
|
645
|
-
{:else if
|
|
801
|
+
{:else if mediaKind === 'audio'}
|
|
646
802
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
647
803
|
<div
|
|
648
804
|
class="browser-input-controller-thumbnail relative flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-background"
|
|
@@ -668,11 +824,11 @@
|
|
|
668
824
|
<track kind="captions" />
|
|
669
825
|
</audio>
|
|
670
826
|
</div>
|
|
671
|
-
{:else if
|
|
672
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
827
|
+
{:else if mediaKind === 'document'}
|
|
673
828
|
<div
|
|
674
829
|
class="browser-input-controller-thumbnail flex size-7 shrink-0 items-center justify-center rounded-lg border border-border bg-background"
|
|
675
|
-
on:click
|
|
830
|
+
on:click={handleThumbnailClick}
|
|
831
|
+
on:keydown={handleThumbnailKeydown}
|
|
676
832
|
role="button"
|
|
677
833
|
tabindex={0}
|
|
678
834
|
>
|
|
@@ -727,12 +883,19 @@
|
|
|
727
883
|
</InputControllerRow>
|
|
728
884
|
</div>
|
|
729
885
|
|
|
886
|
+
{#if isSelectedFilePreviewOpen && typeof value === 'object' && value}
|
|
887
|
+
<EditorSelectedFilePreviewOverlay
|
|
888
|
+
{portalTarget}
|
|
889
|
+
file={valueAsPreviewItem(value)}
|
|
890
|
+
onClose={closeSelectedFilePreview}
|
|
891
|
+
/>
|
|
892
|
+
{/if}
|
|
893
|
+
|
|
730
894
|
{#if isFileBrowserOpen}
|
|
731
895
|
<!-- The browser of the editor (shared with the other file fields); the type of file is fixed by this field. -->
|
|
732
896
|
<EditorFileBrowserOverlay
|
|
733
897
|
{portalTarget}
|
|
734
898
|
fileFilter={fileBrowserFilter}
|
|
735
|
-
instanceId={`props-editor-browser-input-${fileBrowserFilter}`}
|
|
736
899
|
activeFileId={getCurrentFileId()}
|
|
737
900
|
addToEditorLabel={fileBrowserAddToEditorLabelSingular}
|
|
738
901
|
onClose={closeFileBrowser}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* Shadcn UI checkbox components for consistent styling and behavior
|
|
25
25
|
*/
|
|
26
26
|
import { Label, Checkbox } from '@widgetic/design-system/components';
|
|
27
|
+
import { shouldPreventOptionGroupBackgroundFocusSteal } from './optionGroupCardPointerDown';
|
|
27
28
|
|
|
28
29
|
export let value: CheckboxInputControllerProps['value'];
|
|
29
30
|
export let onChange: CheckboxInputControllerProps['onChange'];
|
|
@@ -68,6 +69,14 @@
|
|
|
68
69
|
* Handles click on the entire row
|
|
69
70
|
* @param optionValue - The value to toggle
|
|
70
71
|
*/
|
|
72
|
+
|
|
73
|
+
/** `mousedown` default moves focus to `body` on non-focusable targets; cancel only that (not pointerdown). */
|
|
74
|
+
function handleCardMouseDown(event: MouseEvent) {
|
|
75
|
+
if (shouldPreventOptionGroupBackgroundFocusSteal(event.target)) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
function handleRowClick(optionValue: string) {
|
|
72
81
|
// Toggle the checkbox
|
|
73
82
|
const isCurrentlySelected = selectedValues.includes(optionValue);
|
|
@@ -106,9 +115,11 @@
|
|
|
106
115
|
</script>
|
|
107
116
|
|
|
108
117
|
<div class="flex flex-col gap-1">
|
|
118
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
109
119
|
<div
|
|
110
120
|
class="flex w-full flex-col gap-2 rounded-lg bg-accent px-3 py-4 transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background"
|
|
111
121
|
onfocusin={onFocus}
|
|
122
|
+
onmousedowncapture={handleCardMouseDown}
|
|
112
123
|
>
|
|
113
124
|
{#each options as option}
|
|
114
125
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
@@ -532,6 +532,7 @@
|
|
|
532
532
|
// Close all other color pickers before opening this one
|
|
533
533
|
window.dispatchEvent(new CustomEvent('widgetic:close-color-pickers', { detail: instanceId }));
|
|
534
534
|
closeAutosuggestions();
|
|
535
|
+
recentColors = recentColorsUtil.getRecentColors();
|
|
535
536
|
dispatch('colorselectmodalopen');
|
|
536
537
|
isColorSelectOpen = true;
|
|
537
538
|
lastPickerOpenTimestamp = performance.now();
|
|
@@ -1517,7 +1518,7 @@
|
|
|
1517
1518
|
>
|
|
1518
1519
|
<!-- Color Picker Popover Content Wrapper -->
|
|
1519
1520
|
<div class="color-picker-popover-content-wrapper flex flex-col gap-3">
|
|
1520
|
-
{#if saveRecentColors
|
|
1521
|
+
{#if saveRecentColors}
|
|
1521
1522
|
<!-- Recent Colors Container -->
|
|
1522
1523
|
<div class="recent-colors-container w-full">
|
|
1523
1524
|
{#if recentColors.length > 0}
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
<InputControllerRow {label} {description}>
|
|
264
264
|
<Popover.Root {open} onOpenChange={handleOpenChange}>
|
|
265
265
|
<Popover.Trigger
|
|
266
|
-
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent
|
|
266
|
+
class="date-picker-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent px-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
267
267
|
onfocusin={onFocus}
|
|
268
268
|
>
|
|
269
269
|
<span
|
|
@@ -313,7 +313,8 @@
|
|
|
313
313
|
>
|
|
314
314
|
<span class="truncate">{defaultMonth?.label || $t('editor.date.selectMonth')}</span>
|
|
315
315
|
</Select.Trigger>
|
|
316
|
-
|
|
316
|
+
<!-- No overflow-y-auto of its own (round 26): the list scrolls inside its viewport with the arrow buttons, which show the hand cursor; a second scroller here could only add a double scrollbar -->
|
|
317
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px]">
|
|
317
318
|
{#each monthOptions as { value, label }}
|
|
318
319
|
<Select.Item {value} {label}>
|
|
319
320
|
{label}
|
|
@@ -347,7 +348,8 @@
|
|
|
347
348
|
>
|
|
348
349
|
<span class="truncate">{defaultYear?.label || $t('editor.date.selectYear')}</span>
|
|
349
350
|
</Select.Trigger>
|
|
350
|
-
|
|
351
|
+
<!-- Same as the month list: the viewport scrolls, with the arrow buttons (round 26) -->
|
|
352
|
+
<Select.Content class="month-year-dropdown-content max-h-[200px]">
|
|
351
353
|
{#each yearOptions as { value, label }}
|
|
352
354
|
<Select.Item {value} {label}>
|
|
353
355
|
{label}
|
|
@@ -67,7 +67,10 @@
|
|
|
67
67
|
recentFontsStore
|
|
68
68
|
} from '../../utils/fontUtils';
|
|
69
69
|
import type { FontData } from '../../utils/FontManager';
|
|
70
|
-
import FontManager, {
|
|
70
|
+
import FontManager, {
|
|
71
|
+
mapGoogleVariantIdsToWeightNames,
|
|
72
|
+
normalizeFontWeightName
|
|
73
|
+
} from '../../utils/FontManager';
|
|
71
74
|
|
|
72
75
|
import { shouldSkipFont } from '../../utils/skipFonts';
|
|
73
76
|
import { escapeHtml, cssQuotedString } from '../../utils/htmlSafety';
|
|
@@ -194,7 +197,7 @@
|
|
|
194
197
|
if (typeof raw === 'object' && raw.family) {
|
|
195
198
|
return {
|
|
196
199
|
family: raw.family,
|
|
197
|
-
weight: raw.weight || 'Regular',
|
|
200
|
+
weight: normalizeFontWeightName(raw.weight || 'Regular'),
|
|
198
201
|
category: raw.category || 'Sans Serif'
|
|
199
202
|
};
|
|
200
203
|
}
|
|
@@ -306,7 +309,7 @@
|
|
|
306
309
|
ensureFontPickerPortal();
|
|
307
310
|
const coerced = coerceFontValue(value);
|
|
308
311
|
if (coerced?.weight) {
|
|
309
|
-
selectedWeight = `${controllerId}-${coerced.weight}`;
|
|
312
|
+
selectedWeight = `${controllerId}-${normalizeFontWeightName(coerced.weight)}`;
|
|
310
313
|
}
|
|
311
314
|
if (typeof value === 'string' && coerced && onChange) {
|
|
312
315
|
onChange(coerced);
|
|
@@ -1719,7 +1722,9 @@
|
|
|
1719
1722
|
}
|
|
1720
1723
|
|
|
1721
1724
|
// Update the template to use the modified weight
|
|
1722
|
-
$: displayWeight =
|
|
1725
|
+
$: displayWeight = normalizeFontWeightName(
|
|
1726
|
+
selectedWeight.replace(`${controllerId}-`, '') || 'Regular'
|
|
1727
|
+
);
|
|
1723
1728
|
|
|
1724
1729
|
// Update arrow click handler to use filteredFonts
|
|
1725
1730
|
function handleArrowClick(direction: 'up' | 'down') {
|
|
@@ -118,15 +118,16 @@
|
|
|
118
118
|
|
|
119
119
|
{#if showHelp && !isScrolling}
|
|
120
120
|
<Portal target="editor-tooltips">
|
|
121
|
+
<!-- The floating wrapper is already position: fixed. A fixed content inside it takes the wrapper (zero wide) as its
|
|
122
|
+
containing block, which wrapped the help text one word per line, so the content stays in the flow. -->
|
|
121
123
|
<Tooltip.Content
|
|
122
124
|
side={sideAtEnd($textDirection)}
|
|
123
125
|
sideOffset={5}
|
|
124
126
|
align="center"
|
|
125
127
|
alignOffset={-1}
|
|
126
|
-
class="tooltip-content pointer-events-none
|
|
127
|
-
style="z-index: 99999;"
|
|
128
|
+
class="tooltip-content pointer-events-none z-[99999] max-w-[min(18rem,calc(100vw-2rem))] text-balance whitespace-normal select-none"
|
|
128
129
|
>
|
|
129
|
-
<p class="text-caption">{helpText}</p>
|
|
130
|
+
<p class="text-caption text-pretty">{helpText}</p>
|
|
130
131
|
</Tooltip.Content>
|
|
131
132
|
</Portal>
|
|
132
133
|
{/if}
|
|
@@ -84,6 +84,18 @@
|
|
|
84
84
|
panel.destroy();
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
// Warn before refresh/close while a knowledge file upload is still in flight (the bytes cannot be recovered).
|
|
88
|
+
$effect(() => {
|
|
89
|
+
if (typeof window === 'undefined') return;
|
|
90
|
+
if ($panel.sending === null) return;
|
|
91
|
+
const handler = (event: BeforeUnloadEvent) => {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
event.returnValue = '';
|
|
94
|
+
};
|
|
95
|
+
window.addEventListener('beforeunload', handler);
|
|
96
|
+
return () => window.removeEventListener('beforeunload', handler);
|
|
97
|
+
});
|
|
98
|
+
|
|
87
99
|
/** True while the panel is sending a file or removing a document: nothing else can be started meanwhile. */
|
|
88
100
|
const isBusy = $derived($panel.sending !== null || $panel.removing.length > 0);
|
|
89
101
|
|
|
@@ -196,6 +208,7 @@
|
|
|
196
208
|
? 'outline-2 outline-dashed outline-brand outline-offset-4'
|
|
197
209
|
: ''}"
|
|
198
210
|
data-knowledge-documents
|
|
211
|
+
data-content-field-file-drop
|
|
199
212
|
onfocusin={() => onFocus()}
|
|
200
213
|
ondragenter={handleDragEnter}
|
|
201
214
|
ondragover={handleDragOver}
|