Fix: 하이라이트 메모 표시 오류 수정

- highlight-manager.js에서 showHighlightTooltip 함수 호출 시 배열 대신 단일 객체 전달하도록 수정
- 하이라이트 클릭 시 메모가 0개로 표시되던 문제 해결
- getOverlappingElements 함수에 디버깅 로그 추가
- 하이라이트 매니저 상태 확인 로그 추가
- 브라우저 캐시 무효화를 위한 버전 업데이트 (v=2025012617)
This commit is contained in:
Hyungi Ahn
2025-09-04 07:48:43 +09:00
parent 8f776a5281
commit 0786bdc86d
8 changed files with 1355 additions and 133 deletions

View File

@@ -64,6 +64,7 @@ class DocumentLinkResponse(BaseModel):
# 대상 문서 정보
target_document_title: str
target_document_book_id: Optional[str]
target_content_type: Optional[str] = "document" # "document" 또는 "note"
class Config:
from_attributes = True
@@ -241,19 +242,51 @@ async def get_document_links(
detail="Access denied"
)
# 링크 조회 (JOIN으로 대상 문서 정보도 함께)
# 모든 링크 조회 (문서→문서 + 문서→노트)
result = await db.execute(
select(DocumentLink, Document)
.join(Document, DocumentLink.target_document_id == Document.id)
select(DocumentLink)
.where(DocumentLink.source_document_id == document_id)
.order_by(DocumentLink.start_offset.asc())
)
links_with_targets = result.all()
all_links = result.scalars().all()
print(f"🔍 문서 링크 조회 완료: {len(all_links)}개 발견")
# 응답 데이터 구성
response_links = []
for link, target_doc in links_with_targets:
for link in all_links:
print(f"🔗 링크 처리 중: {link.id} -> {link.target_document_id}")
# 대상이 문서인지 노트인지 확인
target_doc = None
target_note = None
# 먼저 Document 테이블에서 찾기
doc_result = await db.execute(select(Document).where(Document.id == link.target_document_id))
target_doc = doc_result.scalar_one_or_none()
if target_doc:
print(f"✅ 대상 문서 찾음: {target_doc.title}")
target_title = target_doc.title
target_book_id = str(target_doc.book_id) if target_doc.book_id else None
target_content_type = "document"
else:
# Document에서 찾지 못하면 NoteDocument에서 찾기
from ...models.note_document import NoteDocument
note_result = await db.execute(select(NoteDocument).where(NoteDocument.id == link.target_document_id))
target_note = note_result.scalar_one_or_none()
if target_note:
print(f"✅ 대상 노트 찾음: {target_note.title}")
target_title = f"📝 {target_note.title}" # 노트임을 표시
target_book_id = str(target_note.notebook_id) if target_note.notebook_id else None
target_content_type = "note"
else:
print(f"❌ 대상을 찾을 수 없음: {link.target_document_id}")
target_title = "Unknown Target"
target_book_id = None
target_content_type = "document" # 기본값
response_links.append(DocumentLinkResponse(
id=str(link.id),
source_document_id=str(link.source_document_id),
@@ -270,9 +303,10 @@ async def get_document_links(
target_start_offset=getattr(link, 'target_start_offset', None),
target_end_offset=getattr(link, 'target_end_offset', None),
link_type=getattr(link, 'link_type', 'document'),
# 대상 문서 정보
target_document_title=target_doc.title,
target_document_book_id=str(target_doc.book_id) if target_doc.book_id else None
# 대상 문서/노트 정보 추가
target_document_title=target_title,
target_document_book_id=target_book_id,
target_content_type=target_content_type
))
return response_links

View File

@@ -33,7 +33,7 @@ router = APIRouter()
# 용어 정의: 하이라이트에 달리는 짧은 코멘트
@router.post("/")
async def create_note(
def create_note(
note_data: dict,
db: Session = Depends(get_sync_db),
current_user: User = Depends(get_current_user)
@@ -65,6 +65,39 @@ async def create_note(
return note
@router.put("/{note_id}")
def update_note(
note_id: str,
note_data: dict,
db: Session = Depends(get_sync_db),
current_user: User = Depends(get_current_user)
):
"""하이라이트 메모 업데이트"""
from ...models.note import Note
from ...models.highlight import Highlight
# 메모 존재 및 소유권 확인
note = db.query(Note).join(Highlight).filter(
Note.id == note_id,
Highlight.user_id == current_user.id
).first()
if not note:
raise HTTPException(status_code=404, detail="메모를 찾을 수 없습니다")
# 메모 업데이트
if 'content' in note_data:
note.content = note_data['content']
if 'tags' in note_data:
note.tags = note_data['tags']
note.updated_at = datetime.utcnow()
db.commit()
db.refresh(note)
return note
@router.get("/document/{document_id}")
async def get_document_notes(
document_id: str,
@@ -118,7 +151,7 @@ def calculate_word_count(content: str) -> int:
return korean_chars + english_words
@router.get("/", response_model=List[NoteDocumentListItem])
@router.get("/")
def get_notes(
skip: int = Query(0, ge=0),
limit: int = Query(50, ge=1, le=100),
@@ -128,10 +161,34 @@ def get_notes(
published_only: bool = Query(False),
parent_id: Optional[str] = Query(None),
notebook_id: Optional[str] = Query(None), # 노트북 필터
document_id: Optional[str] = Query(None), # 하이라이트 메모 조회용
note_document_id: Optional[str] = Query(None), # 노트 문서의 하이라이트 메모 조회용
db: Session = Depends(get_sync_db),
current_user: User = Depends(get_current_user)
):
"""노트 목록 조회"""
"""노트 목록 조회 또는 하이라이트 메모 조회"""
# 하이라이트 메모 조회 요청인 경우
if document_id or note_document_id:
from ...models.note import Note
from ...models.highlight import Highlight
if document_id:
# 일반 문서의 하이라이트 메모 조회
notes = db.query(Note).join(Highlight).filter(
Highlight.document_id == document_id,
Highlight.user_id == current_user.id
).options(
selectinload(Note.highlight)
).all()
else:
# 노트 문서의 하이라이트 메모 조회 (note_document_id)
# 노트 하이라이트 모델이 있다면 사용, 없다면 빈 리스트 반환
notes = []
return notes
# 일반 노트 문서 목록 조회
# 동기 SQLAlchemy 스타일
query = db.query(NoteDocument)