Code: Prevents HtmlEditorDocument from crashing

* Issue reported by @sqmgh at #1527.
* Fixed suggested by @spadapet at #1527.
* Original issue #1527 still unknown.