@superblocksteam/library 2.0.81-next.1 → 2.0.81
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/dist/lib/index.js +19 -8
- package/dist/lib/index.js.map +1 -1
- package/package.json +3 -3
package/dist/lib/index.js
CHANGED
|
@@ -967,7 +967,11 @@ function useEmbedMessageListeners(navigate, superblocksContext) {
|
|
|
967
967
|
*/
|
|
968
968
|
function isLocalPath(url) {
|
|
969
969
|
if (url.startsWith("#")) return false;
|
|
970
|
-
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//"))
|
|
970
|
+
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) try {
|
|
971
|
+
return new URL(url, window.location.href).origin === window.location.origin;
|
|
972
|
+
} catch {
|
|
973
|
+
return false;
|
|
974
|
+
}
|
|
971
975
|
return true;
|
|
972
976
|
}
|
|
973
977
|
/**
|
|
@@ -1035,29 +1039,36 @@ function linkModifierInterceptor({ isEmbedMode = false, isEditMode: isEditMode$1
|
|
|
1035
1039
|
window.location.href = embedUrl;
|
|
1036
1040
|
return null;
|
|
1037
1041
|
}
|
|
1042
|
+
if (target === "_self") return originalWindowOpen(url, target, features);
|
|
1038
1043
|
const parentUrl = buildParentUrl(urlString, appId, isEditMode$1);
|
|
1039
|
-
|
|
1044
|
+
const shouldOpenNewTab = !target || target === "_blank";
|
|
1045
|
+
editorBridge.navigateTo(parentUrl, shouldOpenNewTab);
|
|
1040
1046
|
return null;
|
|
1041
1047
|
};
|
|
1042
|
-
const navigation = new URLSearchParams(window.location.search).get("app_mode") === "PUBLISHED" ? window.navigation : void 0;
|
|
1043
1048
|
const handleNavigate = (event) => {
|
|
1044
1049
|
if (isInternalNavigation) {
|
|
1045
1050
|
isInternalNavigation = false;
|
|
1046
1051
|
return;
|
|
1047
1052
|
}
|
|
1053
|
+
const destinationUrl = new URL(event.destination.url);
|
|
1054
|
+
if (destinationUrl.origin !== window.location.origin) {
|
|
1055
|
+
event.preventDefault();
|
|
1056
|
+
event.stopPropagation();
|
|
1057
|
+
window.open(event.destination.url, "_blank", "noopener,noreferrer");
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1048
1060
|
if (event.navigationType !== "push" && event.navigationType !== "replace") return;
|
|
1049
1061
|
if (!event.canIntercept) return;
|
|
1050
|
-
|
|
1051
|
-
if (destinationUrl.origin !== window.location.origin) return;
|
|
1052
|
-
if (destinationUrl.pathname === window.location.pathname && destinationUrl.search === window.location.search && destinationUrl.hash !== window.location.hash) return;
|
|
1062
|
+
if (destinationUrl.pathname === window.location.pathname && (destinationUrl.search !== window.location.search || destinationUrl.hash !== window.location.hash)) return;
|
|
1053
1063
|
if (!root_store_default.applicationId) return;
|
|
1054
1064
|
const embedUrl = buildEmbedNavigationUrl(destinationUrl.pathname + destinationUrl.search + destinationUrl.hash);
|
|
1055
1065
|
if (new URL(embedUrl, window.location.href).href === destinationUrl.href) return;
|
|
1056
1066
|
event.intercept({ handler: async () => {
|
|
1057
|
-
|
|
1058
|
-
window.
|
|
1067
|
+
history.replaceState(history.state, "", embedUrl);
|
|
1068
|
+
window.dispatchEvent(new PopStateEvent("popstate", { state: history.state }));
|
|
1059
1069
|
} });
|
|
1060
1070
|
};
|
|
1071
|
+
const navigation = window.navigation;
|
|
1061
1072
|
navigation?.addEventListener("navigate", handleNavigate);
|
|
1062
1073
|
window.addEventListener("click", handleClick, true);
|
|
1063
1074
|
return () => {
|