Hi Aleksandr,
Currently, the Document editor doesn't provide support for preserving hidden text. We have considered this feature for this Vol 1 main release which is expected in mid-March 2025. We will let you know once the release is rolled out.
You can track the status of the feature from the below link:
Support to preserve hidden text in JavaScript | Feedback Portal
Regards,
Dhanush S