mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: refresh overlays via _rebuildVisibleLayers on create/delete
This commit is contained in:
parent
b228f4d472
commit
6618824253
1 changed files with 13 additions and 7 deletions
|
|
@ -816,9 +816,7 @@ function setupSelectionCapture(containerEl, vaultPath, pdfPath) {
|
|||
if (result.ok) {
|
||||
sel.removeAllRanges();
|
||||
if (toolbar) { toolbar.remove(); toolbar = null; }
|
||||
invalidateAnnotationCache();
|
||||
fetchAnnotationsForPaper(vaultPath, pdfPath);
|
||||
renderAnnotationsOnExistingPages(containerEl);
|
||||
_refreshOverlays();
|
||||
} else {
|
||||
console.warn('[PF] create annotation failed:', result.error);
|
||||
}
|
||||
|
|
@ -958,6 +956,16 @@ function colorWithAlpha(color, alpha) {
|
|||
|
||||
function _cleanDebugFlags() { _annotationSummaryLogged = true; }
|
||||
|
||||
function _refreshOverlays() {
|
||||
invalidateAnnotationCache();
|
||||
fetchAnnotationsForPaper(_currentVaultPath, _currentPdfPath);
|
||||
if (_pdfInternalHandle) {
|
||||
_rebuildVisibleLayers(_pdfInternalHandle, _currentPdfPath, _currentVaultPath);
|
||||
} else if (_currentContainerEl) {
|
||||
renderAnnotationsOnExistingPages(_currentContainerEl);
|
||||
}
|
||||
}
|
||||
|
||||
function _removeAllOverlays() {
|
||||
var allOverlays = document.querySelectorAll('.pf-annotation-overlay');
|
||||
for (var oi = 0; oi < allOverlays.length; oi++) allOverlays[oi].remove();
|
||||
|
|
@ -1074,12 +1082,10 @@ function showAnnotationPopover(event, ann, rectEl, vaultPath, pdfPath, container
|
|||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', function () {
|
||||
if (!confirm('Delete this annotation?')) return;
|
||||
deleteLocalAnnotation(vaultPath, ann.id).then(function (result) {
|
||||
deleteLocalAnnotation(_currentVaultPath, ann.id).then(function (result) {
|
||||
hideAnnotationPopover();
|
||||
if (result.ok) {
|
||||
fetchAnnotationsForPaper(vaultPath, pdfPath).then(function () {
|
||||
renderAnnotationsOnExistingPages(containerEl);
|
||||
});
|
||||
_refreshOverlays();
|
||||
} else {
|
||||
console.warn('[PF] delete annotation failed:', result.error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue