As far as my research, using bidi is the best approach for handling RTL in almost any context including markdown.
For editor, you just need to add dir="auto"
into textarea tag. rest should be handled by the rendering engine which would simply add dir="auto"
attribute into each top level elements while composing HTML file.