Fix document links and backlinks rendering issue

- Fixed CachedAPI endpoint routing: /documents/{id}/links was incorrectly routed to getDocument()
- Added proper pattern matching for document API calls using regex
- Fixed link and backlink API calls to use correct getDocumentLinks() and getDocumentBacklinks() methods
- Added comprehensive debugging logs for API response tracking
- Resolved issue where links were not rendering in document viewer

Changes:
- cached-api.js: Fixed endpoint routing with proper regex pattern matching
- link-manager.js: Enhanced debugging and API response handling
- viewer-core.js: Added closeAllModals() to prevent modal auto-opening

Result: Document links and backlinks now render correctly (8 links restored)
This commit is contained in:
Hyungi Ahn
2025-08-28 13:21:03 +09:00
parent 844587c86f
commit 7f68c19481
3 changed files with 99 additions and 13 deletions

View File

@@ -148,9 +148,12 @@ window.documentViewer = () => ({
throw new Error('필수 모듈을 로드할 수 없습니다.');
}
// UI 상태를 UIManager와 동기화
// UI 상태를 UIManager와 동기화 (모달은 초기화 시 닫힌 상태로)
this.syncUIState();
// 초기화 시 모든 모달을 명시적으로 닫기
this.closeAllModals();
// 나머지 모듈들은 백그라운드에서 프리로딩 (지연 로딩 가능한 경우만)
if (window.moduleLoader) {
window.moduleLoader.preloadModules(['HighlightManager', 'BookmarkManager', 'LinkManager']);
@@ -223,6 +226,22 @@ window.documentViewer = () => ({
}
},
// ==================== 모든 모달 닫기 ====================
closeAllModals() {
console.log('🔒 초기화 시 모든 모달 닫기');
this.showLinksModal = false;
this.showLinkModal = false;
this.showNotesModal = false;
this.showBookmarksModal = false;
this.showBacklinksModal = false;
this.showNoteInputModal = false;
// UIManager에도 반영
if (this.uiManager) {
this.uiManager.closeAllModals();
}
},
// ==================== URL 파라미터 처리 ====================
parseUrlParameters() {
const urlParams = new URLSearchParams(window.location.search);
@@ -289,13 +308,17 @@ window.documentViewer = () => ({
this.linkManager.loadBacklinks(this.documentId)
]);
// 데이터 저장
// 데이터 저장 및 모듈 동기화
this.highlights = highlights;
this.notes = notes;
this.bookmarks = bookmarks;
this.documentLinks = documentLinks;
this.backlinks = backlinks;
// 모듈에 데이터 동기화 (중요!)
this.linkManager.documentLinks = documentLinks;
this.linkManager.backlinks = backlinks;
console.log('📊 로드된 데이터:', {
highlights: highlights.length,
notes: notes.length,
@@ -303,6 +326,11 @@ window.documentViewer = () => ({
documentLinks: documentLinks.length,
backlinks: backlinks.length
});
console.log('🔄 모듈 데이터 동기화 완료:', {
'linkManager.documentLinks': this.linkManager.documentLinks?.length || 0,
'linkManager.backlinks': this.linkManager.backlinks?.length || 0
});
},
// ==================== 모듈 지연 로딩 보장 (폴백 포함) ====================