mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: remove rect directly on delete, add rect directly on create
This commit is contained in:
parent
51cc0fb0c4
commit
6d2d761a31
1 changed files with 15 additions and 2 deletions
|
|
@ -825,7 +825,18 @@ function setupSelectionCapture(containerEl, vaultPath, pdfPath) {
|
|||
if (result.ok) {
|
||||
sel.removeAllRanges();
|
||||
if (toolbar) { toolbar.remove(); toolbar = null; }
|
||||
_refreshOverlays();
|
||||
invalidateAnnotationCache();
|
||||
// Add the new rect to the page directly if handle is available
|
||||
var newAnn = result.data;
|
||||
if (newAnn && newAnn.page_index != null && _pdfInternalHandle) {
|
||||
try {
|
||||
var pv = _pdfInternalHandle.getPageView(Number(newAnn.page_index));
|
||||
if (pv && pv.div) {
|
||||
var l = _getOrCreateAlignedLayer(pv);
|
||||
renderAnnotationRect(l, newAnn, vaultPath, pdfPath, null);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
} else {
|
||||
console.warn('[PF] create annotation failed:', result.error);
|
||||
}
|
||||
|
|
@ -1138,7 +1149,9 @@ function showAnnotationPopover(event, ann, rectEl, vaultPath, pdfPath, container
|
|||
deleteLocalAnnotation(_currentVaultPath, ann.id).then(function (result) {
|
||||
hideAnnotationPopover();
|
||||
if (result.ok) {
|
||||
_refreshOverlays();
|
||||
// Remove the rect element directly — no full rebuild
|
||||
if (targetEl && targetEl.parentElement) targetEl.remove();
|
||||
invalidateAnnotationCache();
|
||||
} else {
|
||||
console.warn('[PF] delete annotation failed:', result.error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue