froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.28k stars 671 forks source link

Unable to use custom HTML tags despite `htmlAllowedTags` option #3581

Open klimov-paul opened 5 years ago

klimov-paul commented 5 years ago
Expected behavior.

In case custom HTML tag (for example: 'template') is listed in 'htmlAllowedTags' option, it should be allowed to be used within editor. In case custom button, inserting HTML block with custom tag, created and used - HTML block with custom tag appears in editor and can be viewed in 'Code View' mode.

Actual behavior.

Custom HTML tag is stripped from the editor along with its inner HTML.

Steps to reproduce the problem.

Test code snippet:

$(function() {
  $.FroalaEditor.DefineIcon('insertHTML', {NAME: 'plus'});
  $.FroalaEditor.RegisterCommand('insertHTML', {
    title: 'Insert HTML',
    focus: true,
    undo: true,
    refreshAfterCallback: true,
    callback: function () {
      this.html.insert('Custom <template>Custom tag</template>');
      this.undo.saveStep();
    }
  });

  $('div#froala-editor').froalaEditor({
    'htmlAllowedTags': ['a', 'div', 'br', 'template'],
    toolbarButtons: [
      'bold', 'italic', 'underline', 'paragraphFormat', 'formatOL',
      'formatUL', 'insertHTML', 'undo', 'redo', 'html'
    ]
  })
});
Editor version.

^3.0.3

OS.

Ubuntu 18.04.2 LTS

Browser.

Firefox

Recording.

N/A

casualuser commented 5 years ago

Hello, I've re-checked this issue and it seems it is reproducible only for 'template' custom tag. So f.e. 'mytemplate' or 'temp' or 'something' tags work as it should. Possible this limitation somehow sourced from different tags render. I will report this to our development and at the moment you can tweak your custom 'template' tag if this works in your use case.