feat: PDF 불러오기 (Phase 2, 텍스트 + 기본 구조화)#16
Open
revfactory wants to merge 5 commits into
Open
Conversation
issue #5 B 분기 — 텍스트와 기본 구조화만 추출하는 1차 구현. 추가 파일: - src/types/pdf.ts: PdfBlock / PdfImportOptions / PdfParseResult / PdfParsedPage 등 워커-UI 간 메시지·결과 타입 정의. - src/lib/pdf-converter.ts: pdfjs 페이지 라인 → 마크다운 블록 변환 휴리스틱. - 제목: 페이지 평균 폰트 1.2배 이상인 줄을 H1~H3 으로 매핑. - 목록: •/·/-/*/1./1)/① 등 마커 인식 → 순서·비순서 리스트. - 문단: 동일 단락 라인은 공백으로 이어 붙여 단일 블록화. - 페이지 사이: 빈 줄만 삽입 (페이지 번호·머리말·꼬리말 제거, 줄끝 하이픈 복원은 후속 PR — TODO 주석으로 명시). - src/workers/pdf-parser.worker.ts: pdfjs-dist 를 동적 import 한 뒤 중첩 워커 없이(fake-worker 모드) 페이지별 텍스트와 폰트 크기를 추출. 진행률 메시지 + %PDF 매직 검증 + 스캔본 추정 경고 포함. Refs #5
issue #5 B 분기 — use-hwp.ts / hwp-import.tsx 패턴을 그대로 복제해 UI 톤을 통일. - src/hooks/use-pdf.ts: usePdfImport — File → Worker → 진행률/ 결과/에러 상태 관리. transferable ArrayBuffer 로 복사 비용 제거. - src/components/features/import-export/pdf-import.tsx: 드롭존 + 파일 선택 + 진행률 + 결과·경고·오류 모달. 상단에 "텍스트와 기본 구조만 추출, 표·이미지·OCR 미지원" 안내를 상시 노출. 50MB 초과 시 시간 경고, 200페이지 초과 시 정확도 경고. Refs #5
issue #5 B 분기 — UI 진입점을 기존 MD/HWP 임포트 옆에 추가. - src/components/layout/sidebar.tsx: 사이드바 임포트 버튼 영역에 PDF 버튼 추가. 한 줄에 3개가 들어가도록 라벨을 MD/HWP/PDF 로 축약. onImportPdf prop 추가. - src/app/page.tsx: pdfImportOpen 상태 + handlePdfImportComplete 핸들러 추가. 변환 완료 후 "텍스트만 추출되었습니다. 표·이미지· OCR 미지원" 토스트 노출. 대용량 결과는 기존 청크 분할 파이프 라인 재사용. PdfImport 모달을 page tree 에 마운트. - src/lib/analytics.ts: analytics.importPdf 이벤트 추가. Closes #5
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+184
to
+188
| return text | ||
| // Escape leading characters that would be parsed as block syntax | ||
| .replace(/^(\s*)([#>|])/, '$1\\$2') | ||
| // Escape backticks to avoid accidental inline code spans | ||
| .replace(/`/g, '\\`'); |
|
|
||
| // ---------- Message handler ---------- | ||
|
|
||
| self.onmessage = async (e: MessageEvent<PdfParseMessage>) => { |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📝 변경 요약
PDF 파일 임포트 기능을 Branch B (텍스트 + 기본 구조화) 범위로 구현합니다.
pdfjs-dist(Mozilla, Apache-2.0) 기반 Web Worker 파서•,·,-,*,1.,1),①) 인식 → 마크다운 리스트MDVIEW_SPEC.md<future_considerations>에 PDF 임포트(Phase 2) 항목을 정식 추가했고, CHANGELOG[Unreleased]에도 등록했습니다.Closes #5
🔍 원인 · 배경
이슈 트리아지 (
_workspace/issues/5/triage.md) 결론:<out_of_scope>직전).🧱 변경 파일
MDVIEW_SPEC.md<future_considerations>에 PDF 임포트 (Phase 2) 한 줄 추가package.json/package-lock.jsonpdfjs-dist@^5.7의존성 추가src/types/pdf.ts(신규)PdfBlock,PdfImportOptions,PdfParseResult,PdfParsedPage등 메시지·결과 타입src/lib/pdf-converter.ts(신규)src/workers/pdf-parser.worker.ts(신규)pdfjs-dist동적 import → 페이지별 텍스트/폰트 크기 추출src/hooks/use-pdf.ts(신규)src/components/features/import-export/pdf-import.tsx(신규)src/components/layout/sidebar.tsxsrc/app/page.tsxpdfImportOpen상태,handlePdfImportComplete,<PdfImport />마운트src/lib/analytics.tsanalytics.importPdf이벤트CHANGELOG.md[Unreleased]에 PDF 임포트 항목❌ 이번 PR에 포함되지 않은 것 (의도적)
tesseract.js미도입위 항목들은
pdf-converter.ts파일 헤더 / TODO 주석에 후속 PR 대상으로 명시했습니다.🧪 검증
npm run lint— 신규 추가 lint 이슈 0건 (베이스라인 29개 문제 동일, 모두 사전 존재)npm run typecheck— 깨끗npm run build— 정적 빌드 성공⚙️ 구현 메모
disableFontFace: true+ 빈workerSrc로 fake-worker 모드 사용 → 중첩 Worker 회피.postMessagetransferable 로 전달 → 메인 ↔ 워커 메모리 복사 제거.chunkDocument파이프라인을 그대로 재사용해 페이지네이션 편집기로 자동 전환.📌 비고 / 후속