@contentstack/live-preview-utils 3.3.0 → 3.4.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 +1 -1
- package/dist/legacy/light-sdk.cjs +1 -1
- package/dist/legacy/light-sdk.js +1 -1
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +2 -2
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +3 -3
- package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
- package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
- package/dist/legacy/utils/addLivePreviewQueryTags.cjs +7 -1
- package/dist/legacy/utils/addLivePreviewQueryTags.cjs.map +1 -1
- package/dist/legacy/utils/addLivePreviewQueryTags.js +7 -1
- package/dist/legacy/utils/addLivePreviewQueryTags.js.map +1 -1
- package/dist/legacy/utils/index.cjs +8 -4
- package/dist/legacy/utils/index.cjs.map +1 -1
- package/dist/legacy/utils/index.js +8 -4
- package/dist/legacy/utils/index.js.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.cjs +186 -0
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.cjs.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.d.cts +35 -0
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.d.ts +35 -0
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.js +153 -0
- package/dist/legacy/visualBuilder/components/FieldLocationAppList.js.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.cjs +125 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.cjs.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.d.cts +13 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.d.ts +13 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.js +92 -0
- package/dist/legacy/visualBuilder/components/FieldLocationIcon.js.map +1 -0
- package/dist/legacy/visualBuilder/components/FieldToolbar.cjs +181 -115
- package/dist/legacy/visualBuilder/components/FieldToolbar.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/FieldToolbar.js +182 -116
- package/dist/legacy/visualBuilder/components/FieldToolbar.js.map +1 -1
- package/dist/legacy/visualBuilder/components/emptyBlock.cjs +26 -5
- package/dist/legacy/visualBuilder/components/emptyBlock.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/emptyBlock.js +26 -5
- package/dist/legacy/visualBuilder/components/emptyBlock.js.map +1 -1
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.cjs +78 -0
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.cjs.map +1 -0
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.d.cts +9 -0
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.d.ts +9 -0
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.js +53 -0
- package/dist/legacy/visualBuilder/components/icons/EmptyAppIcon.js.map +1 -0
- package/dist/legacy/visualBuilder/components/icons/index.cjs +19 -0
- package/dist/legacy/visualBuilder/components/icons/index.cjs.map +1 -1
- package/dist/legacy/visualBuilder/components/icons/index.d.cts +2 -1
- package/dist/legacy/visualBuilder/components/icons/index.d.ts +2 -1
- package/dist/legacy/visualBuilder/components/icons/index.js +18 -0
- package/dist/legacy/visualBuilder/components/icons/index.js.map +1 -1
- package/dist/legacy/visualBuilder/generators/generateToolbar.cjs +2 -1
- package/dist/legacy/visualBuilder/generators/generateToolbar.cjs.map +1 -1
- package/dist/legacy/visualBuilder/generators/generateToolbar.js +2 -1
- package/dist/legacy/visualBuilder/generators/generateToolbar.js.map +1 -1
- package/dist/legacy/visualBuilder/index.cjs +11 -1
- package/dist/legacy/visualBuilder/index.cjs.map +1 -1
- package/dist/legacy/visualBuilder/index.js +11 -1
- package/dist/legacy/visualBuilder/index.js.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.cjs +4 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.cjs.map +1 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.js +4 -1
- package/dist/legacy/visualBuilder/listeners/mouseHover.js.map +1 -1
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs +3 -0
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.cts +4 -1
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.ts +4 -1
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.js +3 -0
- package/dist/legacy/visualBuilder/utils/types/postMessage.types.js.map +1 -1
- package/dist/legacy/visualBuilder/visualBuilder.style.cjs +117 -2
- package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
- package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +18 -0
- package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +18 -0
- package/dist/legacy/visualBuilder/visualBuilder.style.js +117 -2
- package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
- package/dist/modern/light-sdk.cjs +1 -1
- package/dist/modern/light-sdk.js +1 -1
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +2 -2
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +3 -3
- package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
- package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
- package/dist/modern/utils/addLivePreviewQueryTags.cjs +7 -1
- package/dist/modern/utils/addLivePreviewQueryTags.cjs.map +1 -1
- package/dist/modern/utils/addLivePreviewQueryTags.js +7 -1
- package/dist/modern/utils/addLivePreviewQueryTags.js.map +1 -1
- package/dist/modern/utils/index.cjs +8 -4
- package/dist/modern/utils/index.cjs.map +1 -1
- package/dist/modern/utils/index.js +8 -4
- package/dist/modern/utils/index.js.map +1 -1
- package/dist/modern/visualBuilder/components/FieldLocationAppList.cjs +185 -0
- package/dist/modern/visualBuilder/components/FieldLocationAppList.cjs.map +1 -0
- package/dist/modern/visualBuilder/components/FieldLocationAppList.d.cts +35 -0
- package/dist/modern/visualBuilder/components/FieldLocationAppList.d.ts +35 -0
- package/dist/modern/visualBuilder/components/FieldLocationAppList.js +152 -0
- package/dist/modern/visualBuilder/components/FieldLocationAppList.js.map +1 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.cjs +123 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.cjs.map +1 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.d.cts +13 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.d.ts +13 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.js +90 -0
- package/dist/modern/visualBuilder/components/FieldLocationIcon.js.map +1 -0
- package/dist/modern/visualBuilder/components/FieldToolbar.cjs +180 -115
- package/dist/modern/visualBuilder/components/FieldToolbar.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/FieldToolbar.js +181 -116
- package/dist/modern/visualBuilder/components/FieldToolbar.js.map +1 -1
- package/dist/modern/visualBuilder/components/emptyBlock.cjs +26 -5
- package/dist/modern/visualBuilder/components/emptyBlock.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/emptyBlock.js +26 -5
- package/dist/modern/visualBuilder/components/emptyBlock.js.map +1 -1
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.cjs +78 -0
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.cjs.map +1 -0
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.d.cts +9 -0
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.d.ts +9 -0
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.js +53 -0
- package/dist/modern/visualBuilder/components/icons/EmptyAppIcon.js.map +1 -0
- package/dist/modern/visualBuilder/components/icons/index.cjs +19 -0
- package/dist/modern/visualBuilder/components/icons/index.cjs.map +1 -1
- package/dist/modern/visualBuilder/components/icons/index.d.cts +2 -1
- package/dist/modern/visualBuilder/components/icons/index.d.ts +2 -1
- package/dist/modern/visualBuilder/components/icons/index.js +18 -0
- package/dist/modern/visualBuilder/components/icons/index.js.map +1 -1
- package/dist/modern/visualBuilder/generators/generateToolbar.cjs +2 -1
- package/dist/modern/visualBuilder/generators/generateToolbar.cjs.map +1 -1
- package/dist/modern/visualBuilder/generators/generateToolbar.js +2 -1
- package/dist/modern/visualBuilder/generators/generateToolbar.js.map +1 -1
- package/dist/modern/visualBuilder/index.cjs +10 -0
- package/dist/modern/visualBuilder/index.cjs.map +1 -1
- package/dist/modern/visualBuilder/index.js +10 -0
- package/dist/modern/visualBuilder/index.js.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.cjs +4 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.cjs.map +1 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.js +4 -1
- package/dist/modern/visualBuilder/listeners/mouseHover.js.map +1 -1
- package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs +3 -0
- package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
- package/dist/modern/visualBuilder/utils/types/postMessage.types.d.cts +4 -1
- package/dist/modern/visualBuilder/utils/types/postMessage.types.d.ts +4 -1
- package/dist/modern/visualBuilder/utils/types/postMessage.types.js +3 -0
- package/dist/modern/visualBuilder/utils/types/postMessage.types.js.map +1 -1
- package/dist/modern/visualBuilder/visualBuilder.style.cjs +117 -2
- package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
- package/dist/modern/visualBuilder/visualBuilder.style.d.cts +18 -0
- package/dist/modern/visualBuilder/visualBuilder.style.d.ts +18 -0
- package/dist/modern/visualBuilder/visualBuilder.style.js +117 -2
- package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Alternatively, if you want to include the package directly in your website HTML
|
|
|
16
16
|
|
|
17
17
|
```html
|
|
18
18
|
<script type='module' integrity='sha384-b6G+ggU20rGxqCqsgaS6zludFgj5N11xsuXhMEIARMuQY2PtyDS04TU0H5goP+32' crossorigin="anonymous">
|
|
19
|
-
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@3.
|
|
19
|
+
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@3.4.0';
|
|
20
20
|
|
|
21
21
|
ContentstackLivePreview.init({
|
|
22
22
|
stackDetails: {
|
package/dist/legacy/light-sdk.js
CHANGED
|
@@ -89,7 +89,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
|
|
|
89
89
|
config: {
|
|
90
90
|
shouldReload: import_configManager.default.get().ssr,
|
|
91
91
|
href: window.location.href,
|
|
92
|
-
sdkVersion: "3.
|
|
92
|
+
sdkVersion: "3.4.0",
|
|
93
93
|
mode: import_configManager.default.get().mode
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -110,7 +110,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
|
|
|
110
110
|
});
|
|
111
111
|
} else {
|
|
112
112
|
}
|
|
113
|
-
if (import_configManager.default.get().ssr) {
|
|
113
|
+
if (import_configManager.default.get().ssr || (0, import_utils.isOpeningInTimeline)()) {
|
|
114
114
|
(0, import_utils.addParamsToUrl)();
|
|
115
115
|
}
|
|
116
116
|
import_configManager.default.set("windowType", windowType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n const { ssr, onChange } = Config.get();\n if (!ssr) {\n onChange();\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA4C;AAC5C,mBAAuC;AACvC,
|
|
1
|
+
{"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n const { ssr, onChange } = Config.get();\n if (!ssr) {\n onChange();\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA4C;AAC5C,mBAAuC;AACvC,mBAAoD;AACpD,qCAAmC;AACnC,IAAAA,kCAAiD;AAW1C,SAAS,6BAAmC;AAfnD;AAgBI,uCAAAC,YAAA,mBAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ;AAAA,QACA,KAAK,UAAU;AACX,iBAAO,QAAQ,GAAG;AAClB;AAAA,QACJ;AAAA,QACA,SAAS;AACL,gBAAM,kBAAyB,MAAM,KAAK;AAC1C,gBAAM,IAAI,MAAM,oBAAoB,eAAe,EAAE;AAAA,QACzD;AAAA,MACJ;AAAA,IACJ;AAAA;AAER;AAKO,SAAS,mCAAyC;AA5CzD;AA6CI,uCAAAA,YAAA,mBAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,oDAAoB;AAAA,QAChB,cAAc,MAAM,KAAK;AAAA,MAC7B,CAAC;AACD,YAAM,EAAE,KAAK,SAAS,IAAI,qBAAAC,QAAO,IAAI;AACrC,UAAI,CAAC,KAAK;AACN,iBAAS;AAAA,MACb;AAAA,IACJ;AAAA;AAER;AAEO,SAAS,4CAAkD;AA3DlE;AA4DI,uCAAAD,YAAA,mBACM;AAAA,IACE,iEAAiC;AAAA,IACjC;AAAA,MACI,QAAQ;AAAA,QACJ,cAAc,qBAAAC,QAAO,IAAI,EAAE;AAAA,QAC3B,MAAM,OAAO,SAAS;AAAA,QACtB,YAAY;AAAA,QACZ,MAAM,qBAAAA,QAAO,IAAI,EAAE;AAAA,MACvB;AAAA,IACJ;AAAA,IAEH,KAAK,CAAC,SAAS;AAxExB,QAAAC,KAAA;AAyEY,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,oCAAuB;AAAA,IACxC,IAAI,QAAQ,CAAC;AAIb,UAAI,MAAAA,MAAA,qBAAAD,YAAA,gBAAAC,IAAQ,UAAR,mBAAe,eAAc,qBAAAD,QAAO,IAAI,EAAE,eAAe,oCAAuB,SAAS;AACzF;AAAA,IACJ;AAEA,QAAI,kBAAkB,UAAU;AAE5B,oDAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,qBAAAA,QAAO,IAAI,EAAE,WAAO,kCAAoB,GAAG;AAC3C,uCAAe;AAAA,IACnB;AACA,yBAAAA,QAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,qBAAAA,QAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,GACC,MAAM,CAAC,MAAM;AAAA,EAGd;AACR;AAEA,SAAS,qCAA2C;AAtHpD;AAuHI,uCAAAD,YAAA,mBACM,KAAK,iEAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["import_livePreviewEventManager","livePreviewPostMessage","Config","_a"]}
|
|
@@ -3,7 +3,7 @@ import "../../chunk-5WRI5ZAA.js";
|
|
|
3
3
|
// src/livePreview/eventManager/postMessageEvent.hooks.ts
|
|
4
4
|
import Config, { setConfigFromParams } from "../../configManager/configManager.js";
|
|
5
5
|
import { ILivePreviewWindowType } from "../../types/types.js";
|
|
6
|
-
import { addParamsToUrl } from "../../utils/index.js";
|
|
6
|
+
import { addParamsToUrl, isOpeningInTimeline } from "../../utils/index.js";
|
|
7
7
|
import livePreviewPostMessage from "./livePreviewEventManager.js";
|
|
8
8
|
import { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from "./livePreviewEventManager.constant.js";
|
|
9
9
|
function useHistoryPostMessageEvent() {
|
|
@@ -55,7 +55,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
|
|
|
55
55
|
config: {
|
|
56
56
|
shouldReload: Config.get().ssr,
|
|
57
57
|
href: window.location.href,
|
|
58
|
-
sdkVersion: "3.
|
|
58
|
+
sdkVersion: "3.4.0",
|
|
59
59
|
mode: Config.get().mode
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -76,7 +76,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
|
|
|
76
76
|
});
|
|
77
77
|
} else {
|
|
78
78
|
}
|
|
79
|
-
if (Config.get().ssr) {
|
|
79
|
+
if (Config.get().ssr || isOpeningInTimeline()) {
|
|
80
80
|
addParamsToUrl();
|
|
81
81
|
}
|
|
82
82
|
Config.set("windowType", windowType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n const { ssr, onChange } = Config.get();\n if (!ssr) {\n onChange();\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;AAAA,OAAO,UAAU,2BAA2B;AAC5C,SAAS,8BAA8B;AACvC,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n const { ssr, onChange } = Config.get();\n if (!ssr) {\n onChange();\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;AAAA,OAAO,UAAU,2BAA2B;AAC5C,SAAS,8BAA8B;AACvC,SAAS,gBAAgB,2BAA2B;AACpD,OAAO,4BAA4B;AACnC,SAAS,wCAAwC;AAW1C,SAAS,6BAAmC;AAfnD;AAgBI,sDAAwB;AAAA,IACpB,iCAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ;AAAA,QACA,KAAK,UAAU;AACX,iBAAO,QAAQ,GAAG;AAClB;AAAA,QACJ;AAAA,QACA,SAAS;AACL,gBAAM,kBAAyB,MAAM,KAAK;AAC1C,gBAAM,IAAI,MAAM,oBAAoB,eAAe,EAAE;AAAA,QACzD;AAAA,MACJ;AAAA,IACJ;AAAA;AAER;AAKO,SAAS,mCAAyC;AA5CzD;AA6CI,sDAAwB;AAAA,IACpB,iCAAiC;AAAA,IACjC,CAAC,UAAU;AACP,0BAAoB;AAAA,QAChB,cAAc,MAAM,KAAK;AAAA,MAC7B,CAAC;AACD,YAAM,EAAE,KAAK,SAAS,IAAI,OAAO,IAAI;AACrC,UAAI,CAAC,KAAK;AACN,iBAAS;AAAA,MACb;AAAA,IACJ;AAAA;AAER;AAEO,SAAS,4CAAkD;AA3DlE;AA4DI,sDACM;AAAA,IACE,iCAAiC;AAAA,IACjC;AAAA,MACI,QAAQ;AAAA,QACJ,cAAc,OAAO,IAAI,EAAE;AAAA,QAC3B,MAAM,OAAO,SAAS;AAAA,QACtB,YAAY;AAAA,QACZ,MAAM,OAAO,IAAI,EAAE;AAAA,MACvB;AAAA,IACJ;AAAA,IAEH,KAAK,CAAC,SAAS;AAxExB,QAAAA,KAAA;AAyEY,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,uBAAuB;AAAA,IACxC,IAAI,QAAQ,CAAC;AAIb,UAAI,MAAAA,MAAA,2BAAAA,IAAQ,UAAR,mBAAe,eAAc,OAAO,IAAI,EAAE,eAAe,uBAAuB,SAAS;AACzF;AAAA,IACJ;AAEA,QAAI,kBAAkB,UAAU;AAE5B,0BAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,OAAO,IAAI,EAAE,OAAO,oBAAoB,GAAG;AAC3C,qBAAe;AAAA,IACnB;AACA,WAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,OAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,GACC,MAAM,CAAC,MAAM;AAAA,EAGd;AACR;AAEA,SAAS,qCAA2C;AAtHpD;AAuHI,sDACM,KAAK,iCAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["_a"]}
|
|
@@ -227,7 +227,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
|
|
|
227
227
|
* @returns The version of the SDK as a string.
|
|
228
228
|
*/
|
|
229
229
|
static getSdkVersion() {
|
|
230
|
-
return "3.
|
|
230
|
+
return "3.4.0";
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
_ContentstackLivePreview.previewConstructors = {};
|
|
@@ -195,7 +195,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
|
|
|
195
195
|
* @returns The version of the SDK as a string.
|
|
196
196
|
*/
|
|
197
197
|
static getSdkVersion() {
|
|
198
|
-
return "3.
|
|
198
|
+
return "3.4.0";
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
_ContentstackLivePreview.previewConstructors = {};
|
|
@@ -31,11 +31,17 @@ function addLivePreviewQueryTags(link) {
|
|
|
31
31
|
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
32
32
|
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
33
33
|
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
34
|
-
|
|
34
|
+
const previewTimestamp = docUrl.searchParams.get("preview_timestamp");
|
|
35
|
+
if (livePreviewHash) {
|
|
35
36
|
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
37
|
+
}
|
|
38
|
+
if (ctUid && entryUid) {
|
|
36
39
|
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
37
40
|
newUrl.searchParams.set("entry_uid", entryUid);
|
|
38
41
|
}
|
|
42
|
+
if (previewTimestamp) {
|
|
43
|
+
newUrl.searchParams.set("preview_timestamp", previewTimestamp);
|
|
44
|
+
}
|
|
39
45
|
return newUrl.href;
|
|
40
46
|
} catch (error) {
|
|
41
47
|
import_logger.PublicLogger.error("Error while adding live preview to URL");
|
|
@@ -1 +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
|
|
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 const previewTimestamp: string | null = docUrl.searchParams.get(\"preview_timestamp\");\n if (livePreviewHash) {\n newUrl.searchParams.set(\"live_preview\", livePreviewHash);\n }\n if(ctUid && entryUid){\n newUrl.searchParams.set(\"content_type_uid\", ctUid);\n newUrl.searchParams.set(\"entry_uid\", entryUid);\n }\n if (previewTimestamp) {\n newUrl.searchParams.set(\"preview_timestamp\", previewTimestamp);\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,UAAM,mBAAkC,OAAO,aAAa,IAAI,mBAAmB;AACnF,QAAI,iBAAiB;AACjB,aAAO,aAAa,IAAI,gBAAgB,eAAe;AAAA,IAC3D;AACA,QAAG,SAAS,UAAS;AACjB,aAAO,aAAa,IAAI,oBAAoB,KAAK;AACjD,aAAO,aAAa,IAAI,aAAa,QAAQ;AAAA,IACjD;AACA,QAAI,kBAAkB;AAClB,aAAO,aAAa,IAAI,qBAAqB,gBAAgB;AAAA,IACjE;AACA,WAAO,OAAO;AAAA,EAClB,SAAS,OAAO;AACZ,+BAAa,MAAM,wCAAwC;AAC3D,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -9,11 +9,17 @@ function addLivePreviewQueryTags(link) {
|
|
|
9
9
|
const livePreviewHash = docUrl.searchParams.get("live_preview");
|
|
10
10
|
const ctUid = docUrl.searchParams.get("content_type_uid");
|
|
11
11
|
const entryUid = docUrl.searchParams.get("entry_uid");
|
|
12
|
-
|
|
12
|
+
const previewTimestamp = docUrl.searchParams.get("preview_timestamp");
|
|
13
|
+
if (livePreviewHash) {
|
|
13
14
|
newUrl.searchParams.set("live_preview", livePreviewHash);
|
|
15
|
+
}
|
|
16
|
+
if (ctUid && entryUid) {
|
|
14
17
|
newUrl.searchParams.set("content_type_uid", ctUid);
|
|
15
18
|
newUrl.searchParams.set("entry_uid", entryUid);
|
|
16
19
|
}
|
|
20
|
+
if (previewTimestamp) {
|
|
21
|
+
newUrl.searchParams.set("preview_timestamp", previewTimestamp);
|
|
22
|
+
}
|
|
17
23
|
return newUrl.href;
|
|
18
24
|
} catch (error) {
|
|
19
25
|
PublicLogger.error("Error while adding live preview to URL");
|
|
@@ -1 +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
|
|
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 const previewTimestamp: string | null = docUrl.searchParams.get(\"preview_timestamp\");\n if (livePreviewHash) {\n newUrl.searchParams.set(\"live_preview\", livePreviewHash);\n }\n if(ctUid && entryUid){\n newUrl.searchParams.set(\"content_type_uid\", ctUid);\n newUrl.searchParams.set(\"entry_uid\", entryUid);\n }\n if (previewTimestamp) {\n newUrl.searchParams.set(\"preview_timestamp\", previewTimestamp);\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,UAAM,mBAAkC,OAAO,aAAa,IAAI,mBAAmB;AACnF,QAAI,iBAAiB;AACjB,aAAO,aAAa,IAAI,gBAAgB,eAAe;AAAA,IAC3D;AACA,QAAG,SAAS,UAAS;AACjB,aAAO,aAAa,IAAI,oBAAoB,KAAK;AACjD,aAAO,aAAa,IAAI,aAAa,QAAQ;AAAA,IACjD;AACA,QAAI,kBAAkB;AAClB,aAAO,aAAa,IAAI,qBAAqB,gBAAgB;AAAA,IACjE;AACA,WAAO,OAAO;AAAA,EAClB,SAAS,OAAO;AACZ,iBAAa,MAAM,wCAAwC;AAC3D,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -33,12 +33,16 @@ function hasWindow() {
|
|
|
33
33
|
}
|
|
34
34
|
function addParamsToUrl() {
|
|
35
35
|
window.addEventListener("click", (event) => {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
36
|
+
const clickedElement = event.target;
|
|
37
|
+
const anchorElement = clickedElement.closest("a");
|
|
38
|
+
if (!anchorElement || !anchorElement.contains(clickedElement)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const targetHref = anchorElement.href;
|
|
38
42
|
const docOrigin = document.location.origin;
|
|
39
43
|
if (targetHref && targetHref.includes(docOrigin) && !targetHref.includes("live_preview")) {
|
|
40
|
-
const newUrl = (0, import_addLivePreviewQueryTags.addLivePreviewQueryTags)(
|
|
41
|
-
|
|
44
|
+
const newUrl = (0, import_addLivePreviewQueryTags.addLivePreviewQueryTags)(targetHref);
|
|
45
|
+
anchorElement.href = newUrl || targetHref;
|
|
42
46
|
}
|
|
43
47
|
});
|
|
44
48
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 clickedElement = event.target;\n const anchorElement = clickedElement.closest('a');\n \n // Only proceed if the clicked element is either an anchor or a direct/indirect child of an anchor\n if (!anchorElement || !anchorElement.contains(clickedElement)) {\n return;\n }\n\n const targetHref: string | any = anchorElement.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(targetHref);\n anchorElement.href = newUrl || targetHref;\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}\n\nexport function isOpenInBuilder(): boolean {\n if (hasWindow()) {\n const urlParams = new URLSearchParams(window.location.search);\n const builder = urlParams.get(\"builder\");\n return !!builder;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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,iBAAiB,MAAM;AAC7B,UAAM,gBAAgB,eAAe,QAAQ,GAAG;AAGhD,QAAI,CAAC,iBAAiB,CAAC,cAAc,SAAS,cAAc,GAAG;AAC3D;AAAA,IACJ;AAEA,UAAM,aAA2B,cAAc;AAC/C,UAAM,YAAoB,SAAS,SAAS;AAC5C,QACI,cACA,WAAW,SAAS,SAAS,KAC7B,CAAC,WAAW,SAAS,cAAc,GACrC;AACE,YAAM,aAAS,wDAAwB,UAAU;AACjD,oBAAc,OAAO,UAAU;AAAA,IACnC;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;AAEO,SAAS,kBAA2B;AACvC,MAAI,UAAU,GAAG;AACb,UAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC5D,UAAM,UAAU,UAAU,IAAI,SAAS;AACvC,WAAO,CAAC,CAAC;AAAA,EACb;AACA,SAAO;AACX;","names":[]}
|
|
@@ -7,12 +7,16 @@ function hasWindow() {
|
|
|
7
7
|
}
|
|
8
8
|
function addParamsToUrl() {
|
|
9
9
|
window.addEventListener("click", (event) => {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const clickedElement = event.target;
|
|
11
|
+
const anchorElement = clickedElement.closest("a");
|
|
12
|
+
if (!anchorElement || !anchorElement.contains(clickedElement)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const targetHref = anchorElement.href;
|
|
12
16
|
const docOrigin = document.location.origin;
|
|
13
17
|
if (targetHref && targetHref.includes(docOrigin) && !targetHref.includes("live_preview")) {
|
|
14
|
-
const newUrl = addLivePreviewQueryTags(
|
|
15
|
-
|
|
18
|
+
const newUrl = addLivePreviewQueryTags(targetHref);
|
|
19
|
+
anchorElement.href = newUrl || targetHref;
|
|
16
20
|
}
|
|
17
21
|
});
|
|
18
22
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 clickedElement = event.target;\n const anchorElement = clickedElement.closest('a');\n \n // Only proceed if the clicked element is either an anchor or a direct/indirect child of an anchor\n if (!anchorElement || !anchorElement.contains(clickedElement)) {\n return;\n }\n\n const targetHref: string | any = anchorElement.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(targetHref);\n anchorElement.href = newUrl || targetHref;\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}\n\nexport function isOpenInBuilder(): boolean {\n if (hasWindow()) {\n const urlParams = new URLSearchParams(window.location.search);\n const builder = urlParams.get(\"builder\");\n return !!builder;\n }\n return false;\n}\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,iBAAiB,MAAM;AAC7B,UAAM,gBAAgB,eAAe,QAAQ,GAAG;AAGhD,QAAI,CAAC,iBAAiB,CAAC,cAAc,SAAS,cAAc,GAAG;AAC3D;AAAA,IACJ;AAEA,UAAM,aAA2B,cAAc;AAC/C,UAAM,YAAoB,SAAS,SAAS;AAC5C,QACI,cACA,WAAW,SAAS,SAAS,KAC7B,CAAC,WAAW,SAAS,cAAc,GACrC;AACE,YAAM,SAAS,wBAAwB,UAAU;AACjD,oBAAc,OAAO,UAAU;AAAA,IACnC;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;AAEO,SAAS,kBAA2B;AACvC,MAAI,UAAU,GAAG;AACb,UAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC5D,UAAM,UAAU,UAAU,IAAI,SAAS;AACvC,WAAO,CAAC,CAAC;AAAA,EACb;AACA,SAAO;AACX;","names":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/visualBuilder/components/FieldLocationAppList.tsx
|
|
31
|
+
var FieldLocationAppList_exports = {};
|
|
32
|
+
__export(FieldLocationAppList_exports, {
|
|
33
|
+
FieldLocationAppList: () => FieldLocationAppList
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(FieldLocationAppList_exports);
|
|
36
|
+
var import_compat = require("preact/compat");
|
|
37
|
+
var import_EmptyAppIcon = require("./icons/EmptyAppIcon.cjs");
|
|
38
|
+
var import_postMessage = require("../utils/types/postMessage.types.cjs");
|
|
39
|
+
var import_visualBuilderPostMessage = __toESM(require("../utils/visualBuilderPostMessage.cjs"), 1);
|
|
40
|
+
var import_visualBuilder = require("../visualBuilder.style.cjs");
|
|
41
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
42
|
+
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
43
|
+
var normalize = (text) => text.toLowerCase().replace(/[^a-z0-9 ]/gi, "").trim();
|
|
44
|
+
var FieldLocationAppList = ({
|
|
45
|
+
apps,
|
|
46
|
+
position,
|
|
47
|
+
toolbarRef,
|
|
48
|
+
domEditStack,
|
|
49
|
+
setDisplayAllApps
|
|
50
|
+
}) => {
|
|
51
|
+
const remainingApps = apps.filter((app, index) => index !== 0);
|
|
52
|
+
const [search, setSearch] = (0, import_compat.useState)("");
|
|
53
|
+
const filteredApps = (0, import_compat.useMemo)(() => {
|
|
54
|
+
if (!search.trim()) return remainingApps;
|
|
55
|
+
const normalizedSearch = normalize(search);
|
|
56
|
+
return remainingApps.filter((app) => {
|
|
57
|
+
return normalize(app.title).includes(normalizedSearch);
|
|
58
|
+
});
|
|
59
|
+
}, [search, remainingApps]);
|
|
60
|
+
const handleAppClick = (app) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
(_b = import_visualBuilderPostMessage.default) == null ? void 0 : _b.send(
|
|
63
|
+
import_postMessage.VisualBuilderPostMessageEvents.FIELD_LOCATION_SELECTED_APP,
|
|
64
|
+
{
|
|
65
|
+
app,
|
|
66
|
+
position: (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect(),
|
|
67
|
+
DomEditStack: domEditStack
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
setDisplayAllApps(false);
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
className: (0, import_classnames.default)(
|
|
76
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list"],
|
|
77
|
+
{
|
|
78
|
+
[(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list--left"]]: position === "left",
|
|
79
|
+
[(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list--right"]]: position === "right"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__search-container"],
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
"svg",
|
|
90
|
+
{
|
|
91
|
+
width: "14",
|
|
92
|
+
height: "14",
|
|
93
|
+
viewBox: "0 0 14 14",
|
|
94
|
+
fill: "none",
|
|
95
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
96
|
+
className: (0, import_classnames.default)(
|
|
97
|
+
"Search__search-icon Icon--mini",
|
|
98
|
+
(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__search-icon"]
|
|
99
|
+
),
|
|
100
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
+
"path",
|
|
102
|
+
{
|
|
103
|
+
d: "M12.438 12.438L9.624 9.624M6.25 10.75a4.5 4.5 0 100-9 4.5 4.5 0 000 9z",
|
|
104
|
+
stroke: "#A9B6CB",
|
|
105
|
+
strokeWidth: "2",
|
|
106
|
+
strokeMiterlimit: "10",
|
|
107
|
+
strokeLinecap: "round",
|
|
108
|
+
strokeLinejoin: "round"
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
+
"input",
|
|
115
|
+
{
|
|
116
|
+
type: "text",
|
|
117
|
+
value: search,
|
|
118
|
+
onInput: (e) => setSearch(e.target.value),
|
|
119
|
+
placeholder: "Search for Apps",
|
|
120
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__search-input"]
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__content"],
|
|
130
|
+
children: [
|
|
131
|
+
filteredApps.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__no-results"],
|
|
135
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
"span",
|
|
137
|
+
{
|
|
138
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__no-results-text"],
|
|
139
|
+
children: "No matching results found!"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
filteredApps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__item"],
|
|
148
|
+
onClick: () => handleAppClick(app),
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__item-icon-container"],
|
|
154
|
+
children: app.icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
"img",
|
|
156
|
+
{
|
|
157
|
+
src: app.icon,
|
|
158
|
+
alt: app.title,
|
|
159
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__item-icon"]
|
|
160
|
+
}
|
|
161
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_EmptyAppIcon.EmptyAppIcon, { id: app.app_installation_uid })
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
+
"span",
|
|
166
|
+
{
|
|
167
|
+
className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-location-app-list__item-title"],
|
|
168
|
+
children: app.title
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
app.uid
|
|
174
|
+
))
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
FieldLocationAppList
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=FieldLocationAppList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/visualBuilder/components/FieldLocationAppList.tsx"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"preact/compat\";\nimport { EmptyAppIcon } from \"./icons/EmptyAppIcon\";\nimport { VisualBuilderPostMessageEvents } from \"../utils/types/postMessage.types\";\nimport visualBuilderPostMessage from \"../utils/visualBuilderPostMessage\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\nimport classNames from \"classnames\";\nimport { CslpData } from \"../../utils/cslpdata\";\n\ninterface App {\n app_installation_uid: string;\n app_uid: string;\n contentTypeUid: string;\n entryUid: string;\n fieldDataType: string;\n fieldDisplayName: string;\n fieldPath: string;\n icon?: string;\n locale: string;\n manifest: {\n uid: string;\n name: string;\n description: string;\n icon: string;\n visibility: string;\n };\n title: string;\n uid: string;\n}\n\ninterface FieldLocationAppListProps {\n apps: App[];\n position: \"left\" | \"right\";\n toolbarRef: React.RefObject<HTMLDivElement>;\n domEditStack:CslpData[]\n setDisplayAllApps: (displayAllApps: boolean) => void;\n displayAllApps: boolean;\n}\n\nconst normalize = (text: string) =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9 ]/gi, \"\")\n .trim();\n\nexport const FieldLocationAppList = ({\n apps,\n position,\n toolbarRef,\n domEditStack,\n setDisplayAllApps,\n}: FieldLocationAppListProps) => {\n const remainingApps = apps.filter((app, index) => index !== 0);\n const [search, setSearch] = useState(\"\");\n\n const filteredApps = useMemo(() => {\n if (!search.trim()) return remainingApps;\n\n const normalizedSearch = normalize(search);\n return remainingApps.filter((app) => {\n return (\n normalize(app.title).includes(normalizedSearch) \n );\n });\n }, [search, remainingApps]);\n\n const handleAppClick = (app: App) => {\n visualBuilderPostMessage?.send(\n VisualBuilderPostMessageEvents.FIELD_LOCATION_SELECTED_APP,\n {\n app: app,\n position: toolbarRef.current?.getBoundingClientRect(),\n DomEditStack:domEditStack\n }\n );\n setDisplayAllApps(false);\n };\n\n return (\n <div\n className={classNames(\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list\"\n ],\n {\n [visualBuilderStyles()[\n \"visual-builder__field-location-app-list--left\"\n ]]: position === \"left\",\n [visualBuilderStyles()[\n \"visual-builder__field-location-app-list--right\"\n ]]: position === \"right\",\n }\n )}\n >\n <div\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__search-container\"\n ]\n }\n >\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={classNames(\n \"Search__search-icon Icon--mini\",\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__search-icon\"\n ]\n )}\n >\n <path\n d=\"M12.438 12.438L9.624 9.624M6.25 10.75a4.5 4.5 0 100-9 4.5 4.5 0 000 9z\"\n stroke=\"#A9B6CB\"\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n ></path>\n </svg>\n <input\n type=\"text\"\n value={search}\n onInput={(e) =>\n setSearch((e.target as HTMLInputElement).value)\n }\n placeholder=\"Search for Apps\"\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__search-input\"\n ]\n }\n />\n </div>\n\n <div\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__content\"\n ]\n }\n >\n {filteredApps.length === 0 && (\n <div\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__no-results\"\n ]\n }\n >\n <span\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__no-results-text\"\n ]\n }\n >\n No matching results found!\n </span>\n </div>\n )}\n {filteredApps.map((app) => (\n <div\n key={app.uid}\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__item\"\n ]\n }\n onClick={() => handleAppClick(app)}\n >\n <div\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__item-icon-container\"\n ]\n }\n >\n {app.icon ? (\n <img\n src={app.icon}\n alt={app.title}\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__item-icon\"\n ]\n }\n />\n ) : (\n <EmptyAppIcon id={app.app_installation_uid} />\n )}\n </div>\n <span\n className={\n visualBuilderStyles()[\n \"visual-builder__field-location-app-list__item-title\"\n ]\n }\n >\n {app.title}\n </span>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoD;AACpD,0BAA6B;AAC7B,yBAA+C;AAC/C,sCAAqC;AACrC,2BAAoC;AACpC,wBAAuB;AAwFX;AAvDZ,IAAM,YAAY,CAAC,SACf,KACK,YAAY,EACZ,QAAQ,gBAAgB,EAAE,EAC1B,KAAK;AAEP,IAAM,uBAAuB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAiC;AAC7B,QAAM,gBAAgB,KAAK,OAAO,CAAC,KAAK,UAAU,UAAU,CAAC;AAC7D,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAAS,EAAE;AAEvC,QAAM,mBAAe,uBAAQ,MAAM;AAC/B,QAAI,CAAC,OAAO,KAAK,EAAG,QAAO;AAE3B,UAAM,mBAAmB,UAAU,MAAM;AACzC,WAAO,cAAc,OAAO,CAAC,QAAQ;AACjC,aACI,UAAU,IAAI,KAAK,EAAE,SAAS,gBAAgB;AAAA,IAEtD,CAAC;AAAA,EACL,GAAG,CAAC,QAAQ,aAAa,CAAC;AAE1B,QAAM,iBAAiB,CAAC,QAAa;AAjEzC;AAkEQ,0CAAAA,YAAA,mBAA0B;AAAA,MACtB,kDAA+B;AAAA,MAC/B;AAAA,QACI;AAAA,QACA,WAAU,gBAAW,YAAX,mBAAoB;AAAA,QAC9B,cAAa;AAAA,MACjB;AAAA;AAEJ,sBAAkB,KAAK;AAAA,EAC3B;AAEA,SACI;AAAA,IAAC;AAAA;AAAA,MACG,eAAW,kBAAAC;AAAA,YACP,0CAAoB,EAChB,yCACJ;AAAA,QACA;AAAA,UACI,KAAC,0CAAoB,EACjB,+CACJ,CAAC,GAAG,aAAa;AAAA,UACjB,KAAC,0CAAoB,EACjB,gDACJ,CAAC,GAAG,aAAa;AAAA,QACrB;AAAA,MACJ;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACG,eACI,0CAAoB,EAChB,2DACJ;AAAA,YAGJ;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACG,OAAM;AAAA,kBACN,QAAO;AAAA,kBACP,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,OAAM;AAAA,kBACN,eAAW,kBAAAA;AAAA,oBACP;AAAA,wBACA,0CAAoB,EAChB,sDACJ;AAAA,kBACJ;AAAA,kBAEA;AAAA,oBAAC;AAAA;AAAA,sBACG,GAAE;AAAA,sBACF,QAAO;AAAA,sBACP,aAAY;AAAA,sBACZ,kBAAiB;AAAA,sBACjB,eAAc;AAAA,sBACd,gBAAe;AAAA;AAAA,kBAClB;AAAA;AAAA,cACL;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACG,MAAK;AAAA,kBACL,OAAO;AAAA,kBACP,SAAS,CAAC,MACN,UAAW,EAAE,OAA4B,KAAK;AAAA,kBAElD,aAAY;AAAA,kBACZ,eACI,0CAAoB,EAChB,uDACJ;AAAA;AAAA,cAER;AAAA;AAAA;AAAA,QACJ;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACG,eACI,0CAAoB,EAChB,kDACJ;AAAA,YAGH;AAAA,2BAAa,WAAW,KACrB;AAAA,gBAAC;AAAA;AAAA,kBACG,eACI,0CAAoB,EAChB,qDACJ;AAAA,kBAGJ;AAAA,oBAAC;AAAA;AAAA,sBACG,eACI,0CAAoB,EAChB,0DACJ;AAAA,sBAEP;AAAA;AAAA,kBAED;AAAA;AAAA,cACJ;AAAA,cAEH,aAAa,IAAI,CAAC,QACf;AAAA,gBAAC;AAAA;AAAA,kBAEG,eACI,0CAAoB,EAChB,+CACJ;AAAA,kBAEJ,SAAS,MAAM,eAAe,GAAG;AAAA,kBAEjC;AAAA;AAAA,sBAAC;AAAA;AAAA,wBACG,eACI,0CAAoB,EAChB,8DACJ;AAAA,wBAGH,cAAI,OACD;AAAA,0BAAC;AAAA;AAAA,4BACG,KAAK,IAAI;AAAA,4BACT,KAAK,IAAI;AAAA,4BACT,eACI,0CAAoB,EAChB,oDACJ;AAAA;AAAA,wBAER,IAEA,4CAAC,oCAAa,IAAI,IAAI,sBAAsB;AAAA;AAAA,oBAEpD;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACG,eACI,0CAAoB,EAChB,qDACJ;AAAA,wBAGH,cAAI;AAAA;AAAA,oBACT;AAAA;AAAA;AAAA,gBArCK,IAAI;AAAA,cAsCb,CACH;AAAA;AAAA;AAAA,QACL;AAAA;AAAA;AAAA,EACJ;AAER;","names":["visualBuilderPostMessage","classNames"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'preact/compat';
|
|
3
|
+
import { CslpData } from '../../utils/cslpdata.cjs';
|
|
4
|
+
|
|
5
|
+
interface App {
|
|
6
|
+
app_installation_uid: string;
|
|
7
|
+
app_uid: string;
|
|
8
|
+
contentTypeUid: string;
|
|
9
|
+
entryUid: string;
|
|
10
|
+
fieldDataType: string;
|
|
11
|
+
fieldDisplayName: string;
|
|
12
|
+
fieldPath: string;
|
|
13
|
+
icon?: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
manifest: {
|
|
16
|
+
uid: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
icon: string;
|
|
20
|
+
visibility: string;
|
|
21
|
+
};
|
|
22
|
+
title: string;
|
|
23
|
+
uid: string;
|
|
24
|
+
}
|
|
25
|
+
interface FieldLocationAppListProps {
|
|
26
|
+
apps: App[];
|
|
27
|
+
position: "left" | "right";
|
|
28
|
+
toolbarRef: React.RefObject<HTMLDivElement>;
|
|
29
|
+
domEditStack: CslpData[];
|
|
30
|
+
setDisplayAllApps: (displayAllApps: boolean) => void;
|
|
31
|
+
displayAllApps: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const FieldLocationAppList: ({ apps, position, toolbarRef, domEditStack, setDisplayAllApps, }: FieldLocationAppListProps) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
export { FieldLocationAppList };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'preact/compat';
|
|
3
|
+
import { CslpData } from '../../utils/cslpdata.js';
|
|
4
|
+
|
|
5
|
+
interface App {
|
|
6
|
+
app_installation_uid: string;
|
|
7
|
+
app_uid: string;
|
|
8
|
+
contentTypeUid: string;
|
|
9
|
+
entryUid: string;
|
|
10
|
+
fieldDataType: string;
|
|
11
|
+
fieldDisplayName: string;
|
|
12
|
+
fieldPath: string;
|
|
13
|
+
icon?: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
manifest: {
|
|
16
|
+
uid: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
icon: string;
|
|
20
|
+
visibility: string;
|
|
21
|
+
};
|
|
22
|
+
title: string;
|
|
23
|
+
uid: string;
|
|
24
|
+
}
|
|
25
|
+
interface FieldLocationAppListProps {
|
|
26
|
+
apps: App[];
|
|
27
|
+
position: "left" | "right";
|
|
28
|
+
toolbarRef: React.RefObject<HTMLDivElement>;
|
|
29
|
+
domEditStack: CslpData[];
|
|
30
|
+
setDisplayAllApps: (displayAllApps: boolean) => void;
|
|
31
|
+
displayAllApps: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const FieldLocationAppList: ({ apps, position, toolbarRef, domEditStack, setDisplayAllApps, }: FieldLocationAppListProps) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
export { FieldLocationAppList };
|