简体   繁体   English

移除块 html 标签。 TinyMCE

[英]Removing block html tags. TinyMCE

I have added TinyMCE to my project.我已将 TinyMCE 添加到我的项目中。 I have styled text and sent its value to database.我已经设置了文本样式并将其值发送到数据库。 Then I want it to be shown in the view.然后我希望它显示在视图中。 But it shown in HTML tags.但它显示在 HTML 标签中。 How can I get rid of HTML tags?如何摆脱 HTML 标签?

Js: JS:

  <script>
    tinymce.init({
        selector: '#Content',
        height: 500,
        theme: 'modern',
        plugins: [
            'advlist autolink lists link image charmap print preview hr anchor pagebreak',
            'searchreplace wordcount visualblocks visualchars code fullscreen',
            'insertdatetime media nonbreaking save table contextmenu directionality',
            'emoticons template paste textcolor colorpicker textpattern imagetools'
        ],
        forecolor: { inline: 'span', classes: 'forecolor', styles: { color: '%value' } },
        hilitecolor: { inline: 'span', classes: 'hilitecolor', styles: { backgroundColor: '%value' } },
        custom_format: { block: 'h1', attributes: { title: 'Header' }, styles: { color: 'red' } },
        toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
        toolbar2: 'print preview media | forecolor backcolor emoticons ',
        image_advtab: true,

    });
</script>

View:看法:

   @foreach (Blog blog in Model.Blog)
      {
    @blog.posttext
                   }

posttext is shown like: <p><span style="color: #008080; background-color: #33cccc;">hi</span></p> posttext显示如下: <p><span style="color: #008080; background-color: #33cccc;">hi</span></p>

Finally, I solved it by disabling HTML encoding:最后,我通过禁用 HTML 编码解决了这个问题:

@Html.Raw(HttpUtility.HtmlDecode(blog.posttext))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM