-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: (#816) 이벤트 코드 삭제 * fix: (#816) 파이어폭스에서 게시글 카테고리 및 제목이 중앙정렬되는 문제 해결 * fix: (#816) 사파리에서 지원되지 않는 정규표현식 수정 - 불특정 사파리에서 Invalid regular expression: Invalid group specifier name 오류 - WebKit 기반의 브라우저에서 정규표현식의 lookbehind를 지원하지 않음 - 해당 로직 수정 * test: 첨부링크 형식 변환 유틸함수 테스트 코드 추가 - []가 삼중인 경우 가장 안쪽 [[]]를 링크태그 변환 * fix: (#816) 파이어폭스에서 알림 툴팁 UI 오류 해결 * fix: (#816) IOS 15버전의 버튼/링크 태그 글씨색 파란색으로 표시 오류 수정 * refactor: (#816) 불필요한 코드 삭제
- Loading branch information
Showing
13 changed files
with
27 additions
and
135 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
This file contains 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 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 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 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 |
---|---|---|
@@ -1,31 +1,15 @@ | ||
import React, { useState } from 'react'; | ||
import React from 'react'; | ||
|
||
import chevronUp from '@assets/chevron_up_primary.svg'; | ||
import mascotYo from '@assets/dangseon-yo.png'; | ||
|
||
import * as S from './style'; | ||
|
||
interface UpButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {} | ||
|
||
export default function UpButton({ ...rest }: UpButtonProps) { | ||
const [count, setCount] = useState(0); | ||
|
||
//이벤트를 위한 코드 | ||
const handleLogoClick = () => { | ||
if (count > 5) return; | ||
|
||
setCount(count + 1); | ||
}; | ||
const handleClick = () => { | ||
setCount(0); | ||
}; | ||
|
||
return ( | ||
<> | ||
<S.Button {...rest}> | ||
<img src={chevronUp} alt="페이지 최상단으로 스크롤 올리기" onClick={handleLogoClick} /> | ||
</S.Button> | ||
<S.Image src={mascotYo} onClick={handleClick} $isMoving={count > 5} /> | ||
</> | ||
<S.Button {...rest}> | ||
<img src={chevronUp} alt="페이지 최상단으로 스크롤 올리기" /> | ||
</S.Button> | ||
); | ||
} |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,29 +1,18 @@ | ||
/** | ||
* https://abc.co.kr/@abc/4 | ||
* https://votogether.com/ | ||
* http://localhost:3000/posts/100035 | ||
* http://votogether.com/ | ||
* (?<!\[\[) 는 앞에 [[로 시작하는 지 여부를 확인한다 | ||
* https?:\/\/는 http:// 혹은 https:// 로 시작하는 지 여부를 확인한다. | ||
* (?!\]\]) 는 뒤에 ]]로 끝나는 지 여부를 확인한다. | ||
* [^\s] 는 공백이 아닌 문자인지 여부를 확인한다. | ||
*/ | ||
const httpsOrHttpRegex = /(?<!\[\[)(https?:\/\/[^\s]+)(?!\]\])/g; | ||
|
||
/** | ||
* www.naver.com | ||
* www.tistory.com | ||
* (?<!\[\[) 는 앞에 [[로 시작하는 지 여부를 확인한다 | ||
* (?<!\/)는 앞에 /로 시작하는 지 여부를 확인한다. https://www 에서 www 앞에 /가 있기에 중복되어 확인하는 것을 방지하기 위함 | ||
* \b(w{3})\b 는 www로 시작하는 지 여부를 정확히 확인한다. w가 4개인 경우 판별하지 않음 | ||
* [^\s] 는 공백이 아닌 문자인지 여부를 확인한다. | ||
* (?!\]\]) 는 뒤에 ]]로 끝나는 지 여부를 확인한다. | ||
*/ | ||
const wwwRegex = /(?<!\[\[)(?<!\/)\b(w{3})\b[^\s]+(?!\]\])/g; | ||
// linkRegex: https:// | http:// | www. 뒤에 문자+숫자+특수기호가 이어져있는 정규표현식 | ||
const linkRegex = /(?:https?:\/\/|w{3}\.)+[a-z0-9-+&@#/%?=~_|!:,.;]*[a-z0-9-+&@#/%=~_|]/g; | ||
// [[ ]]를 표현하는 정규표현식 | ||
const customLinkPattern = /\[\[([^[\]]+)\]\]/g; | ||
|
||
export const convertTextToUrl = (text: string) => { | ||
const httpOrHttpsConvertedText = text.replace(httpsOrHttpRegex, url => `[[${url}]]`); | ||
const wwwConvertedText = httpOrHttpsConvertedText.replace(wwwRegex, url => `[[${url}]]`); | ||
//아아[[링크]]다다 = [아아, 링크, 다다]; | ||
const parts = text.split(customLinkPattern); | ||
|
||
return parts | ||
.map(part => { | ||
//linkRegex를 포함하지 않는다면 그대로 return | ||
if (!linkRegex.test(part)) return part; | ||
|
||
return wwwConvertedText; | ||
return part.replace(linkRegex, url => `[[${url}]]`); | ||
}) | ||
.join(''); | ||
}; |