@contentstack/live-preview-utils 3.0.2 → 3.1.1
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 +1 -1
- package/dist/legacy/index.cjs +5 -5
- package/dist/legacy/index.cjs.map +1 -1
- package/dist/legacy/index.js +2 -2
- package/dist/legacy/index.js.map +1 -1
- package/dist/legacy/livePreview/editButton/editButton.cjs +3 -0
- package/dist/legacy/livePreview/editButton/editButton.cjs.map +1 -1
- package/dist/legacy/livePreview/editButton/editButton.js +3 -0
- package/dist/legacy/livePreview/editButton/editButton.js.map +1 -1
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +23 -4
- package/dist/legacy/preview/contentstack-live-preview-HOC.cjs.map +1 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.d.cts +2 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.d.ts +2 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.js +23 -4
- package/dist/legacy/preview/contentstack-live-preview-HOC.js.map +1 -1
- package/dist/legacy/types/types.cjs.map +1 -1
- package/dist/legacy/types/types.d.cts +2 -1
- package/dist/legacy/types/types.d.ts +2 -1
- package/dist/legacy/types/types.js.map +1 -1
- package/dist/legacy/utils/addLivePreviewQueryTags.cjs +49 -0
- package/dist/legacy/utils/addLivePreviewQueryTags.cjs.map +1 -0
- package/dist/legacy/utils/addLivePreviewQueryTags.d.cts +3 -0
- package/dist/legacy/utils/addLivePreviewQueryTags.d.ts +3 -0
- package/dist/legacy/utils/addLivePreviewQueryTags.js +26 -0
- package/dist/legacy/utils/addLivePreviewQueryTags.js.map +1 -0
- package/dist/legacy/utils/index.cjs +3 -21
- package/dist/legacy/utils/index.cjs.map +1 -1
- package/dist/legacy/utils/index.d.cts +4 -2
- package/dist/legacy/utils/index.d.ts +4 -2
- package/dist/legacy/utils/index.js +1 -19
- package/dist/legacy/utils/index.js.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.cjs +60 -13
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.d.cts +2 -1
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.d.ts +2 -1
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.js +61 -15
- package/dist/legacy/visualBuilder/components/FieldRevert/FieldRevertComponent.js.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.cjs +41 -0
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.cjs.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.d.cts +3 -0
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.d.ts +3 -0
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.js +22 -0
- package/dist/legacy/visualBuilder/components/FieldRevert/useHandleOutsideClick.js.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldToolbar.cjs +118 -119
- package/dist/legacy/visualBuilder/components/FieldToolbar.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldToolbar.js +120 -121
- package/dist/legacy/visualBuilder/components/FieldToolbar.js.map +1 -1
- package/dist/legacy/visualBuilder/components/emptyBlock.cjs +1 -0
- package/dist/legacy/visualBuilder/components/emptyBlock.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/emptyBlock.js +1 -0
- package/dist/legacy/visualBuilder/components/emptyBlock.js.map +1 -1
- package/dist/legacy/visualBuilder/components/icons/variant.cjs +1 -1
- package/dist/legacy/visualBuilder/components/icons/variant.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/icons/variant.js +1 -1
- package/dist/legacy/visualBuilder/components/icons/variant.js.map +1 -1
- package/dist/legacy/visualBuilder/index.cjs +2 -1
- package/dist/legacy/visualBuilder/index.cjs.map +1 -1
- package/dist/legacy/visualBuilder/index.js +2 -1
- package/dist/legacy/visualBuilder/index.js.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseClick.cjs +2 -1
- package/dist/legacy/visualBuilder/listeners/mouseClick.cjs.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseClick.js +2 -1
- package/dist/legacy/visualBuilder/listeners/mouseClick.js.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.cjs +2 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.cjs.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.js +2 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.js.map +1 -1
- package/dist/legacy/visualBuilder/utils/getCsDataOfElement.cjs +17 -2
- package/dist/legacy/visualBuilder/utils/getCsDataOfElement.cjs.map +1 -1
- package/dist/legacy/visualBuilder/utils/getCsDataOfElement.js +17 -2
- package/dist/legacy/visualBuilder/utils/getCsDataOfElement.js.map +1 -1
- package/dist/legacy/visualBuilder/visualBuilder.style.cjs +3 -0
- package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
- package/dist/legacy/visualBuilder/visualBuilder.style.js +3 -0
- package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
- package/dist/modern/index.cjs +5 -5
- package/dist/modern/index.cjs.map +1 -1
- package/dist/modern/index.js +2 -2
- package/dist/modern/index.js.map +1 -1
- package/dist/modern/livePreview/editButton/editButton.cjs +3 -0
- package/dist/modern/livePreview/editButton/editButton.cjs.map +1 -1
- package/dist/modern/livePreview/editButton/editButton.js +3 -0
- package/dist/modern/livePreview/editButton/editButton.js.map +1 -1
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.cjs +23 -4
- package/dist/modern/preview/contentstack-live-preview-HOC.cjs.map +1 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.d.cts +2 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.d.ts +2 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.js +23 -4
- package/dist/modern/preview/contentstack-live-preview-HOC.js.map +1 -1
- package/dist/modern/types/types.cjs.map +1 -1
- package/dist/modern/types/types.d.cts +2 -1
- package/dist/modern/types/types.d.ts +2 -1
- package/dist/modern/types/types.js.map +1 -1
- package/dist/modern/utils/addLivePreviewQueryTags.cjs +49 -0
- package/dist/modern/utils/addLivePreviewQueryTags.cjs.map +1 -0
- package/dist/modern/utils/addLivePreviewQueryTags.d.cts +3 -0
- package/dist/modern/utils/addLivePreviewQueryTags.d.ts +3 -0
- package/dist/modern/utils/addLivePreviewQueryTags.js +26 -0
- package/dist/modern/utils/addLivePreviewQueryTags.js.map +1 -0
- package/dist/modern/utils/index.cjs +3 -21
- package/dist/modern/utils/index.cjs.map +1 -1
- package/dist/modern/utils/index.d.cts +4 -2
- package/dist/modern/utils/index.d.ts +4 -2
- package/dist/modern/utils/index.js +1 -19
- package/dist/modern/utils/index.js.map +1 -1
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.cjs +60 -13
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.d.cts +2 -1
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.d.ts +2 -1
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.js +61 -15
- package/dist/modern/visualBuilder/components/FieldRevert/FieldRevertComponent.js.map +1 -1
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.cjs +41 -0
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.cjs.map +1 -0
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.d.cts +3 -0
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.d.ts +3 -0
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.js +22 -0
- package/dist/modern/visualBuilder/components/FieldRevert/useHandleOutsideClick.js.map +1 -0
- package/dist/modern/visualBuilder/components/FieldToolbar.cjs +118 -119
- package/dist/modern/visualBuilder/components/FieldToolbar.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/FieldToolbar.js +120 -121
- package/dist/modern/visualBuilder/components/FieldToolbar.js.map +1 -1
- package/dist/modern/visualBuilder/components/emptyBlock.cjs +1 -0
- package/dist/modern/visualBuilder/components/emptyBlock.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/emptyBlock.js +1 -0
- package/dist/modern/visualBuilder/components/emptyBlock.js.map +1 -1
- package/dist/modern/visualBuilder/components/icons/variant.cjs +1 -1
- package/dist/modern/visualBuilder/components/icons/variant.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/icons/variant.js +1 -1
- package/dist/modern/visualBuilder/components/icons/variant.js.map +1 -1
- package/dist/modern/visualBuilder/index.cjs +2 -1
- package/dist/modern/visualBuilder/index.cjs.map +1 -1
- package/dist/modern/visualBuilder/index.js +2 -1
- package/dist/modern/visualBuilder/index.js.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseClick.cjs +2 -1
- package/dist/modern/visualBuilder/listeners/mouseClick.cjs.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseClick.js +2 -1
- package/dist/modern/visualBuilder/listeners/mouseClick.js.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.cjs +2 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.cjs.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.js +2 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.js.map +1 -1
- package/dist/modern/visualBuilder/utils/getCsDataOfElement.cjs +17 -2
- package/dist/modern/visualBuilder/utils/getCsDataOfElement.cjs.map +1 -1
- package/dist/modern/visualBuilder/utils/getCsDataOfElement.js +17 -2
- package/dist/modern/visualBuilder/utils/getCsDataOfElement.js.map +1 -1
- package/dist/modern/visualBuilder/visualBuilder.style.cjs +3 -0
- package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
- package/dist/modern/visualBuilder/visualBuilder.style.js +3 -0
- package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
- package/package.json +21 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/preview/contentstack-live-preview-HOC.ts"],"sourcesContent":["import { v4 as uuidv4 } from \"uuid\";\n\nimport { isEmpty } from \"lodash-es\";\nimport { getUserInitData } from \"../configManager/config.default\";\nimport Config, { updateConfigFromUrl } from \"../configManager/configManager\";\nimport { VisualBuilder } from \"../visualBuilder\";\nimport LivePreview from \"../livePreview/live-preview\";\nimport { removeFromOnChangeSubscribers } from \"../livePreview/removeFromOnChangeSubscribers\";\nimport {\n OnEntryChangeCallback,\n OnEntryChangeCallbackSubscribers,\n OnEntryChangeCallbackUID,\n OnEntryChangeConfig,\n OnEntryChangeUnsubscribeParameters,\n} from \"../livePreview/types/onEntryChangeCallback.type\";\nimport { PublicLogger } from \"../logger/logger\";\nimport type { IInitData } from \"../types/types\";\nimport { handlePageTraversal } from \"../livePreview/onPageTraversal\";\nimport { handleWebCompare } from \"../timeline/compare/compare\";\n\nclass ContentstackLivePreview {\n private static previewConstructors:\n | {\n livePreview: LivePreview;\n visualBuilder: VisualBuilder;\n }\n | Record<string, never> = {};\n\n /**\n * The subscribers for the onEntryChange event. We store them here when the SDK is not initialized.\n */\n private static onEntryChangeCallbacks: OnEntryChangeCallbackSubscribers =\n {};\n\n /**\n * Initializes the Live Preview SDK with the provided user configuration.\n * If the SDK is already initialized, subsequent calls to this method will return the existing SDK instance.\n * @param userConfig - The user configuration to initialize the SDK with. See {@link https://github.com/contentstack/live-preview-sdk/blob/main/docs/live-preview-configs.md#initconfig-iconfig|Live preview User config} for more details.\n * @returns A promise that resolves to the constructors of the Live Preview SDK.\n */\n static init(\n userConfig: Partial<IInitData> = getUserInitData()\n ): Promise<typeof ContentstackLivePreview.previewConstructors> {\n if (typeof window === \"undefined\") {\n PublicLogger.warn(\"The SDK is not initialized in the browser.\");\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n }\n\n // handle user config\n Config.replace(userConfig);\n updateConfigFromUrl();\n\n if (ContentstackLivePreview.isInitialized()) {\n PublicLogger.warn(\n \"You have already initialized the Live Preview SDK. So, any subsequent initialization returns the existing SDK instance.\"\n );\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n } else {\n return ContentstackLivePreview.initializePreview();\n }\n }\n\n /**\n * It is the live preview hash.\n * This hash could be used when data is fetched manually.\n */\n static get hash(): string {\n if (!ContentstackLivePreview.isInitialized()) {\n updateConfigFromUrl(); // check if we could extract from the URL\n }\n return Config.get().hash;\n }\n\n private static isInitialized(): boolean {\n return !isEmpty(ContentstackLivePreview.previewConstructors);\n }\n\n private static initializePreview() {\n ContentstackLivePreview.previewConstructors = {\n livePreview: new LivePreview(),\n visualBuilder: new VisualBuilder(),\n };\n\n // set up onEntryChange callbacks added when the SDK was not initialized\n const livePreview =\n ContentstackLivePreview.previewConstructors.livePreview;\n Object.entries(ContentstackLivePreview.onEntryChangeCallbacks).forEach(\n ([callbackUid, callback]) => {\n livePreview.subscribeToOnEntryChange(callback, callbackUid);\n }\n );\n\n ContentstackLivePreview.onEntryChangeCallbacks = {};\n\n handlePageTraversal();\n handleWebCompare();\n\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n }\n\n /**\n * Registers a callback function to be called when an entry changes.\n * @param onChangeCallback The callback function to be called when an entry changes.\n * @param config Optional configuration for the callback.\n * @param config.skipInitialRender If true, the callback will not be called when it is first registered.\n * @returns A unique identifier for the registered callback.\n *\n * @example\n * ```js\n * const callbackUid = ContentstackLivePreview.onEntryChange(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n */\n static onEntryChange(\n onChangeCallback: OnEntryChangeCallback,\n config: OnEntryChangeConfig = {}\n ): OnEntryChangeCallbackUID {\n const { skipInitialRender = false } = config;\n\n const callbackUid = uuidv4();\n\n if (ContentstackLivePreview.isInitialized()) {\n ContentstackLivePreview.previewConstructors.livePreview.subscribeToOnEntryChange(\n onChangeCallback,\n callbackUid\n );\n } else {\n ContentstackLivePreview.onEntryChangeCallbacks[callbackUid] =\n onChangeCallback;\n }\n\n if (!skipInitialRender) {\n onChangeCallback();\n }\n\n return callbackUid;\n }\n\n /**\n * Registers a callback function to be called when there is a change in the entry being edited in live preview mode. The difference between this and `onEntryChange` is that this callback will not be called when it is first registered.\n * @param onChangeCallback The callback function to be called when there is a change in the entry.\n * @returns A unique identifier for the registered callback.\n *\n * @example\n * ```js\n * const callbackUid = ContentstackLivePreview.onLiveEdit(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n */\n static onLiveEdit(\n onChangeCallback: OnEntryChangeCallback\n ): OnEntryChangeCallbackUID {\n return ContentstackLivePreview.onEntryChange(onChangeCallback, {\n skipInitialRender: true,\n });\n }\n\n /**\n * Unsubscribes from the entry change event.\n * @param callback - The callback function to be unsubscribed.\n *\n * @example\n * ```js\n * // unsubscribing using the Callback UID\n * const callbackUid = ContentstackLivePreview.onEntryChange(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n * @example\n * ```js\n * // unsubscribing using the callback function\n * const callback = () => {console.log(\"Entry changed\")};\n * ContentstackLivePreview.onEntryChange(callback);\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callback);\n * ```\n *\n * @example\n * ```js\n * // The same is applicable to onLiveEdit\n * const callbackUid = ContentstackLivePreview.onLiveEdit(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n *\n */\n static unsubscribeOnEntryChange(\n callback: OnEntryChangeUnsubscribeParameters\n ): void {\n if (!ContentstackLivePreview.isInitialized()) {\n removeFromOnChangeSubscribers(\n ContentstackLivePreview.onEntryChangeCallbacks,\n callback\n );\n return;\n }\n ContentstackLivePreview.previewConstructors.livePreview.unsubscribeOnEntryChange(\n callback\n );\n }\n\n /**\n * Retrieves the version of the SDK.\n * @returns The version of the SDK as a string.\n */\n static getSdkVersion(): string {\n return process?.env?.PACKAGE_VERSION!;\n }\n}\n\nexport default ContentstackLivePreview;\n"],"mappings":";;;AAAA,SAAS,MAAM,cAAc;AAE7B,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,OAAO,UAAU,2BAA2B;AAC5C,SAAS,qBAAqB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,qCAAqC;AAQ9C,SAAS,oBAAoB;AAE7B,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAEjC,IAAM,2BAAN,MAAM,yBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB1B,OAAO,KACH,aAAiC,gBAAgB,GACU;AAC3D,QAAI,OAAO,WAAW,aAAa;AAC/B,mBAAa,KAAK,4CAA4C;AAC9D,aAAO,QAAQ,QAAQ,yBAAwB,mBAAmB;AAAA,IACtE;AAGA,WAAO,QAAQ,UAAU;AACzB,wBAAoB;AAEpB,QAAI,yBAAwB,cAAc,GAAG;AACzC,mBAAa;AAAA,QACT;AAAA,MACJ;AACA,aAAO,QAAQ,QAAQ,yBAAwB,mBAAmB;AAAA,IACtE,OAAO;AACH,aAAO,yBAAwB,kBAAkB;AAAA,IACrD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,OAAe;AACtB,QAAI,CAAC,yBAAwB,cAAc,GAAG;AAC1C,0BAAoB;AAAA,IACxB;AACA,WAAO,OAAO,IAAI,EA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwCA,OAAO,yBACH,UACI;AACJ,QAAI,CAAC,yBAAwB,cAAc,GAAG;AAC1C;AAAA,QACI,yBAAwB;AAAA,QACxB;AAAA,MACJ;AACA;AAAA,IACJ;AACA,6BAAwB,oBAAoB,YAAY;AAAA,MACpD;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,gBAAwB;AAC3B,WAAO;AAAA,EACX;AACJ;AA9MM,yBACa,sBAKe,CAAC;AAAA;AAAA;AAAA;AAN7B,yBAWa,yBACX,CAAC;AAZT,IAAM,0BAAN;AAgNA,IAAO,wCAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/preview/contentstack-live-preview-HOC.ts"],"sourcesContent":["import { cloneDeep, isEmpty, pick } from \"lodash-es\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { getUserInitData } from \"../configManager/config.default\";\nimport Config, { updateConfigFromUrl } from \"../configManager/configManager\";\nimport LivePreview from \"../livePreview/live-preview\";\nimport { handlePageTraversal } from \"../livePreview/onPageTraversal\";\nimport { removeFromOnChangeSubscribers } from \"../livePreview/removeFromOnChangeSubscribers\";\nimport {\n OnEntryChangeCallback,\n OnEntryChangeCallbackSubscribers,\n OnEntryChangeCallbackUID,\n OnEntryChangeConfig,\n OnEntryChangeUnsubscribeParameters,\n} from \"../livePreview/types/onEntryChangeCallback.type\";\nimport { PublicLogger } from \"../logger/logger\";\nimport { handleWebCompare } from \"../timeline/compare/compare\";\nimport type { IExportedConfig, IInitData } from \"../types/types\";\nimport { VisualBuilder } from \"../visualBuilder\";\n\nclass ContentstackLivePreview {\n private static previewConstructors:\n | {\n livePreview: LivePreview;\n visualBuilder: VisualBuilder;\n }\n | Record<string, never> = {};\n\n /**\n * The subscribers for the onEntryChange event. We store them here when the SDK is not initialized.\n */\n private static onEntryChangeCallbacks: OnEntryChangeCallbackSubscribers =\n {};\n\n /**\n * Initializes the Live Preview SDK with the provided user configuration.\n * If the SDK is already initialized, subsequent calls to this method will return the existing SDK instance.\n * @param userConfig - The user configuration to initialize the SDK with. See {@link https://github.com/contentstack/live-preview-sdk/blob/main/docs/live-preview-configs.md#initconfig-iconfig|Live preview User config} for more details.\n * @returns A promise that resolves to the constructors of the Live Preview SDK.\n */\n static init(\n userConfig: Partial<IInitData> = getUserInitData()\n ): Promise<typeof ContentstackLivePreview.previewConstructors> {\n if (typeof window === \"undefined\") {\n PublicLogger.warn(\"The SDK is not initialized in the browser.\");\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n }\n\n // handle user config\n Config.replace(userConfig);\n updateConfigFromUrl();\n\n if (ContentstackLivePreview.isInitialized()) {\n PublicLogger.warn(\n \"You have already initialized the Live Preview SDK. So, any subsequent initialization returns the existing SDK instance.\"\n );\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n } else {\n return ContentstackLivePreview.initializePreview();\n }\n }\n\n /**\n * It is the live preview hash.\n * This hash could be used when data is fetched manually.\n */\n static get hash(): string {\n if (!ContentstackLivePreview.isInitialized()) {\n updateConfigFromUrl(); // check if we could extract from the URL\n }\n return Config.get().hash;\n }\n\n static get config(): IExportedConfig {\n if (!ContentstackLivePreview.isInitialized()) {\n updateConfigFromUrl(); // check if we could extract from the URL\n }\n const config = Config.get();\n const clonedConfig = cloneDeep(config);\n const configToShare = pick(clonedConfig, [\n 'ssr',\n 'enable',\n 'cleanCslpOnProduction',\n 'stackDetails',\n 'clientUrlParams',\n 'windowType',\n 'hash',\n 'editButton',\n 'mode',\n ]);\n return configToShare;\n }\n\n private static isInitialized(): boolean {\n return !isEmpty(ContentstackLivePreview.previewConstructors);\n }\n\n private static initializePreview() {\n ContentstackLivePreview.previewConstructors = {\n livePreview: new LivePreview(),\n visualBuilder: new VisualBuilder(),\n };\n\n // set up onEntryChange callbacks added when the SDK was not initialized\n const livePreview =\n ContentstackLivePreview.previewConstructors.livePreview;\n Object.entries(ContentstackLivePreview.onEntryChangeCallbacks).forEach(\n ([callbackUid, callback]) => {\n livePreview.subscribeToOnEntryChange(callback, callbackUid);\n }\n );\n\n ContentstackLivePreview.onEntryChangeCallbacks = {};\n\n handlePageTraversal();\n handleWebCompare();\n\n return Promise.resolve(ContentstackLivePreview.previewConstructors);\n }\n\n /**\n * Registers a callback function to be called when an entry changes.\n * @param onChangeCallback The callback function to be called when an entry changes.\n * @param config Optional configuration for the callback.\n * @param config.skipInitialRender If true, the callback will not be called when it is first registered.\n * @returns A unique identifier for the registered callback.\n *\n * @example\n * ```js\n * const callbackUid = ContentstackLivePreview.onEntryChange(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n */\n static onEntryChange(\n onChangeCallback: OnEntryChangeCallback,\n config: OnEntryChangeConfig = {}\n ): OnEntryChangeCallbackUID {\n const { skipInitialRender = false } = config;\n\n const callbackUid = uuidv4();\n\n if (ContentstackLivePreview.isInitialized()) {\n ContentstackLivePreview.previewConstructors.livePreview.subscribeToOnEntryChange(\n onChangeCallback,\n callbackUid\n );\n } else {\n ContentstackLivePreview.onEntryChangeCallbacks[callbackUid] =\n onChangeCallback;\n }\n\n if (!skipInitialRender) {\n onChangeCallback();\n }\n\n return callbackUid;\n }\n\n /**\n * Registers a callback function to be called when there is a change in the entry being edited in live preview mode. The difference between this and `onEntryChange` is that this callback will not be called when it is first registered.\n * @param onChangeCallback The callback function to be called when there is a change in the entry.\n * @returns A unique identifier for the registered callback.\n *\n * @example\n * ```js\n * const callbackUid = ContentstackLivePreview.onLiveEdit(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n */\n static onLiveEdit(\n onChangeCallback: OnEntryChangeCallback\n ): OnEntryChangeCallbackUID {\n return ContentstackLivePreview.onEntryChange(onChangeCallback, {\n skipInitialRender: true,\n });\n }\n\n /**\n * Unsubscribes from the entry change event.\n * @param callback - The callback function to be unsubscribed.\n *\n * @example\n * ```js\n * // unsubscribing using the Callback UID\n * const callbackUid = ContentstackLivePreview.onEntryChange(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n * @example\n * ```js\n * // unsubscribing using the callback function\n * const callback = () => {console.log(\"Entry changed\")};\n * ContentstackLivePreview.onEntryChange(callback);\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callback);\n * ```\n *\n * @example\n * ```js\n * // The same is applicable to onLiveEdit\n * const callbackUid = ContentstackLivePreview.onLiveEdit(() => {\n * console.log(\"Entry changed\");\n * });\n *\n * // Unsubscribe the callback\n * ContentstackLivePreview.unsubscribeOnEntryChange(callbackUid);\n * ```\n *\n *\n */\n static unsubscribeOnEntryChange(\n callback: OnEntryChangeUnsubscribeParameters\n ): void {\n if (!ContentstackLivePreview.isInitialized()) {\n removeFromOnChangeSubscribers(\n ContentstackLivePreview.onEntryChangeCallbacks,\n callback\n );\n return;\n }\n ContentstackLivePreview.previewConstructors.livePreview.unsubscribeOnEntryChange(\n callback\n );\n }\n\n /**\n * Retrieves the version of the SDK.\n * @returns The version of the SDK as a string.\n */\n static getSdkVersion(): string {\n return process?.env?.PACKAGE_VERSION!;\n }\n}\n\nexport default ContentstackLivePreview;"],"mappings":";;;AAAA,SAAS,WAAW,SAAS,YAAY;AACzC,SAAS,MAAM,cAAc;AAC7B,SAAS,uBAAuB;AAChC,OAAO,UAAU,2BAA2B;AAC5C,OAAO,iBAAiB;AACxB,SAAS,2BAA2B;AACpC,SAAS,qCAAqC;AAQ9C,SAAS,oBAAoB;AAC7B,SAAS,w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A,MACJ;AACA;AAAA,IACJ;AACA,6BAAwB,oBAAoB,YAAY;AAAA,MACpD;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,gBAAwB;AAC3B,WAAO;AAAA,EACX;AACJ;AAlOM,yBACa,sBAKe,CAAC;AAAA;AAAA;AAAA;AAN7B,yBAWa,yBACX,CAAC;AAZT,IAAM,0BAAN;AAoOA,IAAO,wCAAQ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/types.ts"],"sourcesContent":["export declare interface IEditEntrySearchParams {\n hash?: string;\n entry_uid?: string;\n content_type_uid?: string;\n /**\n * @deprecated pass this value as hash instead\n */\n live_preview?: string;\n}\n\nexport declare interface IClientUrlParams {\n protocol: \"http\" | \"https\";\n host: string;\n port: string | number;\n url: string;\n}\n\nexport declare interface IStackSdk {\n live_preview: { [key: string]: any } & Partial<IConfig>;\n [key: string]: any;\n environment: string;\n}\n\nexport declare interface IStackDetails {\n apiKey: string;\n environment: string;\n contentTypeUid: string;\n entryUid: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n masterLocale: string;\n}\n\nexport declare interface IInitStackDetails {\n apiKey: string;\n environment: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n}\n\nexport declare type ILivePreviewMode = \"builder\" | \"preview\";\n\n//? We kept it as number so that we could disable only the unrequired features,\n//? since the \"Builder\" mode will contain all the features of the \"Preview\" mode.\nexport enum ILivePreviewModeConfig {\n PREVIEW = 1,\n BUILDER = 2,\n}\n\nexport enum ILivePreviewWindowType {\n PREVIEW = \"preview\",\n BUILDER = \"builder\",\n INDEPENDENT = \"independent\",\n}\n\nexport declare interface IConfig {\n ssr: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: IStackDetails;\n clientUrlParams: IClientUrlParams;\n stackSdk: IStackSdk;\n onChange: () => void;\n runScriptsOnUpdate: boolean;\n windowType: ILivePreviewWindowType;\n hash: string;\n editButton: IConfigEditButton;\n mode: ILivePreviewModeConfig;\n elements: {\n highlightedElement: HTMLElement | null;\n };\n}\n\nexport declare interface IConfigEditButton {\n enable: boolean;\n exclude?: (\"insideLivePreviewPortal\" | \"outsideLivePreviewPortal\")[];\n includeByQueryParameter?: boolean;\n position?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\";\n}\n\nexport declare interface IInitData {\n ssr: boolean;\n runScriptsOnUpdate: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: Partial<IInitStackDetails>;\n clientUrlParams: Partial<Omit<IClientUrlParams, \"url\">>;\n stackSdk: IStackSdk;\n editButton: IConfigEditButton;\n mode: ILivePreviewMode;\n}\n\n// type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;\n\n// export type IInitData =\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// };\n\n// Post message types\n\nexport declare interface ILivePreviewMessageCommon {\n from: \"live-preview\";\n}\n\nexport declare interface IEditButtonPosition {\n upperBoundOfTooltip: number;\n leftBoundOfTooltip: number;\n}\n\n// end of Post message types\n\nexport interface IVisualBuilderInitEvent {\n windowType: ILivePreviewWindowType;\n stackDetails: {\n masterLocale: string;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDO,IAAK,yBAAL,kBAAKA,4BAAL;AACH,EAAAA,gDAAA,aAAU,KAAV;AACA,EAAAA,gDAAA,aAAU,KAAV;AAFQ,SAAAA;AAAA,GAAA;AAKL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,iBAAc;AAHN,SAAAA;AAAA,GAAA;","names":["ILivePreviewModeConfig","ILivePreviewWindowType"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/types/types.ts"],"sourcesContent":["export declare interface IEditEntrySearchParams {\n hash?: string;\n entry_uid?: string;\n content_type_uid?: string;\n /**\n * @deprecated pass this value as hash instead\n */\n live_preview?: string;\n}\n\nexport declare interface IClientUrlParams {\n protocol: \"http\" | \"https\";\n host: string;\n port: string | number;\n url: string;\n}\n\nexport declare interface IStackSdk {\n live_preview: { [key: string]: any } & Partial<IConfig>;\n [key: string]: any;\n environment: string;\n}\n\nexport declare interface IStackDetails {\n apiKey: string;\n environment: string;\n contentTypeUid: string;\n entryUid: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n masterLocale: string;\n}\n\nexport declare interface IInitStackDetails {\n apiKey: string;\n environment: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n}\n\nexport declare type ILivePreviewMode = \"builder\" | \"preview\";\n\n//? We kept it as number so that we could disable only the unrequired features,\n//? since the \"Builder\" mode will contain all the features of the \"Preview\" mode.\nexport enum ILivePreviewModeConfig {\n PREVIEW = 1,\n BUILDER = 2,\n}\n\nexport enum ILivePreviewWindowType {\n PREVIEW = \"preview\",\n BUILDER = \"builder\",\n INDEPENDENT = \"independent\",\n}\n\nexport declare interface IConfig {\n ssr: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: IStackDetails;\n clientUrlParams: IClientUrlParams;\n stackSdk: IStackSdk;\n onChange: () => void;\n runScriptsOnUpdate: boolean;\n windowType: ILivePreviewWindowType;\n hash: string;\n editButton: IConfigEditButton;\n mode: ILivePreviewModeConfig;\n elements: {\n highlightedElement: HTMLElement | null;\n };\n}\n\nexport declare interface IConfigEditButton {\n enable: boolean;\n exclude?: (\"insideLivePreviewPortal\" | \"outsideLivePreviewPortal\")[];\n includeByQueryParameter?: boolean;\n position?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\";\n}\n\nexport declare interface IInitData {\n ssr: boolean;\n runScriptsOnUpdate: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: Partial<IInitStackDetails>;\n clientUrlParams: Partial<Omit<IClientUrlParams, \"url\">>;\n stackSdk: IStackSdk;\n editButton: IConfigEditButton;\n mode: ILivePreviewMode;\n}\n\n// type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;\n\n// export type IInitData =\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// };\n\n// Post message types\n\nexport declare interface ILivePreviewMessageCommon {\n from: \"live-preview\";\n}\n\nexport declare interface IEditButtonPosition {\n upperBoundOfTooltip: number;\n leftBoundOfTooltip: number;\n}\n\n// end of Post message types\n\nexport interface IVisualBuilderInitEvent {\n windowType: ILivePreviewWindowType;\n stackDetails: {\n masterLocale: string;\n };\n}\n\nexport type IExportedConfig = Pick<\n IConfig,\n | \"ssr\"\n | \"enable\"\n | \"cleanCslpOnProduction\"\n | \"stackDetails\"\n | \"clientUrlParams\"\n | \"windowType\"\n | \"hash\"\n | \"editButton\"\n | \"mode\"\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDO,IAAK,yBAAL,kBAAKA,4BAAL;AACH,EAAAA,gDAAA,aAAU,KAAV;AACA,EAAAA,gDAAA,aAAU,KAAV;AAFQ,SAAAA;AAAA,GAAA;AAKL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,iBAAc;AAHN,SAAAA;AAAA,GAAA;","names":["ILivePreviewModeConfig","ILivePreviewWindowType"]}
|
|
@@ -110,5 +110,6 @@ interface IVisualBuilderInitEvent {
|
|
|
110
110
|
masterLocale: string;
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
+
type IExportedConfig = Pick<IConfig, "ssr" | "enable" | "cleanCslpOnProduction" | "stackDetails" | "clientUrlParams" | "windowType" | "hash" | "editButton" | "mode">;
|
|
113
114
|
|
|
114
|
-
export { type IClientUrlParams, type IConfig, type IConfigEditButton, type IEditButtonPosition, type IEditEntrySearchParams, type IInitData, type IInitStackDetails, type ILivePreviewMessageCommon, type ILivePreviewMode, ILivePreviewModeConfig, ILivePreviewWindowType, type IStackDetails, type IStackSdk, type IVisualBuilderInitEvent };
|
|
115
|
+
export { type IClientUrlParams, type IConfig, type IConfigEditButton, type IEditButtonPosition, type IEditEntrySearchParams, type IExportedConfig, type IInitData, type IInitStackDetails, type ILivePreviewMessageCommon, type ILivePreviewMode, ILivePreviewModeConfig, ILivePreviewWindowType, type IStackDetails, type IStackSdk, type IVisualBuilderInitEvent };
|
|
@@ -110,5 +110,6 @@ interface IVisualBuilderInitEvent {
|
|
|
110
110
|
masterLocale: string;
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
+
type IExportedConfig = Pick<IConfig, "ssr" | "enable" | "cleanCslpOnProduction" | "stackDetails" | "clientUrlParams" | "windowType" | "hash" | "editButton" | "mode">;
|
|
113
114
|
|
|
114
|
-
export { type IClientUrlParams, type IConfig, type IConfigEditButton, type IEditButtonPosition, type IEditEntrySearchParams, type IInitData, type IInitStackDetails, type ILivePreviewMessageCommon, type ILivePreviewMode, ILivePreviewModeConfig, ILivePreviewWindowType, type IStackDetails, type IStackSdk, type IVisualBuilderInitEvent };
|
|
115
|
+
export { type IClientUrlParams, type IConfig, type IConfigEditButton, type IEditButtonPosition, type IEditEntrySearchParams, type IExportedConfig, type IInitData, type IInitStackDetails, type ILivePreviewMessageCommon, type ILivePreviewMode, ILivePreviewModeConfig, ILivePreviewWindowType, type IStackDetails, type IStackSdk, type IVisualBuilderInitEvent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/types.ts"],"sourcesContent":["export declare interface IEditEntrySearchParams {\n hash?: string;\n entry_uid?: string;\n content_type_uid?: string;\n /**\n * @deprecated pass this value as hash instead\n */\n live_preview?: string;\n}\n\nexport declare interface IClientUrlParams {\n protocol: \"http\" | \"https\";\n host: string;\n port: string | number;\n url: string;\n}\n\nexport declare interface IStackSdk {\n live_preview: { [key: string]: any } & Partial<IConfig>;\n [key: string]: any;\n environment: string;\n}\n\nexport declare interface IStackDetails {\n apiKey: string;\n environment: string;\n contentTypeUid: string;\n entryUid: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n masterLocale: string;\n}\n\nexport declare interface IInitStackDetails {\n apiKey: string;\n environment: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n}\n\nexport declare type ILivePreviewMode = \"builder\" | \"preview\";\n\n//? We kept it as number so that we could disable only the unrequired features,\n//? since the \"Builder\" mode will contain all the features of the \"Preview\" mode.\nexport enum ILivePreviewModeConfig {\n PREVIEW = 1,\n BUILDER = 2,\n}\n\nexport enum ILivePreviewWindowType {\n PREVIEW = \"preview\",\n BUILDER = \"builder\",\n INDEPENDENT = \"independent\",\n}\n\nexport declare interface IConfig {\n ssr: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: IStackDetails;\n clientUrlParams: IClientUrlParams;\n stackSdk: IStackSdk;\n onChange: () => void;\n runScriptsOnUpdate: boolean;\n windowType: ILivePreviewWindowType;\n hash: string;\n editButton: IConfigEditButton;\n mode: ILivePreviewModeConfig;\n elements: {\n highlightedElement: HTMLElement | null;\n };\n}\n\nexport declare interface IConfigEditButton {\n enable: boolean;\n exclude?: (\"insideLivePreviewPortal\" | \"outsideLivePreviewPortal\")[];\n includeByQueryParameter?: boolean;\n position?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\";\n}\n\nexport declare interface IInitData {\n ssr: boolean;\n runScriptsOnUpdate: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: Partial<IInitStackDetails>;\n clientUrlParams: Partial<Omit<IClientUrlParams, \"url\">>;\n stackSdk: IStackSdk;\n editButton: IConfigEditButton;\n mode: ILivePreviewMode;\n}\n\n// type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;\n\n// export type IInitData =\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// };\n\n// Post message types\n\nexport declare interface ILivePreviewMessageCommon {\n from: \"live-preview\";\n}\n\nexport declare interface IEditButtonPosition {\n upperBoundOfTooltip: number;\n leftBoundOfTooltip: number;\n}\n\n// end of Post message types\n\nexport interface IVisualBuilderInitEvent {\n windowType: ILivePreviewWindowType;\n stackDetails: {\n masterLocale: string;\n };\n}\n"],"mappings":";;;AAsDO,IAAK,yBAAL,kBAAKA,4BAAL;AACH,EAAAA,gDAAA,aAAU,KAAV;AACA,EAAAA,gDAAA,aAAU,KAAV;AAFQ,SAAAA;AAAA,GAAA;AAKL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,iBAAc;AAHN,SAAAA;AAAA,GAAA;","names":["ILivePreviewModeConfig","ILivePreviewWindowType"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/types/types.ts"],"sourcesContent":["export declare interface IEditEntrySearchParams {\n hash?: string;\n entry_uid?: string;\n content_type_uid?: string;\n /**\n * @deprecated pass this value as hash instead\n */\n live_preview?: string;\n}\n\nexport declare interface IClientUrlParams {\n protocol: \"http\" | \"https\";\n host: string;\n port: string | number;\n url: string;\n}\n\nexport declare interface IStackSdk {\n live_preview: { [key: string]: any } & Partial<IConfig>;\n [key: string]: any;\n environment: string;\n}\n\nexport declare interface IStackDetails {\n apiKey: string;\n environment: string;\n contentTypeUid: string;\n entryUid: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n masterLocale: string;\n}\n\nexport declare interface IInitStackDetails {\n apiKey: string;\n environment: string;\n branch: string;\n /**\n * This locale is currently used by the visual builder to\n * redirect to the correct locale if the no data-cslp tag\n * is present in the HTML to extract the locale.\n */\n locale: string;\n}\n\nexport declare type ILivePreviewMode = \"builder\" | \"preview\";\n\n//? We kept it as number so that we could disable only the unrequired features,\n//? since the \"Builder\" mode will contain all the features of the \"Preview\" mode.\nexport enum ILivePreviewModeConfig {\n PREVIEW = 1,\n BUILDER = 2,\n}\n\nexport enum ILivePreviewWindowType {\n PREVIEW = \"preview\",\n BUILDER = \"builder\",\n INDEPENDENT = \"independent\",\n}\n\nexport declare interface IConfig {\n ssr: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: IStackDetails;\n clientUrlParams: IClientUrlParams;\n stackSdk: IStackSdk;\n onChange: () => void;\n runScriptsOnUpdate: boolean;\n windowType: ILivePreviewWindowType;\n hash: string;\n editButton: IConfigEditButton;\n mode: ILivePreviewModeConfig;\n elements: {\n highlightedElement: HTMLElement | null;\n };\n}\n\nexport declare interface IConfigEditButton {\n enable: boolean;\n exclude?: (\"insideLivePreviewPortal\" | \"outsideLivePreviewPortal\")[];\n includeByQueryParameter?: boolean;\n position?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\";\n}\n\nexport declare interface IInitData {\n ssr: boolean;\n runScriptsOnUpdate: boolean;\n enable: boolean;\n /**\n * @default false\n */\n debug: boolean;\n cleanCslpOnProduction: boolean;\n stackDetails: Partial<IInitStackDetails>;\n clientUrlParams: Partial<Omit<IClientUrlParams, \"url\">>;\n stackSdk: IStackSdk;\n editButton: IConfigEditButton;\n mode: ILivePreviewMode;\n}\n\n// type PickPartial<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;\n\n// export type IInitData =\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr?: true;\n// stackSdk?: IStackSdk;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails?: Partial<IInitStackDetails>;\n// clientUrlParams?: Partial<Omit<IClientUrlParams, \"url\">>;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode?: \"preview\";\n// }\n// | {\n// ssr: false;\n// runScriptsOnUpdate?: boolean;\n// enable?: boolean;\n// cleanCslpOnProduction?: boolean;\n// stackDetails: PickPartial<IInitStackDetails, \"branch\">;\n// clientUrlParams: PickPartial<\n// Omit<IClientUrlParams, \"url\">,\n// \"port\" | \"protocol\"\n// >;\n// stackSdk: IStackSdk;\n// editButton?: IConfigEditButton;\n// mode: \"builder\";\n// };\n\n// Post message types\n\nexport declare interface ILivePreviewMessageCommon {\n from: \"live-preview\";\n}\n\nexport declare interface IEditButtonPosition {\n upperBoundOfTooltip: number;\n leftBoundOfTooltip: number;\n}\n\n// end of Post message types\n\nexport interface IVisualBuilderInitEvent {\n windowType: ILivePreviewWindowType;\n stackDetails: {\n masterLocale: string;\n };\n}\n\nexport type IExportedConfig = Pick<\n IConfig,\n | \"ssr\"\n | \"enable\"\n | \"cleanCslpOnProduction\"\n | \"stackDetails\"\n | \"clientUrlParams\"\n | \"windowType\"\n | \"hash\"\n | \"editButton\"\n | \"mode\"\n>;\n"],"mappings":";;;AAsDO,IAAK,yBAAL,kBAAKA,4BAAL;AACH,EAAAA,gDAAA,aAAU,KAAV;AACA,EAAAA,gDAAA,aAAU,KAAV;AAFQ,SAAAA;AAAA,GAAA;AAKL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,aAAU;AACV,EAAAA,wBAAA,iBAAc;AAHN,SAAAA;AAAA,GAAA;","names":["ILivePreviewModeConfig","ILivePreviewWindowType"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/addLivePreviewQueryTags.ts
|
|
21
|
+
var addLivePreviewQueryTags_exports = {};
|
|
22
|
+
__export(addLivePreviewQueryTags_exports, {
|
|
23
|
+
addLivePreviewQueryTags: () => addLivePreviewQueryTags
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(addLivePreviewQueryTags_exports);
|
|
26
|
+
var import_logger = require("../logger/logger.cjs");
|
|
27
|
+
function addLivePreviewQueryTags(link) {
|
|
28
|
+
try {
|
|
29
|
+
const docUrl = new URL(document.location.href);
|
|
30
|
+
const newUrl = new URL(link);
|
|
31
|
+
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
32
|
+
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
33
|
+
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
34
|
+
if (livePreviewHash && ctUid && entryUid) {
|
|
35
|
+
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
36
|
+
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
37
|
+
newUrl.searchParams.set("entry_uid", entryUid);
|
|
38
|
+
}
|
|
39
|
+
return newUrl.href;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
import_logger.PublicLogger.error("Error while adding live preview to URL");
|
|
42
|
+
return link;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
addLivePreviewQueryTags
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=addLivePreviewQueryTags.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/addLivePreviewQueryTags.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\nexport function addLivePreviewQueryTags(link: string): string {\n try {\n const docUrl: URL = new URL(document.location.href);\n const newUrl: URL = new URL(link);\n const livePreviewHash: string | null =\n docUrl.searchParams.get(\"live_preview\");\n const ctUid: string | null =\n docUrl.searchParams.get(\"content_type_uid\");\n const entryUid: string | null = docUrl.searchParams.get(\"entry_uid\");\n if (livePreviewHash && ctUid && entryUid) {\n newUrl.searchParams.set(\"live_preview\", livePreviewHash);\n newUrl.searchParams.set(\"content_type_uid\", ctUid);\n newUrl.searchParams.set(\"entry_uid\", entryUid);\n }\n return newUrl.href;\n } catch (error) {\n PublicLogger.error(\"Error while adding live preview to URL\");\n return link;\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AACtB,SAAS,wBAAwB,MAAsB;AAC1D,MAAI;AACA,UAAM,SAAc,IAAI,IAAI,SAAS,SAAS,IAAI;AAClD,UAAM,SAAc,IAAI,IAAI,IAAI;AAChC,UAAM,kBACF,OAAO,aAAa,IAAI,cAAc;AAC1C,UAAM,QACF,OAAO,aAAa,IAAI,kBAAkB;AAC9C,UAAM,WAA0B,OAAO,aAAa,IAAI,WAAW;AACnE,QAAI,mBAAmB,SAAS,UAAU;AACtC,aAAO,aAAa,IAAI,gBAAgB,eAAe;AACvD,aAAO,aAAa,IAAI,oBAAoB,KAAK;AACjD,aAAO,aAAa,IAAI,aAAa,QAAQ;AAAA,IACjD;AACA,WAAO,OAAO;AAAA,EAClB,SAAS,OAAO;AACZ,+BAAa,MAAM,wCAAwC;AAC3D,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/addLivePreviewQueryTags.ts
|
|
4
|
+
import { PublicLogger } from "../logger/logger.js";
|
|
5
|
+
function addLivePreviewQueryTags(link) {
|
|
6
|
+
try {
|
|
7
|
+
const docUrl = new URL(document.location.href);
|
|
8
|
+
const newUrl = new URL(link);
|
|
9
|
+
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
10
|
+
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
11
|
+
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
12
|
+
if (livePreviewHash && ctUid && entryUid) {
|
|
13
|
+
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
14
|
+
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
15
|
+
newUrl.searchParams.set("entry_uid", entryUid);
|
|
16
|
+
}
|
|
17
|
+
return newUrl.href;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
PublicLogger.error("Error while adding live preview to URL");
|
|
20
|
+
return link;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
addLivePreviewQueryTags
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=addLivePreviewQueryTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/addLivePreviewQueryTags.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\nexport function addLivePreviewQueryTags(link: string): string {\n try {\n const docUrl: URL = new URL(document.location.href);\n const newUrl: URL = new URL(link);\n const livePreviewHash: string | null =\n docUrl.searchParams.get(\"live_preview\");\n const ctUid: string | null =\n docUrl.searchParams.get(\"content_type_uid\");\n const entryUid: string | null = docUrl.searchParams.get(\"entry_uid\");\n if (livePreviewHash && ctUid && entryUid) {\n newUrl.searchParams.set(\"live_preview\", livePreviewHash);\n newUrl.searchParams.set(\"content_type_uid\", ctUid);\n newUrl.searchParams.set(\"entry_uid\", entryUid);\n }\n return newUrl.href;\n } catch (error) {\n PublicLogger.error(\"Error while adding live preview to URL\");\n return link;\n }\n}"],"mappings":";;;AAAA,SAAS,oBAAoB;AACtB,SAAS,wBAAwB,MAAsB;AAC1D,MAAI;AACA,UAAM,SAAc,IAAI,IAAI,SAAS,SAAS,IAAI;AAClD,UAAM,SAAc,IAAI,IAAI,IAAI;AAChC,UAAM,kBACF,OAAO,aAAa,IAAI,cAAc;AAC1C,UAAM,QACF,OAAO,aAAa,IAAI,kBAAkB;AAC9C,UAAM,WAA0B,OAAO,aAAa,IAAI,WAAW;AACnE,QAAI,mBAAmB,SAAS,UAAU;AACtC,aAAO,aAAa,IAAI,gBAAgB,eAAe;AACvD,aAAO,aAAa,IAAI,oBAAoB,KAAK;AACjD,aAAO,aAAa,IAAI,aAAa,QAAQ;AAAA,IACjD;AACA,WAAO,OAAO;AAAA,EAClB,SAAS,OAAO;AACZ,iBAAa,MAAM,wCAAwC;AAC3D,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -20,41 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils/index.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
-
addLivePreviewQueryTags: () => addLivePreviewQueryTags,
|
|
23
|
+
addLivePreviewQueryTags: () => import_addLivePreviewQueryTags.addLivePreviewQueryTags,
|
|
24
24
|
addParamsToUrl: () => addParamsToUrl,
|
|
25
25
|
hasWindow: () => hasWindow,
|
|
26
26
|
isOpeningInTimeline: () => isOpeningInTimeline
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(utils_exports);
|
|
29
|
-
var
|
|
29
|
+
var import_addLivePreviewQueryTags = require("./addLivePreviewQueryTags.cjs");
|
|
30
30
|
function hasWindow() {
|
|
31
31
|
return typeof window !== "undefined";
|
|
32
32
|
}
|
|
33
|
-
function addLivePreviewQueryTags(link) {
|
|
34
|
-
try {
|
|
35
|
-
const docUrl = new URL(document.location.href);
|
|
36
|
-
const newUrl = new URL(link);
|
|
37
|
-
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
38
|
-
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
39
|
-
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
40
|
-
if (livePreviewHash && ctUid && entryUid) {
|
|
41
|
-
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
42
|
-
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
43
|
-
newUrl.searchParams.set("entry_uid", entryUid);
|
|
44
|
-
}
|
|
45
|
-
return newUrl.href;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
import_logger.PublicLogger.error("Error while adding live preview to URL");
|
|
48
|
-
return link;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
33
|
function addParamsToUrl() {
|
|
52
34
|
window.addEventListener("click", (event) => {
|
|
53
35
|
const target = event.target;
|
|
54
36
|
const targetHref = target.href;
|
|
55
37
|
const docOrigin = document.location.origin;
|
|
56
38
|
if (targetHref && targetHref.includes(docOrigin) && !targetHref.includes("live_preview")) {
|
|
57
|
-
const newUrl = addLivePreviewQueryTags(target.href);
|
|
39
|
+
const newUrl = (0, import_addLivePreviewQueryTags.addLivePreviewQueryTags)(target.href);
|
|
58
40
|
event.target.href = newUrl || target.href;
|
|
59
41
|
}
|
|
60
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\nimport { addLivePreviewQueryTags } from \"./addLivePreviewQueryTags\";\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\";\n}\nexport { addLivePreviewQueryTags };\nexport function addParamsToUrl() {\n // Setting the query params to all the click events related to current domain\n window.addEventListener(\"click\", (event: any) => {\n const target: any = event.target;\n const targetHref: string | any = target.href;\n const docOrigin: string = document.location.origin;\n if (\n targetHref &&\n targetHref.includes(docOrigin) &&\n !targetHref.includes(\"live_preview\")\n ) {\n const newUrl = addLivePreviewQueryTags(target.href);\n event.target.href = newUrl || target.href;\n }\n });\n}\nexport function isOpeningInTimeline(): boolean {\n if (hasWindow()) {\n const urlParams = new URLSearchParams(window.location.search);\n const previewTimestamp = urlParams.get(\"preview_timestamp\");\n return !!previewTimestamp;\n }\n return false;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qCAAwC;AACjC,SAAS,YAAqB;AACjC,SAAO,OAAO,WAAW;AAC7B;AAEO,SAAS,iBAAiB;AAE7B,SAAO,iBAAiB,SAAS,CAAC,UAAe;AAC7C,UAAM,SAAc,MAAM;AAC1B,UAAM,aAA2B,OAAO;AACxC,UAAM,YAAoB,SAAS,SAAS;AAC5C,QACI,cACA,WAAW,SAAS,SAAS,KAC7B,CAAC,WAAW,SAAS,cAAc,GACrC;AACE,YAAM,aAAS,wDAAwB,OAAO,IAAI;AAClD,YAAM,OAAO,OAAO,UAAU,OAAO;AAAA,IACzC;AAAA,EACJ,CAAC;AACL;AACO,SAAS,sBAA+B;AAC3C,MAAI,UAAU,GAAG;AACb,UAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC5D,UAAM,mBAAmB,UAAU,IAAI,mBAAmB;AAC1D,WAAO,CAAC,CAAC;AAAA,EACb;AACA,SAAO;AACX;","names":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { addLivePreviewQueryTags } from './addLivePreviewQueryTags.cjs';
|
|
2
|
+
|
|
1
3
|
declare function hasWindow(): boolean;
|
|
2
|
-
|
|
4
|
+
|
|
3
5
|
declare function addParamsToUrl(): void;
|
|
4
6
|
declare function isOpeningInTimeline(): boolean;
|
|
5
7
|
|
|
6
|
-
export {
|
|
8
|
+
export { addParamsToUrl, hasWindow, isOpeningInTimeline };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { addLivePreviewQueryTags } from './addLivePreviewQueryTags.js';
|
|
2
|
+
|
|
1
3
|
declare function hasWindow(): boolean;
|
|
2
|
-
|
|
4
|
+
|
|
3
5
|
declare function addParamsToUrl(): void;
|
|
4
6
|
declare function isOpeningInTimeline(): boolean;
|
|
5
7
|
|
|
6
|
-
export {
|
|
8
|
+
export { addParamsToUrl, hasWindow, isOpeningInTimeline };
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import "../chunk-5WRI5ZAA.js";
|
|
2
2
|
|
|
3
3
|
// src/utils/index.ts
|
|
4
|
-
import {
|
|
4
|
+
import { addLivePreviewQueryTags } from "./addLivePreviewQueryTags.js";
|
|
5
5
|
function hasWindow() {
|
|
6
6
|
return typeof window !== "undefined";
|
|
7
7
|
}
|
|
8
|
-
function addLivePreviewQueryTags(link) {
|
|
9
|
-
try {
|
|
10
|
-
const docUrl = new URL(document.location.href);
|
|
11
|
-
const newUrl = new URL(link);
|
|
12
|
-
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
13
|
-
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
14
|
-
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
15
|
-
if (livePreviewHash && ctUid && entryUid) {
|
|
16
|
-
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
17
|
-
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
18
|
-
newUrl.searchParams.set("entry_uid", entryUid);
|
|
19
|
-
}
|
|
20
|
-
return newUrl.href;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
PublicLogger.error("Error while adding live preview to URL");
|
|
23
|
-
return link;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
8
|
function addParamsToUrl() {
|
|
27
9
|
window.addEventListener("click", (event) => {
|
|
28
10
|
const target = event.target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import { PublicLogger } from \"../logger/logger\";\nimport { addLivePreviewQueryTags } from \"./addLivePreviewQueryTags\";\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\";\n}\nexport { addLivePreviewQueryTags };\nexport function addParamsToUrl() {\n // Setting the query params to all the click events related to current domain\n window.addEventListener(\"click\", (event: any) => {\n const target: any = event.target;\n const targetHref: string | any = target.href;\n const docOrigin: string = document.location.origin;\n if (\n targetHref &&\n targetHref.includes(docOrigin) &&\n !targetHref.includes(\"live_preview\")\n ) {\n const newUrl = addLivePreviewQueryTags(target.href);\n event.target.href = newUrl || target.href;\n }\n });\n}\nexport function isOpeningInTimeline(): boolean {\n if (hasWindow()) {\n const urlParams = new URLSearchParams(window.location.search);\n const previewTimestamp = urlParams.get(\"preview_timestamp\");\n return !!previewTimestamp;\n }\n return false;\n}"],"mappings":";;;AACA,SAAS,+BAA+B;AACjC,SAAS,YAAqB;AACjC,SAAO,OAAO,WAAW;AAC7B;AAEO,SAAS,iBAAiB;AAE7B,SAAO,iBAAiB,SAAS,CAAC,UAAe;AAC7C,UAAM,SAAc,MAAM;AAC1B,UAAM,aAA2B,OAAO;AACxC,UAAM,YAAoB,SAAS,SAAS;AAC5C,QACI,cACA,WAAW,SAAS,SAAS,KAC7B,CAAC,WAAW,SAAS,cAAc,GACrC;AACE,YAAM,SAAS,wBAAwB,OAAO,IAAI;AAClD,YAAM,OAAO,OAAO,UAAU,OAAO;AAAA,IACzC;AAAA,EACJ,CAAC;AACL;AACO,SAAS,sBAA+B;AAC3C,MAAI,UAAU,GAAG;AACb,UAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC5D,UAAM,mBAAmB,UAAU,IAAI,mBAAmB;AAC1D,WAAO,CAAC,CAAC;AAAA,EACb;AACA,SAAO;AACX;","names":[]}
|
|
@@ -32,6 +32,7 @@ var FieldRevertComponent_exports = {};
|
|
|
32
32
|
__export(FieldRevertComponent_exports, {
|
|
33
33
|
BASE_VARIANT_STATUS: () => BASE_VARIANT_STATUS,
|
|
34
34
|
FieldRevertComponent: () => FieldRevertComponent,
|
|
35
|
+
VariantRevertDropdown: () => VariantRevertDropdown,
|
|
35
36
|
getFieldVariantStatus: () => getFieldVariantStatus
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(FieldRevertComponent_exports);
|
|
@@ -39,6 +40,9 @@ var import_classnames = __toESM(require("classnames"), 1);
|
|
|
39
40
|
var import_compat = require("preact/compat");
|
|
40
41
|
var import_visualBuilder = require("../../visualBuilder.style.cjs");
|
|
41
42
|
var import_visualBuilderPostMessage = __toESM(require("../../utils/visualBuilderPostMessage.cjs"), 1);
|
|
43
|
+
var import_variant = require("../icons/variant.cjs");
|
|
44
|
+
var import_icons = require("../icons/index.cjs");
|
|
45
|
+
var import_useHandleOutsideClick = __toESM(require("./useHandleOutsideClick.cjs"), 1);
|
|
42
46
|
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
43
47
|
var BASE_VARIANT_STATUS = {
|
|
44
48
|
isAddedInstances: false,
|
|
@@ -67,18 +71,6 @@ var FieldRevertComponent = (props) => {
|
|
|
67
71
|
isOpen,
|
|
68
72
|
closeDropdown
|
|
69
73
|
} = props;
|
|
70
|
-
const dropdownRef = (0, import_compat.useRef)(null);
|
|
71
|
-
(0, import_compat.useEffect)(() => {
|
|
72
|
-
const handleClickOutside = (event) => {
|
|
73
|
-
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
74
|
-
closeDropdown();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
78
|
-
return () => {
|
|
79
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
80
|
-
};
|
|
81
|
-
}, []);
|
|
82
74
|
const getDropdownItems = () => {
|
|
83
75
|
const {
|
|
84
76
|
isAddedInstances,
|
|
@@ -154,11 +146,11 @@ var FieldRevertComponent = (props) => {
|
|
|
154
146
|
"variant-field-revert-component",
|
|
155
147
|
(0, import_visualBuilder.visualBuilderStyles)()["variant-field-revert-component"]
|
|
156
148
|
),
|
|
157
|
-
ref: dropdownRef,
|
|
158
149
|
onClick: (e) => e.stopPropagation(),
|
|
159
150
|
children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
151
|
"div",
|
|
161
152
|
{
|
|
153
|
+
"data-testid": "variant-field-revert-component__dropdown-content",
|
|
162
154
|
className: (0, import_classnames.default)(
|
|
163
155
|
"variant-field-revert-component__dropdown-content",
|
|
164
156
|
(0, import_visualBuilder.visualBuilderStyles)()["variant-field-revert-component__dropdown-content"]
|
|
@@ -185,10 +177,65 @@ var FieldRevertComponent = (props) => {
|
|
|
185
177
|
}
|
|
186
178
|
);
|
|
187
179
|
};
|
|
180
|
+
var VariantRevertDropdown = (props) => {
|
|
181
|
+
const {
|
|
182
|
+
closeDropdown,
|
|
183
|
+
invertTooltipPosition,
|
|
184
|
+
toggleVariantDropdown,
|
|
185
|
+
variantStatus = BASE_VARIANT_STATUS
|
|
186
|
+
} = props;
|
|
187
|
+
const dropdownRef = (0, import_compat.useRef)(null);
|
|
188
|
+
(0, import_useHandleOutsideClick.default)(dropdownRef, closeDropdown);
|
|
189
|
+
const hasDropdownItems = Object.values(variantStatus).some(
|
|
190
|
+
(value) => value
|
|
191
|
+
);
|
|
192
|
+
const buttonClassNames = (0, import_classnames.default)(
|
|
193
|
+
"visual-builder__button visual-builder__button--secondary",
|
|
194
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
|
|
195
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--secondary"],
|
|
196
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__tooltip"],
|
|
197
|
+
{
|
|
198
|
+
"visual-builder__tooltip--bottom": invertTooltipPosition,
|
|
199
|
+
[(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__tooltip--bottom"]]: invertTooltipPosition
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
if (!hasDropdownItems) {
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
|
+
"button",
|
|
205
|
+
{
|
|
206
|
+
className: (0, import_classnames.default)(buttonClassNames),
|
|
207
|
+
style: { padding: "6px" },
|
|
208
|
+
"data-tooltip": "Variant",
|
|
209
|
+
"data-testid": `visual-builder-canvas-variant-icon`,
|
|
210
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_variant.VariantIcon, {})
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: dropdownRef, children: [
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
className: (0, import_classnames.default)(
|
|
219
|
+
buttonClassNames,
|
|
220
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__variant-button"]
|
|
221
|
+
),
|
|
222
|
+
"data-tooltip": "Variant Revert",
|
|
223
|
+
"data-testid": `visual-builder-canvas-variant-revert`,
|
|
224
|
+
onClick: toggleVariantDropdown,
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_variant.VariantIcon, {}),
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CaretIcon, { open: props.isOpen })
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldRevertComponent, { ...props })
|
|
232
|
+
] });
|
|
233
|
+
};
|
|
188
234
|
// Annotate the CommonJS export names for ESM import in node:
|
|
189
235
|
0 && (module.exports = {
|
|
190
236
|
BASE_VARIANT_STATUS,
|
|
191
237
|
FieldRevertComponent,
|
|
238
|
+
VariantRevertDropdown,
|
|
192
239
|
getFieldVariantStatus
|
|
193
240
|
});
|
|
194
241
|
//# sourceMappingURL=FieldRevertComponent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/visualBuilder/components/FieldRevert/FieldRevertComponent.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React, { useRef, useEffect } from \"preact/compat\";\nimport { visualBuilderStyles } from \"../../visualBuilder.style\";\nimport visualBuilderPostMessage from \"../../utils/visualBuilderPostMessage\";\nimport { CslpData } from \"../../../cslp/types/cslp.types\";\n\nexport interface IVariantStatus {\n fieldLevelCustomizations: boolean;\n isBaseModified: boolean;\n isAddedInstances: boolean;\n isDeletedInstances: boolean;\n isOrderChanged: boolean;\n}\n\nexport type TFieldRevertActionCallback =\n | \"revert_to_base_entry_value\"\n | \"revert_added_instances\"\n | \"restore_deleted_instances\"\n | \"reset_field_level_customizations\"\n | \"restore_sorted_instances\";\n\ninterface FieldRevertComponentProps {\n fieldDataName: string;\n fieldMetadata: CslpData;\n isOpen: boolean;\n closeDropdown: () => void;\n variantStatus?: IVariantStatus;\n}\n\ninterface IItem {\n label: string;\n action: TFieldRevertActionCallback;\n id: string;\n testId: string;\n fieldDataName: string;\n}\n\nexport const BASE_VARIANT_STATUS: IVariantStatus = {\n isAddedInstances: false,\n isBaseModified: false,\n isDeletedInstances: false,\n isOrderChanged: false,\n fieldLevelCustomizations: false,\n};\n\nexport async function getFieldVariantStatus(\n fieldMetadata: CslpData\n): Promise<IVariantStatus | undefined> {\n try {\n const result = await visualBuilderPostMessage?.send<IVariantStatus>(\n \"get-field-variant-status\",\n fieldMetadata\n );\n return result;\n } catch (error) {\n console.error(\"Failed to get field variant status:\", error);\n }\n}\n\nexport const FieldRevertComponent = (props: FieldRevertComponentProps) => {\n const {\n fieldDataName,\n fieldMetadata,\n variantStatus = BASE_VARIANT_STATUS,\n isOpen,\n closeDropdown,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node)\n ) {\n closeDropdown();\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, []);\n\n const getDropdownItems = () => {\n const {\n isAddedInstances,\n isDeletedInstances,\n isBaseModified,\n isOrderChanged,\n fieldLevelCustomizations,\n } = variantStatus;\n\n const dropdownItems: IItem[] = [];\n\n if (isBaseModified) {\n dropdownItems.push({\n label: \"Revert to base entry value\",\n action: \"revert_to_base_entry_value\",\n id: `iframe-cs-variant-field-${fieldDataName}-revert`,\n testId: `iframe-cs-variant-field-${fieldDataName}-revert`,\n fieldDataName,\n });\n }\n\n if (isAddedInstances) {\n dropdownItems.push({\n label: \"Revert added instances\",\n action: \"revert_added_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-revert-added-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-revert-added-instances`,\n fieldDataName,\n });\n }\n\n if (isDeletedInstances) {\n dropdownItems.push({\n label: \"Restore deleted instances\",\n action: \"restore_deleted_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-restore-deleted-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-restore-deleted-instances`,\n fieldDataName,\n });\n }\n\n if (fieldLevelCustomizations) {\n dropdownItems.push({\n label: \"Reset field-level customizations\",\n action: \"reset_field_level_customizations\",\n id: `iframe-cs-variant-field-${fieldDataName}-reset-field-level-customizations`,\n testId: `iframe-cs-variant-field-${fieldDataName}-reset-field-level-customizations`,\n fieldDataName,\n });\n }\n\n if (isOrderChanged) {\n dropdownItems.push({\n label: \"Restore sorted instances\",\n action: \"restore_sorted_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-restore-sorted-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-restore-sorted-instances`,\n fieldDataName,\n });\n }\n\n return dropdownItems;\n };\n\n const dropdownItems = getDropdownItems();\n\n function handleOnClick(item: IItem) {\n const { fieldDataName, action } = item;\n visualBuilderPostMessage?.send(\"send-variant-revert-action-trigger\", {\n fieldDataName,\n action,\n euid: fieldMetadata.entry_uid,\n ct_uid: fieldMetadata.content_type_uid,\n locale: fieldMetadata.locale,\n });\n }\n\n return (\n <div\n className={classNames(\n \"variant-field-revert-component\",\n visualBuilderStyles()[\"variant-field-revert-component\"]\n )}\n ref={dropdownRef}\n onClick={(e) => e.stopPropagation()}\n >\n {isOpen && (\n <div\n className={classNames(\n \"variant-field-revert-component__dropdown-content\",\n visualBuilderStyles()[\n \"variant-field-revert-component__dropdown-content\"\n ]\n )}\n >\n {dropdownItems.map((item) => (\n <div\n className={classNames(\n \"variant-field-revert-component__dropdown-content__list-item\",\n visualBuilderStyles()[\n \"variant-field-revert-component__dropdown-content__list-item\"\n ]\n )}\n onClick={(e) => {\n e.preventDefault();\n handleOnClick(item);\n closeDropdown();\n }}\n key={item.id}\n data-testid={item.testId}\n >\n <span>{item.label}</span>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuB;AACvB,oBAAyC;AACzC,2BAAoC;AACpC,sCAAqC;AAiMT;AA/JrB,IAAM,sBAAsC;AAAA,EAC/C,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,0BAA0B;AAC9B;AAEA,eAAsB,sBAClB,eACmC;AA/CvC;AAgDI,MAAI;AACA,UAAM,SAAS,QAAM,qCAAAA,YAAA,mBAA0B;AAAA,MAC3C;AAAA,MACA;AAAA;AAEJ,WAAO;AAAA,EACX,SAAS,OAAO;AACZ,YAAQ,MAAM,uCAAuC,KAAK;AAA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UAId,CACH;AAAA;AAAA,MACL;AAAA;AAAA,EAER;AAER;","names":["visualBuilderPostMessage","dropdownItems","fieldDataName","classNames"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/visualBuilder/components/FieldRevert/FieldRevertComponent.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React, { useRef, useEffect } from \"preact/compat\";\nimport { visualBuilderStyles } from \"../../visualBuilder.style\";\nimport visualBuilderPostMessage from \"../../utils/visualBuilderPostMessage\";\nimport { CslpData } from \"../../../cslp/types/cslp.types\";\nimport { VariantIcon } from \"../icons/variant\";\nimport { CaretIcon } from \"../icons\";\nimport useHandleOutsideClick from \"./useHandleOutsideClick\";\n\nexport interface IVariantStatus {\n fieldLevelCustomizations: boolean;\n isBaseModified: boolean;\n isAddedInstances: boolean;\n isDeletedInstances: boolean;\n isOrderChanged: boolean;\n}\n\nexport type TFieldRevertActionCallback =\n | \"revert_to_base_entry_value\"\n | \"revert_added_instances\"\n | \"restore_deleted_instances\"\n | \"reset_field_level_customizations\"\n | \"restore_sorted_instances\";\n\ninterface FieldRevertComponentProps {\n fieldDataName: string;\n fieldMetadata: CslpData;\n isOpen: boolean;\n closeDropdown: () => void;\n variantStatus?: IVariantStatus;\n}\n\ninterface IItem {\n label: string;\n action: TFieldRevertActionCallback;\n id: string;\n testId: string;\n fieldDataName: string;\n}\n\nexport const BASE_VARIANT_STATUS: IVariantStatus = {\n isAddedInstances: false,\n isBaseModified: false,\n isDeletedInstances: false,\n isOrderChanged: false,\n fieldLevelCustomizations: false,\n};\n\nexport async function getFieldVariantStatus(\n fieldMetadata: CslpData\n): Promise<IVariantStatus | undefined> {\n try {\n const result = await visualBuilderPostMessage?.send<IVariantStatus>(\n \"get-field-variant-status\",\n fieldMetadata\n );\n return result;\n } catch (error) {\n console.error(\"Failed to get field variant status:\", error);\n }\n}\n\nexport const FieldRevertComponent = (props: FieldRevertComponentProps) => {\n const {\n fieldDataName,\n fieldMetadata,\n variantStatus = BASE_VARIANT_STATUS,\n isOpen,\n closeDropdown,\n } = props;\n\n const getDropdownItems = () => {\n const {\n isAddedInstances,\n isDeletedInstances,\n isBaseModified,\n isOrderChanged,\n fieldLevelCustomizations,\n } = variantStatus;\n\n const dropdownItems: IItem[] = [];\n\n if (isBaseModified) {\n dropdownItems.push({\n label: \"Revert to base entry value\",\n action: \"revert_to_base_entry_value\",\n id: `iframe-cs-variant-field-${fieldDataName}-revert`,\n testId: `iframe-cs-variant-field-${fieldDataName}-revert`,\n fieldDataName,\n });\n }\n\n if (isAddedInstances) {\n dropdownItems.push({\n label: \"Revert added instances\",\n action: \"revert_added_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-revert-added-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-revert-added-instances`,\n fieldDataName,\n });\n }\n\n if (isDeletedInstances) {\n dropdownItems.push({\n label: \"Restore deleted instances\",\n action: \"restore_deleted_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-restore-deleted-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-restore-deleted-instances`,\n fieldDataName,\n });\n }\n\n if (fieldLevelCustomizations) {\n dropdownItems.push({\n label: \"Reset field-level customizations\",\n action: \"reset_field_level_customizations\",\n id: `iframe-cs-variant-field-${fieldDataName}-reset-field-level-customizations`,\n testId: `iframe-cs-variant-field-${fieldDataName}-reset-field-level-customizations`,\n fieldDataName,\n });\n }\n\n if (isOrderChanged) {\n dropdownItems.push({\n label: \"Restore sorted instances\",\n action: \"restore_sorted_instances\",\n id: `iframe-cs-variant-field-${fieldDataName}-restore-sorted-instances`,\n testId: `iframe-cs-variant-field-${fieldDataName}-restore-sorted-instances`,\n fieldDataName,\n });\n }\n\n return dropdownItems;\n };\n\n const dropdownItems = getDropdownItems();\n\n function handleOnClick(item: IItem) {\n const { fieldDataName, action } = item;\n visualBuilderPostMessage?.send(\"send-variant-revert-action-trigger\", {\n fieldDataName,\n action,\n euid: fieldMetadata.entry_uid,\n ct_uid: fieldMetadata.content_type_uid,\n locale: fieldMetadata.locale,\n });\n }\n\n return (\n <div\n className={classNames(\n \"variant-field-revert-component\",\n visualBuilderStyles()[\"variant-field-revert-component\"]\n )}\n onClick={(e) => e.stopPropagation()}\n >\n {isOpen && (\n <div\n data-testid=\"variant-field-revert-component__dropdown-content\"\n className={classNames(\n \"variant-field-revert-component__dropdown-content\",\n visualBuilderStyles()[\n \"variant-field-revert-component__dropdown-content\"\n ]\n )}\n >\n {dropdownItems.map((item) => (\n <div\n className={classNames(\n \"variant-field-revert-component__dropdown-content__list-item\",\n visualBuilderStyles()[\n \"variant-field-revert-component__dropdown-content__list-item\"\n ]\n )}\n onClick={(e) => {\n e.preventDefault();\n handleOnClick(item);\n closeDropdown();\n }}\n key={item.id}\n data-testid={item.testId}\n >\n <span>{item.label}</span>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n\nexport const VariantRevertDropdown = (props: any) => {\n const {\n closeDropdown,\n invertTooltipPosition,\n toggleVariantDropdown,\n variantStatus = BASE_VARIANT_STATUS,\n } = props;\n const dropdownRef = useRef<HTMLDivElement>(null);\n useHandleOutsideClick(dropdownRef, closeDropdown);\n const hasDropdownItems = Object.values(variantStatus).some(\n (value) => value\n );\n\n const buttonClassNames = classNames(\n \"visual-builder__button visual-builder__button--secondary\",\n visualBuilderStyles()[\"visual-builder__button\"],\n visualBuilderStyles()[\"visual-builder__button--secondary\"],\n visualBuilderStyles()[\"visual-builder__tooltip\"],\n {\n \"visual-builder__tooltip--bottom\": invertTooltipPosition,\n [visualBuilderStyles()[\"visual-builder__tooltip--bottom\"]]:\n invertTooltipPosition,\n }\n );\n\n if (!hasDropdownItems) {\n return (\n <button\n className={classNames(buttonClassNames)}\n style={{ padding: \"6px\" }}\n data-tooltip={\"Variant\"}\n data-testid={`visual-builder-canvas-variant-icon`}\n >\n <VariantIcon />\n </button>\n );\n }\n return (\n <div ref={dropdownRef}>\n <button\n className={classNames(\n buttonClassNames,\n visualBuilderStyles()[\"visual-builder__variant-button\"]\n )}\n data-tooltip={\"Variant Revert\"}\n data-testid={`visual-builder-canvas-variant-revert`}\n onClick={toggleVariantDropdown}\n >\n <VariantIcon />\n <CaretIcon open={props.isOpen} />\n </button>\n <FieldRevertComponent {...props} />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuB;AACvB,oBAAyC;AACzC,2BAAoC;AACpC,sCAAqC;AAErC,qBAA4B;AAC5B,mBAA0B;AAC1B,mCAAkC;AA+KN;AA9IrB,IAAM,sBAAsC;AAAA,EAC/C,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,0BAA0B;AAC9B;AAEA,eAAsB,sBAClB,eACmC;AAlDvC;AAmDI,MAAI;AACA,UAAM,SAAS,QAAM,qCAAAA,YAAA,mBAA0B;AAAA,MAC3C;AAAA,MACA;AAAA;AAEJ,WAAO;AAAA,EACX,SAAS,OAAO;AACZ,YAAQ,MAAM,uCAAuC,KAAK;AAAA,EAC9D;AACJ;AAEO,IAAM,uBAAuB,CAAC,UAAqC;AACtE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,EACJ,IAAI;AAEJ,QAAM,mBAAmB,MAAM;AAC3B,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI;AAEJ,UAAMC,iBAAyB,CAAC;AAEhC,QAAI,gBAAgB;AAChB,MAAAA,eAAc,KAAK;AAAA,QACf,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,IAAI,2BAA2B,aAAa;AAAA,QAC5C,QAAQ,2BAA2B,aAAa;AAAA,QAChD;AAAA,MACJ,CAAC;AAAA,IACL;AAEA,QAAI,kBAAkB;AAClB,MAAAA,eAAc,KAAK;AAAA,QACf,OAAO;AAAA,Q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kBAAAA;AAAA,UACP;AAAA,cACA,0CAAoB,EAAE,gCAAgC;AAAA,QAC1D;AAAA,QACA,gBAAc;AAAA,QACd,eAAa;AAAA,QACb,SAAS;AAAA,QAET;AAAA,sDAAC,8BAAY;AAAA,UACb,4CAAC,0BAAU,MAAM,MAAM,QAAQ;AAAA;AAAA;AAAA,IACnC;AAAA,IACA,4CAAC,wBAAsB,GAAG,OAAO;AAAA,KACrC;AAER;","names":["visualBuilderPostMessage","dropdownItems","fieldDataName","classNames","useHandleOutsideClick"]}
|
|
@@ -19,5 +19,6 @@ interface FieldRevertComponentProps {
|
|
|
19
19
|
declare const BASE_VARIANT_STATUS: IVariantStatus;
|
|
20
20
|
declare function getFieldVariantStatus(fieldMetadata: CslpData): Promise<IVariantStatus | undefined>;
|
|
21
21
|
declare const FieldRevertComponent: (props: FieldRevertComponentProps) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
declare const VariantRevertDropdown: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
23
|
|
|
23
|
-
export { BASE_VARIANT_STATUS, FieldRevertComponent, type IVariantStatus, type TFieldRevertActionCallback, getFieldVariantStatus };
|
|
24
|
+
export { BASE_VARIANT_STATUS, FieldRevertComponent, type IVariantStatus, type TFieldRevertActionCallback, VariantRevertDropdown, getFieldVariantStatus };
|
|
@@ -19,5 +19,6 @@ interface FieldRevertComponentProps {
|
|
|
19
19
|
declare const BASE_VARIANT_STATUS: IVariantStatus;
|
|
20
20
|
declare function getFieldVariantStatus(fieldMetadata: CslpData): Promise<IVariantStatus | undefined>;
|
|
21
21
|
declare const FieldRevertComponent: (props: FieldRevertComponentProps) => react_jsx_runtime.JSX.Element;
|
|
22
|
+
declare const VariantRevertDropdown: (props: any) => react_jsx_runtime.JSX.Element;
|
|
22
23
|
|
|
23
|
-
export { BASE_VARIANT_STATUS, FieldRevertComponent, type IVariantStatus, type TFieldRevertActionCallback, getFieldVariantStatus };
|
|
24
|
+
export { BASE_VARIANT_STATUS, FieldRevertComponent, type IVariantStatus, type TFieldRevertActionCallback, VariantRevertDropdown, getFieldVariantStatus };
|