How to disabled wysihtml5 HTML Clean Up in Editor?

前端 未结 2 725
忘了有多久
忘了有多久 2021-02-08 18:39

How to disable HTML Clean Up while in the editor mode? I\'m in a need of allowing css format & inline html in code. The idea is to disable parser and html clean up action wh

2条回答
  •  独厮守ぢ
    2021-02-08 19:18

    You can provide an identity function as the parser attribute upon initializing the wysihtml5 editor. The below script is a coffeescript snippet that disables the cleanup completely.

    enableWysiwyg: ->
        @$el.find('textarea').wysihtml5
            "style": false
            "font-styles": false #Font styling, e.g. h1, h2, etc. Default true
            "emphasis": true #Italics, bold, etc. Default true
            "lists": false #(Un)ordered lists, e.g. Bullets, Numbers. Default true
            "html": true #Button which allows you to edit the generated HTML. Default false
            "link": false #Button to insert a link. Default true
            "image": false #Button to insert an image. Default true,
            "color": false #Button to change color of font
            parser: (html) -> html
    

    JavaScript version of the above code:

    $('textarea').wysihtml5({
        "style": false,
        "font-styles": false,
        "emphasis": true,
        "lists": false,
        "html": true,
        "link": false,
        "image": false,
        "color": false,
        parser: function(html) {
            return html;
        }
    });
    

提交回复
热议问题