Tinymce不会返回HTML而只返回文本

时间:2017-11-12 16:26:49

标签: javascript jquery html razor tinymce-4

我正在解决这个问题。我是一个非常新的javascript我为我的网站工作了tinymce v3,但我想更新它也看起来很复杂。所以我安装了v4它花了我一段时间,但我最终让我工作。在它显示textarea的意义。当我发布我的页面时,它不会返回带有html标签的文本,而只是一个字符串。当我使用blockquotes时,它只返回一个字符串 [引用] [/报价]。 这是我使用的代码。

<script src="@Url.Content("~/Scripts/tinymce/jquery.tinymce.min.js")" type="text/javascript"></script>

<script type="text/javascript">

    (function(){ 

      $(function() { 

          $('#@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)').tinymce({

            // Location of TinyMCE script
            script_url: '@Url.Content("~/Scripts/tinymce/tinymce.js")',
            theme: "modern",

            height: "300",
            width: "1150",
            verify_html: true,
            statusbar: true,
            plugins : "pagebreak,bbcode,link,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

            // Theme options
            theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,thisisnotvaled,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,codehighlighting,netadvimage",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : false,

            // Example content CSS (should be your site CSS)
            content_css : "@Url.Content("~/Scripts/tinymce/css/content.css")",
            convert_urls: false,

            // TODO: Make line breaks work and qoutes are now also not working

            force_br_newlines: true,
            force_p_newlines: true,
            forced_root_block: '',
            remove_linebreaks: false,
            convert_newlines_to_br: true,

            // Drop lists for link/image/media/template dialogs
            template_external_list_url : "lists/template_list.js",
            external_link_list_url : "lists/link_list.js",
            external_image_list_url : "lists/image_list.js",
            media_external_list_url : "lists/media_list.js"

        });

      });

    })();

</script>

它也没有强制换行我认为主要是因为它也没有返回HTML。我一直在寻找,但我找不到具体的东西。所以只需简单地将它返回就像这样:Hello world. But i want it like this : <p>hello world</p>

1 个答案:

答案 0 :(得分:0)

好吧,我花了整整24小时才发现。这是BBcode插件。 Tinymce的文档并不是真的存在。对于有问题的人,请确保你检查你的插件,这对你来说真的很痛苦。