에디터 미디어 모달 컴포넌트 분리

This commit is contained in:
2026-07-24 18:53:56 +09:00
parent 48982cfa52
commit 84cb3ad9e7
8 changed files with 378 additions and 210 deletions

View File

@@ -434,6 +434,17 @@ export const findUploadSizeLimitError = ({
return null
}
/**
* 미디어 선택 페이지 번호를 유효 범위로 보정한다.
* @param {number|string} page - 요청 페이지
* @param {number|string} pageCount - 전체 페이지 수
* @returns {number} 보정된 페이지
*/
export const normalizeMediaPickerPage = (page, pageCount) => {
const total = Math.max(1, Number(pageCount) || 1)
return Math.min(Math.max(Number(page) || 1, 1), total)
}
/**
* 미디어 선택 모달의 페이지 범위 표시 문구를 만든다.
* @param {Object} options - 범위 표시 옵션
@@ -455,8 +466,7 @@ export const buildMediaPickerRangeLabel = ({
return '0개'
}
const normalizedPageCount = Math.max(1, Number(pageCount) || 1)
const page = Math.min(Math.max(Number(pagination?.page) || currentPage, 1), normalizedPageCount)
const page = normalizeMediaPickerPage(Number(pagination?.page) || currentPage, pageCount)
const pageSize = Number(pagination?.pageSize) || defaultPageSize
const start = ((page - 1) * pageSize) + 1
const end = Math.min(start + pageSize - 1, total)
@@ -476,7 +486,7 @@ export const buildMediaPickerPageItems = ({
pageCount
}) => {
const total = Math.max(1, Number(pageCount) || 1)
const current = Math.min(Math.max(Number(currentPage) || 1, 1), total)
const current = normalizeMediaPickerPage(currentPage, total)
const pages = new Set([1, total, current])
for (let page = current - 2; page <= current + 2; page += 1) {