@focus-reactive/payload-plugin-visual-editing 1.1.0 → 1.2.0
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 +365 -95
- package/dist/admin/InstantPreviewBroadcaster.d.ts +3 -0
- package/dist/admin/InstantPreviewBroadcaster.js +64 -0
- package/dist/admin/InstantPreviewBroadcaster.js.map +1 -0
- package/dist/admin/VisualEditingBridgeProvider.js +28 -27
- package/dist/admin/VisualEditingBridgeProvider.js.map +1 -1
- package/dist/admin/expandAndFocus.d.ts +0 -1
- package/dist/admin/expandAndFocus.js +19 -61
- package/dist/admin/expandAndFocus.js.map +1 -1
- package/dist/admin/fieldDomId.d.ts +5 -0
- package/dist/admin/fieldDomId.js +11 -0
- package/dist/admin/fieldDomId.js.map +1 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +2 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/instantPreview/fieldMessages.d.ts +26 -0
- package/dist/admin/instantPreview/fieldMessages.js +90 -0
- package/dist/admin/instantPreview/fieldMessages.js.map +1 -0
- package/dist/admin/instantPreview/formFields.d.ts +9 -0
- package/dist/admin/instantPreview/formFields.js +54 -0
- package/dist/admin/instantPreview/formFields.js.map +1 -0
- package/dist/admin/instantPreview/previewSession.d.ts +18 -0
- package/dist/admin/instantPreview/previewSession.js +157 -0
- package/dist/admin/instantPreview/previewSession.js.map +1 -0
- package/dist/admin/instantPreview/richTextReads.d.ts +29 -0
- package/dist/admin/instantPreview/richTextReads.js +67 -0
- package/dist/admin/instantPreview/richTextReads.js.map +1 -0
- package/dist/admin/instantPreview/unsavedStructures.d.ts +16 -0
- package/dist/admin/instantPreview/unsavedStructures.js +71 -0
- package/dist/admin/instantPreview/unsavedStructures.js.map +1 -0
- package/dist/admin/instantPreview/useEditableSchema.d.ts +7 -0
- package/dist/admin/instantPreview/useEditableSchema.js +30 -0
- package/dist/admin/instantPreview/useEditableSchema.js.map +1 -0
- package/dist/admin/instantPreview/usePreviewPage.d.ts +3 -0
- package/dist/admin/instantPreview/usePreviewPage.js +50 -0
- package/dist/admin/instantPreview/usePreviewPage.js.map +1 -0
- package/dist/admin/instantPreview/usePreviewWindow.d.ts +7 -0
- package/dist/admin/instantPreview/usePreviewWindow.js +46 -0
- package/dist/admin/instantPreview/usePreviewWindow.js.map +1 -0
- package/dist/admin/openField/OpenFormAnnouncer.d.ts +1 -0
- package/dist/admin/openField/OpenFormAnnouncer.js +8 -0
- package/dist/admin/openField/OpenFormAnnouncer.js.map +1 -0
- package/dist/admin/openField/formPathOfKey.d.ts +11 -0
- package/dist/admin/openField/formPathOfKey.js +20 -0
- package/dist/admin/openField/formPathOfKey.js.map +1 -0
- package/dist/admin/openField/openDocument.d.ts +8 -0
- package/dist/admin/openField/openDocument.js +13 -0
- package/dist/admin/openField/openDocument.js.map +1 -0
- package/dist/admin/openField/openForms.d.ts +9 -0
- package/dist/admin/openField/openForms.js +20 -0
- package/dist/admin/openField/openForms.js.map +1 -0
- package/dist/admin/openField/useOpenFormAnnouncement.d.ts +1 -0
- package/dist/admin/openField/useOpenFormAnnouncement.js +29 -0
- package/dist/admin/openField/useOpenFormAnnouncement.js.map +1 -0
- package/dist/admin/parseFieldPath.js +7 -17
- package/dist/admin/parseFieldPath.js.map +1 -1
- package/dist/admin/resolveContainerChain.d.ts +3 -2
- package/dist/admin/resolveContainerChain.js +10 -33
- package/dist/admin/resolveContainerChain.js.map +1 -1
- package/dist/client/VisualEditingOverlay.js +24 -15
- package/dist/client/VisualEditingOverlay.js.map +1 -1
- package/dist/client/VisualEditingProvider.d.ts +5 -3
- package/dist/client/VisualEditingProvider.js +6 -6
- package/dist/client/VisualEditingProvider.js.map +1 -1
- package/dist/client/VisualEditingToggle.js +1 -11
- package/dist/client/VisualEditingToggle.js.map +1 -1
- package/dist/client/adminWindow.d.ts +2 -0
- package/dist/client/adminWindow.js +8 -0
- package/dist/client/adminWindow.js.map +1 -0
- package/dist/client/createOverlay.d.ts +17 -0
- package/dist/client/createOverlay.js +30 -0
- package/dist/client/createOverlay.js.map +1 -0
- package/dist/client/index.d.ts +5 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/instantPreview/LiveRichText.d.ts +16 -0
- package/dist/client/instantPreview/LiveRichText.js +18 -0
- package/dist/client/instantPreview/LiveRichText.js.map +1 -0
- package/dist/client/instantPreview/adminChannel.d.ts +14 -0
- package/dist/client/instantPreview/adminChannel.js +40 -0
- package/dist/client/instantPreview/adminChannel.js.map +1 -0
- package/dist/client/instantPreview/instantPreview.d.ts +8 -0
- package/dist/client/instantPreview/instantPreview.js +49 -0
- package/dist/client/instantPreview/instantPreview.js.map +1 -0
- package/dist/client/instantPreview/liveFields.d.ts +18 -0
- package/dist/client/instantPreview/liveFields.js +158 -0
- package/dist/client/instantPreview/liveFields.js.map +1 -0
- package/dist/client/instantPreview/liveMessages.d.ts +6 -0
- package/dist/client/instantPreview/liveMessages.js +39 -0
- package/dist/client/instantPreview/liveMessages.js.map +1 -0
- package/dist/client/instantPreview/liveRichTextOf.d.ts +6 -0
- package/dist/client/instantPreview/liveRichTextOf.js +23 -0
- package/dist/client/instantPreview/liveRichTextOf.js.map +1 -0
- package/dist/client/instantPreview/pageLoad.d.ts +6 -0
- package/dist/client/instantPreview/pageLoad.js +11 -0
- package/dist/client/instantPreview/pageLoad.js.map +1 -0
- package/dist/client/instantPreview/unsavedRender/UnsavedRenderBoundary.d.ts +19 -0
- package/dist/client/instantPreview/unsavedRender/UnsavedRenderBoundary.js +28 -0
- package/dist/client/instantPreview/unsavedRender/UnsavedRenderBoundary.js.map +1 -0
- package/dist/client/instantPreview/unsavedRender/announcer.d.ts +3 -0
- package/dist/client/instantPreview/unsavedRender/announcer.js +25 -0
- package/dist/client/instantPreview/unsavedRender/announcer.js.map +1 -0
- package/dist/client/instantPreview/unsavedRender/savedShapes.d.ts +6 -0
- package/dist/client/instantPreview/unsavedRender/savedShapes.js +20 -0
- package/dist/client/instantPreview/unsavedRender/savedShapes.js.map +1 -0
- package/dist/client/instantPreview/unsavedRender/unsavedRender.d.ts +40 -0
- package/dist/client/instantPreview/unsavedRender/unsavedRender.js +158 -0
- package/dist/client/instantPreview/unsavedRender/unsavedRender.js.map +1 -0
- package/dist/client/instantPreview/unsavedRender/useUnsavedRender.d.ts +10 -0
- package/dist/client/instantPreview/unsavedRender/useUnsavedRender.js +118 -0
- package/dist/client/instantPreview/unsavedRender/useUnsavedRender.js.map +1 -0
- package/dist/client/overlay/constants.d.ts +2 -2
- package/dist/client/overlay/constants.js +4 -12
- package/dist/client/overlay/constants.js.map +1 -1
- package/dist/client/overlay/editBadge.d.ts +2 -8
- package/dist/client/overlay/editBadge.js +0 -8
- package/dist/client/overlay/editBadge.js.map +1 -1
- package/dist/client/overlay/editTargets.d.ts +3 -0
- package/dist/client/overlay/editTargets.js +98 -0
- package/dist/client/overlay/editTargets.js.map +1 -0
- package/dist/client/overlay/fieldTracker.d.ts +20 -0
- package/dist/client/overlay/fieldTracker.js +194 -0
- package/dist/client/overlay/fieldTracker.js.map +1 -0
- package/dist/client/overlay/hoverController.d.ts +0 -5
- package/dist/client/overlay/hoverController.js +0 -16
- package/dist/client/overlay/hoverController.js.map +1 -1
- package/dist/client/overlay/markerExtractor.d.ts +4 -3
- package/dist/client/overlay/markerExtractor.js +12 -19
- package/dist/client/overlay/markerExtractor.js.map +1 -1
- package/dist/client/overlay/mutationPipeline.d.ts +2 -2
- package/dist/client/overlay/mutationPipeline.js +51 -35
- package/dist/client/overlay/mutationPipeline.js.map +1 -1
- package/dist/client/overlay/targetRegistry.d.ts +5 -11
- package/dist/client/overlay/targetRegistry.js +14 -7
- package/dist/client/overlay/targetRegistry.js.map +1 -1
- package/dist/client/overlay/targetSelector.js +0 -9
- package/dist/client/overlay/targetSelector.js.map +1 -1
- package/dist/client/overlayClickHandler.d.ts +1 -1
- package/dist/client/overlayClickHandler.js +7 -13
- package/dist/client/overlayClickHandler.js.map +1 -1
- package/dist/client/overlayContext.d.ts +3 -0
- package/dist/client/overlayContext.js +5 -0
- package/dist/client/overlayContext.js.map +1 -0
- package/dist/client/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/client/useIsomorphicLayoutEffect.js +4 -0
- package/dist/client/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/client/useVisualEditingOverlay.d.ts +2 -2
- package/dist/client/useVisualEditingOverlay.js +21 -9
- package/dist/client/useVisualEditingOverlay.js.map +1 -1
- package/dist/client/visualEditingMode.d.ts +3 -0
- package/dist/client/visualEditingMode.js +8 -0
- package/dist/client/visualEditingMode.js.map +1 -0
- package/dist/client/withVisualEditingPath.d.ts +3 -1
- package/dist/client/withVisualEditingPath.js +17 -10
- package/dist/client/withVisualEditingPath.js.map +1 -1
- package/dist/excludeValues.d.ts +4 -0
- package/dist/excludeValues.js +4 -16
- package/dist/excludeValues.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +40 -30
- package/dist/index.js.map +1 -1
- package/dist/readUnsavedRichText.d.ts +13 -0
- package/dist/readUnsavedRichText.js +75 -0
- package/dist/readUnsavedRichText.js.map +1 -0
- package/dist/server/hooks/readHooks.d.ts +14 -0
- package/dist/server/hooks/readHooks.js +67 -0
- package/dist/server/hooks/readHooks.js.map +1 -0
- package/dist/{internal → server/hooks}/stripStegaHook.js +11 -12
- package/dist/server/hooks/stripStegaHook.js.map +1 -0
- package/dist/server/localeCodesKeyingValues.d.ts +4 -0
- package/dist/server/localeCodesKeyingValues.js +15 -0
- package/dist/server/localeCodesKeyingValues.js.map +1 -0
- package/dist/server/markRead.d.ts +12 -0
- package/dist/server/markRead.js +220 -0
- package/dist/server/markRead.js.map +1 -0
- package/dist/server/markedReads.d.ts +28 -0
- package/dist/server/markedReads.js +58 -0
- package/dist/server/markedReads.js.map +1 -0
- package/dist/server/richText/markTextLeaves.d.ts +1 -0
- package/dist/server/richText/markTextLeaves.js +16 -0
- package/dist/server/richText/markTextLeaves.js.map +1 -0
- package/dist/server/schemaCache.d.ts +29 -0
- package/dist/server/schemaCache.js +35 -0
- package/dist/server/schemaCache.js.map +1 -0
- package/dist/server/unsavedRichText/hooks.d.ts +4 -0
- package/dist/server/unsavedRichText/hooks.js +42 -0
- package/dist/server/unsavedRichText/hooks.js.map +1 -0
- package/dist/server/unsavedRichText/jsonBody.d.ts +1 -0
- package/dist/server/unsavedRichText/jsonBody.js +47 -0
- package/dist/server/unsavedRichText/jsonBody.js.map +1 -0
- package/dist/server/unsavedRichText/latestReads.d.ts +17 -0
- package/dist/server/unsavedRichText/latestReads.js +70 -0
- package/dist/server/unsavedRichText/latestReads.js.map +1 -0
- package/dist/server/unsavedRichText/placeUnsavedState.d.ts +8 -0
- package/dist/server/unsavedRichText/placeUnsavedState.js +12 -0
- package/dist/server/unsavedRichText/placeUnsavedState.js.map +1 -0
- package/dist/server/unsavedRichText/postedEditorState.d.ts +2 -0
- package/dist/server/unsavedRichText/postedEditorState.js +45 -0
- package/dist/server/unsavedRichText/postedEditorState.js.map +1 -0
- package/dist/server/unsavedRichText/postedRequest.d.ts +36 -0
- package/dist/server/unsavedRichText/postedRequest.js +96 -0
- package/dist/server/unsavedRichText/postedRequest.js.map +1 -0
- package/dist/server/unsavedRichText/readAsUser.d.ts +6 -0
- package/dist/server/unsavedRichText/readAsUser.js +60 -0
- package/dist/server/unsavedRichText/readAsUser.js.map +1 -0
- package/dist/server/unsavedRichText/readContext.d.ts +10 -0
- package/dist/server/unsavedRichText/readContext.js +9 -0
- package/dist/server/unsavedRichText/readContext.js.map +1 -0
- package/dist/server/unsavedRichText/relatedIds.d.ts +2 -0
- package/dist/server/unsavedRichText/relatedIds.js +30 -0
- package/dist/server/unsavedRichText/relatedIds.js.map +1 -0
- package/dist/server/unsavedRichText/savedNodeFields.d.ts +2 -0
- package/dist/server/unsavedRichText/savedNodeFields.js +47 -0
- package/dist/server/unsavedRichText/savedNodeFields.js.map +1 -0
- package/dist/server/withInstantPreview.d.ts +9 -0
- package/dist/server/withInstantPreview.js +41 -0
- package/dist/server/withInstantPreview.js.map +1 -0
- package/dist/{client → shared}/buildAdminEditUrl.d.ts +2 -2
- package/dist/{client → shared}/buildAdminEditUrl.js +2 -1
- package/dist/shared/buildAdminEditUrl.js.map +1 -0
- package/dist/shared/editableSchema/editableSchema.d.ts +26 -0
- package/dist/shared/editableSchema/editableSchema.js +165 -0
- package/dist/shared/editableSchema/editableSchema.js.map +1 -0
- package/dist/shared/editableSchema/schemaOfFields.d.ts +16 -0
- package/dist/shared/editableSchema/schemaOfFields.js +106 -0
- package/dist/shared/editableSchema/schemaOfFields.js.map +1 -0
- package/dist/shared/fieldKey.d.ts +23 -0
- package/dist/shared/fieldKey.js +44 -0
- package/dist/shared/fieldKey.js.map +1 -0
- package/dist/shared/messageSource.d.ts +1 -0
- package/dist/shared/messageSource.js +3 -0
- package/dist/shared/messageSource.js.map +1 -0
- package/dist/shared/packageName.d.ts +1 -0
- package/dist/shared/packageName.js +3 -0
- package/dist/shared/packageName.js.map +1 -0
- package/dist/shared/plainObject.d.ts +2 -0
- package/dist/shared/plainObject.js +3 -0
- package/dist/shared/plainObject.js.map +1 -0
- package/dist/shared/protocol.d.ts +80 -0
- package/dist/shared/protocol.js +26 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/richText/blockNodes.d.ts +3 -0
- package/dist/shared/richText/blockNodes.js +35 -0
- package/dist/shared/richText/blockNodes.js.map +1 -0
- package/dist/shared/richText/editorNodes.d.ts +6 -0
- package/dist/shared/richText/editorNodes.js +25 -0
- package/dist/shared/richText/editorNodes.js.map +1 -0
- package/dist/shared/richText/nodeKey.d.ts +13 -0
- package/dist/shared/richText/nodeKey.js +22 -0
- package/dist/shared/richText/nodeKey.js.map +1 -0
- package/dist/shared/richText/nodeTypes.d.ts +5 -0
- package/dist/shared/richText/nodeTypes.js +20 -0
- package/dist/shared/richText/nodeTypes.js.map +1 -0
- package/dist/shared/richText/shapeOf.d.ts +1 -0
- package/dist/shared/richText/shapeOf.js +24 -0
- package/dist/shared/richText/shapeOf.js.map +1 -0
- package/dist/shared/richText/textLeaves.d.ts +14 -0
- package/dist/shared/richText/textLeaves.js +32 -0
- package/dist/shared/richText/textLeaves.js.map +1 -0
- package/dist/shared/rowWithId.d.ts +2 -0
- package/dist/shared/rowWithId.js +7 -0
- package/dist/shared/rowWithId.js.map +1 -0
- package/dist/{internal → shared}/shared.d.ts +5 -13
- package/dist/shared/shared.js +38 -0
- package/dist/shared/shared.js.map +1 -0
- package/dist/shared/stegaText.d.ts +2 -0
- package/dist/shared/stegaText.js +6 -0
- package/dist/shared/stegaText.js.map +1 -0
- package/dist/shared/veDocument.d.ts +15 -0
- package/dist/shared/veDocument.js +31 -0
- package/dist/shared/veDocument.js.map +1 -0
- package/dist/stripMarkers.d.ts +1 -0
- package/dist/stripMarkers.js +19 -0
- package/dist/stripMarkers.js.map +1 -0
- package/package.json +8 -9
- package/dist/client/buildAdminEditUrl.js.map +0 -1
- package/dist/client/overlay/createOverlay.d.ts +0 -11
- package/dist/client/overlay/createOverlay.js +0 -80
- package/dist/client/overlay/createOverlay.js.map +0 -1
- package/dist/client/overlay/stegaBookkeeper.d.ts +0 -11
- package/dist/client/overlay/stegaBookkeeper.js +0 -36
- package/dist/client/overlay/stegaBookkeeper.js.map +0 -1
- package/dist/client/overlay/stegaScanner.d.ts +0 -11
- package/dist/client/overlay/stegaScanner.js +0 -54
- package/dist/client/overlay/stegaScanner.js.map +0 -1
- package/dist/constants.d.ts +0 -16
- package/dist/constants.js +0 -15
- package/dist/constants.js.map +0 -1
- package/dist/internal/afterOperationHook.d.ts +0 -12
- package/dist/internal/afterOperationHook.js +0 -28
- package/dist/internal/afterOperationHook.js.map +0 -1
- package/dist/internal/afterReadHook.d.ts +0 -3
- package/dist/internal/afterReadHook.js +0 -16
- package/dist/internal/afterReadHook.js.map +0 -1
- package/dist/internal/beforeOperationHook.d.ts +0 -4
- package/dist/internal/beforeOperationHook.js +0 -16
- package/dist/internal/beforeOperationHook.js.map +0 -1
- package/dist/internal/buildFieldSchema.d.ts +0 -3
- package/dist/internal/buildFieldSchema.js +0 -67
- package/dist/internal/buildFieldSchema.js.map +0 -1
- package/dist/internal/encodeStega.d.ts +0 -7
- package/dist/internal/encodeStega.js +0 -171
- package/dist/internal/encodeStega.js.map +0 -1
- package/dist/internal/enrichWithPathMeta.d.ts +0 -4
- package/dist/internal/enrichWithPathMeta.js +0 -76
- package/dist/internal/enrichWithPathMeta.js.map +0 -1
- package/dist/internal/filterEditableFields.d.ts +0 -2
- package/dist/internal/filterEditableFields.js +0 -88
- package/dist/internal/filterEditableFields.js.map +0 -1
- package/dist/internal/gate.d.ts +0 -3
- package/dist/internal/gate.js +0 -16
- package/dist/internal/gate.js.map +0 -1
- package/dist/internal/globalAfterReadHook.d.ts +0 -12
- package/dist/internal/globalAfterReadHook.js +0 -19
- package/dist/internal/globalAfterReadHook.js.map +0 -1
- package/dist/internal/markTerminalUploads.d.ts +0 -13
- package/dist/internal/markTerminalUploads.js +0 -79
- package/dist/internal/markTerminalUploads.js.map +0 -1
- package/dist/internal/schemaCache.d.ts +0 -10
- package/dist/internal/schemaCache.js +0 -29
- package/dist/internal/schemaCache.js.map +0 -1
- package/dist/internal/shared.js +0 -55
- package/dist/internal/shared.js.map +0 -1
- package/dist/internal/stripStegaHook.js.map +0 -1
- /package/dist/{internal → server/hooks}/stripStegaHook.d.ts +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAllFormFields, useDocumentInfo, useLocale } from "@payloadcms/ui";
|
|
3
|
+
import { useLayoutEffect, useMemo, useState } from "react";
|
|
4
|
+
import { createPreviewSession } from "./instantPreview/previewSession.js";
|
|
5
|
+
import { useEditableSchema } from "./instantPreview/useEditableSchema.js";
|
|
6
|
+
import { usePreviewPage } from "./instantPreview/usePreviewPage.js";
|
|
7
|
+
import { usePreviewWindow } from "./instantPreview/usePreviewWindow.js";
|
|
8
|
+
import { openDocumentOf } from "./openField/openDocument.js";
|
|
9
|
+
export function InstantPreviewBroadcaster({ excludeFieldNames }) {
|
|
10
|
+
const [formState] = useAllFormFields();
|
|
11
|
+
const { id, collectionSlug, globalSlug, data: savedDocument } = useDocumentInfo();
|
|
12
|
+
const editableSchema = useEditableSchema({
|
|
13
|
+
collectionSlug,
|
|
14
|
+
globalSlug
|
|
15
|
+
}, excludeFieldNames);
|
|
16
|
+
const { code: locale } = useLocale();
|
|
17
|
+
const preview = usePreviewWindow();
|
|
18
|
+
const { getWindow: getPreviewWindow, post: postToPreview } = preview;
|
|
19
|
+
const [session] = useState(createPreviewSession);
|
|
20
|
+
const admin = useMemo(()=>{
|
|
21
|
+
const document = openDocumentOf({
|
|
22
|
+
collectionSlug,
|
|
23
|
+
globalSlug,
|
|
24
|
+
id
|
|
25
|
+
});
|
|
26
|
+
if (!document) return null;
|
|
27
|
+
return {
|
|
28
|
+
document: {
|
|
29
|
+
...document,
|
|
30
|
+
locale
|
|
31
|
+
},
|
|
32
|
+
editableSchema,
|
|
33
|
+
formState,
|
|
34
|
+
savedDocument
|
|
35
|
+
};
|
|
36
|
+
}, [
|
|
37
|
+
collectionSlug,
|
|
38
|
+
editableSchema,
|
|
39
|
+
formState,
|
|
40
|
+
globalSlug,
|
|
41
|
+
id,
|
|
42
|
+
locale,
|
|
43
|
+
savedDocument
|
|
44
|
+
]);
|
|
45
|
+
usePreviewPage(preview, session);
|
|
46
|
+
useLayoutEffect(()=>{
|
|
47
|
+
session.localeChanged(locale);
|
|
48
|
+
}, [
|
|
49
|
+
locale,
|
|
50
|
+
session
|
|
51
|
+
]);
|
|
52
|
+
useLayoutEffect(()=>{
|
|
53
|
+
if (!getPreviewWindow()) session.pageLeft();
|
|
54
|
+
postToPreview(session.formChanged(admin));
|
|
55
|
+
}, [
|
|
56
|
+
admin,
|
|
57
|
+
getPreviewWindow,
|
|
58
|
+
postToPreview,
|
|
59
|
+
session
|
|
60
|
+
]);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=InstantPreviewBroadcaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/InstantPreviewBroadcaster.tsx"],"sourcesContent":["\"use client\";\n\nimport { useAllFormFields, useDocumentInfo, useLocale } from \"@payloadcms/ui\";\nimport { useLayoutEffect, useMemo, useState } from \"react\";\n\nimport type { AdminState } from \"./instantPreview/previewSession.js\";\n\nimport { createPreviewSession } from \"./instantPreview/previewSession.js\";\nimport { useEditableSchema } from \"./instantPreview/useEditableSchema.js\";\nimport { usePreviewPage } from \"./instantPreview/usePreviewPage.js\";\nimport { usePreviewWindow } from \"./instantPreview/usePreviewWindow.js\";\nimport { openDocumentOf } from \"./openField/openDocument.js\";\n\nexport function InstantPreviewBroadcaster({ excludeFieldNames }: { excludeFieldNames?: string[] }) {\n const [formState] = useAllFormFields();\n const { id, collectionSlug, globalSlug, data: savedDocument } = useDocumentInfo();\n const editableSchema = useEditableSchema({ collectionSlug, globalSlug }, excludeFieldNames);\n const { code: locale } = useLocale();\n const preview = usePreviewWindow();\n const { getWindow: getPreviewWindow, post: postToPreview } = preview;\n const [session] = useState(createPreviewSession);\n\n const admin = useMemo((): AdminState | null => {\n const document = openDocumentOf({ collectionSlug, globalSlug, id });\n if (!document) return null;\n return { document: { ...document, locale }, editableSchema, formState, savedDocument };\n }, [collectionSlug, editableSchema, formState, globalSlug, id, locale, savedDocument]);\n\n usePreviewPage(preview, session);\n\n useLayoutEffect(() => {\n session.localeChanged(locale);\n }, [locale, session]);\n\n useLayoutEffect(() => {\n if (!getPreviewWindow()) session.pageLeft();\n postToPreview(session.formChanged(admin));\n }, [admin, getPreviewWindow, postToPreview, session]);\n\n return null;\n}\n"],"names":["useAllFormFields","useDocumentInfo","useLocale","useLayoutEffect","useMemo","useState","createPreviewSession","useEditableSchema","usePreviewPage","usePreviewWindow","openDocumentOf","InstantPreviewBroadcaster","excludeFieldNames","formState","id","collectionSlug","globalSlug","data","savedDocument","editableSchema","code","locale","preview","getWindow","getPreviewWindow","post","postToPreview","session","admin","document","localeChanged","pageLeft","formChanged"],"mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,eAAe,EAAEC,SAAS,QAAQ,iBAAiB;AAC9E,SAASC,eAAe,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAI3D,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,cAAc,QAAQ,qCAAqC;AACpE,SAASC,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,cAAc,QAAQ,8BAA8B;AAE7D,OAAO,SAASC,0BAA0B,EAAEC,iBAAiB,EAAoC;IAC/F,MAAM,CAACC,UAAU,GAAGb;IACpB,MAAM,EAAEc,EAAE,EAAEC,cAAc,EAAEC,UAAU,EAAEC,MAAMC,aAAa,EAAE,GAAGjB;IAChE,MAAMkB,iBAAiBZ,kBAAkB;QAAEQ;QAAgBC;IAAW,GAAGJ;IACzE,MAAM,EAAEQ,MAAMC,MAAM,EAAE,GAAGnB;IACzB,MAAMoB,UAAUb;IAChB,MAAM,EAAEc,WAAWC,gBAAgB,EAAEC,MAAMC,aAAa,EAAE,GAAGJ;IAC7D,MAAM,CAACK,QAAQ,GAAGtB,SAASC;IAE3B,MAAMsB,QAAQxB,QAAQ;QACpB,MAAMyB,WAAWnB,eAAe;YAAEK;YAAgBC;YAAYF;QAAG;QACjE,IAAI,CAACe,UAAU,OAAO;QACtB,OAAO;YAAEA,UAAU;gBAAE,GAAGA,QAAQ;gBAAER;YAAO;YAAGF;YAAgBN;YAAWK;QAAc;IACvF,GAAG;QAACH;QAAgBI;QAAgBN;QAAWG;QAAYF;QAAIO;QAAQH;KAAc;IAErFV,eAAec,SAASK;IAExBxB,gBAAgB;QACdwB,QAAQG,aAAa,CAACT;IACxB,GAAG;QAACA;QAAQM;KAAQ;IAEpBxB,gBAAgB;QACd,IAAI,CAACqB,oBAAoBG,QAAQI,QAAQ;QACzCL,cAAcC,QAAQK,WAAW,CAACJ;IACpC,GAAG;QAACA;QAAOJ;QAAkBE;QAAeC;KAAQ;IAEpD,OAAO;AACT"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useConfig } from "@payloadcms/ui";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import {
|
|
4
|
+
import { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { defaultBuildAdminEditUrl } from "../shared/buildAdminEditUrl.js";
|
|
6
|
+
import { VE_FOCUS_PARAM, VE_MESSAGE_TYPE } from "../shared/protocol.js";
|
|
6
7
|
import { expandAndFocus } from "./expandAndFocus.js";
|
|
8
|
+
import { currentFormPathOf, OpenFormsContext } from "./openField/openForms.js";
|
|
7
9
|
import { parseFieldPath } from "./parseFieldPath.js";
|
|
8
10
|
import { resolveContainerChain } from "./resolveContainerChain.js";
|
|
9
|
-
const VE_FOCUS_PARAM = "veFocus";
|
|
10
11
|
const escapeRegex = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11
12
|
const isSameOrigin = (eventOrigin)=>{
|
|
12
13
|
if (typeof window === "undefined") return false;
|
|
@@ -31,17 +32,14 @@ const makeLocators = (adminBasePath)=>{
|
|
|
31
32
|
return match?.[1] ?? null;
|
|
32
33
|
};
|
|
33
34
|
const navigateAndFocus = (message)=>{
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// `noopener` here would force the return value to null, defeating the
|
|
43
|
-
// popup-block detection below. We're same-origin (admin -> admin), so
|
|
44
|
-
// the retained opener reference isn't a security concern.
|
|
35
|
+
const url = defaultBuildAdminEditUrl({
|
|
36
|
+
adminBasePath,
|
|
37
|
+
collectionSlug: message.collectionSlug,
|
|
38
|
+
docId: message.docId,
|
|
39
|
+
kind: message.kind,
|
|
40
|
+
locale: message.locale,
|
|
41
|
+
path: message.path
|
|
42
|
+
});
|
|
45
43
|
const opened = window.open(url, "_blank");
|
|
46
44
|
if (!opened) window.location.assign(url);
|
|
47
45
|
};
|
|
@@ -51,8 +49,6 @@ const makeLocators = (adminBasePath)=>{
|
|
|
51
49
|
navigateAndFocus
|
|
52
50
|
};
|
|
53
51
|
};
|
|
54
|
-
// If the schema walk fails (drift, malformed path), reconstruct a row-only
|
|
55
|
-
// chain from numeric segments in the path — matches the pre-resolver behavior.
|
|
56
52
|
const fallbackResolution = (path)=>{
|
|
57
53
|
const { rowIds, fieldId } = parseFieldPath(path);
|
|
58
54
|
return {
|
|
@@ -71,6 +67,15 @@ const focusFieldPath = async (path, kind, slug, getFields)=>{
|
|
|
71
67
|
};
|
|
72
68
|
export function VisualEditingBridgeProvider({ adminBasePath = "/admin", children }) {
|
|
73
69
|
const { getEntityConfig } = useConfig();
|
|
70
|
+
const [openForms] = useState(()=>new Set());
|
|
71
|
+
const announceOpenForm = useCallback((form)=>{
|
|
72
|
+
openForms.add(form);
|
|
73
|
+
return ()=>{
|
|
74
|
+
openForms.delete(form);
|
|
75
|
+
};
|
|
76
|
+
}, [
|
|
77
|
+
openForms
|
|
78
|
+
]);
|
|
74
79
|
useEffect(()=>{
|
|
75
80
|
const { currentCollectionLocation, currentGlobalSlug, navigateAndFocus } = makeLocators(adminBasePath);
|
|
76
81
|
const getFields = (kind, slug)=>{
|
|
@@ -85,8 +90,6 @@ export function VisualEditingBridgeProvider({ adminBasePath = "/admin", children
|
|
|
85
90
|
return null;
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
|
-
// URL-param activation: strip `veFocus` from URL, then defer to give the
|
|
89
|
-
// admin form time to paint.
|
|
90
93
|
const url = new URL(window.location.href);
|
|
91
94
|
const focusPath = url.searchParams.get(VE_FOCUS_PARAM);
|
|
92
95
|
if (focusPath) {
|
|
@@ -106,10 +109,6 @@ export function VisualEditingBridgeProvider({ adminBasePath = "/admin", children
|
|
|
106
109
|
if (!isSameOrigin(event.origin)) return;
|
|
107
110
|
const data = event.data;
|
|
108
111
|
if (!data || data.type !== VE_MESSAGE_TYPE) return;
|
|
109
|
-
// Collection mismatch: navigate to the correct (collection, doc) pair —
|
|
110
|
-
// compare BOTH slug and id. Two collections can share an id (pages/1 vs
|
|
111
|
-
// forms/1), so matching on id alone would leave the user on the wrong
|
|
112
|
-
// edit view and every field lookup would fail.
|
|
113
112
|
if (data.kind === "collection") {
|
|
114
113
|
const current = currentCollectionLocation();
|
|
115
114
|
const wrongCollection = current?.slug !== data.collectionSlug;
|
|
@@ -118,7 +117,7 @@ export function VisualEditingBridgeProvider({ adminBasePath = "/admin", children
|
|
|
118
117
|
navigateAndFocus(data);
|
|
119
118
|
return;
|
|
120
119
|
}
|
|
121
|
-
void focusFieldPath(data
|
|
120
|
+
void focusFieldPath(currentFormPathOf(data, openForms), "collection", data.collectionSlug, getFields);
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
123
|
if (data.kind === "global") {
|
|
@@ -127,16 +126,18 @@ export function VisualEditingBridgeProvider({ adminBasePath = "/admin", children
|
|
|
127
126
|
navigateAndFocus(data);
|
|
128
127
|
return;
|
|
129
128
|
}
|
|
130
|
-
void focusFieldPath(data
|
|
129
|
+
void focusFieldPath(currentFormPathOf(data, openForms), "global", data.collectionSlug, getFields);
|
|
131
130
|
}
|
|
132
131
|
};
|
|
133
132
|
window.addEventListener("message", handle);
|
|
134
133
|
return ()=>window.removeEventListener("message", handle);
|
|
135
134
|
}, [
|
|
136
135
|
getEntityConfig,
|
|
137
|
-
adminBasePath
|
|
136
|
+
adminBasePath,
|
|
137
|
+
openForms
|
|
138
138
|
]);
|
|
139
|
-
return /*#__PURE__*/ _jsx(
|
|
139
|
+
return /*#__PURE__*/ _jsx(OpenFormsContext.Provider, {
|
|
140
|
+
value: announceOpenForm,
|
|
140
141
|
children: children
|
|
141
142
|
});
|
|
142
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/VisualEditingBridgeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useConfig } from \"@payloadcms/ui\";\nimport { useEffect } from \"react\";\n\nimport { VE_MESSAGE_TYPE } from \"../constants.js\";\nimport type { VeOpenFieldMessage } from \"../constants.js\";\nimport { expandAndFocus } from \"./expandAndFocus.js\";\nimport { parseFieldPath } from \"./parseFieldPath.js\";\nimport { resolveContainerChain } from \"./resolveContainerChain.js\";\nimport type { ContainerInstruction, ResolverField } from \"./resolveContainerChain.js\";\n\nconst VE_FOCUS_PARAM = \"veFocus\";\n\nconst escapeRegex = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nconst isSameOrigin = (eventOrigin: string): boolean => {\n if (typeof window === \"undefined\") return false;\n return eventOrigin === window.location.origin;\n};\n\nconst makeLocators = (adminBasePath: string) => {\n const base = escapeRegex(adminBasePath);\n const collectionRe = new RegExp(`^${base}/collections/([^/]+)/([^/?#]+)`);\n const globalRe = new RegExp(`^${base}/globals/([^/?#]+)`);\n\n const currentCollectionLocation = (): { slug: string; id: string } | null => {\n const match = window.location.pathname.match(collectionRe);\n if (!match) return null;\n const [, slug, id] = match;\n if (!slug || !id) return null;\n return { slug, id };\n };\n\n const currentGlobalSlug = (): string | null => {\n const match = window.location.pathname.match(globalRe);\n return match?.[1] ?? null;\n };\n\n const navigateAndFocus = (message: VeOpenFieldMessage): void => {\n const target =\n message.kind === \"global\"\n ? `${adminBasePath}/globals/${message.collectionSlug}`\n : `${adminBasePath}/collections/${message.collectionSlug}/${message.docId}`;\n const params = new URLSearchParams();\n if (message.path) params.set(VE_FOCUS_PARAM, message.path);\n if (message.locale) params.set(\"locale\", message.locale);\n const qs = params.toString();\n const url = qs ? `${target}?${qs}` : target;\n // Different doc => new tab so the current admin context is preserved.\n // Same-doc field focus goes through `focusFieldPath`, not this helper.\n // `noopener` here would force the return value to null, defeating the\n // popup-block detection below. We're same-origin (admin -> admin), so\n // the retained opener reference isn't a security concern.\n const opened = window.open(url, \"_blank\");\n if (!opened) window.location.assign(url);\n };\n\n return { currentCollectionLocation, currentGlobalSlug, navigateAndFocus };\n};\n\n// If the schema walk fails (drift, malformed path), reconstruct a row-only\n// chain from numeric segments in the path — matches the pre-resolver behavior.\nconst fallbackResolution = (\n path: string\n): { chain: ContainerInstruction[]; fieldId: string | null } => {\n const { rowIds, fieldId } = parseFieldPath(path);\n return {\n chain: rowIds.map((rowContainerId) => ({ kind: \"row\", rowContainerId }) as const),\n fieldId,\n };\n};\n\ntype EntityFieldsLookup = (kind: \"collection\" | \"global\", slug: string) => ResolverField[] | null;\n\nconst focusFieldPath = async (\n path: string,\n kind: \"collection\" | \"global\",\n slug: string,\n getFields: EntityFieldsLookup\n): Promise<void> => {\n const fields = getFields(kind, slug);\n const chainResult = fields !== null ? resolveContainerChain(path, fields) : null;\n const resolved = chainResult ?? fallbackResolution(path);\n await expandAndFocus(resolved.chain, resolved.fieldId);\n};\n\nexport function VisualEditingBridgeProvider({\n adminBasePath = \"/admin\",\n children,\n}: {\n adminBasePath?: string;\n children: React.ReactNode;\n}) {\n const { getEntityConfig } = useConfig();\n\n useEffect(() => {\n const { currentCollectionLocation, currentGlobalSlug, navigateAndFocus } =\n makeLocators(adminBasePath);\n\n const getFields: EntityFieldsLookup = (kind, slug) => {\n try {\n const entity =\n kind === \"collection\"\n ? getEntityConfig({ collectionSlug: slug })\n : getEntityConfig({ globalSlug: slug });\n return (entity?.fields ?? null) as ResolverField[] | null;\n } catch {\n return null;\n }\n };\n\n // URL-param activation: strip `veFocus` from URL, then defer to give the\n // admin form time to paint.\n const url = new URL(window.location.href);\n const focusPath = url.searchParams.get(VE_FOCUS_PARAM);\n if (focusPath) {\n url.searchParams.delete(VE_FOCUS_PARAM);\n window.history.replaceState(null, \"\", url.toString());\n const collection = currentCollectionLocation();\n const globalSlug = currentGlobalSlug();\n setTimeout(() => {\n if (collection) {\n void focusFieldPath(focusPath, \"collection\", collection.slug, getFields);\n } else if (globalSlug) {\n void focusFieldPath(focusPath, \"global\", globalSlug, getFields);\n }\n }, 500);\n }\n\n const handle = (event: MessageEvent) => {\n if (!isSameOrigin(event.origin)) return;\n const data = event.data as VeOpenFieldMessage | undefined;\n if (!data || data.type !== VE_MESSAGE_TYPE) return;\n\n // Collection mismatch: navigate to the correct (collection, doc) pair —\n // compare BOTH slug and id. Two collections can share an id (pages/1 vs\n // forms/1), so matching on id alone would leave the user on the wrong\n // edit view and every field lookup would fail.\n if (data.kind === \"collection\") {\n const current = currentCollectionLocation();\n const wrongCollection = current?.slug !== data.collectionSlug;\n const wrongDoc = data.docId !== undefined && current?.id !== data.docId;\n if (!current || wrongCollection || wrongDoc) {\n navigateAndFocus(data);\n return;\n }\n void focusFieldPath(data.path, \"collection\", data.collectionSlug, getFields);\n return;\n }\n\n if (data.kind === \"global\") {\n const slug = currentGlobalSlug();\n if (slug !== data.collectionSlug) {\n navigateAndFocus(data);\n return;\n }\n void focusFieldPath(data.path, \"global\", data.collectionSlug, getFields);\n }\n };\n\n window.addEventListener(\"message\", handle);\n return () => window.removeEventListener(\"message\", handle);\n }, [getEntityConfig, adminBasePath]);\n\n return <>{children}</>;\n}\n"],"names":["useConfig","useEffect","VE_MESSAGE_TYPE","expandAndFocus","parseFieldPath","resolveContainerChain","VE_FOCUS_PARAM","escapeRegex","value","replace","isSameOrigin","eventOrigin","window","location","origin","makeLocators","adminBasePath","base","collectionRe","RegExp","globalRe","currentCollectionLocation","match","pathname","slug","id","currentGlobalSlug","navigateAndFocus","message","target","kind","collectionSlug","docId","params","URLSearchParams","path","set","locale","qs","toString","url","opened","open","assign","fallbackResolution","rowIds","fieldId","chain","map","rowContainerId","focusFieldPath","getFields","fields","chainResult","resolved","VisualEditingBridgeProvider","children","getEntityConfig","entity","globalSlug","URL","href","focusPath","searchParams","get","delete","history","replaceState","collection","setTimeout","handle","event","data","type","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,UAAU;oBAC3CjD,iBAAiB6C;oBACjB;gBACF;gBACA,KAAKtB,eAAesB,KAAKrC,IAAI,EAAE,cAAcqC,KAAKzC,cAAc,EAAEoB;gBAClE;YACF;YAEA,IAAIqB,KAAK1C,IAAI,KAAK,UAAU;gBAC1B,MAAMN,OAAOE;gBACb,IAAIF,SAASgD,KAAKzC,cAAc,EAAE;oBAChCJ,iBAAiB6C;oBACjB;gBACF;gBACA,KAAKtB,eAAesB,KAAKrC,IAAI,EAAE,UAAUqC,KAAKzC,cAAc,EAAEoB;YAChE;QACF;QAEAvC,OAAOkE,gBAAgB,CAAC,WAAWR;QACnC,OAAO,IAAM1D,OAAOmE,mBAAmB,CAAC,WAAWT;IACrD,GAAG;QAACb;QAAiBzC;KAAc;IAEnC,qBAAO;kBAAGwC;;AACZ"}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/VisualEditingBridgeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useConfig } from \"@payloadcms/ui\";\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { defaultBuildAdminEditUrl } from \"../shared/buildAdminEditUrl.js\";\nimport { VE_FOCUS_PARAM, VE_MESSAGE_TYPE } from \"../shared/protocol.js\";\nimport type { DocKind } from \"../shared/protocol.js\";\nimport type { VeOpenFieldMessage } from \"../shared/protocol.js\";\nimport { expandAndFocus } from \"./expandAndFocus.js\";\nimport { currentFormPathOf, OpenFormsContext } from \"./openField/openForms.js\";\nimport type { AnnounceOpenForm, OpenForm } from \"./openField/openForms.js\";\nimport { parseFieldPath } from \"./parseFieldPath.js\";\nimport { resolveContainerChain } from \"./resolveContainerChain.js\";\nimport type { ContainerInstruction, ResolverField } from \"./resolveContainerChain.js\";\n\nconst escapeRegex = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nconst isSameOrigin = (eventOrigin: string): boolean => {\n if (typeof window === \"undefined\") return false;\n return eventOrigin === window.location.origin;\n};\n\nconst makeLocators = (adminBasePath: string) => {\n const base = escapeRegex(adminBasePath);\n const collectionRe = new RegExp(`^${base}/collections/([^/]+)/([^/?#]+)`);\n const globalRe = new RegExp(`^${base}/globals/([^/?#]+)`);\n\n const currentCollectionLocation = (): { slug: string; id: string } | null => {\n const match = window.location.pathname.match(collectionRe);\n if (!match) return null;\n const [, slug, id] = match;\n if (!slug || !id) return null;\n return { slug, id };\n };\n\n const currentGlobalSlug = (): string | null => {\n const match = window.location.pathname.match(globalRe);\n return match?.[1] ?? null;\n };\n\n const navigateAndFocus = (message: VeOpenFieldMessage): void => {\n const url = defaultBuildAdminEditUrl({\n adminBasePath,\n collectionSlug: message.collectionSlug,\n docId: message.docId,\n kind: message.kind,\n locale: message.locale,\n path: message.path,\n });\n const opened = window.open(url, \"_blank\");\n if (!opened) window.location.assign(url);\n };\n\n return { currentCollectionLocation, currentGlobalSlug, navigateAndFocus };\n};\n\nconst fallbackResolution = (\n path: string\n): { chain: ContainerInstruction[]; fieldId: string | null } => {\n const { rowIds, fieldId } = parseFieldPath(path);\n return {\n chain: rowIds.map((rowContainerId) => ({ kind: \"row\", rowContainerId }) as const),\n fieldId,\n };\n};\n\ntype EntityFieldsLookup = (kind: DocKind, slug: string) => ResolverField[] | null;\n\nconst focusFieldPath = async (\n path: string,\n kind: DocKind,\n slug: string,\n getFields: EntityFieldsLookup\n): Promise<void> => {\n const fields = getFields(kind, slug);\n const chainResult = fields !== null ? resolveContainerChain(path, fields) : null;\n const resolved = chainResult ?? fallbackResolution(path);\n await expandAndFocus(resolved.chain, resolved.fieldId);\n};\n\nexport function VisualEditingBridgeProvider({\n adminBasePath = \"/admin\",\n children,\n}: {\n adminBasePath?: string;\n children: React.ReactNode;\n}) {\n const { getEntityConfig } = useConfig();\n const [openForms] = useState(() => new Set<OpenForm>());\n\n const announceOpenForm = useCallback<AnnounceOpenForm>(\n (form) => {\n openForms.add(form);\n return () => {\n openForms.delete(form);\n };\n },\n [openForms]\n );\n\n useEffect(() => {\n const { currentCollectionLocation, currentGlobalSlug, navigateAndFocus } =\n makeLocators(adminBasePath);\n\n const getFields: EntityFieldsLookup = (kind, slug) => {\n try {\n const entity =\n kind === \"collection\"\n ? getEntityConfig({ collectionSlug: slug })\n : getEntityConfig({ globalSlug: slug });\n return (entity?.fields ?? null) as ResolverField[] | null;\n } catch {\n return null;\n }\n };\n\n const url = new URL(window.location.href);\n const focusPath = url.searchParams.get(VE_FOCUS_PARAM);\n if (focusPath) {\n url.searchParams.delete(VE_FOCUS_PARAM);\n window.history.replaceState(null, \"\", url.toString());\n const collection = currentCollectionLocation();\n const globalSlug = currentGlobalSlug();\n setTimeout(() => {\n if (collection) {\n void focusFieldPath(focusPath, \"collection\", collection.slug, getFields);\n } else if (globalSlug) {\n void focusFieldPath(focusPath, \"global\", globalSlug, getFields);\n }\n }, 500);\n }\n\n const handle = (event: MessageEvent) => {\n if (!isSameOrigin(event.origin)) return;\n const data = event.data as VeOpenFieldMessage | undefined;\n if (!data || data.type !== VE_MESSAGE_TYPE) return;\n\n if (data.kind === \"collection\") {\n const current = currentCollectionLocation();\n const wrongCollection = current?.slug !== data.collectionSlug;\n const wrongDoc = data.docId !== undefined && current?.id !== data.docId;\n if (!current || wrongCollection || wrongDoc) {\n navigateAndFocus(data);\n return;\n }\n void focusFieldPath(\n currentFormPathOf(data, openForms),\n \"collection\",\n data.collectionSlug,\n getFields\n );\n return;\n }\n\n if (data.kind === \"global\") {\n const slug = currentGlobalSlug();\n if (slug !== data.collectionSlug) {\n navigateAndFocus(data);\n return;\n }\n void focusFieldPath(\n currentFormPathOf(data, openForms),\n \"global\",\n data.collectionSlug,\n getFields\n );\n }\n };\n\n window.addEventListener(\"message\", handle);\n return () => window.removeEventListener(\"message\", handle);\n }, [getEntityConfig, adminBasePath, openForms]);\n\n return <OpenFormsContext.Provider value={announceOpenForm}>{children}</OpenFormsContext.Provider>;\n}\n"],"names":["useConfig","useCallback","useEffect","useState","defaultBuildAdminEditUrl","VE_FOCUS_PARAM","VE_MESSAGE_TYPE","expandAndFocus","currentFormPathOf","OpenFormsContext","parseFieldPath","resolveContainerChain","escapeRegex","value","replace","isSameOrigin","eventOrigin","window","location","origin","makeLocators","adminBasePath","base","collectionRe","RegExp","globalRe","currentCollectionLocation","match","pathname","slug","id","currentGlobalSlug","navigateAndFocus","message","url","collectionSlug","docId","kind","locale","path","opened","open","assign","fallbackResolution","rowIds","fieldId","chain","map","rowContainerId","focusFieldPath","getFields","fields","chainResult","resolved","VisualEditingBridgeProvider","children","getEntityConfig","openForms","Set","announceOpenForm","form","add","delete","entity","globalSlug","URL","href","focusPath","searchParams","get","history","replaceState","toString","collection","setTimeout","handle","event","data","type","current","wrongCollection","wrongDoc","undefined","addEventListener","removeEventListener","Provider"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEzD,SAASC,wBAAwB,QAAQ,iCAAiC;AAC1E,SAASC,cAAc,EAAEC,eAAe,QAAQ,wBAAwB;AAGxE,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,2BAA2B;AAE/E,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,qBAAqB,QAAQ,6BAA6B;AAGnE,MAAMC,cAAc,CAACC,QAA0BA,MAAMC,OAAO,CAAC,uBAAuB;AAEpF,MAAMC,eAAe,CAACC;IACpB,IAAI,OAAOC,WAAW,aAAa,OAAO;IAC1C,OAAOD,gBAAgBC,OAAOC,QAAQ,CAACC,MAAM;AAC/C;AAEA,MAAMC,eAAe,CAACC;IACpB,MAAMC,OAAOV,YAAYS;IACzB,MAAME,eAAe,IAAIC,OAAO,CAAC,CAAC,EAAEF,KAAK,8BAA8B,CAAC;IACxE,MAAMG,WAAW,IAAID,OAAO,CAAC,CAAC,EAAEF,KAAK,kBAAkB,CAAC;IAExD,MAAMI,4BAA4B;QAChC,MAAMC,QAAQV,OAAOC,QAAQ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0C,UAAUrD;gBAChB,MAAMsD,kBAAkBD,SAASlD,SAASgD,KAAK1C,cAAc;gBAC7D,MAAM8C,WAAWJ,KAAKzC,KAAK,KAAK8C,aAAaH,SAASjD,OAAO+C,KAAKzC,KAAK;gBACvE,IAAI,CAAC2C,WAAWC,mBAAmBC,UAAU;oBAC3CjD,iBAAiB6C;oBACjB;gBACF;gBACA,KAAK5B,eACHzC,kBAAkBqE,MAAMpB,YACxB,cACAoB,KAAK1C,cAAc,EACnBe;gBAEF;YACF;YAEA,IAAI2B,KAAKxC,IAAI,KAAK,UAAU;gBAC1B,MAAMR,OAAOE;gBACb,IAAIF,SAASgD,KAAK1C,cAAc,EAAE;oBAChCH,iBAAiB6C;oBACjB;gBACF;gBACA,KAAK5B,eACHzC,kBAAkBqE,MAAMpB,YACxB,UACAoB,KAAK1C,cAAc,EACnBe;YAEJ;QACF;QAEAjC,OAAOkE,gBAAgB,CAAC,WAAWR;QACnC,OAAO,IAAM1D,OAAOmE,mBAAmB,CAAC,WAAWT;IACrD,GAAG;QAACnB;QAAiBnC;QAAeoC;KAAU;IAE9C,qBAAO,KAAChD,iBAAiB4E,QAAQ;QAACxE,OAAO8C;kBAAmBJ;;AAC9D"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ContainerInstruction } from "./resolveContainerChain.js";
|
|
2
|
-
export declare const playSweep: (el: HTMLElement) => void;
|
|
3
2
|
export declare const findFieldElement: (fieldId: string) => HTMLElement | null;
|
|
4
3
|
export declare const scrollNearestAncestorIntoView: (fieldId: string) => void;
|
|
5
4
|
export declare const applyContainerChain: (chain: readonly ContainerInstruction[]) => Promise<boolean>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { arrayFieldIdOfRow, FIELD_ID_PREFIX, FIELD_ID_SEPARATOR, fieldDomIdOf } from "./fieldDomId.js";
|
|
1
2
|
const FOCUS_SELECTOR = '[data-lexical-editor="true"], input:not([type="hidden"]), textarea';
|
|
3
|
+
const FIELD_WRAPPER_SELECTOR = ".field-type";
|
|
4
|
+
const BLOCK_NAME_INPUT_SELECTOR = ".section-title__input";
|
|
5
|
+
const FOCUSED_FIELD_FRAME_SELECTOR = ".section-title, .field-type";
|
|
2
6
|
const SWEEP_STYLE_ID = "ve-sweep-styles";
|
|
3
7
|
const POLL_INTERVAL_MS = 60;
|
|
4
8
|
const STEP_BUDGET_MS = 1500;
|
|
5
9
|
const POST_SCROLL_DELAY_MS = 500;
|
|
6
10
|
const REVEAL_TOTAL_MS = 1800;
|
|
7
|
-
// Focus-reveal accent. HSL so alpha variants share a stable hue/sat/lightness
|
|
8
|
-
// — swap the three numbers to re-theme the whole reveal (ring, corners, sweep,
|
|
9
|
-
// reduced-motion fallback) in one place.
|
|
10
|
-
// Current: electric cyan (≈ #22d3ee).
|
|
11
11
|
const FOCUS_HSL = {
|
|
12
12
|
h: 189,
|
|
13
13
|
s: 85,
|
|
@@ -19,10 +19,6 @@ const ensureSweepStyles = ()=>{
|
|
|
19
19
|
if (document.getElementById(SWEEP_STYLE_ID)) return;
|
|
20
20
|
const style = document.createElement("style");
|
|
21
21
|
style.id = SWEEP_STYLE_ID;
|
|
22
|
-
// Viewport-fixed ornament anchored to the field's bounding rect via RAF. Not
|
|
23
|
-
// injected into the field's subtree: adding `position: relative; overflow: hidden`
|
|
24
|
-
// to arbitrary Payload field wrappers breaks Lexical's sticky toolbar positioning.
|
|
25
|
-
// Layers: corner brackets (reticle), ring (pulsing border + glow halo), sweep (gradient pass).
|
|
26
22
|
style.textContent = `
|
|
27
23
|
@keyframes ve-focus-corner-in {
|
|
28
24
|
0% { transform: scale(1.35); opacity: 0; }
|
|
@@ -97,7 +93,7 @@ const ensureSweepStyles = ()=>{
|
|
|
97
93
|
document.head.append(style);
|
|
98
94
|
};
|
|
99
95
|
const SWEEP_DECORATION_PAD = 24;
|
|
100
|
-
|
|
96
|
+
const playSweep = (el)=>{
|
|
101
97
|
ensureSweepStyles();
|
|
102
98
|
const wrap = document.createElement("div");
|
|
103
99
|
wrap.className = "ve-sweep-wrap";
|
|
@@ -121,9 +117,6 @@ export const playSweep = (el)=>{
|
|
|
121
117
|
clip.append(overlay);
|
|
122
118
|
wrap.append(ring, ...corners, clip);
|
|
123
119
|
document.body.append(wrap);
|
|
124
|
-
// Track the field's current rect for the full reveal. If the browser's smooth-scroll
|
|
125
|
-
// is still running when the reveal starts, or the layout shifts mid-animation, the
|
|
126
|
-
// wrap stays anchored to the field instead of drifting off.
|
|
127
120
|
let rafId = 0;
|
|
128
121
|
const pad = SWEEP_DECORATION_PAD;
|
|
129
122
|
const track = ()=>{
|
|
@@ -143,29 +136,25 @@ export const playSweep = (el)=>{
|
|
|
143
136
|
wrap.remove();
|
|
144
137
|
}, REVEAL_TOTAL_MS);
|
|
145
138
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
const blockNameInputOf = (fieldId)=>{
|
|
140
|
+
const inputs = document.querySelectorAll(BLOCK_NAME_INPUT_SELECTOR);
|
|
141
|
+
return Array.from(inputs).find((input)=>fieldDomIdOf(input.name) === fieldId) ?? null;
|
|
142
|
+
};
|
|
143
|
+
const labelOf = (fieldId)=>Array.from(document.querySelectorAll("label")).find((label)=>label.htmlFor === fieldId) ?? null;
|
|
149
144
|
export const findFieldElement = (fieldId)=>{
|
|
150
145
|
// oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors
|
|
151
146
|
const direct = document.getElementById(fieldId);
|
|
152
147
|
if (direct) return direct;
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
return wrapper ?? null;
|
|
148
|
+
const wrapper = labelOf(fieldId)?.closest(FIELD_WRAPPER_SELECTOR);
|
|
149
|
+
return wrapper ?? blockNameInputOf(fieldId);
|
|
156
150
|
};
|
|
157
|
-
// Payload lazily renders groups that are below the viewport — their inner fields
|
|
158
|
-
// (including the `*-row-<n>` containers the `row` instruction waits on) don't
|
|
159
|
-
// exist in the DOM until the group is scrolled near. Before waiting, walk up
|
|
160
|
-
// the path and scroll the deepest already-mounted ancestor into view so the
|
|
161
|
-
// virtualized subtree hydrates. Safe to call repeatedly; does nothing when the
|
|
162
|
-
// full field id is already present.
|
|
163
151
|
export const scrollNearestAncestorIntoView = (fieldId)=>{
|
|
164
|
-
if (!fieldId.startsWith(
|
|
165
|
-
const segments = fieldId.slice(
|
|
152
|
+
if (!fieldId.startsWith(FIELD_ID_PREFIX)) return;
|
|
153
|
+
const segments = fieldId.slice(FIELD_ID_PREFIX.length).split(FIELD_ID_SEPARATOR);
|
|
166
154
|
for(let i = segments.length; i > 0; i--){
|
|
155
|
+
const ancestorId = `${FIELD_ID_PREFIX}${segments.slice(0, i).join(FIELD_ID_SEPARATOR)}`;
|
|
167
156
|
// oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors
|
|
168
|
-
const el = document.getElementById(
|
|
157
|
+
const el = document.getElementById(ancestorId);
|
|
169
158
|
if (el && typeof el.scrollIntoView === "function") {
|
|
170
159
|
el.scrollIntoView({
|
|
171
160
|
behavior: "auto",
|
|
@@ -186,15 +175,7 @@ const waitFor = (predicate, budgetMs)=>{
|
|
|
186
175
|
tick();
|
|
187
176
|
});
|
|
188
177
|
};
|
|
189
|
-
|
|
190
|
-
// @payloadcms/ui/dist/fields/Collapsible/index.js:52.
|
|
191
|
-
const collapsibleDomId = (path)=>`field-collapsible-${path.replace(/\./g, "__")}`;
|
|
192
|
-
// Tab buttons can exist at multiple nesting levels (top-level tabs, plus any
|
|
193
|
-
// nested tabs fields inside blocks). A raw `querySelectorAll` at document scope
|
|
194
|
-
// would match all of them, and `buttons[instruction.tabIndex]` would pick the
|
|
195
|
-
// wrong one for any chain step past the top level. The executor narrows the
|
|
196
|
-
// search scope as it descends — each row instruction sets the next scope to
|
|
197
|
-
// the row's container so subsequent tab/collapsible lookups stay inside it.
|
|
178
|
+
const collapsibleDomId = (path)=>fieldDomIdOf(`collapsible-${path}`);
|
|
198
179
|
const runInstruction = async (instruction, scope)=>{
|
|
199
180
|
switch(instruction.kind){
|
|
200
181
|
case "tab":
|
|
@@ -218,7 +199,6 @@ const runInstruction = async (instruction, scope)=>{
|
|
|
218
199
|
}
|
|
219
200
|
case "collapsible":
|
|
220
201
|
{
|
|
221
|
-
// Collapsible ids are globally unique in the DOM — resolve at document scope.
|
|
222
202
|
const id = collapsibleDomId(instruction.path);
|
|
223
203
|
// oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors
|
|
224
204
|
const ready = await waitFor(()=>document.getElementById(id) !== null, STEP_BUDGET_MS);
|
|
@@ -248,11 +228,7 @@ const runInstruction = async (instruction, scope)=>{
|
|
|
248
228
|
}
|
|
249
229
|
case "row":
|
|
250
230
|
{
|
|
251
|
-
|
|
252
|
-
// parent array's field id and scroll it into view to force Payload to
|
|
253
|
-
// hydrate the virtualized rows before we wait for the row container.
|
|
254
|
-
const parentArrayFieldId = `field-${instruction.rowContainerId.replace(/-row-\d+$/, "").replace(/-/g, "__")}`;
|
|
255
|
-
scrollNearestAncestorIntoView(parentArrayFieldId);
|
|
231
|
+
scrollNearestAncestorIntoView(arrayFieldIdOfRow(instruction.rowContainerId));
|
|
256
232
|
const ready = await waitFor(// oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors
|
|
257
233
|
()=>document.getElementById(instruction.rowContainerId) !== null, STEP_BUDGET_MS);
|
|
258
234
|
if (!ready) return {
|
|
@@ -290,14 +266,6 @@ export const applyContainerChain = async (chain)=>{
|
|
|
290
266
|
}
|
|
291
267
|
return true;
|
|
292
268
|
};
|
|
293
|
-
// `scrollIntoView({block: 'center'})` beats a precomputed `scrollBy` delta here:
|
|
294
|
-
// the browser tracks the element's live rect across the smooth-scroll animation,
|
|
295
|
-
// so virtualized fields hydrating mid-scroll (RenderIfInViewport firing as we
|
|
296
|
-
// pass its rootMargin) can't leave us off-target. `.focus({preventScroll: true})`
|
|
297
|
-
// suppresses the browser's default "scroll focusable into nearest view" that
|
|
298
|
-
// would otherwise race our centering call. After POST_SCROLL_DELAY_MS the
|
|
299
|
-
// initial scroll should be settled — if additional virtualization shifted the
|
|
300
|
-
// field out of view we re-center once more.
|
|
301
269
|
const focusAndSweep = (fieldEl)=>{
|
|
302
270
|
if (typeof fieldEl.scrollIntoView === "function") {
|
|
303
271
|
fieldEl.scrollIntoView({
|
|
@@ -311,7 +279,7 @@ const focusAndSweep = (fieldEl)=>{
|
|
|
311
279
|
fieldEl.focus({
|
|
312
280
|
preventScroll: true
|
|
313
281
|
});
|
|
314
|
-
const wrapper = fieldEl.closest(
|
|
282
|
+
const wrapper = fieldEl.closest(FOCUSED_FIELD_FRAME_SELECTOR);
|
|
315
283
|
if (wrapper) sweepTarget = wrapper;
|
|
316
284
|
} else {
|
|
317
285
|
const focusable = fieldEl.querySelector(FOCUS_SELECTOR);
|
|
@@ -322,10 +290,6 @@ const focusAndSweep = (fieldEl)=>{
|
|
|
322
290
|
if (typeof fieldEl.scrollIntoView === "function") {
|
|
323
291
|
const rect = fieldEl.getBoundingClientRect();
|
|
324
292
|
const viewportHeight = window.innerHeight;
|
|
325
|
-
// Re-center only when the field is outside the viewport — don't
|
|
326
|
-
// re-scroll a centered field whose intrinsic height exceeds the
|
|
327
|
-
// viewport (rect.top < 0 AND rect.bottom > viewportHeight is the
|
|
328
|
-
// correctly-centered state for tall fields).
|
|
329
293
|
const outOfView = rect.bottom <= 0 || rect.top >= viewportHeight;
|
|
330
294
|
if (outOfView) {
|
|
331
295
|
fieldEl.scrollIntoView({
|
|
@@ -337,15 +301,9 @@ const focusAndSweep = (fieldEl)=>{
|
|
|
337
301
|
playSweep(sweepTarget);
|
|
338
302
|
}, POST_SCROLL_DELAY_MS);
|
|
339
303
|
};
|
|
340
|
-
// Soft-fails on each step: if a chain step times out we still attempt the
|
|
341
|
-
// scroll/focus so the user lands near the target (chain partially works,
|
|
342
|
-
// field visible via ancestor scroll).
|
|
343
304
|
export const expandAndFocus = async (chain, fieldId)=>{
|
|
344
305
|
await applyContainerChain(chain);
|
|
345
306
|
if (!fieldId) return;
|
|
346
|
-
// After the chain opens the tab/collapsible, the target may still live inside
|
|
347
|
-
// a virtualized group — kick off a scroll to the nearest existing ancestor
|
|
348
|
-
// before polling so Payload hydrates the subtree.
|
|
349
307
|
scrollNearestAncestorIntoView(fieldId);
|
|
350
308
|
const ready = await waitFor(()=>findFieldElement(fieldId) !== null, STEP_BUDGET_MS);
|
|
351
309
|
if (!ready) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/expandAndFocus.ts"],"sourcesContent":["import type { ContainerInstruction } from \"./resolveContainerChain.js\";\n\nconst FOCUS_SELECTOR = '[data-lexical-editor=\"true\"], input:not([type=\"hidden\"]), textarea';\n\nconst SWEEP_STYLE_ID = \"ve-sweep-styles\";\nconst POLL_INTERVAL_MS = 60;\nconst STEP_BUDGET_MS = 1500;\nconst POST_SCROLL_DELAY_MS = 500;\n\nconst REVEAL_TOTAL_MS = 1800;\n\n// Focus-reveal accent. HSL so alpha variants share a stable hue/sat/lightness\n// — swap the three numbers to re-theme the whole reveal (ring, corners, sweep,\n// reduced-motion fallback) in one place.\n// Current: electric cyan (≈ #22d3ee).\nconst FOCUS_HSL = { h: 189, s: 85, l: 53 } as const;\nconst focusColor = (alpha: number): string =>\n `hsla(${FOCUS_HSL.h}, ${FOCUS_HSL.s}%, ${FOCUS_HSL.l}%, ${alpha})`;\n\nconst ensureSweepStyles = (): void => {\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n if (document.getElementById(SWEEP_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = SWEEP_STYLE_ID;\n // Viewport-fixed ornament anchored to the field's bounding rect via RAF. Not\n // injected into the field's subtree: adding `position: relative; overflow: hidden`\n // to arbitrary Payload field wrappers breaks Lexical's sticky toolbar positioning.\n // Layers: corner brackets (reticle), ring (pulsing border + glow halo), sweep (gradient pass).\n style.textContent = `\n\t\t@keyframes ve-focus-corner-in {\n\t\t\t0% { transform: scale(1.35); opacity: 0; }\n\t\t\t60% { opacity: 1; }\n\t\t\t100% { transform: scale(1); opacity: 1; }\n\t\t}\n\t\t@keyframes ve-focus-ring-pulse {\n\t\t\t0% { box-shadow: 0 0 0 0 ${focusColor(0.55)}, 0 0 0 0 ${focusColor(0.22)}; border-color: ${focusColor(0.95)}; }\n\t\t\t50% { box-shadow: 0 0 0 4px ${focusColor(0.3)}, 0 0 0 14px ${focusColor(0.06)}; border-color: ${focusColor(0.95)}; }\n\t\t\t100% { box-shadow: 0 0 0 0 ${focusColor(0)}, 0 0 0 0 ${focusColor(0)}; border-color: ${focusColor(0)}; }\n\t\t}\n\t\t@keyframes ve-focus-sweep {\n\t\t\t0% { transform: translateY(-100%); opacity: 0; }\n\t\t\t18% { opacity: 1; }\n\t\t\t100% { transform: translateY(100%); opacity: 0; }\n\t\t}\n\t\t@keyframes ve-focus-fadeout {\n\t\t\tto { opacity: 0; }\n\t\t}\n\t\t.ve-sweep-wrap {\n\t\t\tpointer-events: none;\n\t\t\tposition: fixed;\n\t\t\tz-index: 9999;\n\t\t}\n\t\t.ve-sweep-ring {\n\t\t\tposition: absolute;\n\t\t\tinset: -2px;\n\t\t\tborder: 2px solid transparent;\n\t\t\tborder-radius: 6px;\n\t\t\tanimation: ve-focus-ring-pulse 0.7s cubic-bezier(0.4, 0, 0.2, 1) 120ms 2 forwards;\n\t\t}\n\t\t.ve-sweep-corner {\n\t\t\tposition: absolute;\n\t\t\twidth: 14px;\n\t\t\theight: 14px;\n\t\t\tborder-color: ${focusColor(0.95)};\n\t\t\tborder-style: solid;\n\t\t\tborder-width: 0;\n\t\t\tanimation:\n\t\t\t\tve-focus-corner-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) 0ms both,\n\t\t\t\tve-focus-fadeout 300ms ease 1400ms forwards;\n\t\t}\n\t\t.ve-sweep-corner.tl { top: -4px; left: -4px; border-width: 2px 0 0 2px; border-top-left-radius: 4px; }\n\t\t.ve-sweep-corner.tr { top: -4px; right: -4px; border-width: 2px 2px 0 0; border-top-right-radius: 4px; }\n\t\t.ve-sweep-corner.bl { bottom: -4px; left: -4px; border-width: 0 0 2px 2px; border-bottom-left-radius: 4px; }\n\t\t.ve-sweep-corner.br { bottom: -4px; right: -4px; border-width: 0 2px 2px 0; border-bottom-right-radius: 4px; }\n\t\t.ve-sweep-clip {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\toverflow: hidden;\n\t\t\tborder-radius: 4px;\n\t\t}\n\t\t.ve-sweep-overlay {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\tbackground: linear-gradient(\n\t\t\t\tto bottom,\n\t\t\t\ttransparent 0%,\n\t\t\t\t${focusColor(0.06)} 22%,\n\t\t\t\t${focusColor(0.22)} 50%,\n\t\t\t\t${focusColor(0.06)} 78%,\n\t\t\t\ttransparent 100%\n\t\t\t);\n\t\t\tanimation: ve-focus-sweep 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;\n\t\t}\n\t\t@media (prefers-reduced-motion: reduce) {\n\t\t\t.ve-sweep-ring { animation: none; border-color: ${focusColor(0.9)}; box-shadow: 0 0 0 2px ${focusColor(0.22)}, 0 0 0 6px ${focusColor(0.08)}; }\n\t\t\t.ve-sweep-corner { animation: ve-focus-fadeout 300ms ease 1400ms forwards; }\n\t\t\t.ve-sweep-overlay { animation: none; opacity: 0; }\n\t\t}\n\t`;\n document.head.append(style);\n};\n\nconst SWEEP_DECORATION_PAD = 24;\n\nexport const playSweep = (el: HTMLElement): void => {\n ensureSweepStyles();\n const wrap = document.createElement(\"div\");\n wrap.className = \"ve-sweep-wrap\";\n\n const docHeader = document.querySelector<HTMLElement>(\".doc-controls\");\n\n const ring = document.createElement(\"div\");\n ring.className = \"ve-sweep-ring\";\n\n const corners = ([\"tl\", \"tr\", \"bl\", \"br\"] as const).map((pos) => {\n const corner = document.createElement(\"div\");\n corner.className = `ve-sweep-corner ${pos}`;\n return corner;\n });\n\n const clip = document.createElement(\"div\");\n clip.className = \"ve-sweep-clip\";\n const overlay = document.createElement(\"div\");\n overlay.className = \"ve-sweep-overlay\";\n clip.append(overlay);\n\n wrap.append(ring, ...corners, clip);\n document.body.append(wrap);\n\n // Track the field's current rect for the full reveal. If the browser's smooth-scroll\n // is still running when the reveal starts, or the layout shifts mid-animation, the\n // wrap stays anchored to the field instead of drifting off.\n let rafId = 0;\n const pad = SWEEP_DECORATION_PAD;\n const track = () => {\n const rect = el.getBoundingClientRect();\n wrap.style.top = `${rect.top}px`;\n wrap.style.left = `${rect.left}px`;\n wrap.style.width = `${rect.width}px`;\n wrap.style.height = `${rect.height}px`;\n\n const headerBottom = docHeader?.getBoundingClientRect().bottom ?? 0;\n const topClip = Math.max(headerBottom - rect.top, -pad);\n wrap.style.clipPath = `polygon(${-pad}px ${topClip}px, calc(100% + ${pad}px) ${topClip}px, calc(100% + ${pad}px) calc(100% + ${pad}px), ${-pad}px calc(100% + ${pad}px))`;\n\n rafId = requestAnimationFrame(track);\n };\n track();\n\n setTimeout(() => {\n cancelAnimationFrame(rafId);\n wrap.remove();\n }, REVEAL_TOTAL_MS);\n};\n\n// Lexical rich-text wrappers don't carry the `field-<path>` id — only a\n// `<label htmlFor=\"field-<path>\">` pointing inside. Everything else Payload\n// renders exposes the id on an element (input, select, textarea, group wrapper).\nexport const findFieldElement = (fieldId: string): HTMLElement | null => {\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const direct = document.getElementById(fieldId);\n if (direct) return direct;\n const label = document.querySelector<HTMLElement>(`label[for=\"${fieldId}\"]`);\n const wrapper = label?.closest<HTMLElement>(\".field-type\");\n return wrapper ?? null;\n};\n\n// Payload lazily renders groups that are below the viewport — their inner fields\n// (including the `*-row-<n>` containers the `row` instruction waits on) don't\n// exist in the DOM until the group is scrolled near. Before waiting, walk up\n// the path and scroll the deepest already-mounted ancestor into view so the\n// virtualized subtree hydrates. Safe to call repeatedly; does nothing when the\n// full field id is already present.\nexport const scrollNearestAncestorIntoView = (fieldId: string): void => {\n if (!fieldId.startsWith(\"field-\")) return;\n const segments = fieldId.slice(\"field-\".length).split(\"__\");\n for (let i = segments.length; i > 0; i--) {\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const el = document.getElementById(`field-${segments.slice(0, i).join(\"__\")}`);\n if (el && typeof el.scrollIntoView === \"function\") {\n el.scrollIntoView({ behavior: \"auto\", block: \"center\" });\n return;\n }\n }\n};\n\nconst waitFor = (predicate: () => boolean, budgetMs: number): Promise<boolean> => {\n return new Promise((resolve) => {\n const deadline = Date.now() + budgetMs;\n const tick = () => {\n if (predicate()) return resolve(true);\n if (Date.now() >= deadline) return resolve(false);\n setTimeout(tick, POLL_INTERVAL_MS);\n };\n tick();\n });\n};\n\n// Payload's Collapsible uses its `path` as the id suffix — see\n// @payloadcms/ui/dist/fields/Collapsible/index.js:52.\nconst collapsibleDomId = (path: string): string => `field-collapsible-${path.replace(/\\./g, \"__\")}`;\n\n// Tab buttons can exist at multiple nesting levels (top-level tabs, plus any\n// nested tabs fields inside blocks). A raw `querySelectorAll` at document scope\n// would match all of them, and `buttons[instruction.tabIndex]` would pick the\n// wrong one for any chain step past the top level. The executor narrows the\n// search scope as it descends — each row instruction sets the next scope to\n// the row's container so subsequent tab/collapsible lookups stay inside it.\nconst runInstruction = async (\n instruction: ContainerInstruction,\n scope: ParentNode\n): Promise<{ ok: boolean; nextScope: ParentNode }> => {\n switch (instruction.kind) {\n case \"tab\": {\n const getButton = (): HTMLButtonElement | null => {\n const buttons = scope.querySelectorAll<HTMLButtonElement>(\".tabs-field__tab-button\");\n return buttons[instruction.tabIndex] ?? null;\n };\n const isActive = () =>\n getButton()?.classList.contains(\"tabs-field__tab-button--active\") ?? false;\n\n const ready = await waitFor(() => getButton() !== null, STEP_BUDGET_MS);\n if (!ready) return { ok: false, nextScope: scope };\n if (!isActive()) getButton()!.click();\n const activated = await waitFor(isActive, STEP_BUDGET_MS);\n return { ok: activated, nextScope: scope };\n }\n case \"collapsible\": {\n // Collapsible ids are globally unique in the DOM — resolve at document scope.\n const id = collapsibleDomId(instruction.path);\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const ready = await waitFor(() => document.getElementById(id) !== null, STEP_BUDGET_MS);\n if (!ready) return { ok: false, nextScope: scope };\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const wrapper = document.getElementById(id)!;\n const toggle = wrapper.querySelector<HTMLButtonElement>(\".collapsible__toggle\");\n if (!toggle) return { ok: true, nextScope: wrapper };\n if (toggle.classList.contains(\"collapsible__toggle--collapsed\")) {\n toggle.click();\n const opened = await waitFor(\n () => !toggle.classList.contains(\"collapsible__toggle--collapsed\"),\n STEP_BUDGET_MS\n );\n return { ok: opened, nextScope: wrapper };\n }\n return { ok: true, nextScope: wrapper };\n }\n case \"row\": {\n // `rowContainerId` mirrors the path shape (`a-b-c-row-<n>`). Derive the\n // parent array's field id and scroll it into view to force Payload to\n // hydrate the virtualized rows before we wait for the row container.\n const parentArrayFieldId = `field-${instruction.rowContainerId\n .replace(/-row-\\d+$/, \"\")\n .replace(/-/g, \"__\")}`;\n scrollNearestAncestorIntoView(parentArrayFieldId);\n const ready = await waitFor(\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n () => document.getElementById(instruction.rowContainerId) !== null,\n STEP_BUDGET_MS\n );\n if (!ready) return { ok: false, nextScope: scope };\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const row = document.getElementById(instruction.rowContainerId)!;\n const toggle = row.querySelector<HTMLButtonElement>(\".collapsible__toggle\");\n if (!toggle) return { ok: true, nextScope: row };\n if (toggle.classList.contains(\"collapsible__toggle--collapsed\")) {\n toggle.click();\n const opened = await waitFor(\n () => !toggle.classList.contains(\"collapsible__toggle--collapsed\"),\n STEP_BUDGET_MS\n );\n return { ok: opened, nextScope: row };\n }\n return { ok: true, nextScope: row };\n }\n }\n};\n\nexport const applyContainerChain = async (\n chain: readonly ContainerInstruction[]\n): Promise<boolean> => {\n let scope: ParentNode = document;\n for (const instruction of chain) {\n const result = await runInstruction(instruction, scope);\n if (!result.ok) return false;\n scope = result.nextScope;\n }\n return true;\n};\n\n// `scrollIntoView({block: 'center'})` beats a precomputed `scrollBy` delta here:\n// the browser tracks the element's live rect across the smooth-scroll animation,\n// so virtualized fields hydrating mid-scroll (RenderIfInViewport firing as we\n// pass its rootMargin) can't leave us off-target. `.focus({preventScroll: true})`\n// suppresses the browser's default \"scroll focusable into nearest view\" that\n// would otherwise race our centering call. After POST_SCROLL_DELAY_MS the\n// initial scroll should be settled — if additional virtualization shifted the\n// field out of view we re-center once more.\nconst focusAndSweep = (fieldEl: HTMLElement): void => {\n if (typeof fieldEl.scrollIntoView === \"function\") {\n fieldEl.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n\n setTimeout(() => {\n let sweepTarget: HTMLElement = fieldEl;\n if (fieldEl.matches(FOCUS_SELECTOR)) {\n fieldEl.focus({ preventScroll: true });\n const wrapper = fieldEl.closest<HTMLElement>(\".field-type\");\n if (wrapper) sweepTarget = wrapper;\n } else {\n const focusable = fieldEl.querySelector<HTMLElement>(FOCUS_SELECTOR);\n focusable?.focus({ preventScroll: true });\n }\n if (typeof fieldEl.scrollIntoView === \"function\") {\n const rect = fieldEl.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n // Re-center only when the field is outside the viewport — don't\n // re-scroll a centered field whose intrinsic height exceeds the\n // viewport (rect.top < 0 AND rect.bottom > viewportHeight is the\n // correctly-centered state for tall fields).\n const outOfView = rect.bottom <= 0 || rect.top >= viewportHeight;\n if (outOfView) {\n fieldEl.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n }\n playSweep(sweepTarget);\n }, POST_SCROLL_DELAY_MS);\n};\n\n// Soft-fails on each step: if a chain step times out we still attempt the\n// scroll/focus so the user lands near the target (chain partially works,\n// field visible via ancestor scroll).\nexport const expandAndFocus = async (\n chain: readonly ContainerInstruction[],\n fieldId: string | null\n): Promise<void> => {\n await applyContainerChain(chain);\n if (!fieldId) return;\n // After the chain opens the tab/collapsible, the target may still live inside\n // a virtualized group — kick off a scroll to the nearest existing ancestor\n // before polling so Payload hydrates the subtree.\n scrollNearestAncestorIntoView(fieldId);\n const ready = await waitFor(() => findFieldElement(fieldId) !== null, STEP_BUDGET_MS);\n if (!ready) return;\n const fieldEl = findFieldElement(fieldId);\n if (fieldEl) focusAndSweep(fieldEl);\n};\n"],"names":["FOCUS_SELECTOR","SWEEP_STYLE_ID","POLL_INTERVAL_MS","STEP_BUDGET_MS","POST_SCROLL_DELAY_MS","REVEAL_TOTAL_MS","FOCUS_HSL","h","s","l","focusColor","alpha","ensureSweepStyles","document","getElementById","style","createElement","id","textContent","head","append","SWEEP_DECORATION_PAD","playSweep","el","wrap","className","docHeader","querySelector","ring","corners","map","pos","corner","clip","overlay","body","rafId","pad","track","rect","getBoundingClientRect","top","left","width","height","headerBottom","bottom","topClip","Math","max","clipPath","requestAnimationFrame","setTimeout","cancelAnimationFrame","remove","findFieldElement","fieldId","direct","label","wrapper","closest","scrollNearestAncestorIntoView","startsWith","segments","slice","length","split","i","join","scrollIntoView","behavior","block","waitFor","predicate","budgetMs","Promise","resolve","deadline","Date","now","tick","collapsibleDomId","path","replace","runInstruction","instruction","scope","kind","getButton","buttons","querySelectorAll","tabIndex","isActive","classList","contains","ready","ok","nextScope","click","activated","toggle","opened","parentArrayFieldId","rowContainerId","row","applyContainerChain","chain","result","focusAndSweep","fieldEl","sweepTarget","matches","focus","preventScroll","focusable","viewportHeight","window","innerHeight","outOfView","expandAndFocus"],"mappings":"AAEA,MAAMA,iBAAiB;AAEvB,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,uBAAuB;AAE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OAAO;gBAAS;YAC/D;QACF;QACAjD,UAAUwF;IACZ,GAAG1G;AACL;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,sCAAsC;AACtC,OAAO,MAAMmH,iBAAiB,OAC5Bb,OACAlD;IAEA,MAAMiD,oBAAoBC;IAC1B,IAAI,CAAClD,SAAS;IACd,8EAA8E;IAC9E,2EAA2E;IAC3E,kDAAkD;IAClDK,8BAA8BL;IAC9B,MAAMuC,QAAQ,MAAMvB,QAAQ,IAAMjB,iBAAiBC,aAAa,MAAMrD;IACtE,IAAI,CAAC4F,OAAO;IACZ,MAAMc,UAAUtD,iBAAiBC;IACjC,IAAIqD,SAASD,cAAcC;AAC7B,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/expandAndFocus.ts"],"sourcesContent":["import type { ContainerInstruction } from \"./resolveContainerChain.js\";\n\nimport {\n arrayFieldIdOfRow,\n FIELD_ID_PREFIX,\n FIELD_ID_SEPARATOR,\n fieldDomIdOf,\n} from \"./fieldDomId.js\";\n\nconst FOCUS_SELECTOR = '[data-lexical-editor=\"true\"], input:not([type=\"hidden\"]), textarea';\n\nconst FIELD_WRAPPER_SELECTOR = \".field-type\";\nconst BLOCK_NAME_INPUT_SELECTOR = \".section-title__input\";\nconst FOCUSED_FIELD_FRAME_SELECTOR = \".section-title, .field-type\";\n\nconst SWEEP_STYLE_ID = \"ve-sweep-styles\";\nconst POLL_INTERVAL_MS = 60;\nconst STEP_BUDGET_MS = 1500;\nconst POST_SCROLL_DELAY_MS = 500;\n\nconst REVEAL_TOTAL_MS = 1800;\n\nconst FOCUS_HSL = { h: 189, s: 85, l: 53 } as const;\nconst focusColor = (alpha: number): string =>\n `hsla(${FOCUS_HSL.h}, ${FOCUS_HSL.s}%, ${FOCUS_HSL.l}%, ${alpha})`;\n\nconst ensureSweepStyles = (): void => {\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n if (document.getElementById(SWEEP_STYLE_ID)) return;\n const style = document.createElement(\"style\");\n style.id = SWEEP_STYLE_ID;\n style.textContent = `\n\t\t@keyframes ve-focus-corner-in {\n\t\t\t0% { transform: scale(1.35); opacity: 0; }\n\t\t\t60% { opacity: 1; }\n\t\t\t100% { transform: scale(1); opacity: 1; }\n\t\t}\n\t\t@keyframes ve-focus-ring-pulse {\n\t\t\t0% { box-shadow: 0 0 0 0 ${focusColor(0.55)}, 0 0 0 0 ${focusColor(0.22)}; border-color: ${focusColor(0.95)}; }\n\t\t\t50% { box-shadow: 0 0 0 4px ${focusColor(0.3)}, 0 0 0 14px ${focusColor(0.06)}; border-color: ${focusColor(0.95)}; }\n\t\t\t100% { box-shadow: 0 0 0 0 ${focusColor(0)}, 0 0 0 0 ${focusColor(0)}; border-color: ${focusColor(0)}; }\n\t\t}\n\t\t@keyframes ve-focus-sweep {\n\t\t\t0% { transform: translateY(-100%); opacity: 0; }\n\t\t\t18% { opacity: 1; }\n\t\t\t100% { transform: translateY(100%); opacity: 0; }\n\t\t}\n\t\t@keyframes ve-focus-fadeout {\n\t\t\tto { opacity: 0; }\n\t\t}\n\t\t.ve-sweep-wrap {\n\t\t\tpointer-events: none;\n\t\t\tposition: fixed;\n\t\t\tz-index: 9999;\n\t\t}\n\t\t.ve-sweep-ring {\n\t\t\tposition: absolute;\n\t\t\tinset: -2px;\n\t\t\tborder: 2px solid transparent;\n\t\t\tborder-radius: 6px;\n\t\t\tanimation: ve-focus-ring-pulse 0.7s cubic-bezier(0.4, 0, 0.2, 1) 120ms 2 forwards;\n\t\t}\n\t\t.ve-sweep-corner {\n\t\t\tposition: absolute;\n\t\t\twidth: 14px;\n\t\t\theight: 14px;\n\t\t\tborder-color: ${focusColor(0.95)};\n\t\t\tborder-style: solid;\n\t\t\tborder-width: 0;\n\t\t\tanimation:\n\t\t\t\tve-focus-corner-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) 0ms both,\n\t\t\t\tve-focus-fadeout 300ms ease 1400ms forwards;\n\t\t}\n\t\t.ve-sweep-corner.tl { top: -4px; left: -4px; border-width: 2px 0 0 2px; border-top-left-radius: 4px; }\n\t\t.ve-sweep-corner.tr { top: -4px; right: -4px; border-width: 2px 2px 0 0; border-top-right-radius: 4px; }\n\t\t.ve-sweep-corner.bl { bottom: -4px; left: -4px; border-width: 0 0 2px 2px; border-bottom-left-radius: 4px; }\n\t\t.ve-sweep-corner.br { bottom: -4px; right: -4px; border-width: 0 2px 2px 0; border-bottom-right-radius: 4px; }\n\t\t.ve-sweep-clip {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\toverflow: hidden;\n\t\t\tborder-radius: 4px;\n\t\t}\n\t\t.ve-sweep-overlay {\n\t\t\tposition: absolute;\n\t\t\tinset: 0;\n\t\t\tbackground: linear-gradient(\n\t\t\t\tto bottom,\n\t\t\t\ttransparent 0%,\n\t\t\t\t${focusColor(0.06)} 22%,\n\t\t\t\t${focusColor(0.22)} 50%,\n\t\t\t\t${focusColor(0.06)} 78%,\n\t\t\t\ttransparent 100%\n\t\t\t);\n\t\t\tanimation: ve-focus-sweep 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;\n\t\t}\n\t\t@media (prefers-reduced-motion: reduce) {\n\t\t\t.ve-sweep-ring { animation: none; border-color: ${focusColor(0.9)}; box-shadow: 0 0 0 2px ${focusColor(0.22)}, 0 0 0 6px ${focusColor(0.08)}; }\n\t\t\t.ve-sweep-corner { animation: ve-focus-fadeout 300ms ease 1400ms forwards; }\n\t\t\t.ve-sweep-overlay { animation: none; opacity: 0; }\n\t\t}\n\t`;\n document.head.append(style);\n};\n\nconst SWEEP_DECORATION_PAD = 24;\n\nconst playSweep = (el: HTMLElement): void => {\n ensureSweepStyles();\n const wrap = document.createElement(\"div\");\n wrap.className = \"ve-sweep-wrap\";\n\n const docHeader = document.querySelector<HTMLElement>(\".doc-controls\");\n\n const ring = document.createElement(\"div\");\n ring.className = \"ve-sweep-ring\";\n\n const corners = ([\"tl\", \"tr\", \"bl\", \"br\"] as const).map((pos) => {\n const corner = document.createElement(\"div\");\n corner.className = `ve-sweep-corner ${pos}`;\n return corner;\n });\n\n const clip = document.createElement(\"div\");\n clip.className = \"ve-sweep-clip\";\n const overlay = document.createElement(\"div\");\n overlay.className = \"ve-sweep-overlay\";\n clip.append(overlay);\n\n wrap.append(ring, ...corners, clip);\n document.body.append(wrap);\n\n let rafId = 0;\n const pad = SWEEP_DECORATION_PAD;\n const track = () => {\n const rect = el.getBoundingClientRect();\n wrap.style.top = `${rect.top}px`;\n wrap.style.left = `${rect.left}px`;\n wrap.style.width = `${rect.width}px`;\n wrap.style.height = `${rect.height}px`;\n\n const headerBottom = docHeader?.getBoundingClientRect().bottom ?? 0;\n const topClip = Math.max(headerBottom - rect.top, -pad);\n wrap.style.clipPath = `polygon(${-pad}px ${topClip}px, calc(100% + ${pad}px) ${topClip}px, calc(100% + ${pad}px) calc(100% + ${pad}px), ${-pad}px calc(100% + ${pad}px))`;\n\n rafId = requestAnimationFrame(track);\n };\n track();\n\n setTimeout(() => {\n cancelAnimationFrame(rafId);\n wrap.remove();\n }, REVEAL_TOTAL_MS);\n};\n\nconst blockNameInputOf = (fieldId: string): HTMLElement | null => {\n const inputs = document.querySelectorAll<HTMLInputElement>(BLOCK_NAME_INPUT_SELECTOR);\n return Array.from(inputs).find((input) => fieldDomIdOf(input.name) === fieldId) ?? null;\n};\n\nconst labelOf = (fieldId: string): HTMLLabelElement | null =>\n Array.from(document.querySelectorAll(\"label\")).find((label) => label.htmlFor === fieldId) ?? null;\n\nexport const findFieldElement = (fieldId: string): HTMLElement | null => {\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const direct = document.getElementById(fieldId);\n if (direct) return direct;\n const wrapper = labelOf(fieldId)?.closest<HTMLElement>(FIELD_WRAPPER_SELECTOR);\n return wrapper ?? blockNameInputOf(fieldId);\n};\n\nexport const scrollNearestAncestorIntoView = (fieldId: string): void => {\n if (!fieldId.startsWith(FIELD_ID_PREFIX)) return;\n const segments = fieldId.slice(FIELD_ID_PREFIX.length).split(FIELD_ID_SEPARATOR);\n for (let i = segments.length; i > 0; i--) {\n const ancestorId = `${FIELD_ID_PREFIX}${segments.slice(0, i).join(FIELD_ID_SEPARATOR)}`;\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const el = document.getElementById(ancestorId);\n if (el && typeof el.scrollIntoView === \"function\") {\n el.scrollIntoView({ behavior: \"auto\", block: \"center\" });\n return;\n }\n }\n};\n\nconst waitFor = (predicate: () => boolean, budgetMs: number): Promise<boolean> => {\n return new Promise((resolve) => {\n const deadline = Date.now() + budgetMs;\n const tick = () => {\n if (predicate()) return resolve(true);\n if (Date.now() >= deadline) return resolve(false);\n setTimeout(tick, POLL_INTERVAL_MS);\n };\n tick();\n });\n};\n\nconst collapsibleDomId = (path: string): string => fieldDomIdOf(`collapsible-${path}`);\n\nconst runInstruction = async (\n instruction: ContainerInstruction,\n scope: ParentNode\n): Promise<{ ok: boolean; nextScope: ParentNode }> => {\n switch (instruction.kind) {\n case \"tab\": {\n const getButton = (): HTMLButtonElement | null => {\n const buttons = scope.querySelectorAll<HTMLButtonElement>(\".tabs-field__tab-button\");\n return buttons[instruction.tabIndex] ?? null;\n };\n const isActive = () =>\n getButton()?.classList.contains(\"tabs-field__tab-button--active\") ?? false;\n\n const ready = await waitFor(() => getButton() !== null, STEP_BUDGET_MS);\n if (!ready) return { ok: false, nextScope: scope };\n if (!isActive()) getButton()!.click();\n const activated = await waitFor(isActive, STEP_BUDGET_MS);\n return { ok: activated, nextScope: scope };\n }\n case \"collapsible\": {\n const id = collapsibleDomId(instruction.path);\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const ready = await waitFor(() => document.getElementById(id) !== null, STEP_BUDGET_MS);\n if (!ready) return { ok: false, nextScope: scope };\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const wrapper = document.getElementById(id)!;\n const toggle = wrapper.querySelector<HTMLButtonElement>(\".collapsible__toggle\");\n if (!toggle) return { ok: true, nextScope: wrapper };\n if (toggle.classList.contains(\"collapsible__toggle--collapsed\")) {\n toggle.click();\n const opened = await waitFor(\n () => !toggle.classList.contains(\"collapsible__toggle--collapsed\"),\n STEP_BUDGET_MS\n );\n return { ok: opened, nextScope: wrapper };\n }\n return { ok: true, nextScope: wrapper };\n }\n case \"row\": {\n scrollNearestAncestorIntoView(arrayFieldIdOfRow(instruction.rowContainerId));\n const ready = await waitFor(\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n () => document.getElementById(instruction.rowContainerId) !== null,\n STEP_BUDGET_MS\n );\n if (!ready) return { ok: false, nextScope: scope };\n // oxlint-disable-next-line unicorn/prefer-query-selector -- ids are not guaranteed to be valid CSS selectors\n const row = document.getElementById(instruction.rowContainerId)!;\n const toggle = row.querySelector<HTMLButtonElement>(\".collapsible__toggle\");\n if (!toggle) return { ok: true, nextScope: row };\n if (toggle.classList.contains(\"collapsible__toggle--collapsed\")) {\n toggle.click();\n const opened = await waitFor(\n () => !toggle.classList.contains(\"collapsible__toggle--collapsed\"),\n STEP_BUDGET_MS\n );\n return { ok: opened, nextScope: row };\n }\n return { ok: true, nextScope: row };\n }\n }\n};\n\nexport const applyContainerChain = async (\n chain: readonly ContainerInstruction[]\n): Promise<boolean> => {\n let scope: ParentNode = document;\n for (const instruction of chain) {\n const result = await runInstruction(instruction, scope);\n if (!result.ok) return false;\n scope = result.nextScope;\n }\n return true;\n};\n\nconst focusAndSweep = (fieldEl: HTMLElement): void => {\n if (typeof fieldEl.scrollIntoView === \"function\") {\n fieldEl.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n\n setTimeout(() => {\n let sweepTarget: HTMLElement = fieldEl;\n if (fieldEl.matches(FOCUS_SELECTOR)) {\n fieldEl.focus({ preventScroll: true });\n const wrapper = fieldEl.closest<HTMLElement>(FOCUSED_FIELD_FRAME_SELECTOR);\n if (wrapper) sweepTarget = wrapper;\n } else {\n const focusable = fieldEl.querySelector<HTMLElement>(FOCUS_SELECTOR);\n focusable?.focus({ preventScroll: true });\n }\n if (typeof fieldEl.scrollIntoView === \"function\") {\n const rect = fieldEl.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const outOfView = rect.bottom <= 0 || rect.top >= viewportHeight;\n if (outOfView) {\n fieldEl.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n }\n playSweep(sweepTarget);\n }, POST_SCROLL_DELAY_MS);\n};\n\nexport const expandAndFocus = async (\n chain: readonly ContainerInstruction[],\n fieldId: string | null\n): Promise<void> => {\n await applyContainerChain(chain);\n if (!fieldId) return;\n scrollNearestAncestorIntoView(fieldId);\n const ready = await waitFor(() => findFieldElement(fieldId) !== null, STEP_BUDGET_MS);\n if (!ready) return;\n const fieldEl = findFieldElement(fieldId);\n if (fieldEl) focusAndSweep(fieldEl);\n};\n"],"names":["arrayFieldIdOfRow","FIELD_ID_PREFIX","FIELD_ID_SEPARATOR","fieldDomIdOf","FOCUS_SELECTOR","FIELD_WRAPPER_SELECTOR","BLOCK_NAME_INPUT_SELECTOR","FOCUSED_FIELD_FRAME_SELECTOR","SWEEP_STYLE_ID","POLL_INTERVAL_MS","STEP_BUDGET_MS","POST_SCROLL_DELAY_MS","REVEAL_TOTAL_MS","FOCUS_HSL","h","s","l","focusColor","alpha","ensureSweepStyles","document","getElementById","style","createElement","id","textContent","head","append","SWEEP_DECORATION_PAD","playSweep","el","wrap","className","docHeader","querySelector","ring","corners","map","pos","corner","clip","overlay","body","rafId","pad","track","rect","getBoundingClientRect","top","left","width","height","headerBottom","bottom","topClip","Math","max","clipPath","requestAnimationFrame","setTimeout","cancelAnimationFrame","remove","blockNameInputOf","fieldId","inputs","querySelectorAll","Array","from","find","input","name","labelOf","label","htmlFor","findFieldElement","direct","wrapper","closest","scrollNearestAncestorIntoView","startsWith","segments","slice","length","split","i","ancestorId","join","scrollIntoView","behavior","block","waitFor","predicate","budgetMs","Promise","resolve","deadline","Date","now","tick","collapsibleDomId","path","runInstruction","instruction","scope","kind","getButton","buttons","tabIndex","isActive","classList","contains","ready","ok","nextScope","click","activated","toggle","opened","rowContainerId","row","applyContainerChain","chain","result","focusAndSweep","fieldEl","sweepTarget","matches","focus","preventScroll","focusable","viewportHeight","window","innerHeight","outOfView","expandAndFocus"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,eAAe,EACfC,kBAAkB,EAClBC,YAAY,QACP,kBAAkB;AAEzB,MAAMC,iBAAiB;AAEvB,MAAMC,yBAAyB;AAC/B,MAAMC,4BAA4B;AAClC,MAAMC,+BAA+B;AAErC,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,uBAAuB;AAE7B,MAAMC,kBAAkB;AAExB,MAAMC,YAAY;IAAEC,GAAG;IAAKC,GAAG;IAAIC,GAAG;AAAG;AACzC,MAAMC,aAAa,CAACC,QAClB,CAAC,KAAK,EAAEL,UAAUC,CAAC,CAAC,EAAE,EAAED,UAAUE,CAAC,CAAC,GAAG,EAAEF,UAAUG,CAAC,CAAC,GAAG,EAAEE,MAAM,CAAC,CAAC;AAEpE,MAAMC,oBAAoB;IACxB,6GAA6G;IAC7G,IAAIC,SAASC,cAAc,CAACb,iBAAiB;IAC7C,MAAMc,QAAQF,SAASG,aAAa,CAAC;IACrCD,MAAME,EAAE,GAAGhB;IACXc,MAAMG,WAAW,GAAG,CAAC;;;;;;;8BAOO,EAAER,WAAW,MAAM,UAAU,EAAEA,WAAW,MAAM,gBAAgB,EAAEA,WAAW,MAAM;gCACjF,EAAEA,WAAW,KAAK,aAAa,EAAEA,WAAW,MAAM,gBAAgB,EAAEA,WAAW,MAAM;8BACvF,EAAEA,WAAW,GAAG,UAAU,EAAEA,WAAW,GAAG,gBAAgB,EAAEA,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BvF,EAAEA,WAA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C;oBAAEC,UAAU;oBAAUC,OAAO;gBAAS;YAC/D;QACF;QACA5D,UAAUgG;IACZ,GAAGlH;AACL;AAEA,OAAO,MAAM2H,iBAAiB,OAC5Bb,OACA1D;IAEA,MAAMyD,oBAAoBC;IAC1B,IAAI,CAAC1D,SAAS;IACde,8BAA8Bf;IAC9B,MAAMgD,QAAQ,MAAMrB,QAAQ,IAAMhB,iBAAiBX,aAAa,MAAMrD;IACtE,IAAI,CAACqG,OAAO;IACZ,MAAMa,UAAUlD,iBAAiBX;IACjC,IAAI6D,SAASD,cAAcC;AAC7B,EAAE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const FIELD_ID_PREFIX = "field-";
|
|
2
|
+
export declare const FIELD_ID_SEPARATOR = "__";
|
|
3
|
+
export declare const fieldDomIdOf: (fieldPath: string) => string;
|
|
4
|
+
export declare const rowContainerIdOf: (arrayPath: string, rowIndex: string) => string;
|
|
5
|
+
export declare const arrayFieldIdOfRow: (rowContainerId: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FIELD_PATH_SEPARATOR } from "../shared/fieldKey.js";
|
|
2
|
+
export const FIELD_ID_PREFIX = "field-";
|
|
3
|
+
export const FIELD_ID_SEPARATOR = "__";
|
|
4
|
+
const ROW_CONTAINER_ID_SEPARATOR = "-";
|
|
5
|
+
const ROW_CONTAINER_ID_INFIX = "-row-";
|
|
6
|
+
const ROW_SUFFIX = /-row-\d+$/u;
|
|
7
|
+
export const fieldDomIdOf = (fieldPath)=>`${FIELD_ID_PREFIX}${fieldPath.replaceAll(FIELD_PATH_SEPARATOR, FIELD_ID_SEPARATOR)}`;
|
|
8
|
+
export const rowContainerIdOf = (arrayPath, rowIndex)=>`${arrayPath.replaceAll(FIELD_PATH_SEPARATOR, ROW_CONTAINER_ID_SEPARATOR)}${ROW_CONTAINER_ID_INFIX}${rowIndex}`;
|
|
9
|
+
export const arrayFieldIdOfRow = (rowContainerId)=>`${FIELD_ID_PREFIX}${rowContainerId.replace(ROW_SUFFIX, "").replaceAll(ROW_CONTAINER_ID_SEPARATOR, FIELD_ID_SEPARATOR)}`;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=fieldDomId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/fieldDomId.ts"],"sourcesContent":["import { FIELD_PATH_SEPARATOR } from \"../shared/fieldKey.js\";\n\nexport const FIELD_ID_PREFIX = \"field-\";\nexport const FIELD_ID_SEPARATOR = \"__\";\n\nconst ROW_CONTAINER_ID_SEPARATOR = \"-\";\nconst ROW_CONTAINER_ID_INFIX = \"-row-\";\nconst ROW_SUFFIX = /-row-\\d+$/u;\n\nexport const fieldDomIdOf = (fieldPath: string): string =>\n `${FIELD_ID_PREFIX}${fieldPath.replaceAll(FIELD_PATH_SEPARATOR, FIELD_ID_SEPARATOR)}`;\n\nexport const rowContainerIdOf = (arrayPath: string, rowIndex: string): string =>\n `${arrayPath.replaceAll(FIELD_PATH_SEPARATOR, ROW_CONTAINER_ID_SEPARATOR)}${ROW_CONTAINER_ID_INFIX}${rowIndex}`;\n\nexport const arrayFieldIdOfRow = (rowContainerId: string): string =>\n `${FIELD_ID_PREFIX}${rowContainerId\n .replace(ROW_SUFFIX, \"\")\n .replaceAll(ROW_CONTAINER_ID_SEPARATOR, FIELD_ID_SEPARATOR)}`;\n"],"names":["FIELD_PATH_SEPARATOR","FIELD_ID_PREFIX","FIELD_ID_SEPARATOR","ROW_CONTAINER_ID_SEPARATOR","ROW_CONTAINER_ID_INFIX","ROW_SUFFIX","fieldDomIdOf","fieldPath","replaceAll","rowContainerIdOf","arrayPath","rowIndex","arrayFieldIdOfRow","rowContainerId","replace"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAE7D,OAAO,MAAMC,kBAAkB,SAAS;AACxC,OAAO,MAAMC,qBAAqB,KAAK;AAEvC,MAAMC,6BAA6B;AACnC,MAAMC,yBAAyB;AAC/B,MAAMC,aAAa;AAEnB,OAAO,MAAMC,eAAe,CAACC,YAC3B,CAAC,EAAEN,gBAAgB,EAAEM,UAAUC,UAAU,CAACR,sBAAsBE,oBAAoB,CAAC,CAAC;AAExF,OAAO,MAAMO,mBAAmB,CAACC,WAAmBC,WAClD,CAAC,EAAED,UAAUF,UAAU,CAACR,sBAAsBG,4BAA4B,EAAEC,uBAAuB,EAAEO,SAAS,CAAC,CAAC;AAElH,OAAO,MAAMC,oBAAoB,CAACC,iBAChC,CAAC,EAAEZ,gBAAgB,EAAEY,eAClBC,OAAO,CAACT,YAAY,IACpBG,UAAU,CAACL,4BAA4BD,oBAAoB,CAAC,CAAC"}
|
package/dist/admin/index.d.ts
CHANGED
package/dist/admin/index.js
CHANGED
package/dist/admin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/index.ts"],"sourcesContent":["export { VisualEditingBridgeProvider } from \"./VisualEditingBridgeProvider.js\";\n"],"names":["VisualEditingBridgeProvider"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,mCAAmC"}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/index.ts"],"sourcesContent":["export { VisualEditingBridgeProvider } from \"./VisualEditingBridgeProvider.js\";\nexport { InstantPreviewBroadcaster } from \"./InstantPreviewBroadcaster.js\";\nexport { OpenFormAnnouncer } from \"./openField/OpenFormAnnouncer.js\";\n"],"names":["VisualEditingBridgeProvider","InstantPreviewBroadcaster","OpenFormAnnouncer"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,mCAAmC;AAC/E,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,SAASC,iBAAiB,QAAQ,mCAAmC"}
|