With contenteditable, the browser changes the DOM before your code hears about it, so your state and the page drift apart. Here is how to read from the DOM, keep undo and the cursor in step, clean up legacy HTML, and handle selection across header, body and footer.
TanStack's Redact replaces React and React DOM in the browser at build time. The bundle savings are real but depend on your framework, and the catch is synchronous rendering. Here is what I would check before trying it.
A PDF measures from the bottom-left corner in points, a screen measures from the top-left in pixels. Here is the one-line conversion, and the edge cases that break it.