The markdown buttons weren't working with the execCommand function. So it has to fallback to replacing the value in the textarea.
execCommand