mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-12 19:02:53 +08:00
feat: hide edit on embed
This commit is contained in:
parent
98c37cc322
commit
9423d6e14f
@ -24,14 +24,7 @@ import useModal from "src/store/useModal";
|
||||
import useStored from "src/store/useStored";
|
||||
import useUser from "src/store/useUser";
|
||||
import { getNextDirection } from "src/utils/graph/getNextDirection";
|
||||
|
||||
function inIframe() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
import { isIframe } from "src/utils/widget";
|
||||
|
||||
export const StyledTools = styled.div`
|
||||
position: relative;
|
||||
@ -157,7 +150,7 @@ export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) =>
|
||||
]);
|
||||
|
||||
const logoURL = React.useMemo(() => {
|
||||
if (!inIframe()) return "https://jsoncrack.com";
|
||||
if (!isIframe()) return "https://jsoncrack.com";
|
||||
return window.location.href.replace("widget", "editor");
|
||||
}, []);
|
||||
|
||||
@ -168,7 +161,7 @@ export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) =>
|
||||
as="a"
|
||||
title="JSON Crack"
|
||||
href={logoURL}
|
||||
target={inIframe() ? "_blank" : "_parent"}
|
||||
target={isIframe() ? "_blank" : "_parent"}
|
||||
>
|
||||
<Flex gap="xs" align="center" justify="center">
|
||||
<StyledLogo
|
||||
|
@ -11,6 +11,7 @@ import useGraph from "src/store/useGraph";
|
||||
import useModal from "src/store/useModal";
|
||||
import useStored from "src/store/useStored";
|
||||
import useUser from "src/store/useUser";
|
||||
import { isIframe } from "src/utils/widget";
|
||||
|
||||
const dataToString = (data: any) => {
|
||||
const text = Array.isArray(data) ? Object.fromEntries(data) : data;
|
||||
@ -82,7 +83,10 @@ export const NodeModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
||||
onModalClose();
|
||||
};
|
||||
|
||||
const isEditVisible = path !== "{Root}" && !isParent;
|
||||
const isEditVisible = React.useMemo(
|
||||
() => path !== "{Root}" && !isParent && !isIframe(),
|
||||
[isParent, path]
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal title="Node Content" size="auto" opened={opened} onClose={onModalClose} centered>
|
||||
|
7
src/utils/widget.ts
Normal file
7
src/utils/widget.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export function isIframe() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user