@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
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
onclick={() => onDevice(false)}
|
|
34
34
|
onpointerdown={(event) => event.stopPropagation()}
|
|
35
35
|
>
|
|
36
|
-
<IconDeviceDesktop class="size-4 stroke-
|
|
36
|
+
<IconDeviceDesktop class="size-4 stroke-2" aria-hidden="true" />
|
|
37
37
|
</button>
|
|
38
38
|
<button
|
|
39
39
|
type="button"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
onclick={() => onDevice(true)}
|
|
44
44
|
onpointerdown={(event) => event.stopPropagation()}
|
|
45
45
|
>
|
|
46
|
-
<IconDeviceMobile class="size-4 stroke-
|
|
46
|
+
<IconDeviceMobile class="size-4 stroke-2" aria-hidden="true" />
|
|
47
47
|
</button>
|
|
48
48
|
</div>
|
|
49
49
|
{/if}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
IconTool
|
|
17
17
|
} from '@widgetic/design-system/icons';
|
|
18
18
|
import { lockPointerStyle } from '../utils/shadowDom';
|
|
19
|
+
import { isEditableEventTarget } from '../utils/isEditableEventTarget';
|
|
19
20
|
import { useEditorLanguage } from '../i18n/language';
|
|
20
21
|
import PreviewChromeControls from './PreviewChromeControls.svelte';
|
|
21
22
|
|
|
@@ -146,6 +147,10 @@
|
|
|
146
147
|
let isDraggingPreview = false;
|
|
147
148
|
/** Alt held — keeps the alternate stroke (the brand colour, orange before the redesign) on composition even after pointerup. */
|
|
148
149
|
let isAltKeyDown = false;
|
|
150
|
+
/** True while the pointer is over the widget frame or one of its resize handles (not the empty stage around it). */
|
|
151
|
+
let isPointerOverPreview = false;
|
|
152
|
+
/** The widget frame: the preview shell with its resize handles, which are its children. */
|
|
153
|
+
let previewShellEl: HTMLElement | null = null;
|
|
149
154
|
let previewShellLeft = 0;
|
|
150
155
|
let previewShellTop = 0;
|
|
151
156
|
let previewPositionReady = false;
|
|
@@ -159,7 +164,8 @@
|
|
|
159
164
|
$: chromeHeaderHeight = showPreviewChrome ? PREVIEW_CHROME_HEADER_H : 0;
|
|
160
165
|
$: if (resizeWidth != null) widthInputValue = String(Math.round(resizeWidth));
|
|
161
166
|
$: if (resizeHeight != null) heightInputValue = String(Math.round(resizeHeight));
|
|
162
|
-
$: showSymmetricalStroke =
|
|
167
|
+
$: showSymmetricalStroke =
|
|
168
|
+
resizeMode === 'corner' && isAltKeyDown && (isPointerOverPreview || isResizing);
|
|
163
169
|
$: previewStrokeColor = showSymmetricalStroke ? PREVIEW_STROKE_ALT : PREVIEW_STROKE;
|
|
164
170
|
|
|
165
171
|
export function getResizeLimits(): { maxWidth: number; maxHeight: number } {
|
|
@@ -268,6 +274,31 @@
|
|
|
268
274
|
*/
|
|
269
275
|
let finishPointerGesture: (() => void) | null = null;
|
|
270
276
|
|
|
277
|
+
/** Resize handles sit half outside the frame, so the frame counts a few pixels beyond its box. */
|
|
278
|
+
const PREVIEW_HANDLE_REACH_PX = 6;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* After a drag or a resize ends, `pointerleave` was ignored while it ran: ask the geometry whether the pointer
|
|
282
|
+
* still is over the frame (or its handles) so the Alt stroke does not stay on after the pointer left it.
|
|
283
|
+
*/
|
|
284
|
+
function syncPointerOverPreview(clientX: number, clientY: number) {
|
|
285
|
+
try {
|
|
286
|
+
if (!previewShellEl) {
|
|
287
|
+
isPointerOverPreview = false;
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const frameRect = previewShellEl.getBoundingClientRect();
|
|
291
|
+
isPointerOverPreview =
|
|
292
|
+
clientX >= frameRect.left - PREVIEW_HANDLE_REACH_PX &&
|
|
293
|
+
clientX <= frameRect.right + PREVIEW_HANDLE_REACH_PX &&
|
|
294
|
+
clientY >= frameRect.top - PREVIEW_HANDLE_REACH_PX &&
|
|
295
|
+
clientY <= frameRect.bottom + PREVIEW_HANDLE_REACH_PX;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
console.error('[WidgetPreview] Could not tell whether the pointer is over the preview', error);
|
|
298
|
+
isPointerOverPreview = false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
271
302
|
function startPreviewDrag(event: PointerEvent) {
|
|
272
303
|
if (!enableDrag || isResizing) return;
|
|
273
304
|
const target = event.target as HTMLElement | null;
|
|
@@ -291,9 +322,12 @@
|
|
|
291
322
|
previewShellTop = clampDimension(startTop + (e.clientY - startY), edgeInset, maxTop);
|
|
292
323
|
}
|
|
293
324
|
|
|
294
|
-
function endDrag() {
|
|
325
|
+
function endDrag(endEvent?: PointerEvent) {
|
|
295
326
|
isDraggingPreview = false;
|
|
296
327
|
finishPointerGesture?.();
|
|
328
|
+
if (endEvent && typeof endEvent.clientX === 'number') {
|
|
329
|
+
syncPointerOverPreview(endEvent.clientX, endEvent.clientY);
|
|
330
|
+
}
|
|
297
331
|
console.log('[WidgetPreview] Preview drag end', {
|
|
298
332
|
left: previewShellLeft,
|
|
299
333
|
top: previewShellTop,
|
|
@@ -738,10 +772,13 @@
|
|
|
738
772
|
}
|
|
739
773
|
}
|
|
740
774
|
|
|
741
|
-
function endResize() {
|
|
775
|
+
function endResize(endEvent?: PointerEvent) {
|
|
742
776
|
isResizing = false;
|
|
743
777
|
// Keep the alternate stroke (the brand colour) while Alt remains held (composition corner mode).
|
|
744
778
|
finishPointerGesture?.();
|
|
779
|
+
if (endEvent && typeof endEvent.clientX === 'number') {
|
|
780
|
+
syncPointerOverPreview(endEvent.clientX, endEvent.clientY);
|
|
781
|
+
}
|
|
745
782
|
if (resizeWidth != null && resizeHeight != null) {
|
|
746
783
|
dispatch('resize', { width: resizeWidth, height: resizeHeight, source: 'drag' });
|
|
747
784
|
}
|
|
@@ -787,6 +824,7 @@
|
|
|
787
824
|
onMount(() => {
|
|
788
825
|
window.addEventListener('message', handleMessage);
|
|
789
826
|
const onAltDown = (e: KeyboardEvent) => {
|
|
827
|
+
if (isEditableEventTarget(e)) return;
|
|
790
828
|
if (e.key === 'Alt' || e.code === 'AltLeft' || e.code === 'AltRight') {
|
|
791
829
|
isAltKeyDown = true;
|
|
792
830
|
}
|
|
@@ -912,7 +950,7 @@
|
|
|
912
950
|
<div class="widget-preview-unpublished-ct flex items-center justify-center h-full w-full">
|
|
913
951
|
<div class="widget-preview-unpublished-content-ct flex flex-col items-center gap-3 text-center px-6">
|
|
914
952
|
<div class="size-12 rounded-xl bg-brand-subtle flex items-center justify-center">
|
|
915
|
-
<IconAlertTriangle class="size-5 stroke-[1.
|
|
953
|
+
<IconAlertTriangle class="size-5 stroke-[1.6] text-foreground" aria-hidden="true" />
|
|
916
954
|
</div>
|
|
917
955
|
<div>
|
|
918
956
|
<p class="text-body-medium text-foreground">{widget.name || $t('editor.preview.widgetName')}</p>
|
|
@@ -929,7 +967,18 @@
|
|
|
929
967
|
bind:this={resizeStageEl}
|
|
930
968
|
class="{enableResize ? 'preview-resize-stage-ct absolute inset-0 overflow-visible' : 'preview-resize-stage-ct relative flex items-center justify-center w-full h-full'}"
|
|
931
969
|
>
|
|
970
|
+
<!-- The frame (widget + resize handles) is what the modifier keys apply to, not the empty stage around it. -->
|
|
971
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
932
972
|
<div
|
|
973
|
+
bind:this={previewShellEl}
|
|
974
|
+
onpointerenter={() => {
|
|
975
|
+
isPointerOverPreview = true;
|
|
976
|
+
}}
|
|
977
|
+
onpointerleave={() => {
|
|
978
|
+
if (!isResizing && !isDraggingPreview) {
|
|
979
|
+
isPointerOverPreview = false;
|
|
980
|
+
}
|
|
981
|
+
}}
|
|
933
982
|
class="preview-iframe-shell relative flex flex-col {enableResize ? 'preview-iframe-shell-positioned' : ''}"
|
|
934
983
|
class:preview-iframe-shell-symmetrical={showSymmetricalStroke}
|
|
935
984
|
style="{enableResize /* rtl-ok: the preview is placed in pixels from the left edge of the stage; the dock of the editor mirrors it */
|
|
@@ -962,7 +1011,7 @@
|
|
|
962
1011
|
onpointerdown={startPreviewDrag}
|
|
963
1012
|
>
|
|
964
1013
|
{#if enableDrag}
|
|
965
|
-
<span class="preview-chrome-drag-grip shrink-0 text-muted-foreground leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true"><IconGripVertical class="size-4 stroke-
|
|
1014
|
+
<span class="preview-chrome-drag-grip shrink-0 text-muted-foreground leading-none" title={$t('editor.preview.dragHandle')} aria-hidden="true"><IconGripVertical class="size-4 stroke-2" /></span>
|
|
966
1015
|
{/if}
|
|
967
1016
|
<span class="preview-chrome-title text-label text-muted-foreground shrink-0">{$t('editor.preview.title')}</span>
|
|
968
1017
|
<PreviewChromeControls
|
|
@@ -1035,20 +1084,29 @@
|
|
|
1035
1084
|
{/if}
|
|
1036
1085
|
|
|
1037
1086
|
{#if showStandaloneLoading}
|
|
1038
|
-
<div
|
|
1039
|
-
|
|
1087
|
+
<div
|
|
1088
|
+
role="status"
|
|
1089
|
+
aria-busy="true"
|
|
1090
|
+
class="widget-preview-loading-ct absolute inset-0 z-10 flex items-center justify-center bg-background/80"
|
|
1091
|
+
>
|
|
1092
|
+
<span class="sr-only">{$t('editor.preview.loadingWidget')}</span>
|
|
1093
|
+
<GenerateLoader title="" subtitle="" size="md" />
|
|
1040
1094
|
</div>
|
|
1041
1095
|
{:else if showControlledLoading && !isGeneratingCode}
|
|
1042
|
-
<div
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1096
|
+
<div
|
|
1097
|
+
role="status"
|
|
1098
|
+
aria-busy="true"
|
|
1099
|
+
class="loading-overlay absolute inset-0 z-20 flex items-center justify-center bg-background"
|
|
1100
|
+
>
|
|
1101
|
+
<span class="sr-only">
|
|
1102
|
+
{!src && isLoadingUrl
|
|
1046
1103
|
? $t('editor.preview.checkingWidget')
|
|
1047
1104
|
: previewHydrating
|
|
1048
1105
|
? $t('editor.preview.applyingSettings')
|
|
1049
1106
|
: $t('editor.preview.connecting')}
|
|
1050
|
-
|
|
1051
|
-
|
|
1107
|
+
</span>
|
|
1108
|
+
<span class="sr-only">{$t('editor.preview.loadingPreview')}</span>
|
|
1109
|
+
<GenerateLoader title="" subtitle="" size="lg" />
|
|
1052
1110
|
</div>
|
|
1053
1111
|
{/if}
|
|
1054
1112
|
|
|
@@ -1117,8 +1175,9 @@
|
|
|
1117
1175
|
|
|
1118
1176
|
{:else if mode === 'controlled'}
|
|
1119
1177
|
{#if isLoadingUrl}
|
|
1120
|
-
<div class="flex h-full flex-col items-center justify-center p-6">
|
|
1121
|
-
<
|
|
1178
|
+
<div role="status" aria-busy="true" class="flex h-full flex-col items-center justify-center p-6">
|
|
1179
|
+
<span class="sr-only">{$t('editor.preview.loadingPreview')}</span>
|
|
1180
|
+
<GenerateLoader title="" subtitle="" size="lg" />
|
|
1122
1181
|
</div>
|
|
1123
1182
|
{:else}
|
|
1124
1183
|
<div class="flex h-full flex-col items-center justify-center gap-3 p-6 text-center text-body text-muted-foreground">
|
|
@@ -1135,7 +1194,11 @@
|
|
|
1135
1194
|
{$t('editor.preview.retryBuild')}
|
|
1136
1195
|
</Button>
|
|
1137
1196
|
{:else if previewLoading}
|
|
1138
|
-
|
|
1197
|
+
<!-- The editor is loading: the animation shows it, the words are for screen readers only (the same as the loaders above). -->
|
|
1198
|
+
<div role="status" aria-busy="true" class="flex items-center justify-center">
|
|
1199
|
+
<span class="sr-only">{$t('editor.preview.building')}</span>
|
|
1200
|
+
<GenerateLoader title="" subtitle="" size="lg" />
|
|
1201
|
+
</div>
|
|
1139
1202
|
{:else}
|
|
1140
1203
|
<IconPhoto class="size-6 stroke-[1.333]" aria-hidden="true" />
|
|
1141
1204
|
<div class="text-body text-muted-foreground">{$t('editor.preview.noPreview')}</div>
|
|
@@ -73,11 +73,14 @@
|
|
|
73
73
|
type CompositionEditorEvent,
|
|
74
74
|
type CompositionEditorState,
|
|
75
75
|
type ConflictResolution,
|
|
76
|
+
type DraftRestoredInfo,
|
|
76
77
|
type EditorConflict,
|
|
77
78
|
type EditorFailure,
|
|
78
79
|
type PreviewMessage,
|
|
79
80
|
type PropertyChange
|
|
80
81
|
} from '../../composition/compositionEditorController.js';
|
|
82
|
+
import { readCompositionEditorViewState } from '../../drafts/compositionEditorViewState.js';
|
|
83
|
+
import type { ContentFromFilesPlan } from '../../contentBulkDrop/types.js';
|
|
81
84
|
|
|
82
85
|
const dispatch = createEventDispatcher<{
|
|
83
86
|
ready: { name: string; widgetId: string };
|
|
@@ -139,6 +142,8 @@
|
|
|
139
142
|
* Without it, English. The words themselves come from `messages`.
|
|
140
143
|
*/
|
|
141
144
|
export let locale: string | null | undefined = undefined;
|
|
145
|
+
/** User id for Dexie schema cache keys (falls back to cache-layer owner). */
|
|
146
|
+
export let cacheOwnerId: string | null | undefined = undefined;
|
|
142
147
|
/**
|
|
143
148
|
* The words of the editor in the language of the page: any of the keys of `EDITOR_MESSAGES` (and of the File
|
|
144
149
|
* Browser's and the rich text editor's catalogs, which are inside the editor). One flat object; a key left out keeps
|
|
@@ -155,6 +160,10 @@
|
|
|
155
160
|
* Can change while the editor is open.
|
|
156
161
|
*/
|
|
157
162
|
export let dir: TextDirection | undefined = undefined;
|
|
163
|
+
/** Called when unsaved local edits were restored from the draft journal after load (host may toast). */
|
|
164
|
+
export let onDraftRestored: ((info: DraftRestoredInfo) => void) | undefined = undefined;
|
|
165
|
+
|
|
166
|
+
let storedDeviceViewApplied = false;
|
|
158
167
|
|
|
159
168
|
// --- the direction ----------------------------------------------------------------------------------
|
|
160
169
|
|
|
@@ -176,6 +185,13 @@
|
|
|
176
185
|
|
|
177
186
|
// A wrong address or token function throws here, when the editor is made: it is a mistake in the page, not a failure to handle.
|
|
178
187
|
// The token function is read when it is called, so a page that gives a new one later is heard.
|
|
188
|
+
async function requestContentFromFilesPlan(
|
|
189
|
+
files: Array<{ name: string; mimeType: string; sizeBytes?: number; mediaId: string }>
|
|
190
|
+
): Promise<ContentFromFilesPlan> {
|
|
191
|
+
const result = await api.planContentFromFiles(compositionId, { files, apply: false });
|
|
192
|
+
return result.plan;
|
|
193
|
+
}
|
|
194
|
+
|
|
179
195
|
const api = createCompositionApi({
|
|
180
196
|
apiBasePath,
|
|
181
197
|
getAccessToken: (reason, refusedToken) => getAccessToken(reason, refusedToken)
|
|
@@ -191,6 +207,10 @@
|
|
|
191
207
|
api,
|
|
192
208
|
autosaveDelayMs,
|
|
193
209
|
lockPreviewSize,
|
|
210
|
+
locale: locale ?? 'en',
|
|
211
|
+
cacheOwnerId: cacheOwnerId ?? null,
|
|
212
|
+
// Read when it is called, like the token function: a page that gives another callback later is the one that is told.
|
|
213
|
+
onDraftRestored: (info) => onDraftRestored?.(info),
|
|
194
214
|
// The sentences the controller makes (why there is no preview) are made in the language of the moment.
|
|
195
215
|
translate: (key, values) => get(language.t)(key, values),
|
|
196
216
|
// The preview page hears about every change as it happens (and everything, once its page has loaded).
|
|
@@ -389,9 +409,6 @@
|
|
|
389
409
|
$: previewSrc = state.preview?.previewUrl ?? null;
|
|
390
410
|
$: previewLoading = state.phase === 'idle' || state.phase === 'loading';
|
|
391
411
|
$: isMobilePreview = state.deviceView === 'mobile';
|
|
392
|
-
// "Loading editor…" sits in the middle while the composition loads, and where the editor is about to appear after.
|
|
393
|
-
$: loadingCardPosition =
|
|
394
|
-
state.phase === 'ready' ? 'start-4 top-4' : 'left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2';
|
|
395
412
|
// A preview address that has just arrived is a page still to load: the preview says so until its frame has loaded.
|
|
396
413
|
$: startHydrating(previewSrc);
|
|
397
414
|
|
|
@@ -474,8 +491,19 @@
|
|
|
474
491
|
let floatingEditorHeight = 640;
|
|
475
492
|
|
|
476
493
|
$: schemasAvailable = Boolean(state.designSchema || state.contentSchema);
|
|
477
|
-
$: editorVisible =
|
|
478
|
-
|
|
494
|
+
$: editorVisible = state.phase === 'ready' && !state.schemasError && schemasAvailable;
|
|
495
|
+
$: contentItemIds = new Set(
|
|
496
|
+
state.contentItems
|
|
497
|
+
.map((item) => (item && typeof item === 'object' ? (item as { id?: string }).id : undefined))
|
|
498
|
+
.filter((id): id is string => typeof id === 'string' && id !== '')
|
|
499
|
+
);
|
|
500
|
+
$: if (state.phase === 'ready' && !storedDeviceViewApplied && compositionId) {
|
|
501
|
+
const stored = readCompositionEditorViewState(compositionId, contentItemIds);
|
|
502
|
+
if (stored?.deviceView && stored.deviceView !== state.deviceView) {
|
|
503
|
+
controller.setDeviceView(stored.deviceView);
|
|
504
|
+
}
|
|
505
|
+
storedDeviceViewApplied = true;
|
|
506
|
+
}
|
|
479
507
|
// Placed once the editor is on the screen, not on every change: it must not jump back while it is being dragged.
|
|
480
508
|
// It is placed again when the screen turns around, because the pair is the mirror of itself.
|
|
481
509
|
$: if (editorVisible && $textDirection) requestDock();
|
|
@@ -651,11 +679,9 @@
|
|
|
651
679
|
{$t('editor.app.tryAgain')}
|
|
652
680
|
</Button>
|
|
653
681
|
</div>
|
|
654
|
-
{:else if state.phase !== 'ready' || state.schemasLoading}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
class="composition-editor-loading absolute z-30 rounded-xl border border-border bg-background px-4 py-3 text-body text-muted-foreground {loadingCardPosition}"
|
|
658
|
-
>
|
|
682
|
+
{:else if (state.phase !== 'ready' || state.schemasLoading) && !schemasAvailable}
|
|
683
|
+
<!-- Nothing is drawn while it loads (no text, no empty card that flashes): the editor appears when it is ready, and a screen reader is told. -->
|
|
684
|
+
<div role="status" aria-busy="true" class="composition-editor-loading sr-only">
|
|
659
685
|
{$t('editor.app.loading')}
|
|
660
686
|
</div>
|
|
661
687
|
{:else if state.schemasError}
|
|
@@ -683,31 +709,41 @@
|
|
|
683
709
|
which is the left edge only on a left to right screen (on a right to left one it sits at the right edge, and a `left` of
|
|
684
710
|
720px puts it 720px beyond that: out of sight).
|
|
685
711
|
-->
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
712
|
+
<!--
|
|
713
|
+
While the answer of the network is still on its way, the editor shows what the last open kept (`schemasLoading`):
|
|
714
|
+
it is there to be seen, not to be edited, because an edit made now would be replaced by the answer. `contents` keeps
|
|
715
|
+
the wrapper out of the layout: the panel is placed against the editor's area as before.
|
|
716
|
+
-->
|
|
717
|
+
<div class="composition-props-editor-host contents" inert={state.schemasLoading}>
|
|
718
|
+
<PropsEditor
|
|
719
|
+
bind:this={propsEditorRef}
|
|
720
|
+
viewStatePersistenceKey={compositionId}
|
|
721
|
+
persistedDeviceView={state.deviceView}
|
|
722
|
+
class="composition-props-editor absolute z-20 shadow-lg"
|
|
723
|
+
style="position: absolute; left: {EDITOR_PADDING}px; top: {EDITOR_PADDING}px; /* rtl-ok: the dock puts the panel in pixels from the left edge as soon as it is on screen (see dockFloatingEditorOnce) */"
|
|
724
|
+
designSchema={state.designSchema}
|
|
725
|
+
contentSchema={propsEditorContentSchema}
|
|
726
|
+
initialDesignValues={state.designValues}
|
|
727
|
+
initialContentValues={propsEditorContentValues}
|
|
728
|
+
mediaLibrary={mediaLibrary ?? defaultMediaLibrary}
|
|
729
|
+
{requestContentFromFilesPlan}
|
|
730
|
+
{pickFile}
|
|
731
|
+
{storeFileUrl}
|
|
732
|
+
width="{EDITOR_WIDTH_PX}px"
|
|
733
|
+
height="{floatingEditorHeight}px"
|
|
734
|
+
showDragHandle={true}
|
|
735
|
+
enableDrag={true}
|
|
736
|
+
showSaveButton={true}
|
|
737
|
+
saveDirty={state.dirty}
|
|
738
|
+
saveSaving={state.saving}
|
|
739
|
+
defaultTab="content"
|
|
740
|
+
on:propertyChange={handleEditorPropertyChange}
|
|
741
|
+
on:contentItemsChanged={handleEditorContentItemsChanged}
|
|
742
|
+
on:save={() => {
|
|
743
|
+
void controller.save('manual');
|
|
744
|
+
}}
|
|
745
|
+
/>
|
|
746
|
+
</div>
|
|
711
747
|
{/if}
|
|
712
748
|
|
|
713
749
|
{#if state.phase === 'ready' && state.conflict}
|
|
@@ -5,7 +5,7 @@ import type { PartnerPickFileFn } from '../../pickFileContext.js';
|
|
|
5
5
|
import type { StoreFileUrlFn } from '../../fileStorageUrlContext.js';
|
|
6
6
|
import { type EditLeaseHolder, type TokenReason } from '../../composition/compositionApi.js';
|
|
7
7
|
import { type PresencePhase } from '../../composition/editLeaseController.js';
|
|
8
|
-
import { type CompositionEditorState, type ConflictResolution, type EditorConflict, type EditorFailure } from '../../composition/compositionEditorController.js';
|
|
8
|
+
import { type CompositionEditorState, type ConflictResolution, type DraftRestoredInfo, type EditorConflict, type EditorFailure } from '../../composition/compositionEditorController.js';
|
|
9
9
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
10
10
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
11
11
|
$$bindings?: Bindings;
|
|
@@ -55,6 +55,7 @@ declare const CompositionEditorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
55
55
|
* The language of the editor: a BCP 47 tag ("de", "pt-BR") that sets how plurals, numbers and dates are written.
|
|
56
56
|
* Without it, English. The words themselves come from `messages`.
|
|
57
57
|
*/ locale?: string | null | undefined;
|
|
58
|
+
/** User id for Dexie schema cache keys (falls back to cache-layer owner). */ cacheOwnerId?: string | null | undefined;
|
|
58
59
|
/**
|
|
59
60
|
* The words of the editor in the language of the page: any of the keys of `EDITOR_MESSAGES` (and of the File
|
|
60
61
|
* Browser's and the rich text editor's catalogs, which are inside the editor). One flat object; a key left out keeps
|
|
@@ -69,6 +70,7 @@ declare const CompositionEditorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
69
70
|
* to right. Left out, the editor is read the way the screen around it is, and left to right when nothing around it says.
|
|
70
71
|
* Can change while the editor is open.
|
|
71
72
|
*/ dir?: TextDirection | undefined;
|
|
73
|
+
/** Called when unsaved local edits were restored from the draft journal after load (host may toast). */ onDraftRestored?: ((info: DraftRestoredInfo) => void) | undefined;
|
|
72
74
|
save?: () => Promise<boolean>;
|
|
73
75
|
flush?: () => Promise<boolean>;
|
|
74
76
|
isDirty?: () => boolean;
|