const tinymce = require('tinymce/tinymce.min'); import './style.scss'; export default new Class({ Extends: Hedera.Form, Template: require('./ui.xml') ,editor: null ,activate() { this.$.model.mode = Db.Model.Mode.ON_DEMAND; this.$.model.setDefault('userFk', 'news', new Sql.Function({schema: 'account', name: 'myUser_getId'})); tinymce.init({ target: this.$.htmlEditor ,plugins: [ "advlist autolink lists link image charmap print preview hr" ,"anchor pagebreak searchreplace wordcount visualblocks" ,"visualchars code fullscreen insertdatetime media nonbreaking" ,"save table directionality emoticons template paste" ] ,toolbar1: " print preview | link image media emoticons blockquote" +" | insertfile undo redo | bold italic" +" | alignleft aligncenter alignright alignjustify" +" | bullist numlist outdent indent" +" | styleselect | fontselect fontsizeselect" +" | forecolor backcolor" ,image_advtab: true ,init_instance_callback: this._onEditorInit.bind(this) }); }, deactivate() { this.editor.destroy(); }, _onEditorInit(editor) { this.editor = editor; editor.getDoc().body.style.fontSize = '1em'; this.setEditorText(); }, setEditorText() { if (!this.editor) return; const row = this.$.iter.$; this.editor.setContent(row ? row.text : ''); }, onStatusChange() { if (!this.hash.$.new) this.$.iter.insertRow(); }, onOperationsDone() { Htk.Toast.showMessage(_('NewChangedSuccessfully')); this.onReturnClick(); }, onBodyChange() { this.setEditorText(); }, onAcceptClick() { this.$.iter.set('text', this.editor.getContent()); this.$.iter.performOperations(); }, onReturnClick() { this.hash.setAll({form: 'news/news'}); } });