Angular 角度4&;Froala:防止用户输入为空

Angular 角度4&;Froala:防止用户输入为空,angular,froala,angular4-forms,Angular,Froala,Angular4 Forms,我们正在angular4应用程序中使用froala编辑器,我在尝试验证编辑器内容时遇到了问题。基本上,我们想禁止只在编辑器中键入空格、制表符或输入字符的用户 我尝试了以下代码但未成功: options: Object = { placeholderText: '', height: 300, charCounterMax: 3000, htmlAllowedEmptyTags: [], events : { 'froalaEditor.blur' : function

我们正在angular4应用程序中使用froala编辑器,我在尝试验证编辑器内容时遇到了问题。基本上,我们想禁止只在编辑器中键入空格、制表符或输入字符的用户

我尝试了以下代码但未成功:

options: Object = {
  placeholderText: '',
  height: 300,
  charCounterMax: 3000,
  htmlAllowedEmptyTags: [],
  events : {
    'froalaEditor.blur' : function(e, editor) {
      editor.html.unwrap();
      editor.html.cleanEmptyTags();
      console.log("'" + editor.html.get() + "'");
    }
  }
}
无论我在做什么,我都会

'<p>&nbsp;&nbsp;</p>' 

'
当用户输入两次空格键并验证时。 是否有任何微调功能或类似功能?
非常感谢

您可以利用
innerText
属性自己修剪内容

配置
您可以利用
innerText
属性自己修剪内容

配置
你有模板吗?你有模板吗?
const buttonConfig = ['bold', 'italic', 'underline', '|', 'formatOL', 'formatUL', '|', 'insertLink', '|', 'undo', 'redo'];
this.options = {
  charCounterCount: true,
  key: environment.froalaLicenseKey,
  language: 'de',
  charCounterMax: this.maxLength,
  toolbarButtons: buttonConfig,
  toolbarButtonsSM: buttonConfig,
  toolbarButtonsXS: buttonConfig,
  placeholderText: this.placeholder,
  pluginsEnabled: ['link', 'lists', 'charCounter'],
  linkAlwaysBlank: true,
  linkInsertButtons: ['linkBack'],
  linkEditButtons: ['linkOpen', 'linkEdit', 'linkRemove'],
  zIndex: 9999,
  events: {
    /*on every blur event check if the user has actually inserted content and clean if needed*/
    'froalaEditor.blur': (e: FocusEvent, editor) =>  (editor) => {
      let t = document.createElement('div');
      t.innerHTML = editor.html.get();
      let trimmedText = t.innerText.trim();
      if (!trimmedText) {
        editor.html.set('');
        editor.events.trigger('charCounter.update');
      }
    },
  },
};