하이라이트 색상 문제 해결 및 다중 하이라이트 렌더링 개선

주요 수정사항:
- 하이라이트 생성 시 color → highlight_color 필드명 수정으로 색상 전달 문제 해결
- 분홍색을 더 연하게 변경하여 글씨 가독성 향상
- 다중 하이라이트 렌더링을 위아래 균등 분할로 개선
- CSS highlight-span 클래스 추가 및 색상 적용 강화
- 하이라이트 생성/렌더링 과정에 상세한 디버깅 로그 추가

UI 개선:
- 단일 하이라이트: 선택한 색상으로 정확히 표시
- 다중 하이라이트: 위아래로 균등하게 색상 분할 표시
- 메모 입력 모달에서 선택된 텍스트 표시 개선

버그 수정:
- 프론트엔드-백엔드 API 스키마 불일치 해결
- CSS 스타일 우선순위 문제 해결
- 하이라이트 색상이 노랑색으로만 표시되던 문제 해결
This commit is contained in:
Hyungi Ahn
2025-08-28 07:13:00 +09:00
parent 3e0a03f149
commit 5d4465b15c
18 changed files with 5569 additions and 648 deletions

View File

@@ -88,6 +88,16 @@ async def create_document_link(
db: AsyncSession = Depends(get_db)
):
"""문서 링크 생성"""
print(f"🔗 링크 생성 요청 - 문서 ID: {document_id}")
print(f"📋 링크 데이터: {link_data}")
print(f"🎯 target_text: '{link_data.target_text}'")
print(f"🎯 target_start_offset: {link_data.target_start_offset}")
print(f"🎯 target_end_offset: {link_data.target_end_offset}")
print(f"🎯 link_type: {link_data.link_type}")
if link_data.link_type == 'text_fragment' and not link_data.target_text:
print("🚨 CRITICAL: text_fragment 링크인데 target_text가 없습니다!")
# 출발 문서 확인
result = await db.execute(select(Document).where(Document.id == document_id))
source_doc = result.scalar_one_or_none()
@@ -150,6 +160,13 @@ async def create_document_link(
await db.commit()
await db.refresh(new_link)
print(f"✅ 링크 생성 완료: {source_doc.title} -> {target_doc.title}")
print(f" - 링크 타입: {new_link.link_type}")
print(f" - 선택된 텍스트: {new_link.selected_text}")
print(f" - 대상 텍스트: {new_link.target_text}")
# 백링크는 자동으로 생성되지 않음 - 기존 링크를 역방향으로 조회하는 방식 사용
# 응답 데이터 구성
return DocumentLinkResponse(
id=str(new_link.id),
@@ -402,14 +419,17 @@ class BacklinkResponse(BaseModel):
source_document_id: str
source_document_title: str
source_document_book_id: Optional[str]
target_document_id: str # 추가
target_document_title: str # 추가
selected_text: str
start_offset: int
end_offset: int
target_document_id: str
target_document_title: str
selected_text: str # 소스 문서에서 선택한 텍스트
start_offset: int # 소스 문서 오프셋
end_offset: int # 소스 문서 오프셋
link_text: Optional[str]
description: Optional[str]
link_type: str
target_text: Optional[str] # 🎯 타겟 문서의 텍스트 (백링크 렌더링용)
target_start_offset: Optional[int] # 🎯 타겟 문서 오프셋 (백링크 렌더링용)
target_end_offset: Optional[int] # 🎯 타겟 문서 오프셋 (백링크 렌더링용)
created_at: str
class Config:
@@ -465,7 +485,9 @@ async def get_document_backlinks(
for link, source_doc, book in result.fetchall():
print(f"📋 백링크 발견: {source_doc.title} -> {document.title}")
print(f" - 선택된 텍스트: {link.selected_text}")
print(f" - 소스 텍스트 (selected_text): {link.selected_text}")
print(f" - 타겟 텍스트 (target_text): {link.target_text}")
print(f" - 타겟 오프셋: {link.target_start_offset}-{link.target_end_offset}")
print(f" - 링크 타입: {link.link_type}")
backlinks.append(BacklinkResponse(
@@ -473,14 +495,17 @@ async def get_document_backlinks(
source_document_id=str(link.source_document_id),
source_document_title=source_doc.title,
source_document_book_id=str(book.id) if book else None,
target_document_id=str(link.target_document_id), # 추가
target_document_title=document.title, # 추가
selected_text=link.selected_text,
start_offset=link.start_offset,
end_offset=link.end_offset,
target_document_id=str(link.target_document_id),
target_document_title=document.title,
selected_text=link.selected_text, # 소스 문서에서 선택한 텍스트 (참고용)
start_offset=link.start_offset, # 소스 문서 오프셋 (참고용)
end_offset=link.end_offset, # 소스 문서 오프셋 (참고용)
link_text=link.link_text,
description=link.description,
link_type=link.link_type,
target_text=link.target_text, # 🎯 타겟 문서의 텍스트 (백링크 렌더링용)
target_start_offset=link.target_start_offset, # 🎯 타겟 문서 오프셋 (백링크 렌더링용)
target_end_offset=link.target_end_offset, # 🎯 타겟 문서 오프셋 (백링크 렌더링용)
created_at=link.created_at.isoformat()
))