diff --git a/backend/src/api/routes/note_links.py b/backend/src/api/routes/note_links.py index ef372f8..125b11e 100644 --- a/backend/src/api/routes/note_links.py +++ b/backend/src/api/routes/note_links.py @@ -253,6 +253,20 @@ def create_note_link( "updated_at": note_link.updated_at.isoformat() if note_link.updated_at else None, } + # 소스 및 타겟 타입 설정 + response_data["source_content_type"] = "note" # 노트에서 출발하는 링크 + + if note_link.target_note_id: + target_note = db.query(NoteDocument).filter(NoteDocument.id == note_link.target_note_id).first() + if target_note: + response_data["target_note_title"] = target_note.title + response_data["target_content_type"] = "note" + elif note_link.target_document_id: + target_doc = db.query(Document).filter(Document.id == note_link.target_document_id).first() + if target_doc: + response_data["target_document_title"] = target_doc.title + response_data["target_content_type"] = "document" + return NoteLinkResponse(**response_data) diff --git a/backend/src/api/routes/notes.py b/backend/src/api/routes/notes.py index cfd697d..f1be56a 100644 --- a/backend/src/api/routes/notes.py +++ b/backend/src/api/routes/notes.py @@ -98,6 +98,29 @@ def update_note( return note +@router.delete("/{note_id}") +def delete_highlight_note( + note_id: str, + 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="메모를 찾을 수 없습니다") + + db.delete(note) + db.commit() + + return {"message": "메모가 삭제되었습니다"} + @router.get("/document/{document_id}") async def get_document_notes( document_id: str, diff --git a/frontend/static/js/api.js b/frontend/static/js/api.js index e35e256..4bab15c 100644 --- a/frontend/static/js/api.js +++ b/frontend/static/js/api.js @@ -277,6 +277,10 @@ class DocumentServerAPI { return await this.put(`/highlight-notes/${noteId}`, updateData); } + async deleteNote(noteId) { + return await this.delete(`/highlight-notes/${noteId}`); + } + // === 문서 메모 조회 === // 용어 정의: 특정 문서의 모든 하이라이트 메모 조회 async getDocumentNotes(documentId) { diff --git a/frontend/static/js/viewer/features/highlight-manager.js b/frontend/static/js/viewer/features/highlight-manager.js index 8d04152..e676fda 100644 --- a/frontend/static/js/viewer/features/highlight-manager.js +++ b/frontend/static/js/viewer/features/highlight-manager.js @@ -730,7 +730,21 @@ class HighlightManager { async deleteHighlight(highlightId) { try { await this.api.delete(`/highlights/${highlightId}`); + + // 하이라이트 배열에서 제거 this.highlights = this.highlights.filter(h => h.id !== highlightId); + + // 메모 배열에서도 해당 하이라이트의 메모들 제거 + this.notes = this.notes.filter(note => note.highlight_id !== highlightId); + + // 캐시 무효화 (하이라이트와 메모 모두) + if (window.documentViewerInstance && window.documentViewerInstance.cacheManager) { + window.documentViewerInstance.cacheManager.invalidateCategory('highlights'); + window.documentViewerInstance.cacheManager.invalidateCategory('notes'); + console.log('🗑️ 하이라이트 삭제 후 캐시 무효화 완료'); + } + + // 화면 다시 렌더링 this.renderHighlights(); console.log('하이라이트 삭제 완료:', highlightId); } catch (error) { @@ -1071,7 +1085,7 @@ class HighlightManager { 복사 -