Thanks for this post but it only solves part of the problem.
It sets the HTML to RTL but many inner tages such as H and others are still doing LTR and mixed content of Arabic/Hebrew/Farsi/Etc. and English is unreadable.
P.S – Not sure line 266 is the right place now for this change. I’ve added the RTL code to the file inside the function toDOMElement after setting HTML element at $html = $document->createElement(‘html’);