fix: the page count survives switching the pane layout
The pm-pagecount listener sat on the hosts[0] element, which Svelte replaces when the pane layout changes (multi-page grid, split view). The editor view moves to the new host, the listener died with the old one — numPages froze, so no new page ever appeared in the grid. Listen on the view's own DOM instead, which is only ever re-parented.
This commit is contained in:
1 parent
ab79740787
commit
c6aae13a9e
1 file changed
+4
-2
@@ -1097,7 +1097,9 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor';
|
||||
},
|
||||
});
|
||||
|
||||
hosts[0].addEventListener('pm-pagecount', onPageCount);
|
||||
// On the view's own DOM, not hosts[0]: switching the pane layout replaces the
|
||||
// host element, and a listener there would go down with it.
|
||||
editor.view.dom.addEventListener('pm-pagecount', onPageCount);
|
||||
document.fonts?.addEventListener('loadingdone', repaginateOnFontLoad);
|
||||
document.fonts?.ready.then(repaginateOnFontLoad);
|
||||
// Seed the scaled footprint before the first paint (so the page is centered, not
|
||||
@@ -1313,9 +1315,9 @@ import { EMPTY_PAGE_DECOR, type PageDecor } from '../storage/pageDecor';
|
||||
cancelAnimationFrame(marginRecalcRaf);
|
||||
cancelAnimationFrame(marksRecalcRaf);
|
||||
cancelAnimationFrame(tableUiRaf);
|
||||
editor?.view.dom.removeEventListener('pm-pagecount', onPageCount);
|
||||
editor?.destroy();
|
||||
resetHistoryLog();
|
||||
hosts[0]?.removeEventListener('pm-pagecount', onPageCount);
|
||||
document.fonts?.removeEventListener('loadingdone', repaginateOnFontLoad);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user