|  | @@ -20,22 +20,46 @@ const StyledErrorWrapper = styled.div`
 | 
	
		
			
				|  |  |    font-weight: 600;
 | 
	
		
			
				|  |  |  `;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +const StyledFlex = styled.div`
 | 
	
		
			
				|  |  | +  display: flex;
 | 
	
		
			
				|  |  | +  gap: 12px;
 | 
	
		
			
				|  |  | +`;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const StyledContainer = styled.div`
 | 
	
		
			
				|  |  | +  display: flex;
 | 
	
		
			
				|  |  | +  flex-direction: column;
 | 
	
		
			
				|  |  | +  gap: 16px;
 | 
	
		
			
				|  |  | +  padding: 12px 0;
 | 
	
		
			
				|  |  | +  border-top: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
 | 
	
		
			
				|  |  | +  font-size: 12px;
 | 
	
		
			
				|  |  | +  line-height: 16px;
 | 
	
		
			
				|  |  | +  font-weight: 600;
 | 
	
		
			
				|  |  | +  text-transform: uppercase;
 | 
	
		
			
				|  |  | +  color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  &:first-of-type {
 | 
	
		
			
				|  |  | +    padding-top: 0;
 | 
	
		
			
				|  |  | +    border: none;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +`;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  export const ShareModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
 | 
	
		
			
				|  |  |    const json = useConfig((state) => state.json);
 | 
	
		
			
				|  |  | -  const [url, setURL] = React.useState("");
 | 
	
		
			
				|  |  | +  const [encodedJson, setEncodedJson] = React.useState("");
 | 
	
		
			
				|  |  |    const [_, copy] = useCopyToClipboard();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  const embedText = `<iframe src="https://jsonvisio.com/widget/${encodedJson}" width="512" height="384"></iframe>`;
 | 
	
		
			
				|  |  | +  const shareURL = `https://jsonvisio.com/editor?json=${encodedJson}`;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    React.useEffect(() => {
 | 
	
		
			
				|  |  |      const jsonEncode = compress(JSON.parse(json));
 | 
	
		
			
				|  |  |      const jsonString = JSON.stringify(jsonEncode);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    setURL(
 | 
	
		
			
				|  |  | -      `https://jsonvisio.com/editor?json=${encodeURIComponent(jsonString)}`
 | 
	
		
			
				|  |  | -    );
 | 
	
		
			
				|  |  | +    setEncodedJson(encodeURIComponent(jsonString));
 | 
	
		
			
				|  |  |    }, [json]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const handleShare = () => {
 | 
	
		
			
				|  |  | -    copy(url);
 | 
	
		
			
				|  |  | +  const handleShare = (value: string) => {
 | 
	
		
			
				|  |  | +    copy(value);
 | 
	
		
			
				|  |  |      toast.success(`Link copied to clipboard.`);
 | 
	
		
			
				|  |  |      setVisible(false);
 | 
	
		
			
				|  |  |    };
 | 
	
	
		
			
				|  | @@ -44,7 +68,7 @@ export const ShareModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
 | 
	
		
			
				|  |  |      <Modal visible={visible} setVisible={setVisible}>
 | 
	
		
			
				|  |  |        <Modal.Header>Create a Share Link</Modal.Header>
 | 
	
		
			
				|  |  |        <Modal.Content>
 | 
	
		
			
				|  |  | -        {url.length > 5000 ? (
 | 
	
		
			
				|  |  | +        {encodedJson.length > 5000 ? (
 | 
	
		
			
				|  |  |            <StyledErrorWrapper>
 | 
	
		
			
				|  |  |              <BiErrorAlt size={60} />
 | 
	
		
			
				|  |  |              <StyledWarning>
 | 
	
	
		
			
				|  | @@ -53,16 +77,35 @@ export const ShareModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
 | 
	
		
			
				|  |  |              </StyledWarning>
 | 
	
		
			
				|  |  |            </StyledErrorWrapper>
 | 
	
		
			
				|  |  |          ) : (
 | 
	
		
			
				|  |  | -          <Input value={url} type="url" readOnly />
 | 
	
		
			
				|  |  | +          <>
 | 
	
		
			
				|  |  | +            <StyledContainer>
 | 
	
		
			
				|  |  | +              Share Link
 | 
	
		
			
				|  |  | +              <StyledFlex>
 | 
	
		
			
				|  |  | +                <Input value={shareURL} type="url" readOnly />
 | 
	
		
			
				|  |  | +                <Button
 | 
	
		
			
				|  |  | +                  status="SECONDARY"
 | 
	
		
			
				|  |  | +                  onClick={() => handleShare(shareURL)}
 | 
	
		
			
				|  |  | +                >
 | 
	
		
			
				|  |  | +                  Copy
 | 
	
		
			
				|  |  | +                </Button>
 | 
	
		
			
				|  |  | +              </StyledFlex>
 | 
	
		
			
				|  |  | +            </StyledContainer>
 | 
	
		
			
				|  |  | +            <StyledContainer>
 | 
	
		
			
				|  |  | +              Embed into your website
 | 
	
		
			
				|  |  | +              <StyledFlex>
 | 
	
		
			
				|  |  | +                <Input value={embedText} type="url" readOnly />
 | 
	
		
			
				|  |  | +                <Button
 | 
	
		
			
				|  |  | +                  status="SECONDARY"
 | 
	
		
			
				|  |  | +                  onClick={() => handleShare(embedText)}
 | 
	
		
			
				|  |  | +                >
 | 
	
		
			
				|  |  | +                  Copy
 | 
	
		
			
				|  |  | +                </Button>
 | 
	
		
			
				|  |  | +              </StyledFlex>
 | 
	
		
			
				|  |  | +            </StyledContainer>
 | 
	
		
			
				|  |  | +          </>
 | 
	
		
			
				|  |  |          )}
 | 
	
		
			
				|  |  |        </Modal.Content>
 | 
	
		
			
				|  |  | -      <Modal.Controls setVisible={setVisible}>
 | 
	
		
			
				|  |  | -        {url.length < 5000 && (
 | 
	
		
			
				|  |  | -          <Button status="SECONDARY" onClick={handleShare}>
 | 
	
		
			
				|  |  | -            Copy
 | 
	
		
			
				|  |  | -          </Button>
 | 
	
		
			
				|  |  | -        )}
 | 
	
		
			
				|  |  | -      </Modal.Controls>
 | 
	
		
			
				|  |  | +      <Modal.Controls setVisible={setVisible}></Modal.Controls>
 | 
	
		
			
				|  |  |      </Modal>
 | 
	
		
			
				|  |  |    );
 | 
	
		
			
				|  |  |  };
 |