- 
                Notifications
    
You must be signed in to change notification settings  - Fork 50
 
feat: markdown editor and markdown renderer #2140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            15 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      e59e79b
              
                feat: markdown editor and markdown renderer
              
              
                kemuru e7971b8
              
                fix: styling fixes, hack to make the text flicker appear
              
              
                kemuru d82188a
              
                feat: style improvements
              
              
                kemuru e1a3d05
              
                chore: comments from ai reviews
              
              
                kemuru 9d4b286
              
                feat: link popup warning, clean up codes
              
              
                kemuru 4f35c9d
              
                Merge branch 'dev' into feat/markdown-editor-and-markdown-renderer
              
              
                kemuru e3dc195
              
                Potential fix for code scanning alert no. 96: Bad HTML filtering regexp
              
              
                kemuru 942fa9e
              
                chore: dompurify in packagejson
              
              
                kemuru 20ae3a4
              
                Potential fix for code scanning alert no. 97: Incomplete URL scheme c…
              
              
                kemuru e2d7c81
              
                feat: max height and scrollable on mobile
              
              
                kemuru 48abffb
              
                Merge branch 'dev' into feat/markdown-editor-and-markdown-renderer
              
              
                kemuru 859834b
              
                feat: switch to reactmarkdown, remark gfm, rehype raw and rehype sani…
              
              
                kemuru 56aaca8
              
                chore: style impros resolver description
              
              
                kemuru 94e4783
              
                chore: slight transition and coloring
              
              
                kemuru a8d32b8
              
                chore: small styling issue
              
              
                kemuru File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import React from "react"; | ||
| import styled, { css } from "styled-components"; | ||
| 
     | 
||
| import Modal from "react-modal"; | ||
| 
     | 
||
| import { Button } from "@kleros/ui-components-library"; | ||
| 
     | 
||
| import WarningIcon from "svgs/icons/warning-outline.svg"; | ||
| 
     | 
||
| import { landscapeStyle } from "styles/landscapeStyle"; | ||
| 
     | 
||
| const StyledModal = styled(Modal)` | ||
| position: absolute; | ||
| top: 50%; | ||
| left: 50%; | ||
| right: auto; | ||
| bottom: auto; | ||
| margin-right: -50%; | ||
| transform: translate(-50%, -50%); | ||
| height: auto; | ||
| width: min(90%, 480px); | ||
| border: 1px solid ${({ theme }) => theme.stroke}; | ||
| border-radius: 8px; | ||
| background-color: ${({ theme }) => theme.whiteBackground}; | ||
| padding: 32px; | ||
| box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); | ||
| z-index: 10002; | ||
| `; | ||
| 
     | 
||
| const Overlay = styled.div` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background-color: rgba(0, 0, 0, 0.5); | ||
| z-index: 10001; | ||
| `; | ||
| 
     | 
||
| const Header = styled.div` | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 12px; | ||
| margin-bottom: 16px; | ||
| `; | ||
| 
     | 
||
| const StyledWarningIcon = styled(WarningIcon)` | ||
| width: 24px; | ||
| height: 24px; | ||
| fill: ${({ theme }) => theme.warning}; | ||
| `; | ||
| 
     | 
||
| const Title = styled.h3` | ||
| color: ${({ theme }) => theme.primaryText}; | ||
| font-size: 18px; | ||
| font-weight: 600; | ||
| margin: 0; | ||
| `; | ||
| 
     | 
||
| const Message = styled.p` | ||
| color: ${({ theme }) => theme.primaryText}; | ||
| font-size: 14px; | ||
| line-height: 1.5; | ||
| margin: 0 0 16px 0; | ||
| `; | ||
| 
     | 
||
| const UrlContainer = styled.div` | ||
| background-color: ${({ theme }) => theme.lightGrey}; | ||
| border: 1px solid ${({ theme }) => theme.stroke}; | ||
| border-radius: 4px; | ||
| padding: 12px; | ||
| margin: 16px 0; | ||
| word-break: break-all; | ||
| `; | ||
| 
     | 
||
| const Url = styled.code` | ||
| color: ${({ theme }) => theme.secondaryText}; | ||
| font-size: 13px; | ||
| font-family: monospace; | ||
| `; | ||
| 
     | 
||
| const ButtonContainer = styled.div` | ||
| display: flex; | ||
| gap: 12px; | ||
| justify-content: center; | ||
| flex-wrap: wrap; | ||
| margin-top: 24px; | ||
| 
     | 
||
| ${landscapeStyle( | ||
| () => css` | ||
| justify-content: flex-end; | ||
| ` | ||
| )} | ||
| `; | ||
| 
     | 
||
| const CancelButton = styled(Button)` | ||
| background-color: ${({ theme }) => theme.whiteBackground}; | ||
| border: 1px solid ${({ theme }) => theme.stroke}; | ||
| 
     | 
||
| p { | ||
| color: ${({ theme }) => theme.primaryText} !important; | ||
| } | ||
| 
     | 
||
| &:hover { | ||
| background-color: ${({ theme }) => theme.mediumBlue}; | ||
| } | ||
| `; | ||
| 
     | 
||
| const ConfirmButton = styled(Button)` | ||
| background-color: ${({ theme }) => theme.warning}; | ||
| color: ${({ theme }) => theme.whiteBackground}; | ||
| border: 1px solid ${({ theme }) => theme.warning}; | ||
| 
     | 
||
| &:hover { | ||
| background-color: ${({ theme }) => theme.warning}BB; | ||
| } | ||
| `; | ||
| 
     | 
||
| interface IExternalLinkWarning { | ||
| isOpen: boolean; | ||
| url: string; | ||
| onConfirm: () => void; | ||
| onCancel: () => void; | ||
| } | ||
| 
     | 
||
| const ExternalLinkWarning: React.FC<IExternalLinkWarning> = ({ isOpen, url, onConfirm, onCancel }) => { | ||
| return ( | ||
| <StyledModal | ||
| isOpen={isOpen} | ||
| onRequestClose={onCancel} | ||
| overlayElement={(props, contentElement) => <Overlay {...props}>{contentElement}</Overlay>} | ||
| ariaHideApp={false} | ||
| role="dialog" | ||
| aria-labelledby="external-link-title" | ||
| aria-describedby="external-link-description" | ||
| > | ||
| <Header> | ||
| <StyledWarningIcon /> | ||
| <Title id="external-link-title">External Link Warning</Title> | ||
| </Header> | ||
| 
     | 
||
| <Message id="external-link-description"> | ||
| You are about to navigate to an external website. Please verify the URL before proceeding to ensure it's | ||
| safe and legitimate. | ||
| </Message> | ||
| 
     | 
||
| <UrlContainer> | ||
| <Url>{url}</Url> | ||
| </UrlContainer> | ||
| 
     | 
||
| <Message> | ||
| <strong>Safety Tips:</strong> | ||
| <br /> | ||
| • Verify the domain name is correct | ||
| <br /> | ||
| • Check for suspicious characters or typos | ||
| <br />• Only proceed if you trust this destination | ||
| </Message> | ||
| 
     | 
||
| <ButtonContainer> | ||
| <CancelButton text="Cancel" onClick={onCancel} /> | ||
| <ConfirmButton text="Continue to External Site" onClick={onConfirm} /> | ||
| </ButtonContainer> | ||
| </StyledModal> | ||
| ); | ||
| }; | ||
| 
     | 
||
| export default ExternalLinkWarning; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.