Filmed HTML in summernote

I use wysiwyg called summernote, the values ​​of which I send to the server, where I clean it with HTML Purifier. After that, I save it in the database (mysql). Then I need to show the cleaned html back to wysiwyg, so write it as the value of textarea (the text field is connected in js with summernote). But it displays escaped html instead of formatted text. The editor works fine, and the js console shows no errors.

Javascript that I use for init summernote

      $('.summernote').summernote({
      lang: 'cs-CZ',
      height: 100,
      airMode: true,
      prettifyHtml: true
  });

This is a screenshot of wysiwyg (in air mode, so the tools are not displayed) when the console checks its value.

enter image description here

Latte wysiwyg pattern:

 <textarea name="{$key}" class="summernote form-control" >{$value->value|noescape}</textarea> 
+4
1

Summernote (v0.7 ) , , ( , , .)

textarea summernote. div. div , hidden textarea id/name html , summernote. init blur.

:

sytax ASP.NET Razor, , ,

<textarea id="@Html.IdFor(p=>p.Content)" name="@Html.IdFor(p=>p.Content)" hidden class="someDummyClassName"></textarea>
<div class="form-control summernote">@Html.Raw(Model.Content)</div>

$(document).ready(function () {
    $('.summernote').on('summernote.init', function () {
        $('textarea.someDummyClassName').html($('.summernote').summernote("code"))
    }).on("summernote.blur", function () {
        $('textarea.someDummyClassName').html($('.summernote').summernote("code"))
    }).summernote({
        height: 280,
        // YOUR OPTIONS GOES HERE
            ....
        });
});
+6

Source: https://habr.com/ru/post/1615591/


All Articles