@widgetic/editor 4.1.21 → 4.1.23
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/README.md +43 -0
- package/dist/components/editors/CompositionEditorApp.svelte +228 -206
- package/dist/components/editors/EmbedAssistantPanel.svelte +270 -48
- package/dist/components/editors/EmbedEditor.svelte +7 -23
- package/dist/components/ic/AngleInputController.svelte +18 -3
- package/dist/components/ic/NumberInputController.svelte +16 -2
- package/dist/composition/compositionApi.d.ts +25 -0
- package/dist/composition/compositionApi.js +34 -4
- package/dist/composition/compositionEditorController.d.ts +63 -3
- package/dist/composition/compositionEditorController.js +207 -10
- package/dist/composition/staleGuard.d.ts +111 -0
- package/dist/composition/staleGuard.js +279 -0
- package/dist/embedAssistant/embedAssistantSuggest.d.ts +20 -0
- package/dist/embedAssistant/embedAssistantSuggest.js +29 -0
- package/dist/embedAssistant/embedAssistantTurns.d.ts +73 -0
- package/dist/embedAssistant/embedAssistantTurns.js +56 -0
- package/dist/embedAssistant/types.d.ts +15 -0
- package/dist/i18n/language.d.ts +18 -4
- package/dist/i18n/messages.d.ts +9 -2
- package/dist/i18n/messages.js +11 -2
- package/dist/i18n/translate.d.ts +1 -1
- package/package.json +6 -1
- package/dist/components/ic/NumberControls.svelte +0 -505
- package/dist/components/ic/NumberControls.svelte.d.ts +0 -37
- package/dist/components/ic/numberControlsSteps.d.ts +0 -17
- package/dist/components/ic/numberControlsSteps.js +0 -23
- package/dist/components/ic/numberControlsValueArea.d.ts +0 -29
- package/dist/components/ic/numberControlsValueArea.js +0 -51
package/README.md
CHANGED
|
@@ -157,6 +157,49 @@ has no preview address (`WIDGET_NOT_PUBLISHED`): its settings stay editable and
|
|
|
157
157
|
It is a Svelte component for a page that can import it, and it takes the page's styles and fonts as they are. A
|
|
158
158
|
plain-JavaScript module that works on any page, inside a shadow root, is a separate step.
|
|
159
159
|
|
|
160
|
+
## The embed assistant
|
|
161
|
+
|
|
162
|
+
`EmbedEditor` takes an optional `assistant` (an `EmbedAssistantWireConfig`). With `enabled: true` and a `streamUrl`, the
|
|
163
|
+
editor has a side panel where the person describes the embed in their own words ("open it as an overlay when the visitor
|
|
164
|
+
is about to leave"): the assistant answers, asks a question when it needs one, and sets the options. The page gives the
|
|
165
|
+
wiring; the editor holds no key.
|
|
166
|
+
|
|
167
|
+
| Field | Type | What it does |
|
|
168
|
+
| -------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
169
|
+
| `enabled` | `boolean` | `false` leaves the panel out. |
|
|
170
|
+
| `streamUrl` | `string` | Where the person's message goes; the assistant answers as a stream. |
|
|
171
|
+
| `getAuthHeaders` | `Record<string, string> \| (() => Promise<Record<string, string>>)` | The headers of the call (the person's token). |
|
|
172
|
+
| `initialTranscript` | `{ id, role, text }[]` | A conversation to show when the panel opens (to carry one over from an earlier visit). |
|
|
173
|
+
| `onTranscriptChange` | `(transcript) => void` | Called with the whole conversation after every change, so the page can keep it. |
|
|
174
|
+
| `suggestUrl` | `string` | Where the box asks how to go on; the answer is a grey suggestion after what was typed (see below). Optional. |
|
|
175
|
+
| `outcomeUrl` | `string` | Where the counts of what happened to the suggestions go. Optional. |
|
|
176
|
+
| `agentMascot` | `boolean` (default `true`) | `false` draws the chat's plain round avatar instead of the mascot, and never loads the mascot's Three.js (see below). |
|
|
177
|
+
|
|
178
|
+
**Suggestions in the box.** With a `suggestUrl` (`POST /compositions/{id}/embed-assistant/suggest` of the Widgetic gateway),
|
|
179
|
+
the box shows a grey suggestion after what the person has typed, built from what the assistant can set and leaving out the
|
|
180
|
+
settings that are already set (the editor sends the ids of the settings that have a value, never their values). **Tab** takes
|
|
181
|
+
it; typing on or **Esc** sends it away; Enter still sends only what was typed. The box asks with the person's token
|
|
182
|
+
(`getAuthHeaders`, which may be asynchronous) and no cookie. The suggestion goes while the assistant answers, when the box is
|
|
183
|
+
shut. Without `suggestUrl` the box is as it was: nothing is asked and nothing is drawn. With an `outcomeUrl`
|
|
184
|
+
(`POST /agent/composer/outcome`) the panel also reports counts (how many suggestions were shown, taken, sent away, and never a
|
|
185
|
+
word of the box) as it goes away, so the gateway can measure whether its order is what people reach for. The grey words are the
|
|
186
|
+
design system's `inline-completion` (`@widgetic/design-system/inline-completion`), so the page brings a design system that has it.
|
|
187
|
+
|
|
188
|
+
**The assistant's face** is the Scribble Mascot (`@widgetic/brand`), the one it has in the chat of the Widgetic creator, and
|
|
189
|
+
it moves the way it does there: it thinks (large) while the person waits for the first word, writes (small) while the
|
|
190
|
+
assistant answers, and settles to a happy face (large) when it changed the options, or a worried one when the run failed.
|
|
191
|
+
Beside a question waiting for an answer it stays small, which is the one place the panel differs from the chat: the panel is
|
|
192
|
+
narrow, and a large avatar would leave the question two thirds of it. Only the newest turn moves; the turns above it are
|
|
193
|
+
still pictures. The panel asks the chat for these looks (`liveAgentLook`, `settledAgentLook` of `@widgetic/chat`), so the
|
|
194
|
+
two follow one set of rules. The first mascot is warmed up when the panel opens, so it appears without a pause.
|
|
195
|
+
|
|
196
|
+
A page that does not want the mascot sets `agentMascot: false`. The face is then the chat's plain round avatar, with the same
|
|
197
|
+
turns and the same layout, and nothing of the mascot is started. There are no faces of the people of a team in this panel,
|
|
198
|
+
so a page has nothing else to switch off.
|
|
199
|
+
|
|
200
|
+
`@widgetic/chat` (0.1.42 or later) and `@widgetic/brand` are peers of the editor: the panel imports them, so the page brings
|
|
201
|
+
one copy of each (and `three`, which the brand asks for as its own peer).
|
|
202
|
+
|
|
160
203
|
## Languages
|
|
161
204
|
|
|
162
205
|
The editor shows English until it is told otherwise. `CompositionEditorApp` takes two props, and both can change while
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* deviceView { deviceView } the preview is looked at as 'desktop' or 'mobile' now (a button of the
|
|
16
16
|
* preview, a size the user gave it, or `setDeviceView`)
|
|
17
17
|
* conflict { conflict } a save was refused because somebody else saved the composition after it was
|
|
18
|
-
* loaded
|
|
18
|
+
* loaded (or the tab came back and found a newer version while it has edits that
|
|
19
|
+
* are not saved). Nothing is lost and nothing more is sent: the editor asks the person
|
|
19
20
|
* which version stays (a card of its own), and the page may show its own
|
|
20
21
|
* controls with `keepMyChanges` and `loadLatestVersion`
|
|
21
22
|
* conflictResolved { resolution } the person chose: 'keepMine' (their edits are saved on top of the newer
|
|
@@ -31,6 +32,11 @@
|
|
|
31
32
|
* A page with controls of its own for what the editor shows can use `setDeviceView` (the same toggle as the
|
|
32
33
|
* preview's buttons) and, when it saved the composition's embed settings itself, `adoptEmbedSettings`.
|
|
33
34
|
*
|
|
35
|
+
* When the person comes back to the tab, the editor looks at what the API holds (a conditional read: a tab nobody touched
|
|
36
|
+
* costs a header). A newer version saved elsewhere (an MCP client, the assistant, another tab, a teammate) is put on the screen
|
|
37
|
+
* on the spot, behind a dark layer that fades in and out and during which the editor cannot be used, so a copy that is out of
|
|
38
|
+
* date is never edited. Edits that are not saved are never replaced: they raise the `conflict` event and card.
|
|
39
|
+
*
|
|
34
40
|
* A save sends only what changed (the settings and items, or the size of the preview) and never the name: this
|
|
35
41
|
* editor cannot rename, and a name it sent back could undo a rename made in the meantime.
|
|
36
42
|
*
|
|
@@ -42,7 +48,7 @@
|
|
|
42
48
|
import { createEventDispatcher, onDestroy, onMount, tick } from 'svelte';
|
|
43
49
|
import { get, writable } from 'svelte/store';
|
|
44
50
|
import { createWidgeticMediaLibrary, type MediaLibraryProvider } from '@widgetic/file-browser';
|
|
45
|
-
import { Button } from '@widgetic/design-system/components';
|
|
51
|
+
import { Button, ContentRefreshOverlay } from '@widgetic/design-system/components';
|
|
46
52
|
import type { MessageOverrides } from '@widgetic/design-system/i18n';
|
|
47
53
|
import { shareTextDirection, type TextDirection } from '@widgetic/design-system/components/textDirection';
|
|
48
54
|
import { leftOnThisScreen } from '../../utils/dockPlacement';
|
|
@@ -592,6 +598,9 @@
|
|
|
592
598
|
void controller.load();
|
|
593
599
|
// (Beside the load, not after it: the claim is about the composition, and a composition that cannot be loaded says so to this too.)
|
|
594
600
|
startPresence();
|
|
601
|
+
// When the person comes back to this tab, a newer copy saved elsewhere is put on the screen behind the dark layer. A page that
|
|
602
|
+
// is rendered on a server has no window to listen to, and onMount does not run there.
|
|
603
|
+
controller.startStaleGuard();
|
|
595
604
|
|
|
596
605
|
window.addEventListener('resize', syncFloatingEditorHeight);
|
|
597
606
|
if (editorShellEl && typeof ResizeObserver !== 'undefined') {
|
|
@@ -622,221 +631,234 @@
|
|
|
622
631
|
{style}
|
|
623
632
|
bind:this={editorShellEl}
|
|
624
633
|
>
|
|
625
|
-
<!--
|
|
626
|
-
|
|
627
|
-
|
|
634
|
+
<!--
|
|
635
|
+
A newer copy saved elsewhere (an MCP client, the assistant, another tab, a teammate) is put on the screen when the tab comes back:
|
|
636
|
+
the dark layer fades in over the whole editor, which cannot be used meanwhile, and fades out when the copy is applied (see
|
|
637
|
+
`startStaleGuard`). The layer is above the floating panels (z-20, z-30) and sits in the box of the editor, which is relative.
|
|
638
|
+
-->
|
|
639
|
+
<ContentRefreshOverlay
|
|
640
|
+
active={state.refreshing}
|
|
641
|
+
message={$t('editor.stale.updating')}
|
|
642
|
+
description={$t('editor.stale.updatingDescription')}
|
|
643
|
+
statusLabel={$t('editor.stale.updatingStatus')}
|
|
644
|
+
class="h-full w-full"
|
|
628
645
|
>
|
|
629
|
-
<!--
|
|
630
|
-
This editor can run inside a partner's page, and a widget is code written by somebody else. The preview may
|
|
631
|
-
run its scripts, keep its own storage (allow-same-origin), open links in a new tab and submit forms, and
|
|
632
|
-
nothing more: no top navigation (it cannot send the visitor's tab away), no alert/confirm dialogs, no
|
|
633
|
-
downloads; of the page's permissions it may only write to the clipboard.
|
|
634
|
-
-->
|
|
635
|
-
<WidgetPreview
|
|
636
|
-
bind:this={previewRef}
|
|
637
|
-
class="composition-widget-preview h-full w-full"
|
|
638
|
-
mode="controlled"
|
|
639
|
-
sandbox="allow-scripts allow-same-origin allow-popups allow-forms"
|
|
640
|
-
allow="clipboard-write"
|
|
641
|
-
enableResize={true}
|
|
642
|
-
enableDrag={true}
|
|
643
|
-
showDimensionInputs={true}
|
|
644
|
-
showChromeDeviceToggle={true}
|
|
645
|
-
deviceMobile={isMobilePreview}
|
|
646
|
-
on:deviceView={(event) => setDevicePreview(event.detail.mobile)}
|
|
647
|
-
resizeMode="corner"
|
|
648
|
-
defaultStageAlign="center"
|
|
649
|
-
compactChrome={true}
|
|
650
|
-
showUrlBar={false}
|
|
651
|
-
src={previewSrc}
|
|
652
|
-
displayUrl={previewSrc}
|
|
653
|
-
resizeWidth={state.previewWidth}
|
|
654
|
-
resizeHeight={state.previewHeight}
|
|
655
|
-
{previewLoading}
|
|
656
|
-
{previewHydrating}
|
|
657
|
-
previewError={state.previewError}
|
|
658
|
-
{isContentReady}
|
|
659
|
-
on:iframeLoad={handlePreviewIframeLoad}
|
|
660
|
-
on:resize={handlePreviewResize}
|
|
661
|
-
/>
|
|
662
|
-
</div>
|
|
663
|
-
|
|
664
|
-
{#if state.phase === 'failed' && state.loadError}
|
|
665
|
-
<!-- Nothing can be shown behind this one (no composition, so no editor and no preview), so it sits in the middle. -->
|
|
666
|
-
<!-- The notices of the editor (this one, loading, the schemas and the save error) are the cards of the Figma Composition Pages page: radius 12, 16 padding, a 1px border and no shadow. -->
|
|
667
|
-
<div
|
|
668
|
-
role="alert"
|
|
669
|
-
class="composition-editor-error absolute left-1/2 top-1/2 z-30 flex w-max max-w-sm -translate-x-1/2 -translate-y-1/2 flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
670
|
-
>
|
|
671
|
-
<p class="text-body text-destructive">{failureMessage(state.loadError, 'load', $t)}</p>
|
|
672
|
-
<Button
|
|
673
|
-
size="sm"
|
|
674
|
-
class="retry-load-btn w-fit"
|
|
675
|
-
onclick={() => {
|
|
676
|
-
void controller.load();
|
|
677
|
-
}}
|
|
678
|
-
>
|
|
679
|
-
{$t('editor.app.tryAgain')}
|
|
680
|
-
</Button>
|
|
681
|
-
</div>
|
|
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">
|
|
685
|
-
{$t('editor.app.loading')}
|
|
686
|
-
</div>
|
|
687
|
-
{:else if state.schemasError}
|
|
646
|
+
<!-- Keep preview resize handles in their own layer below the floating editor. -->
|
|
688
647
|
<div
|
|
689
|
-
|
|
690
|
-
class="composition-editor-error absolute start-4 top-4 z-30 flex max-w-sm flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
648
|
+
class="composition-editor-preview-area absolute inset-0 z-0 flex min-h-0 min-w-0 bg-[#f3f4f6]"
|
|
691
649
|
>
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
{:else if schemasAvailable}
|
|
706
|
-
<!--
|
|
707
|
-
The panel is placed from the left edge of the editor's area, so it says `position: absolute` itself: the class of the
|
|
708
|
-
same name loses to the `relative` the panel's own root carries, and a relative box moves from where it sits in the flow,
|
|
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
|
|
710
|
-
720px puts it 720px beyond that: out of sight).
|
|
711
|
-
-->
|
|
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}
|
|
650
|
+
<!--
|
|
651
|
+
This editor can run inside a partner's page, and a widget is code written by somebody else. The preview may
|
|
652
|
+
run its scripts, keep its own storage (allow-same-origin), open links in a new tab and submit forms, and
|
|
653
|
+
nothing more: no top navigation (it cannot send the visitor's tab away), no alert/confirm dialogs, no
|
|
654
|
+
downloads; of the page's permissions it may only write to the clipboard.
|
|
655
|
+
-->
|
|
656
|
+
<WidgetPreview
|
|
657
|
+
bind:this={previewRef}
|
|
658
|
+
class="composition-widget-preview h-full w-full"
|
|
659
|
+
mode="controlled"
|
|
660
|
+
sandbox="allow-scripts allow-same-origin allow-popups allow-forms"
|
|
661
|
+
allow="clipboard-write"
|
|
662
|
+
enableResize={true}
|
|
735
663
|
enableDrag={true}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
664
|
+
showDimensionInputs={true}
|
|
665
|
+
showChromeDeviceToggle={true}
|
|
666
|
+
deviceMobile={isMobilePreview}
|
|
667
|
+
on:deviceView={(event) => setDevicePreview(event.detail.mobile)}
|
|
668
|
+
resizeMode="corner"
|
|
669
|
+
defaultStageAlign="center"
|
|
670
|
+
compactChrome={true}
|
|
671
|
+
showUrlBar={false}
|
|
672
|
+
src={previewSrc}
|
|
673
|
+
displayUrl={previewSrc}
|
|
674
|
+
resizeWidth={state.previewWidth}
|
|
675
|
+
resizeHeight={state.previewHeight}
|
|
676
|
+
{previewLoading}
|
|
677
|
+
{previewHydrating}
|
|
678
|
+
previewError={state.previewError}
|
|
679
|
+
{isContentReady}
|
|
680
|
+
on:iframeLoad={handlePreviewIframeLoad}
|
|
681
|
+
on:resize={handlePreviewResize}
|
|
745
682
|
/>
|
|
746
683
|
</div>
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
{
|
|
764
|
-
|
|
765
|
-
{:else}
|
|
766
|
-
{$t('editor.conflict.body')}
|
|
767
|
-
{/if}
|
|
768
|
-
</p>
|
|
684
|
+
|
|
685
|
+
{#if state.phase === 'failed' && state.loadError}
|
|
686
|
+
<!-- Nothing can be shown behind this one (no composition, so no editor and no preview), so it sits in the middle. -->
|
|
687
|
+
<!-- The notices of the editor (this one, loading, the schemas and the save error) are the cards of the Figma Composition Pages page: radius 12, 16 padding, a 1px border and no shadow. -->
|
|
688
|
+
<div
|
|
689
|
+
role="alert"
|
|
690
|
+
class="composition-editor-error absolute left-1/2 top-1/2 z-30 flex w-max max-w-sm -translate-x-1/2 -translate-y-1/2 flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
691
|
+
>
|
|
692
|
+
<p class="text-body text-destructive">{failureMessage(state.loadError, 'load', $t)}</p>
|
|
693
|
+
<Button
|
|
694
|
+
size="sm"
|
|
695
|
+
class="retry-load-btn w-fit"
|
|
696
|
+
onclick={() => {
|
|
697
|
+
void controller.load();
|
|
698
|
+
}}
|
|
699
|
+
>
|
|
700
|
+
{$t('editor.app.tryAgain')}
|
|
701
|
+
</Button>
|
|
769
702
|
</div>
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
</
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
703
|
+
{:else if (state.phase !== 'ready' || state.schemasLoading) && !schemasAvailable}
|
|
704
|
+
<!-- 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. -->
|
|
705
|
+
<div role="status" aria-busy="true" class="composition-editor-loading sr-only">
|
|
706
|
+
{$t('editor.app.loading')}
|
|
707
|
+
</div>
|
|
708
|
+
{:else if state.schemasError}
|
|
709
|
+
<div
|
|
710
|
+
role="alert"
|
|
711
|
+
class="composition-editor-error absolute start-4 top-4 z-30 flex max-w-sm flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
712
|
+
>
|
|
713
|
+
<span class="text-body text-destructive">{state.schemasError}</span>
|
|
714
|
+
<!-- Outline, not the main style: the settings panel (when it is back) has the main action of the editor. -->
|
|
715
|
+
<Button
|
|
716
|
+
size="sm"
|
|
717
|
+
variant="outline"
|
|
718
|
+
class="retry-schemas-btn w-fit"
|
|
719
|
+
onclick={() => {
|
|
720
|
+
void controller.reloadSchemas();
|
|
721
|
+
}}
|
|
722
|
+
>
|
|
723
|
+
{$t('editor.app.retry')}
|
|
724
|
+
</Button>
|
|
725
|
+
</div>
|
|
726
|
+
{:else if schemasAvailable}
|
|
727
|
+
<!--
|
|
728
|
+
The panel is placed from the left edge of the editor's area, so it says `position: absolute` itself: the class of the
|
|
729
|
+
same name loses to the `relative` the panel's own root carries, and a relative box moves from where it sits in the flow,
|
|
730
|
+
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
|
|
731
|
+
720px puts it 720px beyond that: out of sight).
|
|
732
|
+
-->
|
|
733
|
+
<!--
|
|
734
|
+
While the answer of the network is still on its way, the editor shows what the last open kept (`schemasLoading`):
|
|
735
|
+
it is there to be seen, not to be edited, because an edit made now would be replaced by the answer. `contents` keeps
|
|
736
|
+
the wrapper out of the layout: the panel is placed against the editor's area as before.
|
|
737
|
+
-->
|
|
738
|
+
<div class="composition-props-editor-host contents" inert={state.schemasLoading}>
|
|
739
|
+
<PropsEditor
|
|
740
|
+
bind:this={propsEditorRef}
|
|
741
|
+
viewStatePersistenceKey={compositionId}
|
|
742
|
+
persistedDeviceView={state.deviceView}
|
|
743
|
+
class="composition-props-editor absolute z-20 shadow-lg"
|
|
744
|
+
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) */"
|
|
745
|
+
designSchema={state.designSchema}
|
|
746
|
+
contentSchema={propsEditorContentSchema}
|
|
747
|
+
initialDesignValues={state.designValues}
|
|
748
|
+
initialContentValues={propsEditorContentValues}
|
|
749
|
+
mediaLibrary={mediaLibrary ?? defaultMediaLibrary}
|
|
750
|
+
{requestContentFromFilesPlan}
|
|
751
|
+
{pickFile}
|
|
752
|
+
{storeFileUrl}
|
|
753
|
+
width="{EDITOR_WIDTH_PX}px"
|
|
754
|
+
height="{floatingEditorHeight}px"
|
|
755
|
+
showDragHandle={true}
|
|
756
|
+
enableDrag={true}
|
|
757
|
+
showSaveButton={true}
|
|
758
|
+
saveDirty={state.dirty}
|
|
759
|
+
saveSaving={state.saving}
|
|
760
|
+
defaultTab="content"
|
|
761
|
+
on:propertyChange={handleEditorPropertyChange}
|
|
762
|
+
on:contentItemsChanged={handleEditorContentItemsChanged}
|
|
763
|
+
on:save={() => {
|
|
764
|
+
void controller.save('manual');
|
|
765
|
+
}}
|
|
766
|
+
/>
|
|
767
|
+
</div>
|
|
768
|
+
{/if}
|
|
769
|
+
|
|
770
|
+
{#if state.phase === 'ready' && state.conflict}
|
|
771
|
+
<!--
|
|
772
|
+
Somebody else saved the composition after this editor loaded it, so the save was refused and nothing more is sent until the
|
|
773
|
+
person chooses a version. Each choice says what it does to the other version: keeping the edits replaces the newer one, and
|
|
774
|
+
using the newer one drops the edits. (It takes the place of the save error: no save is made while this is on the screen.)
|
|
775
|
+
-->
|
|
776
|
+
<!-- A "Choice Card" of the Figma Composition Pages page, as the card of a teammate editing (see `EditLeaseNotice`). -->
|
|
777
|
+
<div
|
|
778
|
+
role="alert"
|
|
779
|
+
class="composition-editor-conflict absolute bottom-4 start-4 z-30 flex max-w-sm flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
780
|
+
>
|
|
781
|
+
<div class="flex flex-col gap-1">
|
|
782
|
+
<p class="text-body-medium text-foreground">{$t('editor.conflict.title')}</p>
|
|
783
|
+
<p class="text-body text-muted-foreground">
|
|
784
|
+
{#if state.conflict.lastEditedBy?.name}
|
|
785
|
+
{$t('editor.conflict.bodyNamed', { name: state.conflict.lastEditedBy.name })}
|
|
786
|
+
{:else}
|
|
787
|
+
{$t('editor.conflict.body')}
|
|
788
|
+
{/if}
|
|
789
|
+
</p>
|
|
795
790
|
</div>
|
|
796
|
-
|
|
797
|
-
<
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
791
|
+
{#if state.conflict.resolveError}
|
|
792
|
+
<p class="composition-editor-conflict-error text-caption text-destructive">
|
|
793
|
+
{state.conflict.resolveError.sessionEnded
|
|
794
|
+
? failureMessage(state.conflict.resolveError, 'save', $t)
|
|
795
|
+
: $t('editor.conflict.resolveFailed')}
|
|
796
|
+
</p>
|
|
797
|
+
{/if}
|
|
798
|
+
{#if state.conflict.resolving}
|
|
799
|
+
<p role="status" class="composition-editor-conflict-working text-caption text-muted-foreground">
|
|
800
|
+
{$t('editor.conflict.working')}
|
|
801
|
+
</p>
|
|
802
|
+
{/if}
|
|
803
|
+
<div class="flex flex-col gap-3">
|
|
804
|
+
<div class="flex flex-col items-start gap-1">
|
|
805
|
+
<Button
|
|
806
|
+
size="sm"
|
|
807
|
+
class="keep-my-changes-btn"
|
|
808
|
+
disabled={state.conflict.resolving}
|
|
809
|
+
onclick={() => {
|
|
810
|
+
void controller.keepMyChanges();
|
|
811
|
+
}}
|
|
812
|
+
>
|
|
813
|
+
{$t('editor.conflict.keepMine')}
|
|
814
|
+
</Button>
|
|
815
|
+
<span class="text-caption text-muted-foreground">{$t('editor.conflict.keepMineHint')}</span>
|
|
816
|
+
</div>
|
|
817
|
+
<div class="flex flex-col items-start gap-1">
|
|
818
|
+
<Button
|
|
819
|
+
size="sm"
|
|
820
|
+
variant="outline"
|
|
821
|
+
class="load-latest-btn"
|
|
822
|
+
disabled={state.conflict.resolving}
|
|
823
|
+
onclick={() => {
|
|
824
|
+
void controller.loadLatestVersion();
|
|
825
|
+
}}
|
|
826
|
+
>
|
|
827
|
+
{$t('editor.conflict.loadLatest')}
|
|
828
|
+
</Button>
|
|
829
|
+
<span class="text-caption text-muted-foreground">{$t('editor.conflict.loadLatestHint')}</span>
|
|
830
|
+
</div>
|
|
809
831
|
</div>
|
|
810
832
|
</div>
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
class="composition-editor-save-error absolute bottom-4 start-4 z-30 flex max-w-sm flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
816
|
-
>
|
|
817
|
-
<p class="text-body text-destructive">{failureMessage(state.saveError, 'save', $t)}</p>
|
|
818
|
-
<Button
|
|
819
|
-
size="sm"
|
|
820
|
-
variant="outline"
|
|
821
|
-
class="retry-save-btn w-fit"
|
|
822
|
-
onclick={() => {
|
|
823
|
-
void controller.save('manual');
|
|
824
|
-
}}
|
|
833
|
+
{:else if state.phase === 'ready' && state.saveError}
|
|
834
|
+
<div
|
|
835
|
+
role="alert"
|
|
836
|
+
class="composition-editor-save-error absolute bottom-4 start-4 z-30 flex max-w-sm flex-col gap-3 rounded-xl border border-border bg-background p-4"
|
|
825
837
|
>
|
|
826
|
-
{
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
838
|
+
<p class="text-body text-destructive">{failureMessage(state.saveError, 'save', $t)}</p>
|
|
839
|
+
<Button
|
|
840
|
+
size="sm"
|
|
841
|
+
variant="outline"
|
|
842
|
+
class="retry-save-btn w-fit"
|
|
843
|
+
onclick={() => {
|
|
844
|
+
void controller.save('manual');
|
|
845
|
+
}}
|
|
846
|
+
>
|
|
847
|
+
{$t('editor.app.tryAgain')}
|
|
848
|
+
</Button>
|
|
849
|
+
</div>
|
|
850
|
+
{/if}
|
|
851
|
+
|
|
852
|
+
{#if presence && state.phase === 'ready'}
|
|
853
|
+
<!-- Says who else is editing, and asks before their work is overwritten; shows nothing when nobody is. -->
|
|
854
|
+
<EditLeaseNotice
|
|
855
|
+
presence={presenceState}
|
|
856
|
+
on:takeOver={() => leaseController?.takeOver()}
|
|
857
|
+
on:lookOnly={() => leaseController?.openReadOnly()}
|
|
858
|
+
on:startEditing={() => leaseController?.startEditing()}
|
|
859
|
+
/>
|
|
860
|
+
{/if}
|
|
861
|
+
</ContentRefreshOverlay>
|
|
840
862
|
</div>
|
|
841
863
|
|
|
842
864
|
<style>
|