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

@@ -53,8 +53,20 @@ class CachedAPI {
} else if (endpoint === '/document-links/backlinks' && params.target_document_id) {
// 실제: /documents/{documentId}/backlinks
response = await this.api.get(`/documents/${params.target_document_id}/backlinks`);
} else if (endpoint.startsWith('/documents/') && endpoint.includes('/')) {
} else if (endpoint.startsWith('/documents/') && endpoint.endsWith('/links')) {
// /documents/{documentId}/links 패턴
const documentId = endpoint.split('/')[2];
console.log('🔗 CachedAPI: 링크 API 직접 호출:', documentId);
response = await this.api.getDocumentLinks(documentId);
} else if (endpoint.startsWith('/documents/') && endpoint.endsWith('/backlinks')) {
// /documents/{documentId}/backlinks 패턴
const documentId = endpoint.split('/')[2];
console.log('🔗 CachedAPI: 백링크 API 직접 호출:', documentId);
response = await this.api.getDocumentBacklinks(documentId);
} else if (endpoint.startsWith('/documents/') && endpoint.match(/^\/documents\/[^\/]+$/)) {
// /documents/{documentId} 패턴만 (추가 경로 없음)
const documentId = endpoint.split('/')[2];
console.log('📄 CachedAPI: 문서 API 호출:', documentId);
response = await this.api.getDocument(documentId);
} else {
// 기본 API 호출 (기존 방식)