Skip to content

Commit

Permalink
Merge pull request #199 from MeeTeamNumdle/release-1.0
Browse files Browse the repository at this point in the history
fix: 5차 QA 피드백 배포 브랜치에 적용
  • Loading branch information
kimsuyeon0916 authored May 16, 2024
2 parents d4b7f36 + 29774fa commit b73a737
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/muiDatepicker/MuiDatepickerController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const MuiDatepickerController = ({ name, control, formState, rules }: Date) => {
render={({ field: { onChange, ref, value } }) => (
<MuiDatepicker
defaultValue={new Date(value)}
value={new Date(value)}
handleChange={onChange}
inputRef={ref}
invalid={!!inputError}
Expand Down
56 changes: 56 additions & 0 deletions src/pages/portfolio/details/PortfolioDetails.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,62 @@ const PortfolioDetailsContent = styled.article`
padding: 0 clamp(5%, 9.8rem, 8%);
font-weight: 500;
white-space: pre-wrap; // 줄바꿈
/* 상세 내용 스타일링 */
.empty-p {
line-height: 1.2;
}
h1 {
font-size: 3.2rem;
}
h2 {
font-size: 2.4rem;
}
h3 {
font-size: 1.872rem;
}
h4 {
font-size: 1.6rem;
}
h5 {
font-size: 1.328rem;
}
h6 {
font-size: 1.072rem;
}
strong {
font-weight: bold;
}
em {
font-style: italic;
}
blockquote {
border-left: 4px solid #ccc;
margin-bottom: 5px;
margin-top: 5px;
padding-left: 16px;
}
ul {
list-style-type: circle;
padding-left: 2rem;
}
ol {
list-style-type: decimal;
padding-left: 2rem;
}
.ql-indent-1 {
margin-left: 5rem;
}
.ql-indent-2 {
margin-left: 10rem;
}
.ql-indent-3 {
margin-left: 15rem;
}
`;

const PortfolioDetailsButtonContainer = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions src/pages/portfolio/details/PortfolioDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useNavigate, useParams } from 'react-router-dom';
import { useReadPortfolio, useDeletePortfolio } from '../../../hooks';
import { Image, BlobFile } from '../../../types';
import { fixModalBackground, unzipFile } from '../../../utils';
import { addClassToEmptyPTags, fixModalBackground, unzipFile } from '../../../utils';
import { useRecoilState } from 'recoil';
import { uploadImageListState } from '../../../atom';
import { TrashCan } from '../../../assets';
Expand Down Expand Up @@ -148,7 +148,7 @@ const PortfolioDetailsPage = () => {
<S.PortfolioDetailsContent
className='container-contents'
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(portfolio?.content as string),
__html: DOMPurify.sanitize(addClassToEmptyPTags(portfolio?.content as string)),
}}
/>
</S.PortfolioDetailsArticle>
Expand Down
13 changes: 9 additions & 4 deletions src/pages/portfolio/edit/PortfolioEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,19 @@ const PortfolioEditPage = () => {
}
}, [isSuccessReadPortfolio]);

const checkKeyDown = (e: React.KeyboardEvent) => {
const checkEnterKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') e.preventDefault();
};

const checkTabKeyDown = (event: React.KeyboardEvent<ReactQuill>) => {
if (event.key === 'Tab') event.preventDefault();
};

return (
<>
<S.PortfolioEditLayout
onSubmit={handleSubmit(submitHandler)}
onKeyDown={e => checkKeyDown(e)}
onKeyDown={e => checkEnterKeyDown(e)}
>
<S.PortfolioEditColumn $gap='4rem'>
<S.PortfolioEditHeader>
Expand Down Expand Up @@ -350,7 +354,7 @@ const PortfolioEditPage = () => {
differenceInDays(
new Date(watch('endDate') as string),
new Date(startDate)
) < 0 && '시작일을 종료일보다 빠르게 설정해주세요'
) >= 0 || '시작일을 종료일보다 빠르게 설정해주세요'
);
},
}}
Expand Down Expand Up @@ -425,10 +429,11 @@ const PortfolioEditPage = () => {
ref(e);
if (quillRef) quillRef.current = e;
}}
defaultValue={portfolio?.content}
value={portfolio?.content}
onChange={handleChangeEditor}
modules={modules}
formats={formats}
onKeyDown={checkTabKeyDown}
{...PORTFOLIO_EDIT_DATA.content}
/>
</S.PortfolioEditColumn>
Expand Down
15 changes: 15 additions & 0 deletions src/utils/addClassToEmptyPTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const addClassToEmptyPTags = (html: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const pTags = doc.getElementsByTagName('p');

for (let i = 0; i < pTags.length; i++) {
if (pTags[i].innerHTML === '&nbsp;') {
pTags[i].classList.add('empty-p');
}
}

return doc.body.innerHTML;
};

export default addClassToEmptyPTags;
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import isNotNumber from './isNotNumber';
import calculateDate from './calculateDate';
import resetFormData from './resetFormData';
import throttle from './throttle';
import addClassToEmptyPTags from './addClassToEmptyPTags';

export {
modules,
Expand All @@ -31,4 +32,5 @@ export {
calculateDate,
resetFormData,
throttle,
addClassToEmptyPTags,
};

0 comments on commit b73a737

Please sign in to comment.