diff --git a/packages/presentation/src/PostMessageDocumentVersions.ts b/packages/presentation/src/PostMessageDocumentVersions.ts index d9910405d..8eff83b2e 100644 --- a/packages/presentation/src/PostMessageDocumentVersions.ts +++ b/packages/presentation/src/PostMessageDocumentVersions.ts @@ -6,11 +6,10 @@ import type {VisualEditingConnection} from './types' export interface PostMessageDocumentVersionsProps { comlink: VisualEditingConnection perspective: ClientPerspective - bundlesPerspective: string[] } const PostMessageDocumentVersions: FC = (props) => { - const {comlink, perspective, bundlesPerspective} = props + const {comlink, perspective} = props const client = useClient({apiVersion: 'vX'}) @@ -31,11 +30,10 @@ const PostMessageDocumentVersions: FC = (props return { versions: res, - bundlesPerspective, perspective, } }) - }, [bundlesPerspective, client, comlink, perspective]) + }, [client, comlink, perspective]) return null } diff --git a/packages/presentation/src/PostMessageReleases.tsx b/packages/presentation/src/PostMessageReleases.tsx index 5e2d51012..b5ba95515 100644 --- a/packages/presentation/src/PostMessageReleases.tsx +++ b/packages/presentation/src/PostMessageReleases.tsx @@ -6,11 +6,10 @@ import type {VisualEditingConnection} from './types' export interface PostMessageReleasesProps { comlink: VisualEditingConnection perspective: ClientPerspective - bundlesPerspective: string[] } const PostMessageReleases: FC = (props) => { - const {comlink, perspective, bundlesPerspective} = props + const {comlink, perspective} = props const releases = useReleases() @@ -18,13 +17,12 @@ const PostMessageReleases: FC = (props) => { const run = async () => { comlink.post('presentation/releases', { releases: releases.data, - bundlesPerspective, perspective, }) } run() - }, [bundlesPerspective, comlink, perspective, releases.data]) + }, [comlink, perspective, releases.data]) return null } diff --git a/packages/presentation/src/PresentationTool.tsx b/packages/presentation/src/PresentationTool.tsx index a808ec2f3..ede2ad032 100644 --- a/packages/presentation/src/PresentationTool.tsx +++ b/packages/presentation/src/PresentationTool.tsx @@ -548,7 +548,6 @@ export default function PresentationTool(props: { liveDocument={displayedDocument} onDocumentsOnPage={setDocumentsOnPage} onLoadersConnection={setLoadersConnection} - bundlesPerspective={bundlesPerspective} /> ) : ( )} @@ -576,11 +574,7 @@ export default function PresentationTool(props: { )} {visualEditingComlink && ( - + )} {visualEditingComlink && documentsOnPage.length > 0 && ( @@ -589,7 +583,6 @@ export default function PresentationTool(props: { comlink={visualEditingComlink} perspective={perspective} refs={documentsOnPage} - bundlesPerspective={bundlesPerspective} /> )} @@ -605,20 +598,12 @@ export default function PresentationTool(props: { )} {visualEditingComlink && ( - + )} {visualEditingComlink && ( - + )} {visualEditingComlink && ( diff --git a/packages/presentation/src/editor/PostMessagePreviewSnapshots.tsx b/packages/presentation/src/editor/PostMessagePreviewSnapshots.tsx index ef10b1392..7201df4c9 100644 --- a/packages/presentation/src/editor/PostMessagePreviewSnapshots.tsx +++ b/packages/presentation/src/editor/PostMessagePreviewSnapshots.tsx @@ -26,7 +26,6 @@ type Ref = { export interface PostMessagePreviewsProps { comlink: VisualEditingConnection perspective: ClientPerspective - bundlesPerspective: string[] refs: Ref[] } diff --git a/packages/presentation/src/loader/LiveQueries.tsx b/packages/presentation/src/loader/LiveQueries.tsx index 26811c74f..ed99ef882 100644 --- a/packages/presentation/src/loader/LiveQueries.tsx +++ b/packages/presentation/src/loader/LiveQueries.tsx @@ -46,7 +46,6 @@ export interface LoaderQueriesProps { liveDocument: Partial | null | undefined controller: Controller | undefined perspective: ClientPerspective - bundlesPerspective: string[] onLoadersConnection: (event: StatusEvent) => void onDocumentsOnPage: ( key: string, @@ -61,7 +60,6 @@ export default function LoaderQueries(props: LoaderQueriesProps): JSX.Element { controller, perspective: activePerspective, onLoadersConnection, - bundlesPerspective, onDocumentsOnPage, } = props @@ -251,7 +249,6 @@ export default function LoaderQueries(props: LoaderQueriesProps): JSX.Element { key={`${key}${perspective}`} projectId={clientConfig.projectId!} dataset={clientConfig.dataset!} - bundlesPerspective={bundlesPerspective} perspective={perspective} query={query} params={params} @@ -277,7 +274,6 @@ interface QuerySubscriptionProps extends Pick { projectId: string dataset: string - bundlesPerspective: string[] perspective: ClientPerspective query: string params: QueryParams @@ -288,7 +284,6 @@ function QuerySubscriptionComponent(props: QuerySubscriptionProps) { const { projectId, dataset, - bundlesPerspective, perspective, query, client, @@ -307,7 +302,6 @@ function QuerySubscriptionComponent(props: QuerySubscriptionProps) { client, liveDocument, params, - bundlesPerspective, perspective, query, lastLiveEventId, @@ -368,13 +362,11 @@ interface UseQuerySubscriptionProps extends Required liveDocument: Partial | null | undefined query: string params: QueryParams - bundlesPerspective: string[] perspective: ClientPerspective lastLiveEventId: string | null } function useQuerySubscription(props: UseQuerySubscriptionProps) { - const {liveDocument, client, query, params, perspective, lastLiveEventId, bundlesPerspective} = - props + const {liveDocument, client, query, params, perspective, lastLiveEventId} = props const [snapshot, setSnapshot] = useState<{ result: unknown resultSourceMap?: ContentSourceMap @@ -409,7 +401,7 @@ function useQuerySubscription(props: UseQuerySubscriptionProps) { lastLiveEventId, tag: 'presentation-loader', signal, - perspective: undefined, + perspective, filterResponse: false, returnQuery: false, }) @@ -441,16 +433,7 @@ function useQuerySubscription(props: UseQuerySubscriptionProps) { controller.abort() } } - }, [ - client, - lastLiveEventId, - params, - perspective, - query, - shouldRefetch, - startRefresh, - bundlesPerspective, - ]) + }, [client, lastLiveEventId, params, perspective, query, shouldRefetch, startRefresh]) const {result, resultSourceMap, syncTags} = snapshot ?? {} return useMemo(() => { @@ -497,7 +480,7 @@ export function turboChargeResultIfSourceMap( } return changedValue }, - // TODO: Update applySourceDocuments to support bundlePerspective. + // TODO: Update applySourceDocuments to support releases. Array.isArray(perspective) && perspective.some((part) => typeof part === 'string' && part.startsWith('r') && part !== 'raw') ? 'previewDrafts' diff --git a/packages/presentation/src/loader/LoaderQueries.tsx b/packages/presentation/src/loader/LoaderQueries.tsx index 0a3d6bc43..3533a8cd9 100644 --- a/packages/presentation/src/loader/LoaderQueries.tsx +++ b/packages/presentation/src/loader/LoaderQueries.tsx @@ -47,7 +47,6 @@ export interface LoaderQueriesProps { liveDocument: Partial | null | undefined controller: Controller | undefined perspective: ClientPerspective - bundlesPerspective: string[] documentsOnPage: {_id: string; _type: string}[] onLoadersConnection: (event: StatusEvent) => void onDocumentsOnPage: ( @@ -62,7 +61,6 @@ export default function LoaderQueries(props: LoaderQueriesProps): JSX.Element { liveDocument, controller, perspective: activePerspective, - bundlesPerspective, documentsOnPage, onLoadersConnection, onDocumentsOnPage, @@ -209,7 +207,6 @@ export default function LoaderQueries(props: LoaderQueriesProps): JSX.Element { cache={cache} projectId={clientConfig.projectId!} dataset={clientConfig.dataset!} - bundlesPerspective={bundlesPerspective} perspective={perspective} query={query} params={params} @@ -350,7 +347,6 @@ interface QuerySubscriptionProps projectId: string dataset: string perspective: ClientPerspective - bundlesPerspective: string[] query: string params: QueryParams comlink: LoaderConnection | undefined @@ -361,7 +357,6 @@ function QuerySubscription(props: QuerySubscriptionProps) { projectId, dataset, perspective, - bundlesPerspective, query, client, refreshInterval, @@ -376,7 +371,6 @@ function QuerySubscription(props: QuerySubscriptionProps) { client, liveDocument, params, - bundlesPerspective, perspective, query, refreshInterval, @@ -409,7 +403,6 @@ interface UseQuerySubscriptionProps liveDocument: Partial | null | undefined query: string params: QueryParams - bundlesPerspective: string[] perspective: ClientPerspective documentsCacheLastUpdated: number } @@ -421,7 +414,6 @@ function useQuerySubscription(props: UseQuerySubscriptionProps) { refreshInterval, query, params, - bundlesPerspective, perspective, documentsCacheLastUpdated, } = props @@ -456,7 +448,7 @@ function useQuerySubscription(props: UseQuerySubscriptionProps) { const {result, resultSourceMap, syncTags} = await client.fetch(query, params, { tag: 'presentation-loader', signal, - perspective: undefined, + perspective, filterResponse: false, }) fetching = false @@ -487,7 +479,6 @@ function useQuerySubscription(props: UseQuerySubscriptionProps) { liveDocument, params, perspective, - bundlesPerspective, projectId, query, shouldRefetch, @@ -556,7 +547,7 @@ export function turboChargeResultIfSourceMap( } return changedValue }, - // TODO: Update applySourceDocuments to support bundlePerspective. + // TODO: Update applySourceDocuments to support releases. Array.isArray(perspective) && perspective.some((part) => typeof part === 'string' && part.startsWith('r') && part !== 'raw') ? 'previewDrafts' diff --git a/packages/presentation/src/overlays/schema/PostMessageSchema.tsx b/packages/presentation/src/overlays/schema/PostMessageSchema.tsx index b41c8df4d..822b92f65 100644 --- a/packages/presentation/src/overlays/schema/PostMessageSchema.tsx +++ b/packages/presentation/src/overlays/schema/PostMessageSchema.tsx @@ -10,7 +10,6 @@ import {extractSchema} from './extract' export interface PostMessageSchemaProps { comlink: VisualEditingConnection perspective: ClientPerspective - bundlesPerspective: string[] } function getDocumentPathArray(paths: UnresolvedPath[]) { @@ -34,7 +33,7 @@ function getDocumentPathArray(paths: UnresolvedPath[]) { * over postMessage so it can be used to enrich the Visual Editing experience */ function PostMessageSchema(props: PostMessageSchemaProps): JSX.Element | null { - const {comlink, perspective, bundlesPerspective} = props + const {comlink, perspective} = props const workspace = useWorkspace() const theme = useRootTheme() @@ -80,7 +79,7 @@ function PostMessageSchema(props: PostMessageSchemaProps): JSX.Element | null { }) return {types: newState} }) - }, [comlink, client, perspective, bundlesPerspective]) + }, [comlink, client, perspective]) return null } diff --git a/packages/visual-editing-helpers/src/types/comlink.ts b/packages/visual-editing-helpers/src/types/comlink.ts index 2a7e4aeaf..bc7261cab 100644 --- a/packages/visual-editing-helpers/src/types/comlink.ts +++ b/packages/visual-editing-helpers/src/types/comlink.ts @@ -143,7 +143,6 @@ export type VisualEditingControllerMsg = type: 'presentation/releases' data: { perspective: ClientPerspective - bundlesPerspective: string[] releases: unknown[] } } @@ -285,7 +284,6 @@ export type VisualEditingNodeMsg = data: {elements: string[]} response: { perspective: ClientPerspective - bundlesPerspective: string[] versions: { _id: string versions: {_id: string}[] diff --git a/packages/visual-editing/src/ui/ElementOverlay.tsx b/packages/visual-editing/src/ui/ElementOverlay.tsx index de9f681ee..054cacb27 100644 --- a/packages/visual-editing/src/ui/ElementOverlay.tsx +++ b/packages/visual-editing/src/ui/ElementOverlay.tsx @@ -46,7 +46,6 @@ export interface ElementOverlayProps { element: ElementNode focused: ElementFocusedState hovered: boolean - isDragging: boolean node: SanityNode | SanityStegaNode rect: OverlayRect showActions: boolean @@ -175,10 +174,13 @@ function createIntentLink(node: SanityNode) { }) } -const ElementOverlayInner: FunctionComponent = (props) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const {element, focused, componentResolver, node, showActions, draggable, releases, versions} = - props +const ElementOverlayInner: FunctionComponent< + Omit< + ElementOverlayProps, + 'enableScrollIntoView' | 'hovered' | 'rect' | 'releases' | 'versions' | 'wasMaybeCollapsed' + > +> = (props) => { + const {element, focused, componentResolver, node, showActions, draggable} = props const {getField, getType} = useSchema() const schemaType = getType(node) @@ -264,6 +266,10 @@ export const ElementOverlay = memo(function ElementOverlay(props: ElementOverlay enableScrollIntoView, releases, versions, + draggable, + node, + showActions, + componentResolver, } = props const ref = useRef(null) @@ -366,7 +372,16 @@ export const ElementOverlay = memo(function ElementOverlay(props: ElementOverlay ref={ref} style={style} > - {hovered && } + {hovered && ( + + )} {hovered && showReleasePreview && nearestUpcomingRelease && (