The only way I see decorations being used for pagination is likely not the right way about it. It would probably break down for “book size” projects (tens or hundreds of pages.)
Decorations could be used to selectively hide whatever pages (prosemirror nodes) the user is not viewing. Ex: page 2, hide blocks 1-50 and 100-End)
This becomes pretty expensive the more prosemirror nodes / html nodes we are managing. Yet it does achieve the desire - to not worry about presentation given a large prosemirror document; and this solution is amenable to the user deciding whether to view in seamless layout or paged mode, and edits work effortlessly (no need to worry about stitching pages together or storing an array of documents etc.)
This would bypass the need to slice prosemirror documents up, and the page boundaries become dynamic which may or may not be a good thing. It’s a type of occlusion culling but in the direction of virtual pagination. The problem being how many blocks to consider a page? This has been discussed elsewhere but there isn’t really a straightforward way to do this given a dynamic page width and dynamic block size. There would ideally be some primitive algorithm to predict rough page sizes by computing virtual heights of elements, possibly outside the context of prosemirror in a document fragment. But this already is becoming … more complex than one may desire.
Large documents continue to be a kind of sore point for most javascript text editors. I find that the bottleneck though is not prosemirror code, but rather just large numbers of DOM nodes that need to be created and thus exist in a very large DOM tree (even if visible: hidden via decorations - this helps a lot but not enough)
The app I am working on does not do this for pagination. It does it for dynamic filtering of document matches. So given a large document, hide everything with decorations but those that pass some filter predicate. It’s pretty neat for this use case. And although it would theoretically work for pagination (and occlusion culling overall) I have not yet incorporated any implementation.