refactored htmleditor.js